… | |
… | |
46 | is_dragon_pl (const object *op) |
46 | is_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 " >>>" |
296 | static const char * |
295 | static const char * |
297 | expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end) |
296 | expand_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] != '>') |
… | |
… | |
352 | while (*cfpod == '\n'); |
358 | while (*cfpod == '\n'); |
353 | } |
359 | } |
354 | else if (*cfpod != ' ') |
360 | else if (*cfpod != ' ') |
355 | buf << ' '; |
361 | buf << ' '; |
356 | |
362 | |
357 | // start verbatim block's? |
363 | // verbatim block? |
358 | if (*cfpod == ' ') |
364 | if (*cfpod == ' ') |
359 | { |
365 | 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 | |
366 | |
373 | break; |
367 | break; |
374 | |
368 | |
375 | case 'B': case 'C': case 'E': case 'G': |
369 | case 'B': case 'C': case 'E': case 'G': |
376 | case 'H': case 'I': case 'T': case 'U': |
370 | case 'H': case 'I': case 'T': case 'U': |
… | |
… | |
426 | } |
420 | } |
427 | break; |
421 | break; |
428 | |
422 | |
429 | case 'G': // gender |
423 | case 'G': // gender |
430 | { |
424 | { |
431 | expand_cfpod (pl, nest, cfpod, end); |
425 | cfpod = expand_cfpod (pl, nest, cfpod, end); |
432 | nest << '\0'; // zero-terminate |
426 | nest << '\0'; // zero-terminate |
433 | |
427 | |
434 | const char *str = nest.linearise (); |
428 | const char *str = nest.linearise (); |
435 | const char *sep = strchr (str, '|'); |
429 | const char *sep = strchr (str, '|'); |
436 | |
430 | |
437 | if (sep) |
431 | if (sep) |
438 | { |
432 | { |
439 | if (pl->gender || 1) |
433 | if (pl->gender) |
440 | buf.add (sep + 1, nest.size () - (sep - str) - 2); |
434 | buf.add (sep + 1, nest.size () - (sep - str) - 2); |
441 | else |
435 | else |
442 | buf.add (str, sep - str); |
436 | buf.add (str, sep - str); |
443 | } |
437 | } |
444 | |
438 | |
… | |
… | |
458 | default: |
452 | default: |
459 | passthrough: |
453 | passthrough: |
460 | buf << ch; |
454 | buf << ch; |
461 | skip: |
455 | skip: |
462 | break; |
456 | break; |
|
|
457 | |
|
|
458 | verbatim: |
|
|
459 | // elements cannot currently span multiple lines |
|
|
460 | do |
|
|
461 | { |
|
|
462 | buf << "<tt>"; |
|
|
463 | cfpod = expand_cfpod (pl, buf, cfpod, -2); |
|
|
464 | buf << "</tt>\n"; |
|
|
465 | |
|
|
466 | while (*cfpod == '\n') |
|
|
467 | buf << *cfpod++; |
|
|
468 | } |
|
|
469 | while (*cfpod == ' '); |
|
|
470 | |
|
|
471 | break; |
463 | } |
472 | } |
464 | } |
473 | } |
465 | |
474 | |
466 | dynbuf_text * |
475 | dynbuf_text * |
467 | player::expand_cfpod (const char *cfpod) const |
476 | player::expand_cfpod (const char *cfpod) const |
468 | { |
477 | { |
469 | static dynbuf_text buf(1024, 1024); |
478 | static dynbuf_text buf(1024, 1024); |
470 | buf.clear (); |
479 | buf.clear (); |
471 | |
480 | |
472 | ::expand_cfpod (this, buf, cfpod, 0); |
481 | ::expand_cfpod (this, buf, cfpod); |
473 | |
482 | |
474 | return &buf; |
483 | return &buf; |
475 | } |
484 | } |
476 | |
485 | |