ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/player.C
(Generate patch)

Comparing deliantra/server/common/player.C (file contents):
Revision 1.47 by root, Mon Sep 29 10:32:50 2008 UTC vs.
Revision 1.64 by root, Wed Mar 24 16:44:38 2010 UTC

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 */
45int
46is_dragon_pl (const object *op)
47{
48 if (op
49 && op->type == PLAYER
50 && op->arch
51 && op->arch->race
52 && !strcmp (op->arch->race, "dragon"))
53 return 1;
54
55 return 0;
56}
57
58/*
59 * 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
60 */ 46 */
61bool 47bool
62player::save_pl (object_freezer &freezer) 48player::save_pl (object_freezer &freezer)
63{ 49{
64 INVOKE_PLAYER (SAVE, ob->contr); 50 INVOKE_PLAYER (SAVE, ob->contr);
65 51
66 int wiz = ob->flag [FLAG_WIZ]; 52 int wiz = ob->flag [FLAG_WIZ];
67 53
68 /* 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. */
69 object *container = ob->container; 55 object *container = ob->container_ ();
70 ob->container = 0; 56 ob->container = 0;
71 57
72 if (ob->map) 58 if (ob->map)
73 maplevel = ob->map->path; 59 maplevel = ob->map->path;
74 60
75#define PL_OUT(k) freezer.put (KW_ ## k, k) 61#define PL_OUT(k) freezer.put (KW(k), k)
76#define PL_OUT2(k,v) freezer.put (KW_ ## k, v) 62#define PL_OUT2(k,v) freezer.put (KW(k), v)
77 63
78 PL_OUT (password); 64 PL_OUT (password);
79 PL_OUT2 (title, own_title); 65 PL_OUT2 (title, own_title);
80 PL_OUT (gender); 66 PL_OUT (gender);
81 PL_OUT (hintmode); 67 PL_OUT (hintmode);
88 PL_OUT (digestion); 74 PL_OUT (digestion);
89 PL_OUT2 (pickup, mode); 75 PL_OUT2 (pickup, mode);
90 PL_OUT (outputs_sync); 76 PL_OUT (outputs_sync);
91 PL_OUT (outputs_count); 77 PL_OUT (outputs_count);
92 78
93 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)));
94 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)));
95 81
96 PL_OUT2 (map, maplevel); 82 PL_OUT2 (map, maplevel);
97 PL_OUT (savebed_map); 83 PL_OUT (savebed_map);
98 PL_OUT (bed_x); 84 PL_OUT (bed_x);
99 PL_OUT (bed_y); 85 PL_OUT (bed_y);
100 PL_OUT (weapon_sp); 86 PL_OUT (weapon_sp);
101 PL_OUT (weapon_sp_left); 87 PL_OUT (weapon_sp_left);
102 PL_OUT2 (Str, orig_stats.Str); 88 PL_OUT2 (str, orig_stats.Str);
103 PL_OUT2 (Dex, orig_stats.Dex); 89 PL_OUT2 (dex, orig_stats.Dex);
104 PL_OUT2 (Con, orig_stats.Con); 90 PL_OUT2 (con, orig_stats.Con);
105 PL_OUT2 (Int, orig_stats.Int); 91 PL_OUT2 (int, orig_stats.Int);
106 PL_OUT2 (Pow, orig_stats.Pow); 92 PL_OUT2 (pow, orig_stats.Pow);
107 PL_OUT2 (Wis, orig_stats.Wis); 93 PL_OUT2 (wis, orig_stats.Wis);
108 PL_OUT2 (Cha, orig_stats.Cha); 94 PL_OUT2 (cha, orig_stats.Cha);
109 95
110 PL_OUT2 (lev_array, 10); 96 PL_OUT2 (lev_array, 10);
111 97
112 for (int i = 1; i <= 10; i++) 98 for (int i = 1; i <= 10; i++)
113 { 99 {
115 freezer.add (levsp [i]); freezer.add ('\n'); 101 freezer.add (levsp [i]); freezer.add ('\n');
116 freezer.add (levgrace[i]); freezer.add ('\n'); 102 freezer.add (levgrace[i]); freezer.add ('\n');
117 } 103 }
118 104
119 freezer.put (ob->contr); 105 freezer.put (ob->contr);
120 freezer.put (KW_endplst); 106 freezer.put (KW(endplst));
121 107
122 SET_FLAG (ob, FLAG_NO_FIX_PLAYER);
123 CLEAR_FLAG (ob, FLAG_WIZ); 108 CLEAR_FLAG (ob, FLAG_WIZ);
124 ob->write (freezer); 109 ob->write (freezer);
125 110
126 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER);
127
128 /* Eneq(@csd.uu.se): Reveal the container if we have one. */ 111 /* Eneq(@csd.uu.se): Reveal the container if we have one. */
129 ob->container = container; 112 ob->container = container;
130 113
131 ob->flag [FLAG_WIZ] = wiz; 114 ob->flag [FLAG_WIZ] = wiz;
132 115
133 INVOKE_PLAYER (SAVE_DONE, ob->contr); 116 INVOKE_PLAYER (SAVE_DONE, ob->contr);
134 117
135 return true; 118 return true;
136} 119}
120
121//-GPL
137 122
138bool 123bool
139player::save_pl (const char *path) 124player::save_pl (const char *path)
140{ 125{
141 object_freezer freezer; 126 object_freezer freezer;
203 case KW_savebed_map: f.get (pl->savebed_map); break; 188 case KW_savebed_map: f.get (pl->savebed_map); break;
204 case KW_bed_x: f.get (pl->bed_x); break; 189 case KW_bed_x: f.get (pl->bed_x); break;
205 case KW_bed_y: f.get (pl->bed_y); break; 190 case KW_bed_y: f.get (pl->bed_y); break;
206 case KW_weapon_sp: f.get (pl->weapon_sp); break; 191 case KW_weapon_sp: f.get (pl->weapon_sp); break;
207 case KW_weapon_sp_left:f.get (pl->weapon_sp_left); break; 192 case KW_weapon_sp_left:f.get (pl->weapon_sp_left); break;
193
194 case KW_Str: // uppercase alias
208 case KW_Str: f.get (pl->orig_stats.Str); break; 195 case KW_str: f.get (pl->orig_stats.Str); break;
196 case KW_Dex: // uppercase alias
209 case KW_Dex: f.get (pl->orig_stats.Dex); break; 197 case KW_dex: f.get (pl->orig_stats.Dex); break;
198 case KW_Con: // uppercase alias
210 case KW_Con: f.get (pl->orig_stats.Con); break; 199 case KW_con: f.get (pl->orig_stats.Con); break;
200 case KW_Int: // uppercase alias
211 case KW_Int: f.get (pl->orig_stats.Int); break; 201 case KW_int: f.get (pl->orig_stats.Int); break;
202 case KW_Pow: // uppercase alias
212 case KW_Pow: f.get (pl->orig_stats.Pow); break; 203 case KW_pow: f.get (pl->orig_stats.Pow); break;
204 case KW_Wis: // uppercase alias
213 case KW_Wis: f.get (pl->orig_stats.Wis); break; 205 case KW_wis: f.get (pl->orig_stats.Wis); break;
206 case KW_Cha: // uppercase alias
214 case KW_Cha: f.get (pl->orig_stats.Cha); break; 207 case KW_cha: f.get (pl->orig_stats.Cha); break;
208
215 case KW_gen_hp: f.get (pl->gen_hp); break; 209 case KW_gen_hp: f.get (pl->gen_hp); break;
216 case KW_gen_sp: f.get (pl->gen_sp); break; 210 case KW_gen_sp: f.get (pl->gen_sp); break;
217 case KW_gen_grace: f.get (pl->gen_grace); break; 211 case KW_gen_grace: f.get (pl->gen_grace); break;
218 212
219 case KW_usekeys: 213 case KW_usekeys:
266 pl->destroy (); 260 pl->destroy ();
267 261
268 return 0; 262 return 0;
269} 263}
270 264
271const char * 265const_utf8_string
272player::killer_name () const 266player::killer_name () const
273{ 267{
274 static char buf [2048]; 268 static char buf [2048];
275 269
276 if (!killer) 270 if (!killer)
338 buf << "&lt;"; 332 buf << "&lt;";
339 break; 333 break;
340 334
341 case '\r': 335 case '\r':
342 buf << '\n'; 336 buf << '\n';
337 /* \r\n+ becomes one or more newlines */
338 while (*cfpod == '\n')
339 buf << *cfpod++;
343 break; 340 break;
344 341
345 case '\n': 342 case '\n':
346 if (end == -2) 343 if (end == -2)
347 return cfpod; 344 return cfpod;
356 --cfpod; 353 --cfpod;
357 do 354 do
358 buf << *cfpod++; 355 buf << *cfpod++;
359 while (*cfpod == '\n'); 356 while (*cfpod == '\n');
360 } 357 }
361 else if (*cfpod != ' ') 358 else if (*cfpod == ' ')
359 buf << '\n';
360 else
362 buf << ' '; 361 buf << ' ';
363 362
364 // verbatim block? 363 // verbatim block?
365 if (*cfpod == ' ') 364 if (*cfpod == ' ')
366 goto verbatim; 365 goto verbatim;
395 case 'C': pfx = "<tt>" ; sfx = "</tt>" ; break; 394 case 'C': pfx = "<tt>" ; sfx = "</tt>" ; break;
396 case 'E': pfx = "&" ; sfx = ";" ; break; 395 case 'E': pfx = "&" ; sfx = ";" ; break;
397 case 'I': pfx = "<i>" ; sfx = "</i>" ; break; 396 case 'I': pfx = "<i>" ; sfx = "</i>" ; break;
398 case 'U': pfx = "<u>" ; sfx = "</u>" ; break; 397 case 'U': pfx = "<u>" ; sfx = "</u>" ; break;
399 case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break; 398 case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break;
399 case 'Z': pfx = "" ; sfx = "" ; break;
400 400
401 case 'H': // hint 401 case 'H': // hint
402 { 402 {
403 if (pl->hintmode) 403 if (pl->hintmode)
404 { 404 {
405 cfpod = expand_cfpod (pl, nest, cfpod, end); 405 cfpod = expand_cfpod (pl, nest, cfpod, end);
406 nest.clear (); 406 nest.clear ();
407 407
408 if (pl->hintmode == 1) 408 if (pl->hintmode == 1)
409 buf << "<fg name=\"lightblue\">[Hint suppressed, see hintmode]</fg>"; 409 buf << "<fg name=\"lightblue\">[Hint available]</fg>";
410 else 410 else
411 while (*cfpod == ' ') // eat trailing whitespace 411 while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace
412 ++cfpod; 412 ++cfpod;
413 413
414 goto skip; 414 goto skip;
415 } 415 }
416 else 416 else
417 { 417 {
418 pfx = "<fg name=\"lightblue\">["; 418 pfx = "<fg name=\"lightblue\">[Hint: ";
419 sfx = " (Use hintmode to suppress hints)]</fg>"; 419 sfx = "]</fg>";
420 } 420 }
421 } 421 }
422 break; 422 break;
423 423
424 case 'G': // gender 424 case 'G': // gender
439 439
440 nest.clear (); 440 nest.clear ();
441 441
442 goto skip; 442 goto skip;
443 } 443 }
444
445 default:
446 pfx = "UNKNOWN_DIRECTIVE{";
447 sfx = "}";
448 break;
444 } 449 }
445 450
446 buf << pfx; 451 buf << pfx;
447 cfpod = expand_cfpod (pl, buf, cfpod, end); 452 cfpod = expand_cfpod (pl, buf, cfpod, end);
448 buf << sfx; 453 buf << sfx;
461 do 466 do
462 { 467 {
463 buf << "<tt>"; 468 buf << "<tt>";
464 cfpod = expand_cfpod (pl, buf, cfpod, -2); 469 cfpod = expand_cfpod (pl, buf, cfpod, -2);
465 buf << "</tt>\n"; 470 buf << "</tt>\n";
471
472 while (*cfpod == '\n')
473 buf << *cfpod++;
466 } 474 }
467 while (*cfpod == ' '); 475 while (*cfpod == ' ');
468 476
469 while (*cfpod == '\n')
470 buf << *cfpod++;
471
472 break; 477 break;
473 } 478 }
474} 479}
475 480
476dynbuf_text * 481dynbuf_text *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines