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