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.64 by root, Wed Mar 24 16:44:38 2010 UTC vs.
Revision 1.72 by root, Wed Nov 14 06:18:13 2012 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,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * 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 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 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * 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 Affero GNU General Public License 18 * 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 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * 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>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26 26
103 } 103 }
104 104
105 freezer.put (ob->contr); 105 freezer.put (ob->contr);
106 freezer.put (KW(endplst)); 106 freezer.put (KW(endplst));
107 107
108 CLEAR_FLAG (ob, FLAG_WIZ); 108 ob->clr_flag (FLAG_WIZ);
109 ob->write (freezer); 109 ob->write (freezer);
110 110
111 /* Eneq(@csd.uu.se): Reveal the container if we have one. */ 111 /* Eneq(@csd.uu.se): Reveal the container if we have one. */
112 ob->container = container; 112 ob->container = container;
113 113
172 return pl; 172 return pl;
173 173
174 case KW_oid: f.get (pl, f.get_sint32 ()); break; 174 case KW_oid: f.get (pl, f.get_sint32 ()); break;
175 case KW_password: assign (pl->password , f.get_str ()); break; 175 case KW_password: assign (pl->password , f.get_str ()); break;
176 case KW_title: assign (pl->own_title, f.get_str ()); break; 176 case KW_title: assign (pl->own_title, f.get_str ()); break;
177 case KW_bowtype: pl->bowtype = (bowtype_t) f.get_sint32 (); break; 177 case KW_bowtype: pl->bowtype = (bowtype_t) f.get_sint32 (); break;
178 case KW_petmode: pl->petmode = (petmode_t) f.get_sint32 (); break; 178 case KW_petmode: pl->petmode = (petmode_t) f.get_sint32 (); break;
179 case KW_gender: f.get (pl->gender); break; 179 case KW_gender: f.get (pl->gender); break;
180 case KW_hintmode: f.get (pl->hintmode); break; 180 case KW_hintmode: f.get (pl->hintmode); break;
181 case KW_listening: /*TODO*/; break; 181 case KW_listening: /*TODO*/; break;
182 case KW_peaceful: f.get (pl->peaceful); break; 182 case KW_peaceful: f.get (pl->peaceful); break;
183 case KW_digestion: f.get (pl->digestion); break; 183 case KW_digestion: f.get (pl->digestion); break;
236 { 236 {
237 int count = f.get_sint32 (); 237 int count = f.get_sint32 ();
238 238
239 for (int i = 1; i <= count; i++) 239 for (int i = 1; i <= count; i++)
240 { 240 {
241 char line [32]; 241 f.next_line (); f.get (pl->levhp [i]);
242 242 f.next_line (); f.get (pl->levsp [i]);
243 fgets (line, 32, f); pl->levhp [i] = atoi (line); 243 f.next_line (); f.get (pl->levgrace[i]);
244 fgets (line, 32, f); pl->levsp [i] = atoi (line);
245 fgets (line, 32, f); pl->levgrace[i] = atoi (line);
246 } 244 }
247 } 245 }
248 break; 246 break;
249 } 247 }
250 248
286// end == -2, till '\n' 284// end == -2, till '\n'
287// end == -1, till '>' 285// end == -1, till '>'
288// end == 0, till eos 286// end == 0, till eos
289// end >= 1, levels of " >>>" 287// end >= 1, levels of " >>>"
290static const char * 288static const char *
291expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end = 0) 289expand_cfpod (int hintmode, int gender, dynbuf_text &buf, const char *cfpod, int end = 0)
292{ 290{
293 static dynbuf_text nest(128, 128); 291 static dynbuf_text nest(128, 128);
294 292
295 for (;;) 293 for (;;)
296 switch (char ch = *cfpod++) 294 switch (char ch = *cfpod++)
398 case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break; 396 case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break;
399 case 'Z': pfx = "" ; sfx = "" ; break; 397 case 'Z': pfx = "" ; sfx = "" ; break;
400 398
401 case 'H': // hint 399 case 'H': // hint
402 { 400 {
403 if (pl->hintmode) 401 if (hintmode)
404 { 402 {
405 cfpod = expand_cfpod (pl, nest, cfpod, end); 403 cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
406 nest.clear (); 404 nest.clear ();
407 405
408 if (pl->hintmode == 1) 406 if (hintmode == 1)
409 buf << "<fg name=\"lightblue\">[Hint available]</fg>"; 407 buf << "<fg name=\"lightblue\">[Hint available]</fg>";
410 else 408 else
411 while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace 409 while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace
412 ++cfpod; 410 ++cfpod;
413 411
421 } 419 }
422 break; 420 break;
423 421
424 case 'G': // gender 422 case 'G': // gender
425 { 423 {
426 cfpod = expand_cfpod (pl, nest, cfpod, end); 424 cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
427 nest << '\0'; // zero-terminate 425 nest << '\0'; // zero-terminate
428 426
429 const char *str = nest.linearise (); 427 const char *str = nest.linearise ();
430 const char *sep = strchr (str, '|'); 428 const char *sep = strchr (str, '|');
431 429
432 if (sep) 430 if (sep)
433 { 431 {
434 if (pl->gender) 432 if (gender)
435 buf.add (sep + 1, nest.size () - (sep - str) - 2); 433 buf.add (sep + 1, nest.size () - (sep - str) - 2);
436 else 434 else
437 buf.add (str, sep - str); 435 buf.add (str, sep - str);
438 } 436 }
439 437
447 sfx = "}"; 445 sfx = "}";
448 break; 446 break;
449 } 447 }
450 448
451 buf << pfx; 449 buf << pfx;
452 cfpod = expand_cfpod (pl, buf, cfpod, end); 450 cfpod = expand_cfpod (hintmode, gender, buf, cfpod, end);
453 buf << sfx; 451 buf << sfx;
454 } 452 }
455 453
456 break; 454 break;
457 455
464 verbatim: 462 verbatim:
465 // elements cannot currently span multiple lines 463 // elements cannot currently span multiple lines
466 do 464 do
467 { 465 {
468 buf << "<tt>"; 466 buf << "<tt>";
469 cfpod = expand_cfpod (pl, buf, cfpod, -2); 467 cfpod = expand_cfpod (hintmode, gender, buf, cfpod, -2);
470 buf << "</tt>\n"; 468 buf << "</tt>\n";
471 469
472 while (*cfpod == '\n') 470 while (*cfpod == '\n')
473 buf << *cfpod++; 471 buf << *cfpod++;
474 } 472 }
477 break; 475 break;
478 } 476 }
479} 477}
480 478
481dynbuf_text * 479dynbuf_text *
482player::expand_cfpod (const char *cfpod) const 480player::expand_cfpod (int hintmode, int gender, const_utf8_string cfpod)
483{ 481{
484 static dynbuf_text buf(1024, 1024); 482 static dynbuf_text buf(65536, 1024);
485 buf.clear (); 483 buf.clear ();
486 484
487 ::expand_cfpod (this, buf, cfpod); 485 ::expand_cfpod (hintmode, gender, buf, cfpod);
488 486
489 return &buf; 487 return &buf;
490} 488}
491 489
490dynbuf_text *
491player::expand_cfpod (const_utf8_string cfpod) const
492{
493 return expand_cfpod (hintmode, gender, cfpod);
494}
495

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines