… | |
… | |
52 | static std::vector< std::pair<arch_ptr *, shstr> > postponed_arch_ref; |
52 | static std::vector< std::pair<arch_ptr *, shstr> > postponed_arch_ref; |
53 | // the vector of loaded but not yet committed archetypes |
53 | // the vector of loaded but not yet committed archetypes |
54 | static std::vector<archetype *> postponed_arch; |
54 | static std::vector<archetype *> postponed_arch; |
55 | |
55 | |
56 | //+GPL |
56 | //+GPL |
|
|
57 | |
|
|
58 | /* |
|
|
59 | * Creates an object. This function is called by get_archetype () |
|
|
60 | * if it fails to find the appropriate archetype. |
|
|
61 | * Thus get_archetype() will be guaranteed to always return |
|
|
62 | * an object, and never NULL. |
|
|
63 | */ |
|
|
64 | static object * |
|
|
65 | create_singularity (const char *name) |
|
|
66 | { |
|
|
67 | LOG (llevError | logBacktrace, "FATAL: creating singularity for '%s'.\n", name); |
|
|
68 | |
|
|
69 | if (!strcmp (name, "bug")) |
|
|
70 | abort (); |
|
|
71 | |
|
|
72 | object *op = archetype::get (shstr_bug); |
|
|
73 | op->name = op->name_pl = format ("bug, please report (missing archetype %s)", name); |
|
|
74 | |
|
|
75 | return op; |
|
|
76 | } |
57 | |
77 | |
58 | /** |
78 | /** |
59 | * GROS - This function retrieves an archetype given the name that appears |
79 | * GROS - This function retrieves an archetype given the name that appears |
60 | * during the game (for example, "writing pen" instead of "stylus"). |
80 | * during the game (for example, "writing pen" instead of "stylus"). |
61 | * It does not use the hashtable system, but browse the whole archlist each time. |
81 | * It does not use the hashtable system, but browse the whole archlist each time. |
… | |
… | |
329 | return 0; |
349 | return 0; |
330 | else |
350 | else |
331 | return i->second; |
351 | return i->second; |
332 | } |
352 | } |
333 | |
353 | |
|
|
354 | void |
|
|
355 | archetype::post_load_check () |
|
|
356 | { |
|
|
357 | object::post_load_check (); |
|
|
358 | |
|
|
359 | assert (("obj_original MUST NOT be set for archetypes", !flag [FLAG_OBJ_ORIGINAL])); |
|
|
360 | } |
|
|
361 | |
334 | archetype * |
362 | archetype * |
335 | archetype::read (object_thawer &f) |
363 | archetype::read (object_thawer &f) |
336 | { |
364 | { |
337 | assert (f.kw == KW_object); |
365 | assert (f.kw == KW_object); |
338 | |
366 | |
… | |
… | |
548 | } |
576 | } |
549 | |
577 | |
550 | //+GPL |
578 | //+GPL |
551 | |
579 | |
552 | /* |
580 | /* |
553 | * Creates an object. This function is called by get_archetype() |
|
|
554 | * if it fails to find the appropriate archetype. |
|
|
555 | * Thus get_archetype() will be guaranteed to always return |
|
|
556 | * an object, and never NULL. |
|
|
557 | */ |
|
|
558 | object * |
|
|
559 | create_singularity (const char *name) |
|
|
560 | { |
|
|
561 | LOG (llevError | logBacktrace, "FATAL: creating singularity for '%s'.\n", name); |
|
|
562 | |
|
|
563 | if (!strcmp (name, "bug")) |
|
|
564 | abort (); |
|
|
565 | |
|
|
566 | object *op = archetype::get (shstr_bug); |
|
|
567 | op->name = op->name_pl = format ("bug, please report (missing archetype %s)", name); |
|
|
568 | |
|
|
569 | return op; |
|
|
570 | } |
|
|
571 | |
|
|
572 | /* |
|
|
573 | * Finds which archetype matches the given name, and returns a new |
581 | * Finds which archetype matches the given name, and returns a new |
574 | * object containing a copy of the archetype. |
582 | * object containing a copy of the archetype. |
575 | */ |
583 | */ |
576 | object * |
584 | object * |
577 | get_archetype (const char *name) |
585 | get_archetype (const char *name) |
… | |
… | |
592 | |
600 | |
593 | /* |
601 | /* |
594 | * Returns the first archetype using the given type. |
602 | * Returns the first archetype using the given type. |
595 | * Used in treasure-generation. |
603 | * Used in treasure-generation. |
596 | */ |
604 | */ |
597 | archetype * |
605 | static archetype * |
598 | type_to_archetype (int type) |
606 | type_to_archetype (int type) |
599 | { |
607 | { |
600 | for_all_archetypes (at) |
608 | for_all_archetypes (at) |
601 | if (at->type == type && at->head_ () != at) |
609 | if (at->type == type && at->head_ () != at) |
602 | return at; |
610 | return at; |