1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
|
|
26 | |
|
|
27 | //+GPL |
25 | |
28 | |
26 | /* Determine if the attacktype represented by the |
29 | /* Determine if the attacktype represented by the |
27 | * specified attack-number is enabled for dragon players. |
30 | * specified attack-number is enabled for dragon players. |
28 | * A dragon player (quetzal) can gain resistances for |
31 | * A dragon player (quetzal) can gain resistances for |
29 | * all enabled attacktypes. |
32 | * all enabled attacktypes. |
… | |
… | |
37 | |
40 | |
38 | return 0; |
41 | return 0; |
39 | } |
42 | } |
40 | |
43 | |
41 | /* |
44 | /* |
42 | * returns true if the adressed object 'ob' is a player |
|
|
43 | * of the dragon race. |
|
|
44 | */ |
|
|
45 | int |
|
|
46 | is_dragon_pl (const object *op) |
|
|
47 | { |
|
|
48 | if (op |
|
|
49 | && op->type == PLAYER |
|
|
50 | && op->arch |
|
|
51 | && op->arch->race == shstr_dragon) |
|
|
52 | return 1; |
|
|
53 | |
|
|
54 | return 0; |
|
|
55 | } |
|
|
56 | |
|
|
57 | /* |
|
|
58 | * If final is set, it a clean/final save, not a backup, ie dont remove objects from inventory |
45 | * If final is set, it a clean/final save, not a backup, ie dont remove objects from inventory |
59 | */ |
46 | */ |
60 | bool |
47 | bool |
61 | player::save_pl (object_freezer &freezer) |
48 | player::save_pl (object_freezer &freezer) |
62 | { |
49 | { |
63 | INVOKE_PLAYER (SAVE, ob->contr); |
50 | INVOKE_PLAYER (SAVE, ob->contr); |
64 | |
51 | |
65 | int wiz = ob->flag [FLAG_WIZ]; |
52 | int wiz = ob->flag [FLAG_WIZ]; |
66 | |
53 | |
67 | /* Eneq(@csd.uu.se): If we have an open container hide it. */ |
54 | /* Eneq(@csd.uu.se): If we have an open container hide it. */ |
68 | object *container = ob->container; |
55 | object *container = ob->container_ (); |
69 | ob->container = 0; |
56 | ob->container = 0; |
70 | |
57 | |
71 | if (ob->map) |
58 | if (ob->map) |
72 | maplevel = ob->map->path; |
59 | maplevel = ob->map->path; |
73 | |
60 | |
74 | #define PL_OUT(k) freezer.put (KW_ ## k, k) |
61 | #define PL_OUT(k) freezer.put (KW(k), k) |
75 | #define PL_OUT2(k,v) freezer.put (KW_ ## k, v) |
62 | #define PL_OUT2(k,v) freezer.put (KW(k), v) |
76 | |
63 | |
77 | PL_OUT (password); |
64 | PL_OUT (password); |
78 | PL_OUT2 (title, own_title); |
65 | PL_OUT2 (title, own_title); |
79 | PL_OUT (gender); |
66 | PL_OUT (gender); |
80 | PL_OUT (hintmode); |
67 | PL_OUT (hintmode); |
… | |
… | |
87 | PL_OUT (digestion); |
74 | PL_OUT (digestion); |
88 | PL_OUT2 (pickup, mode); |
75 | PL_OUT2 (pickup, mode); |
89 | PL_OUT (outputs_sync); |
76 | PL_OUT (outputs_sync); |
90 | PL_OUT (outputs_count); |
77 | PL_OUT (outputs_count); |
91 | |
78 | |
92 | freezer.put (KW_usekeys, usekeys == key_inventory ? "key_inventory" : (usekeys == keyrings ? "keyrings" : "containers")); |
79 | freezer.put (KW(usekeys), usekeys == key_inventory ? CS(key_inventory) : (usekeys == keyrings ? CS(keyrings) : CS(containers))); |
93 | freezer.put (KW_unapply, unapply == unapply_nochoice ? "unapply_nochoice" : (unapply == unapply_never ? "unapply_never" : "unapply_always")); |
80 | freezer.put (KW(unapply), unapply == unapply_nochoice ? CS(unapply_nochoice) : (unapply == unapply_never ? CS(unapply_never) : CS(unapply_always))); |
94 | |
81 | |
95 | PL_OUT2 (map, maplevel); |
82 | PL_OUT2 (map, maplevel); |
96 | PL_OUT (savebed_map); |
83 | PL_OUT (savebed_map); |
97 | PL_OUT (bed_x); |
84 | PL_OUT (bed_x); |
98 | PL_OUT (bed_y); |
85 | PL_OUT (bed_y); |
… | |
… | |
114 | freezer.add (levsp [i]); freezer.add ('\n'); |
101 | freezer.add (levsp [i]); freezer.add ('\n'); |
115 | freezer.add (levgrace[i]); freezer.add ('\n'); |
102 | freezer.add (levgrace[i]); freezer.add ('\n'); |
116 | } |
103 | } |
117 | |
104 | |
118 | freezer.put (ob->contr); |
105 | freezer.put (ob->contr); |
119 | freezer.put (KW_endplst); |
106 | freezer.put (KW(endplst)); |
120 | |
107 | |
121 | SET_FLAG (ob, FLAG_NO_FIX_PLAYER); |
|
|
122 | CLEAR_FLAG (ob, FLAG_WIZ); |
108 | CLEAR_FLAG (ob, FLAG_WIZ); |
123 | ob->write (freezer); |
109 | ob->write (freezer); |
124 | |
110 | |
125 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
|
|
126 | |
|
|
127 | /* Eneq(@csd.uu.se): Reveal the container if we have one. */ |
111 | /* Eneq(@csd.uu.se): Reveal the container if we have one. */ |
128 | ob->container = container; |
112 | ob->container = container; |
129 | |
113 | |
130 | ob->flag [FLAG_WIZ] = wiz; |
114 | ob->flag [FLAG_WIZ] = wiz; |
131 | |
115 | |
132 | INVOKE_PLAYER (SAVE_DONE, ob->contr); |
116 | INVOKE_PLAYER (SAVE_DONE, ob->contr); |
133 | |
117 | |
134 | return true; |
118 | return true; |
135 | } |
119 | } |
|
|
120 | |
|
|
121 | //-GPL |
136 | |
122 | |
137 | bool |
123 | bool |
138 | player::save_pl (const char *path) |
124 | player::save_pl (const char *path) |
139 | { |
125 | { |
140 | object_freezer freezer; |
126 | object_freezer freezer; |
… | |
… | |
265 | pl->destroy (); |
251 | pl->destroy (); |
266 | |
252 | |
267 | return 0; |
253 | return 0; |
268 | } |
254 | } |
269 | |
255 | |
270 | const char * |
256 | const_utf8_string |
271 | player::killer_name () const |
257 | player::killer_name () const |
272 | { |
258 | { |
273 | static char buf [2048]; |
259 | static char buf [2048]; |
274 | |
260 | |
275 | if (!killer) |
261 | if (!killer) |
… | |
… | |
337 | buf << "<"; |
323 | buf << "<"; |
338 | break; |
324 | break; |
339 | |
325 | |
340 | case '\r': |
326 | case '\r': |
341 | buf << '\n'; |
327 | buf << '\n'; |
|
|
328 | /* \r\n+ becomes one or more newlines */ |
|
|
329 | while (*cfpod == '\n') |
|
|
330 | buf << *cfpod++; |
342 | break; |
331 | break; |
343 | |
332 | |
344 | case '\n': |
333 | case '\n': |
345 | if (end == -2) |
334 | if (end == -2) |
346 | return cfpod; |
335 | return cfpod; |
… | |
… | |
406 | { |
395 | { |
407 | cfpod = expand_cfpod (pl, nest, cfpod, end); |
396 | cfpod = expand_cfpod (pl, nest, cfpod, end); |
408 | nest.clear (); |
397 | nest.clear (); |
409 | |
398 | |
410 | if (pl->hintmode == 1) |
399 | if (pl->hintmode == 1) |
411 | buf << "<fg name=\"lightblue\">[Hint suppressed, see hintmode]</fg>"; |
400 | buf << "<fg name=\"lightblue\">[Hint available]</fg>"; |
412 | else |
401 | else |
413 | while (*cfpod == ' ') // eat trailing whitespace |
402 | while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace |
414 | ++cfpod; |
403 | ++cfpod; |
415 | |
404 | |
416 | goto skip; |
405 | goto skip; |
417 | } |
406 | } |
418 | else |
407 | else |
419 | { |
408 | { |
420 | pfx = "<fg name=\"lightblue\">["; |
409 | pfx = "<fg name=\"lightblue\">[Hint: "; |
421 | sfx = " (Use hintmode to suppress hints)]</fg>"; |
410 | sfx = "]</fg>"; |
422 | } |
411 | } |
423 | } |
412 | } |
424 | break; |
413 | break; |
425 | |
414 | |
426 | case 'G': // gender |
415 | case 'G': // gender |
… | |
… | |
441 | |
430 | |
442 | nest.clear (); |
431 | nest.clear (); |
443 | |
432 | |
444 | goto skip; |
433 | goto skip; |
445 | } |
434 | } |
|
|
435 | |
|
|
436 | default: |
|
|
437 | pfx = "UNKNOWN_DIRECTIVE{"; |
|
|
438 | sfx = "}"; |
|
|
439 | break; |
446 | } |
440 | } |
447 | |
441 | |
448 | buf << pfx; |
442 | buf << pfx; |
449 | cfpod = expand_cfpod (pl, buf, cfpod, end); |
443 | cfpod = expand_cfpod (pl, buf, cfpod, end); |
450 | buf << sfx; |
444 | buf << sfx; |