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.67 by root, Sun Apr 11 00:34:05 2010 UTC vs.
Revision 1.73 by root, Wed Nov 21 12:59:44 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 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 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
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++)
364 if (*cfpod == ' ') 362 if (*cfpod == ' ')
365 goto verbatim; 363 goto verbatim;
366 364
367 break; 365 break;
368 366
369 case 'B': case 'C': case 'E': case 'G': 367 case 'B': case 'C': case 'E': case 'G': case 'H':
370 case 'H': case 'I': case 'T': case 'U': 368 case 'I': case 'L': case 'T': case 'U': case 'Z':
371 case 'Z':
372 { 369 {
373 int end = 0; 370 int end = 0;
374 371
375 while (cfpod [end] == '<') 372 while (cfpod [end] == '<')
376 ++end; 373 ++end;
396 case 'I': pfx = "<i>" ; sfx = "</i>" ; break; 393 case 'I': pfx = "<i>" ; sfx = "</i>" ; break;
397 case 'U': pfx = "<u>" ; sfx = "</u>" ; break; 394 case 'U': pfx = "<u>" ; sfx = "</u>" ; break;
398 case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break; 395 case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break;
399 case 'Z': pfx = "" ; sfx = "" ; break; 396 case 'Z': pfx = "" ; sfx = "" ; break;
400 397
398 case 'L': // link, not really supported - always use first (or only) component
399 {
400 cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
401 nest << '\0'; // zero-terminate
402
403 const char *str = nest.linearise ();
404 const char *sep = strchr (str, '|');
405
406 buf.add (str, sep ? sep - str : nest.size ());
407
408 nest.clear ();
409
410 goto skip;
411 }
412
401 case 'H': // hint 413 case 'H': // hint
402 { 414 {
403 if (pl->hintmode) 415 if (hintmode)
404 { 416 {
405 cfpod = expand_cfpod (pl, nest, cfpod, end); 417 cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
406 nest.clear (); 418 nest.clear ();
407 419
408 if (pl->hintmode == 1) 420 if (hintmode == 1)
409 buf << "<fg name=\"lightblue\">[Hint available]</fg>"; 421 buf << "<fg name=\"lightblue\">[Hint available]</fg>";
410 else 422 else
411 while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace 423 while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace
412 ++cfpod; 424 ++cfpod;
413 425
421 } 433 }
422 break; 434 break;
423 435
424 case 'G': // gender 436 case 'G': // gender
425 { 437 {
426 cfpod = expand_cfpod (pl, nest, cfpod, end); 438 cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
427 nest << '\0'; // zero-terminate 439 nest << '\0'; // zero-terminate
428 440
429 const char *str = nest.linearise (); 441 const char *str = nest.linearise ();
430 const char *sep = strchr (str, '|'); 442 const char *sep = strchr (str, '|');
431 443
432 if (sep) 444 if (sep)
433 { 445 {
434 if (pl->gender) 446 if (gender)
435 buf.add (sep + 1, nest.size () - (sep - str) - 2); 447 buf.add (sep + 1, nest.size () - (sep - str) - 2);
436 else 448 else
437 buf.add (str, sep - str); 449 buf.add (str, sep - str);
438 } 450 }
439 451
447 sfx = "}"; 459 sfx = "}";
448 break; 460 break;
449 } 461 }
450 462
451 buf << pfx; 463 buf << pfx;
452 cfpod = expand_cfpod (pl, buf, cfpod, end); 464 cfpod = expand_cfpod (hintmode, gender, buf, cfpod, end);
453 buf << sfx; 465 buf << sfx;
454 } 466 }
455 467
456 break; 468 break;
457 469
464 verbatim: 476 verbatim:
465 // elements cannot currently span multiple lines 477 // elements cannot currently span multiple lines
466 do 478 do
467 { 479 {
468 buf << "<tt>"; 480 buf << "<tt>";
469 cfpod = expand_cfpod (pl, buf, cfpod, -2); 481 cfpod = expand_cfpod (hintmode, gender, buf, cfpod, -2);
470 buf << "</tt>\n"; 482 buf << "</tt>\n";
471 483
472 while (*cfpod == '\n') 484 while (*cfpod == '\n')
473 buf << *cfpod++; 485 buf << *cfpod++;
474 } 486 }
477 break; 489 break;
478 } 490 }
479} 491}
480 492
481dynbuf_text * 493dynbuf_text *
482player::expand_cfpod (const char *cfpod) const 494player::expand_cfpod (int hintmode, int gender, const_utf8_string cfpod)
483{ 495{
484 static dynbuf_text buf(1024, 1024); 496 static dynbuf_text buf(65536, 1024);
485 buf.clear (); 497 buf.clear ();
486 498
487 ::expand_cfpod (this, buf, cfpod); 499 ::expand_cfpod (hintmode, gender, buf, cfpod);
488 500
489 return &buf; 501 return &buf;
490} 502}
491 503
504dynbuf_text *
505player::expand_cfpod (const_utf8_string cfpod) const
506{
507 return expand_cfpod (hintmode, gender, cfpod);
508}
509

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines