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.43 by root, Mon Sep 8 18:34:35 2008 UTC vs.
Revision 1.51 by elmex, Fri Jun 26 16:21:57 2009 UTC

46is_dragon_pl (const object *op) 46is_dragon_pl (const object *op)
47{ 47{
48 if (op 48 if (op
49 && op->type == PLAYER 49 && op->type == PLAYER
50 && op->arch 50 && op->arch
51 && op->arch->race 51 && op->arch->race == shstr_dragon)
52 && !strcmp (op->arch->race, "dragon"))
53 return 1; 52 return 1;
54 53
55 return 0; 54 return 0;
56} 55}
57 56
292// end == -2, till '\n' 291// end == -2, till '\n'
293// end == -1, till '>' 292// end == -1, till '>'
294// end == 0, till eos 293// end == 0, till eos
295// end >= 1, levels of " >>>" 294// end >= 1, levels of " >>>"
296static const char * 295static const char *
297expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end) 296expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end = 0)
298{ 297{
299 static dynbuf_text nest(128, 128); 298 static dynbuf_text nest(128, 128);
300 299
301 for (;;) 300 for (;;)
302 switch (char ch = *cfpod++) 301 switch (char ch = *cfpod++)
303 { 302 {
304 case 0: 303 case 0:
305 return cfpod - 1; 304 return cfpod - 1;
306 305
307 case ' ': 306 case ' ':
307 // verbatim block?
308 if (!buf.size () && !end)
309 {
310 --cfpod;
311 goto verbatim;
312 }
313
308 if (end < 1) 314 if (end < 1)
309 goto passthrough; 315 goto passthrough;
310 316
311 for (int i = 0; i < end; ++i) 317 for (int i = 0; i < end; ++i)
312 if (cfpod [i] != '>') 318 if (cfpod [i] != '>')
349 --cfpod; 355 --cfpod;
350 do 356 do
351 buf << *cfpod++; 357 buf << *cfpod++;
352 while (*cfpod == '\n'); 358 while (*cfpod == '\n');
353 } 359 }
354 else if (*cfpod != ' ') 360 else if (*cfpod == ' ')
361 buf << '\n';
362 else
355 buf << ' '; 363 buf << ' ';
356 364
357 // start verbatim block's? 365 // verbatim block?
358 if (*cfpod == ' ') 366 if (*cfpod == ' ')
359 { 367 goto verbatim;
360 // elements cannot currently span multiple lines
361 do
362 {
363 buf << "<tt>";
364 cfpod = expand_cfpod (pl, buf, cfpod, -2);
365 buf << "</tt>\n";
366 }
367 while (*cfpod == ' ');
368
369 while (*cfpod == '\n')
370 buf << *cfpod++;
371 }
372 368
373 break; 369 break;
374 370
375 case 'B': case 'C': case 'E': case 'G': 371 case 'B': case 'C': case 'E': case 'G':
376 case 'H': case 'I': case 'T': case 'U': 372 case 'H': case 'I': case 'T': case 'U':
400 case 'C': pfx = "<tt>" ; sfx = "</tt>" ; break; 396 case 'C': pfx = "<tt>" ; sfx = "</tt>" ; break;
401 case 'E': pfx = "&" ; sfx = ";" ; break; 397 case 'E': pfx = "&" ; sfx = ";" ; break;
402 case 'I': pfx = "<i>" ; sfx = "</i>" ; break; 398 case 'I': pfx = "<i>" ; sfx = "</i>" ; break;
403 case 'U': pfx = "<u>" ; sfx = "</u>" ; break; 399 case 'U': pfx = "<u>" ; sfx = "</u>" ; break;
404 case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break; 400 case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break;
401 case 'Z': pfx = "" ; sfx = "" ; break;
405 402
406 case 'H': // hint 403 case 'H': // hint
407 { 404 {
408 if (pl->hintmode) 405 if (pl->hintmode)
409 { 406 {
426 } 423 }
427 break; 424 break;
428 425
429 case 'G': // gender 426 case 'G': // gender
430 { 427 {
431 expand_cfpod (pl, nest, cfpod, end); 428 cfpod = expand_cfpod (pl, nest, cfpod, end);
432 nest << '\0'; // zero-terminate 429 nest << '\0'; // zero-terminate
433 430
434 const char *str = nest.linearise (); 431 const char *str = nest.linearise ();
435 const char *sep = strchr (str, '|'); 432 const char *sep = strchr (str, '|');
436 433
437 if (sep) 434 if (sep)
438 { 435 {
439 if (pl->gender || 1) 436 if (pl->gender)
440 buf.add (sep + 1, nest.size () - (sep - str) - 2); 437 buf.add (sep + 1, nest.size () - (sep - str) - 2);
441 else 438 else
442 buf.add (str, sep - str); 439 buf.add (str, sep - str);
443 } 440 }
444 441
458 default: 455 default:
459 passthrough: 456 passthrough:
460 buf << ch; 457 buf << ch;
461 skip: 458 skip:
462 break; 459 break;
460
461 verbatim:
462 // elements cannot currently span multiple lines
463 do
464 {
465 buf << "<tt>";
466 cfpod = expand_cfpod (pl, buf, cfpod, -2);
467 buf << "</tt>\n";
468
469 while (*cfpod == '\n')
470 buf << *cfpod++;
471 }
472 while (*cfpod == ' ');
473
474 break;
463 } 475 }
464} 476}
465 477
466dynbuf_text * 478dynbuf_text *
467player::expand_cfpod (const char *cfpod) const 479player::expand_cfpod (const char *cfpod) const
468{ 480{
469 static dynbuf_text buf(1024, 1024); 481 static dynbuf_text buf(1024, 1024);
470 buf.clear (); 482 buf.clear ();
471 483
472 ::expand_cfpod (this, buf, cfpod, 0); 484 ::expand_cfpod (this, buf, cfpod);
473 485
474 return &buf; 486 return &buf;
475} 487}
476 488

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines