1 |
elmex |
1.1 |
/* |
2 |
root |
1.35 |
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 |
root |
1.71 |
* |
4 |
root |
1.76 |
* Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
5 |
root |
1.75 |
* Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
6 |
root |
1.65 |
* Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
7 |
|
|
* Copyright (©) 1992 Frank Tore Johansen |
8 |
root |
1.71 |
* |
9 |
root |
1.55 |
* Deliantra is free software: you can redistribute it and/or modify it under |
10 |
|
|
* the terms of the Affero GNU General Public License as published by the |
11 |
|
|
* Free Software Foundation, either version 3 of the License, or (at your |
12 |
|
|
* option) any later version. |
13 |
root |
1.71 |
* |
14 |
root |
1.33 |
* This program is distributed in the hope that it will be useful, |
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
|
|
* GNU General Public License for more details. |
18 |
root |
1.71 |
* |
19 |
root |
1.55 |
* You should have received a copy of the Affero GNU General Public License |
20 |
|
|
* and the GNU General Public License along with this program. If not, see |
21 |
|
|
* <http://www.gnu.org/licenses/>. |
22 |
root |
1.71 |
* |
23 |
root |
1.35 |
* The authors can be reached via e-mail to <support@deliantra.net> |
24 |
root |
1.14 |
*/ |
25 |
elmex |
1.1 |
|
26 |
|
|
#include <global.h> |
27 |
|
|
|
28 |
root |
1.57 |
//+GPL |
29 |
|
|
|
30 |
elmex |
1.1 |
/* Determine if the attacktype represented by the |
31 |
|
|
* specified attack-number is enabled for dragon players. |
32 |
|
|
* A dragon player (quetzal) can gain resistances for |
33 |
|
|
* all enabled attacktypes. |
34 |
|
|
*/ |
35 |
root |
1.4 |
int |
36 |
|
|
atnr_is_dragon_enabled (int attacknr) |
37 |
|
|
{ |
38 |
elmex |
1.1 |
if (attacknr == ATNR_MAGIC || attacknr == ATNR_FIRE || |
39 |
root |
1.4 |
attacknr == ATNR_ELECTRICITY || attacknr == ATNR_COLD || attacknr == ATNR_ACID || attacknr == ATNR_POISON) |
40 |
elmex |
1.1 |
return 1; |
41 |
root |
1.10 |
|
42 |
elmex |
1.1 |
return 0; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
/* |
46 |
root |
1.14 |
* If final is set, it a clean/final save, not a backup, ie dont remove objects from inventory |
47 |
|
|
*/ |
48 |
|
|
bool |
49 |
|
|
player::save_pl (object_freezer &freezer) |
50 |
|
|
{ |
51 |
|
|
INVOKE_PLAYER (SAVE, ob->contr); |
52 |
|
|
|
53 |
|
|
int wiz = ob->flag [FLAG_WIZ]; |
54 |
|
|
|
55 |
|
|
/* Eneq(@csd.uu.se): If we have an open container hide it. */ |
56 |
root |
1.56 |
object *container = ob->container_ (); |
57 |
root |
1.14 |
ob->container = 0; |
58 |
|
|
|
59 |
root |
1.19 |
if (ob->map) |
60 |
|
|
maplevel = ob->map->path; |
61 |
|
|
|
62 |
root |
1.60 |
#define PL_OUT(k) freezer.put (KW(k), k) |
63 |
|
|
#define PL_OUT2(k,v) freezer.put (KW(k), v) |
64 |
root |
1.14 |
|
65 |
|
|
PL_OUT (password); |
66 |
|
|
PL_OUT2 (title, own_title); |
67 |
root |
1.32 |
PL_OUT (gender); |
68 |
root |
1.41 |
PL_OUT (hintmode); |
69 |
root |
1.14 |
PL_OUT (gen_hp); |
70 |
|
|
PL_OUT (gen_sp); |
71 |
|
|
PL_OUT (gen_grace); |
72 |
|
|
PL_OUT (bowtype); |
73 |
|
|
PL_OUT (petmode); |
74 |
|
|
PL_OUT (peaceful); |
75 |
|
|
PL_OUT (digestion); |
76 |
|
|
PL_OUT2 (pickup, mode); |
77 |
|
|
PL_OUT (outputs_sync); |
78 |
|
|
PL_OUT (outputs_count); |
79 |
|
|
|
80 |
root |
1.60 |
freezer.put (KW(usekeys), usekeys == key_inventory ? CS(key_inventory) : (usekeys == keyrings ? CS(keyrings) : CS(containers))); |
81 |
|
|
freezer.put (KW(unapply), unapply == unapply_nochoice ? CS(unapply_nochoice) : (unapply == unapply_never ? CS(unapply_never) : CS(unapply_always))); |
82 |
root |
1.14 |
|
83 |
root |
1.17 |
PL_OUT2 (map, maplevel); |
84 |
root |
1.14 |
PL_OUT (savebed_map); |
85 |
|
|
PL_OUT (bed_x); |
86 |
|
|
PL_OUT (bed_y); |
87 |
|
|
PL_OUT (weapon_sp); |
88 |
root |
1.28 |
PL_OUT (weapon_sp_left); |
89 |
root |
1.64 |
PL_OUT2 (str, orig_stats.Str); |
90 |
|
|
PL_OUT2 (dex, orig_stats.Dex); |
91 |
|
|
PL_OUT2 (con, orig_stats.Con); |
92 |
|
|
PL_OUT2 (int, orig_stats.Int); |
93 |
|
|
PL_OUT2 (pow, orig_stats.Pow); |
94 |
|
|
PL_OUT2 (wis, orig_stats.Wis); |
95 |
|
|
PL_OUT2 (cha, orig_stats.Cha); |
96 |
root |
1.14 |
|
97 |
root |
1.15 |
PL_OUT2 (lev_array, 10); |
98 |
root |
1.14 |
|
99 |
root |
1.15 |
for (int i = 1; i <= 10; i++) |
100 |
root |
1.14 |
{ |
101 |
root |
1.29 |
freezer.add (levhp [i]); freezer.add ('\n'); |
102 |
|
|
freezer.add (levsp [i]); freezer.add ('\n'); |
103 |
|
|
freezer.add (levgrace[i]); freezer.add ('\n'); |
104 |
root |
1.14 |
} |
105 |
|
|
|
106 |
|
|
freezer.put (ob->contr); |
107 |
root |
1.60 |
freezer.put (KW(endplst)); |
108 |
root |
1.14 |
|
109 |
root |
1.67 |
ob->clr_flag (FLAG_WIZ); |
110 |
root |
1.21 |
ob->write (freezer); |
111 |
root |
1.14 |
|
112 |
|
|
/* Eneq(@csd.uu.se): Reveal the container if we have one. */ |
113 |
|
|
ob->container = container; |
114 |
|
|
|
115 |
|
|
ob->flag [FLAG_WIZ] = wiz; |
116 |
|
|
|
117 |
|
|
INVOKE_PLAYER (SAVE_DONE, ob->contr); |
118 |
|
|
|
119 |
|
|
return true; |
120 |
|
|
} |
121 |
|
|
|
122 |
root |
1.57 |
//-GPL |
123 |
|
|
|
124 |
root |
1.14 |
bool |
125 |
|
|
player::save_pl (const char *path) |
126 |
|
|
{ |
127 |
|
|
object_freezer freezer; |
128 |
|
|
|
129 |
|
|
if (!save_pl (freezer)) |
130 |
|
|
return false; |
131 |
|
|
|
132 |
|
|
return freezer.save (path); |
133 |
|
|
} |
134 |
|
|
|
135 |
|
|
player * |
136 |
root |
1.21 |
player::load_pl (object_thawer &f) |
137 |
root |
1.14 |
{ |
138 |
root |
1.21 |
int maxerrs = 20; |
139 |
root |
1.18 |
|
140 |
root |
1.14 |
player *pl = new player; |
141 |
|
|
|
142 |
|
|
pl->savebed_map = first_map_path; |
143 |
|
|
|
144 |
|
|
/* Loop through the file, loading the rest of the values */ |
145 |
|
|
for (;;) |
146 |
|
|
{ |
147 |
root |
1.21 |
switch (f.kw) |
148 |
root |
1.14 |
{ |
149 |
|
|
case KW_EOF: |
150 |
root |
1.21 |
LOG (llevError, "%s: unexpected EOF while reading player header\n", f.name); |
151 |
root |
1.18 |
goto failure; |
152 |
|
|
|
153 |
|
|
default: |
154 |
root |
1.21 |
LOG (llevError, "%s: skipping unknown key in player header: %s\n", f.name, f.kw_str); |
155 |
root |
1.18 |
if (!--maxerrs) goto failure; |
156 |
|
|
break; |
157 |
root |
1.14 |
|
158 |
|
|
case KW_ERROR: |
159 |
root |
1.21 |
LOG (llevError, "%s: parse error while reading player header, skipping (%s,%s).\n", f.name, f.kw_str, f.value); |
160 |
root |
1.18 |
if (!--maxerrs) goto failure; |
161 |
root |
1.14 |
break; |
162 |
|
|
|
163 |
|
|
case KW_endplst: |
164 |
root |
1.21 |
f.next (); |
165 |
|
|
|
166 |
|
|
if (object *op = pl->ob->read (f)) |
167 |
|
|
pl->set_object (op); |
168 |
|
|
else |
169 |
|
|
goto failure; |
170 |
|
|
|
171 |
|
|
INVOKE_PLAYER (LOAD, pl); |
172 |
root |
1.14 |
|
173 |
root |
1.21 |
return pl; |
174 |
|
|
|
175 |
|
|
case KW_oid: f.get (pl, f.get_sint32 ()); break; |
176 |
|
|
case KW_password: assign (pl->password , f.get_str ()); break; |
177 |
|
|
case KW_title: assign (pl->own_title, f.get_str ()); break; |
178 |
root |
1.66 |
case KW_bowtype: pl->bowtype = (bowtype_t) f.get_sint32 (); break; |
179 |
|
|
case KW_petmode: pl->petmode = (petmode_t) f.get_sint32 (); break; |
180 |
root |
1.32 |
case KW_gender: f.get (pl->gender); break; |
181 |
root |
1.41 |
case KW_hintmode: f.get (pl->hintmode); break; |
182 |
root |
1.40 |
case KW_listening: /*TODO*/; break; |
183 |
root |
1.21 |
case KW_peaceful: f.get (pl->peaceful); break; |
184 |
|
|
case KW_digestion: f.get (pl->digestion); break; |
185 |
|
|
case KW_pickup: f.get (pl->mode); break; |
186 |
|
|
case KW_outputs_sync: f.get (pl->outputs_sync); break; |
187 |
|
|
case KW_outputs_count: f.get (pl->outputs_count); break; |
188 |
|
|
case KW_map: f.get (pl->maplevel); break; |
189 |
|
|
case KW_savebed_map: f.get (pl->savebed_map); break; |
190 |
|
|
case KW_bed_x: f.get (pl->bed_x); break; |
191 |
|
|
case KW_bed_y: f.get (pl->bed_y); break; |
192 |
|
|
case KW_weapon_sp: f.get (pl->weapon_sp); break; |
193 |
root |
1.28 |
case KW_weapon_sp_left:f.get (pl->weapon_sp_left); break; |
194 |
root |
1.64 |
|
195 |
|
|
case KW_Str: // uppercase alias |
196 |
|
|
case KW_str: f.get (pl->orig_stats.Str); break; |
197 |
|
|
case KW_Dex: // uppercase alias |
198 |
|
|
case KW_dex: f.get (pl->orig_stats.Dex); break; |
199 |
|
|
case KW_Con: // uppercase alias |
200 |
|
|
case KW_con: f.get (pl->orig_stats.Con); break; |
201 |
|
|
case KW_Int: // uppercase alias |
202 |
|
|
case KW_int: f.get (pl->orig_stats.Int); break; |
203 |
|
|
case KW_Pow: // uppercase alias |
204 |
|
|
case KW_pow: f.get (pl->orig_stats.Pow); break; |
205 |
|
|
case KW_Wis: // uppercase alias |
206 |
|
|
case KW_wis: f.get (pl->orig_stats.Wis); break; |
207 |
|
|
case KW_Cha: // uppercase alias |
208 |
|
|
case KW_cha: f.get (pl->orig_stats.Cha); break; |
209 |
|
|
|
210 |
root |
1.21 |
case KW_gen_hp: f.get (pl->gen_hp); break; |
211 |
|
|
case KW_gen_sp: f.get (pl->gen_sp); break; |
212 |
|
|
case KW_gen_grace: f.get (pl->gen_grace); break; |
213 |
root |
1.14 |
|
214 |
|
|
case KW_usekeys: |
215 |
root |
1.21 |
if (!strcmp (f.get_str (), "key_inventory")) |
216 |
root |
1.14 |
pl->usekeys = key_inventory; |
217 |
root |
1.21 |
else if (!strcmp (f.get_str (), "keyrings")) |
218 |
root |
1.14 |
pl->usekeys = keyrings; |
219 |
root |
1.21 |
else if (!strcmp (f.get_str (), "containers")) |
220 |
root |
1.14 |
pl->usekeys = containers; |
221 |
|
|
else |
222 |
root |
1.21 |
LOG (llevDebug, "load_player: got unknown usekeys type: %s\n", f.get_str ()); |
223 |
root |
1.14 |
break; |
224 |
|
|
|
225 |
|
|
case KW_unapply: |
226 |
root |
1.21 |
if (!strcmp (f.get_str (), "unapply_nochoice")) |
227 |
root |
1.14 |
pl->unapply = unapply_nochoice; |
228 |
root |
1.21 |
else if (!strcmp (f.get_str (), "unapply_never")) |
229 |
root |
1.14 |
pl->unapply = unapply_never; |
230 |
root |
1.21 |
else if (!strcmp (f.get_str (), "unapply_always")) |
231 |
root |
1.14 |
pl->unapply = unapply_always; |
232 |
|
|
else |
233 |
root |
1.21 |
LOG (llevDebug, "load_player: got unknown unapply type: %s\n", f.get_str ()); |
234 |
root |
1.14 |
break; |
235 |
|
|
|
236 |
|
|
case KW_lev_array: |
237 |
|
|
{ |
238 |
root |
1.21 |
int count = f.get_sint32 (); |
239 |
root |
1.14 |
|
240 |
|
|
for (int i = 1; i <= count; i++) |
241 |
|
|
{ |
242 |
root |
1.68 |
f.next_line (); f.get (pl->levhp [i]); |
243 |
|
|
f.next_line (); f.get (pl->levsp [i]); |
244 |
|
|
f.next_line (); f.get (pl->levgrace[i]); |
245 |
root |
1.14 |
} |
246 |
|
|
} |
247 |
|
|
break; |
248 |
|
|
} |
249 |
|
|
|
250 |
root |
1.21 |
f.next (); |
251 |
root |
1.14 |
} |
252 |
|
|
|
253 |
root |
1.18 |
failure: |
254 |
root |
1.21 |
LOG (llevError, "%s: too many or too grave errors, aborting player load.\n", f.name); |
255 |
root |
1.18 |
|
256 |
root |
1.22 |
if (pl->ob) |
257 |
root |
1.47 |
pl->ob->destroy (); |
258 |
root |
1.22 |
|
259 |
root |
1.18 |
pl->destroy (); |
260 |
|
|
|
261 |
|
|
return 0; |
262 |
root |
1.14 |
} |
263 |
|
|
|
264 |
root |
1.61 |
const_utf8_string |
265 |
root |
1.37 |
player::killer_name () const |
266 |
|
|
{ |
267 |
|
|
static char buf [2048]; |
268 |
|
|
|
269 |
|
|
if (!killer) |
270 |
|
|
return "a dungeon collapse"; |
271 |
|
|
else if (killer->contr) |
272 |
root |
1.39 |
snprintf (buf, sizeof (buf), "%s the %s", &killer->name, |
273 |
|
|
*killer->contr->own_title ? killer->contr->own_title : killer->contr->title); |
274 |
root |
1.37 |
else if (killer->type == DEEP_SWAMP) |
275 |
|
|
snprintf (buf, sizeof (buf), "drowning in a %s", &killer->name); |
276 |
|
|
else if (killer->owner) |
277 |
root |
1.38 |
snprintf (buf, sizeof (buf), "%s's %s", &killer->outer_owner ()->name, &killer->name); |
278 |
root |
1.37 |
else |
279 |
|
|
return &killer->name; |
280 |
|
|
|
281 |
|
|
return buf; |
282 |
|
|
} |
283 |
|
|
|
284 |
root |
1.41 |
// expand one level of cfpod |
285 |
root |
1.43 |
// end == -2, till '\n' |
286 |
|
|
// end == -1, till '>' |
287 |
|
|
// end == 0, till eos |
288 |
|
|
// end >= 1, levels of " >>>" |
289 |
root |
1.74 |
// pod sequences not handled: F, S, X |
290 |
root |
1.41 |
static const char * |
291 |
root |
1.72 |
expand_cfpod (int hintmode, int gender, dynbuf_text &buf, const char *cfpod, int end = 0) |
292 |
root |
1.41 |
{ |
293 |
|
|
static dynbuf_text nest(128, 128); |
294 |
|
|
|
295 |
|
|
for (;;) |
296 |
|
|
switch (char ch = *cfpod++) |
297 |
|
|
{ |
298 |
|
|
case 0: |
299 |
|
|
return cfpod - 1; |
300 |
|
|
|
301 |
|
|
case ' ': |
302 |
root |
1.44 |
// verbatim block? |
303 |
|
|
if (!buf.size () && !end) |
304 |
|
|
{ |
305 |
|
|
--cfpod; |
306 |
|
|
goto verbatim; |
307 |
|
|
} |
308 |
|
|
|
309 |
root |
1.43 |
if (end < 1) |
310 |
root |
1.41 |
goto passthrough; |
311 |
|
|
|
312 |
|
|
for (int i = 0; i < end; ++i) |
313 |
|
|
if (cfpod [i] != '>') |
314 |
|
|
goto passthrough; |
315 |
|
|
|
316 |
|
|
return cfpod + end; |
317 |
|
|
|
318 |
|
|
case '>': |
319 |
root |
1.43 |
if (end != -1) |
320 |
root |
1.41 |
{ |
321 |
|
|
buf << ">"; |
322 |
|
|
break; |
323 |
|
|
} |
324 |
|
|
|
325 |
|
|
return cfpod; |
326 |
|
|
|
327 |
|
|
case '&': |
328 |
|
|
buf << "&"; |
329 |
|
|
break; |
330 |
|
|
|
331 |
|
|
case '<': |
332 |
|
|
buf << "<"; |
333 |
|
|
break; |
334 |
|
|
|
335 |
root |
1.42 |
case '\r': |
336 |
|
|
buf << '\n'; |
337 |
root |
1.52 |
/* \r\n+ becomes one or more newlines */ |
338 |
|
|
while (*cfpod == '\n') |
339 |
|
|
buf << *cfpod++; |
340 |
root |
1.42 |
break; |
341 |
|
|
|
342 |
root |
1.41 |
case '\n': |
343 |
root |
1.43 |
if (end == -2) |
344 |
|
|
return cfpod; |
345 |
|
|
|
346 |
|
|
// \n\ => newline, tt |
347 |
|
|
// \n\n => \n\n |
348 |
|
|
// \n => single space |
349 |
|
|
|
350 |
|
|
// two or more newlines will be copied verbatim, one is replaced by space |
351 |
|
|
if (*cfpod == '\n') |
352 |
root |
1.41 |
{ |
353 |
|
|
--cfpod; |
354 |
root |
1.42 |
do |
355 |
root |
1.41 |
buf << *cfpod++; |
356 |
root |
1.42 |
while (*cfpod == '\n'); |
357 |
root |
1.41 |
} |
358 |
root |
1.50 |
else if (*cfpod == ' ') |
359 |
|
|
buf << '\n'; |
360 |
|
|
else |
361 |
root |
1.42 |
buf << ' '; |
362 |
root |
1.41 |
|
363 |
root |
1.44 |
// verbatim block? |
364 |
root |
1.43 |
if (*cfpod == ' ') |
365 |
root |
1.44 |
goto verbatim; |
366 |
root |
1.43 |
|
367 |
root |
1.41 |
break; |
368 |
|
|
|
369 |
root |
1.73 |
case 'B': case 'C': case 'E': case 'G': case 'H': |
370 |
|
|
case 'I': case 'L': case 'T': case 'U': case 'Z': |
371 |
root |
1.41 |
{ |
372 |
root |
1.43 |
int end = 0; |
373 |
root |
1.41 |
|
374 |
root |
1.43 |
while (cfpod [end] == '<') |
375 |
|
|
++end; |
376 |
root |
1.41 |
|
377 |
root |
1.43 |
if (!end) |
378 |
root |
1.41 |
goto passthrough; |
379 |
|
|
|
380 |
root |
1.43 |
if (end == 1 || cfpod [end] != ' ') |
381 |
root |
1.41 |
{ |
382 |
root |
1.43 |
end = -1; |
383 |
root |
1.41 |
++cfpod; |
384 |
|
|
} |
385 |
|
|
else |
386 |
root |
1.43 |
cfpod += end + 1; |
387 |
root |
1.41 |
|
388 |
|
|
const char *pfx, *sfx; |
389 |
|
|
|
390 |
|
|
switch (ch) |
391 |
|
|
{ |
392 |
|
|
case 'B': pfx = "<b>" ; sfx = "</b>" ; break; |
393 |
|
|
case 'C': pfx = "<tt>" ; sfx = "</tt>" ; break; |
394 |
|
|
case 'E': pfx = "&" ; sfx = ";" ; break; |
395 |
|
|
case 'I': pfx = "<i>" ; sfx = "</i>" ; break; |
396 |
|
|
case 'U': pfx = "<u>" ; sfx = "</u>" ; break; |
397 |
|
|
case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break; |
398 |
elmex |
1.51 |
case 'Z': pfx = "" ; sfx = "" ; break; |
399 |
root |
1.41 |
|
400 |
root |
1.73 |
case 'L': // link, not really supported - always use first (or only) component |
401 |
|
|
{ |
402 |
|
|
cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end); |
403 |
|
|
nest << '\0'; // zero-terminate |
404 |
|
|
|
405 |
|
|
const char *str = nest.linearise (); |
406 |
|
|
const char *sep = strchr (str, '|'); |
407 |
|
|
|
408 |
|
|
buf.add (str, sep ? sep - str : nest.size ()); |
409 |
|
|
|
410 |
|
|
nest.clear (); |
411 |
|
|
|
412 |
|
|
goto skip; |
413 |
|
|
} |
414 |
|
|
|
415 |
root |
1.41 |
case 'H': // hint |
416 |
|
|
{ |
417 |
root |
1.72 |
if (hintmode) |
418 |
root |
1.41 |
{ |
419 |
root |
1.72 |
cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end); |
420 |
root |
1.41 |
nest.clear (); |
421 |
|
|
|
422 |
root |
1.72 |
if (hintmode == 1) |
423 |
root |
1.53 |
buf << "<fg name=\"lightblue\">[Hint available]</fg>"; |
424 |
root |
1.41 |
else |
425 |
root |
1.53 |
while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace |
426 |
root |
1.41 |
++cfpod; |
427 |
|
|
|
428 |
|
|
goto skip; |
429 |
|
|
} |
430 |
|
|
else |
431 |
|
|
{ |
432 |
root |
1.53 |
pfx = "<fg name=\"lightblue\">[Hint: "; |
433 |
|
|
sfx = "]</fg>"; |
434 |
root |
1.41 |
} |
435 |
|
|
} |
436 |
|
|
break; |
437 |
|
|
|
438 |
|
|
case 'G': // gender |
439 |
|
|
{ |
440 |
root |
1.72 |
cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end); |
441 |
root |
1.41 |
nest << '\0'; // zero-terminate |
442 |
|
|
|
443 |
|
|
const char *str = nest.linearise (); |
444 |
|
|
const char *sep = strchr (str, '|'); |
445 |
|
|
|
446 |
|
|
if (sep) |
447 |
|
|
{ |
448 |
root |
1.72 |
if (gender) |
449 |
root |
1.41 |
buf.add (sep + 1, nest.size () - (sep - str) - 2); |
450 |
|
|
else |
451 |
|
|
buf.add (str, sep - str); |
452 |
|
|
} |
453 |
|
|
|
454 |
|
|
nest.clear (); |
455 |
|
|
|
456 |
|
|
goto skip; |
457 |
|
|
} |
458 |
root |
1.58 |
|
459 |
|
|
default: |
460 |
|
|
pfx = "UNKNOWN_DIRECTIVE{"; |
461 |
|
|
sfx = "}"; |
462 |
|
|
break; |
463 |
root |
1.41 |
} |
464 |
|
|
|
465 |
|
|
buf << pfx; |
466 |
root |
1.72 |
cfpod = expand_cfpod (hintmode, gender, buf, cfpod, end); |
467 |
root |
1.41 |
buf << sfx; |
468 |
|
|
} |
469 |
|
|
|
470 |
|
|
break; |
471 |
|
|
|
472 |
|
|
default: |
473 |
|
|
passthrough: |
474 |
|
|
buf << ch; |
475 |
|
|
skip: |
476 |
|
|
break; |
477 |
root |
1.44 |
|
478 |
|
|
verbatim: |
479 |
|
|
// elements cannot currently span multiple lines |
480 |
|
|
do |
481 |
|
|
{ |
482 |
|
|
buf << "<tt>"; |
483 |
root |
1.72 |
cfpod = expand_cfpod (hintmode, gender, buf, cfpod, -2); |
484 |
root |
1.44 |
buf << "</tt>\n"; |
485 |
root |
1.48 |
|
486 |
|
|
while (*cfpod == '\n') |
487 |
|
|
buf << *cfpod++; |
488 |
root |
1.44 |
} |
489 |
|
|
while (*cfpod == ' '); |
490 |
|
|
|
491 |
|
|
break; |
492 |
root |
1.41 |
} |
493 |
|
|
} |
494 |
|
|
|
495 |
|
|
dynbuf_text * |
496 |
root |
1.72 |
player::expand_cfpod (int hintmode, int gender, const_utf8_string cfpod) |
497 |
root |
1.41 |
{ |
498 |
root |
1.72 |
static dynbuf_text buf(65536, 1024); |
499 |
root |
1.41 |
buf.clear (); |
500 |
|
|
|
501 |
root |
1.72 |
::expand_cfpod (hintmode, gender, buf, cfpod); |
502 |
root |
1.41 |
|
503 |
|
|
return &buf; |
504 |
|
|
} |
505 |
|
|
|
506 |
root |
1.72 |
dynbuf_text * |
507 |
|
|
player::expand_cfpod (const_utf8_string cfpod) const |
508 |
|
|
{ |
509 |
|
|
return expand_cfpod (hintmode, gender, cfpod); |
510 |
|
|
} |
511 |
|
|
|