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.75 by root, Wed Nov 16 23:41:59 2016 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,2013,2014,2015,2016 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
285// expand one level of cfpod 283// expand one level of cfpod
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 " >>>"
288// pod sequences not handled: F, S, X
290static const char * 289static const char *
291expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end = 0) 290expand_cfpod (int hintmode, int gender, dynbuf_text &buf, const char *cfpod, int end = 0)
292{ 291{
293 static dynbuf_text nest(128, 128); 292 static dynbuf_text nest(128, 128);
294 293
295 for (;;) 294 for (;;)
296 switch (char ch = *cfpod++) 295 switch (char ch = *cfpod++)
364 if (*cfpod == ' ') 363 if (*cfpod == ' ')
365 goto verbatim; 364 goto verbatim;
366 365
367 break; 366 break;
368 367
369 case 'B': case 'C': case 'E': case 'G': 368 case 'B': case 'C': case 'E': case 'G': case 'H':
370 case 'H': case 'I': case 'T': case 'U': 369 case 'I': case 'L': case 'T': case 'U': case 'Z':
371 case 'Z':
372 { 370 {
373 int end = 0; 371 int end = 0;
374 372
375 while (cfpod [end] == '<') 373 while (cfpod [end] == '<')
376 ++end; 374 ++end;
396 case 'I': pfx = "<i>" ; sfx = "</i>" ; break; 394 case 'I': pfx = "<i>" ; sfx = "</i>" ; break;
397 case 'U': pfx = "<u>" ; sfx = "</u>" ; break; 395 case 'U': pfx = "<u>" ; sfx = "</u>" ; break;
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
399 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
401 case 'H': // hint 414 case 'H': // hint
402 { 415 {
403 if (pl->hintmode) 416 if (hintmode)
404 { 417 {
405 cfpod = expand_cfpod (pl, nest, cfpod, end); 418 cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
406 nest.clear (); 419 nest.clear ();
407 420
408 if (pl->hintmode == 1) 421 if (hintmode == 1)
409 buf << "<fg name=\"lightblue\">[Hint available]</fg>"; 422 buf << "<fg name=\"lightblue\">[Hint available]</fg>";
410 else 423 else
411 while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace 424 while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace
412 ++cfpod; 425 ++cfpod;
413 426
421 } 434 }
422 break; 435 break;
423 436
424 case 'G': // gender 437 case 'G': // gender
425 { 438 {
426 cfpod = expand_cfpod (pl, nest, cfpod, end); 439 cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
427 nest << '\0'; // zero-terminate 440 nest << '\0'; // zero-terminate
428 441
429 const char *str = nest.linearise (); 442 const char *str = nest.linearise ();
430 const char *sep = strchr (str, '|'); 443 const char *sep = strchr (str, '|');
431 444
432 if (sep) 445 if (sep)
433 { 446 {
434 if (pl->gender) 447 if (gender)
435 buf.add (sep + 1, nest.size () - (sep - str) - 2); 448 buf.add (sep + 1, nest.size () - (sep - str) - 2);
436 else 449 else
437 buf.add (str, sep - str); 450 buf.add (str, sep - str);
438 } 451 }
439 452
447 sfx = "}"; 460 sfx = "}";
448 break; 461 break;
449 } 462 }
450 463
451 buf << pfx; 464 buf << pfx;
452 cfpod = expand_cfpod (pl, buf, cfpod, end); 465 cfpod = expand_cfpod (hintmode, gender, buf, cfpod, end);
453 buf << sfx; 466 buf << sfx;
454 } 467 }
455 468
456 break; 469 break;
457 470
464 verbatim: 477 verbatim:
465 // elements cannot currently span multiple lines 478 // elements cannot currently span multiple lines
466 do 479 do
467 { 480 {
468 buf << "<tt>"; 481 buf << "<tt>";
469 cfpod = expand_cfpod (pl, buf, cfpod, -2); 482 cfpod = expand_cfpod (hintmode, gender, buf, cfpod, -2);
470 buf << "</tt>\n"; 483 buf << "</tt>\n";
471 484
472 while (*cfpod == '\n') 485 while (*cfpod == '\n')
473 buf << *cfpod++; 486 buf << *cfpod++;
474 } 487 }
477 break; 490 break;
478 } 491 }
479} 492}
480 493
481dynbuf_text * 494dynbuf_text *
482player::expand_cfpod (const char *cfpod) const 495player::expand_cfpod (int hintmode, int gender, const_utf8_string cfpod)
483{ 496{
484 static dynbuf_text buf(1024, 1024); 497 static dynbuf_text buf(65536, 1024);
485 buf.clear (); 498 buf.clear ();
486 499
487 ::expand_cfpod (this, buf, cfpod); 500 ::expand_cfpod (hintmode, gender, buf, cfpod);
488 501
489 return &buf; 502 return &buf;
490} 503}
491 504
505dynbuf_text *
506player::expand_cfpod (const_utf8_string cfpod) const
507{
508 return expand_cfpod (hintmode, gender, cfpod);
509}
510

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines