… | |
… | |
284 | // end == -2, till '\n' |
284 | // end == -2, till '\n' |
285 | // end == -1, till '>' |
285 | // end == -1, till '>' |
286 | // end == 0, till eos |
286 | // end == 0, till eos |
287 | // end >= 1, levels of " >>>" |
287 | // end >= 1, levels of " >>>" |
288 | static const char * |
288 | static const char * |
289 | expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end = 0) |
289 | expand_cfpod (int hintmode, int gender, dynbuf_text &buf, const char *cfpod, int end = 0) |
290 | { |
290 | { |
291 | static dynbuf_text nest(128, 128); |
291 | static dynbuf_text nest(128, 128); |
292 | |
292 | |
293 | for (;;) |
293 | for (;;) |
294 | switch (char ch = *cfpod++) |
294 | switch (char ch = *cfpod++) |
… | |
… | |
396 | case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break; |
396 | case 'T': pfx = "<big><b>"; sfx = "</b></big>"; break; |
397 | case 'Z': pfx = "" ; sfx = "" ; break; |
397 | case 'Z': pfx = "" ; sfx = "" ; break; |
398 | |
398 | |
399 | case 'H': // hint |
399 | case 'H': // hint |
400 | { |
400 | { |
401 | if (pl->hintmode) |
401 | if (hintmode) |
402 | { |
402 | { |
403 | cfpod = expand_cfpod (pl, nest, cfpod, end); |
403 | cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end); |
404 | nest.clear (); |
404 | nest.clear (); |
405 | |
405 | |
406 | if (pl->hintmode == 1) |
406 | if (hintmode == 1) |
407 | buf << "<fg name=\"lightblue\">[Hint available]</fg>"; |
407 | buf << "<fg name=\"lightblue\">[Hint available]</fg>"; |
408 | else |
408 | else |
409 | while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace |
409 | while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace |
410 | ++cfpod; |
410 | ++cfpod; |
411 | |
411 | |
… | |
… | |
419 | } |
419 | } |
420 | break; |
420 | break; |
421 | |
421 | |
422 | case 'G': // gender |
422 | case 'G': // gender |
423 | { |
423 | { |
424 | cfpod = expand_cfpod (pl, nest, cfpod, end); |
424 | cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end); |
425 | nest << '\0'; // zero-terminate |
425 | nest << '\0'; // zero-terminate |
426 | |
426 | |
427 | const char *str = nest.linearise (); |
427 | const char *str = nest.linearise (); |
428 | const char *sep = strchr (str, '|'); |
428 | const char *sep = strchr (str, '|'); |
429 | |
429 | |
430 | if (sep) |
430 | if (sep) |
431 | { |
431 | { |
432 | if (pl->gender) |
432 | if (gender) |
433 | buf.add (sep + 1, nest.size () - (sep - str) - 2); |
433 | buf.add (sep + 1, nest.size () - (sep - str) - 2); |
434 | else |
434 | else |
435 | buf.add (str, sep - str); |
435 | buf.add (str, sep - str); |
436 | } |
436 | } |
437 | |
437 | |
… | |
… | |
445 | sfx = "}"; |
445 | sfx = "}"; |
446 | break; |
446 | break; |
447 | } |
447 | } |
448 | |
448 | |
449 | buf << pfx; |
449 | buf << pfx; |
450 | cfpod = expand_cfpod (pl, buf, cfpod, end); |
450 | cfpod = expand_cfpod (hintmode, gender, buf, cfpod, end); |
451 | buf << sfx; |
451 | buf << sfx; |
452 | } |
452 | } |
453 | |
453 | |
454 | break; |
454 | break; |
455 | |
455 | |
… | |
… | |
462 | verbatim: |
462 | verbatim: |
463 | // elements cannot currently span multiple lines |
463 | // elements cannot currently span multiple lines |
464 | do |
464 | do |
465 | { |
465 | { |
466 | buf << "<tt>"; |
466 | buf << "<tt>"; |
467 | cfpod = expand_cfpod (pl, buf, cfpod, -2); |
467 | cfpod = expand_cfpod (hintmode, gender, buf, cfpod, -2); |
468 | buf << "</tt>\n"; |
468 | buf << "</tt>\n"; |
469 | |
469 | |
470 | while (*cfpod == '\n') |
470 | while (*cfpod == '\n') |
471 | buf << *cfpod++; |
471 | buf << *cfpod++; |
472 | } |
472 | } |
… | |
… | |
475 | break; |
475 | break; |
476 | } |
476 | } |
477 | } |
477 | } |
478 | |
478 | |
479 | dynbuf_text * |
479 | dynbuf_text * |
480 | player::expand_cfpod (const char *cfpod) const |
480 | player::expand_cfpod (int hintmode, int gender, const_utf8_string cfpod) |
481 | { |
481 | { |
482 | static dynbuf_text buf(1024, 1024); |
482 | static dynbuf_text buf(65536, 1024); |
483 | buf.clear (); |
483 | buf.clear (); |
484 | |
484 | |
485 | ::expand_cfpod (this, buf, cfpod); |
485 | ::expand_cfpod (hintmode, gender, buf, cfpod); |
486 | |
486 | |
487 | return &buf; |
487 | return &buf; |
488 | } |
488 | } |
489 | |
489 | |
|
|
490 | dynbuf_text * |
|
|
491 | player::expand_cfpod (const_utf8_string cfpod) const |
|
|
492 | { |
|
|
493 | return expand_cfpod (hintmode, gender, cfpod); |
|
|
494 | } |
|
|
495 | |