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.46 by root, Mon Sep 29 09:04:50 2008 UTC

259 259
260failure: 260failure:
261 LOG (llevError, "%s: too many or too grave errors, aborting player load.\n", f.name); 261 LOG (llevError, "%s: too many or too grave errors, aborting player load.\n", f.name);
262 262
263 if (pl->ob) 263 if (pl->ob)
264 pl->ob->destroy (); 264 pl->ob->destroy (true);
265 265
266 pl->destroy (); 266 pl->destroy ();
267 267
268 return 0; 268 return 0;
269} 269}
292// end == -2, till '\n' 292// end == -2, till '\n'
293// end == -1, till '>' 293// end == -1, till '>'
294// end == 0, till eos 294// end == 0, till eos
295// end >= 1, levels of " >>>" 295// end >= 1, levels of " >>>"
296static const char * 296static const char *
297expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end) 297expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end = 0)
298{ 298{
299 static dynbuf_text nest(128, 128); 299 static dynbuf_text nest(128, 128);
300 300
301 for (;;) 301 for (;;)
302 switch (char ch = *cfpod++) 302 switch (char ch = *cfpod++)
303 { 303 {
304 case 0: 304 case 0:
305 return cfpod - 1; 305 return cfpod - 1;
306 306
307 case ' ': 307 case ' ':
308 // verbatim block?
309 if (!buf.size () && !end)
310 {
311 --cfpod;
312 goto verbatim;
313 }
314
308 if (end < 1) 315 if (end < 1)
309 goto passthrough; 316 goto passthrough;
310 317
311 for (int i = 0; i < end; ++i) 318 for (int i = 0; i < end; ++i)
312 if (cfpod [i] != '>') 319 if (cfpod [i] != '>')
352 while (*cfpod == '\n'); 359 while (*cfpod == '\n');
353 } 360 }
354 else if (*cfpod != ' ') 361 else if (*cfpod != ' ')
355 buf << ' '; 362 buf << ' ';
356 363
357 // start verbatim block's? 364 // verbatim block?
358 if (*cfpod == ' ') 365 if (*cfpod == ' ')
359 { 366 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 367
373 break; 368 break;
374 369
375 case 'B': case 'C': case 'E': case 'G': 370 case 'B': case 'C': case 'E': case 'G':
376 case 'H': case 'I': case 'T': case 'U': 371 case 'H': case 'I': case 'T': case 'U':
426 } 421 }
427 break; 422 break;
428 423
429 case 'G': // gender 424 case 'G': // gender
430 { 425 {
431 expand_cfpod (pl, nest, cfpod, end); 426 cfpod = expand_cfpod (pl, nest, cfpod, end);
432 nest << '\0'; // zero-terminate 427 nest << '\0'; // zero-terminate
433 428
434 const char *str = nest.linearise (); 429 const char *str = nest.linearise ();
435 const char *sep = strchr (str, '|'); 430 const char *sep = strchr (str, '|');
436 431
437 if (sep) 432 if (sep)
438 { 433 {
439 if (pl->gender || 1) 434 if (pl->gender)
440 buf.add (sep + 1, nest.size () - (sep - str) - 2); 435 buf.add (sep + 1, nest.size () - (sep - str) - 2);
441 else 436 else
442 buf.add (str, sep - str); 437 buf.add (str, sep - str);
443 } 438 }
444 439
458 default: 453 default:
459 passthrough: 454 passthrough:
460 buf << ch; 455 buf << ch;
461 skip: 456 skip:
462 break; 457 break;
458
459 verbatim:
460 // elements cannot currently span multiple lines
461 do
462 {
463 buf << "<tt>";
464 cfpod = expand_cfpod (pl, buf, cfpod, -2);
465 buf << "</tt>\n";
466 }
467 while (*cfpod == ' ');
468
469 while (*cfpod == '\n')
470 buf << *cfpod++;
471
472 break;
463 } 473 }
464} 474}
465 475
466dynbuf_text * 476dynbuf_text *
467player::expand_cfpod (const char *cfpod) const 477player::expand_cfpod (const char *cfpod) const
468{ 478{
469 static dynbuf_text buf(1024, 1024); 479 static dynbuf_text buf(1024, 1024);
470 buf.clear (); 480 buf.clear ();
471 481
472 ::expand_cfpod (this, buf, cfpod, 0); 482 ::expand_cfpod (this, buf, cfpod);
473 483
474 return &buf; 484 return &buf;
475} 485}
476 486

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines