--- deliantra/server/common/loader.C 2007/03/14 04:12:27 1.65 +++ deliantra/server/common/loader.C 2007/04/17 18:24:29 1.69 @@ -252,7 +252,7 @@ NULL }; -extern int arch_init; +extern bool loading_arch; /* This function checks the object after it has been loaded (when we * get the 'end' in the input stream). This function can be used to @@ -291,7 +291,7 @@ * really just to catch any errors - program will still run, but * not in the ideal fashion. */ - if ((op->type == WEAPON || op->type == BOW) && arch_init) + if ((op->type == WEAPON || op->type == BOW) && loading_arch) { if (!op->skill) LOG (llevError, "Weapon %s lacks a skill.\n", op->debug_desc ()); @@ -342,7 +342,7 @@ /* Old spellcasting object - need to load in the appropiate object */ if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN || op->type == FIREWALL || /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ - ((op->type == POTION || op->type == ALTAR) && op->stats.sp)) && !op->inv && !arch_init) + ((op->type == POTION || op->type == ALTAR) && op->stats.sp)) && !op->inv && !loading_arch) { /* Fireall is bizarre in that spell type was stored in dam. Rest are 'normal' * in that spell was stored in sp. @@ -353,7 +353,7 @@ } /* spellbooks & runes use slaying. But not to arch name, but to spell name */ - if ((op->type == SPELLBOOK || op->type == RUNE) && op->slaying && !op->inv && !arch_init) + if ((op->type == SPELLBOOK || op->type == RUNE) && op->slaying && !op->inv && !loading_arch) { object *tmp = get_archetype_by_object_name (op->slaying); insert_ob_in_ob (tmp, op); @@ -411,7 +411,7 @@ set_move (MoveType &mt, const char *str) { static const struct flagstr { - char *name; + const char *name; MoveType flags; } move_flags[] = { { "walk" , MOVE_WALK }, @@ -553,7 +553,13 @@ continue; case KW_other_arch: - other_arch = archetype::find (f.get_str ()); + other_arch = + loading_arch + ? archetype::get (f.get_str ()) + : archetype::find (f.get_str ()); + + if (!other_arch) + LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ()); break; case KW_animation: @@ -910,9 +916,16 @@ break; case KW_randomitems: - randomitems = find_treasurelist (f.get_str ()); - //if (!randomitems) - // LOG (llevError, "%s uses unknown randomitems '%s'.\n", debug_desc (), f.get_str ()); + if (f.get_str ()) + { + randomitems = + loading_arch + ? treasurelist::get (f.get_str ()) + : treasurelist::find (f.get_str ()); + + if (!randomitems) + LOG (llevError, "%s uses unknown randomitems '%s'.\n", debug_desc (), f.get_str ()); + } break; case KW_msg: @@ -943,7 +956,7 @@ case KW_end: check_loaded_object (this); - if (!arch_init) + if (!loading_arch) instantiate (); f.next (); @@ -982,14 +995,13 @@ object *op = object::create (); op->map = map; - op->arch = arch; arch->clone.copy_to (op); // copy_to activates, this should be fixed properly op->deactivate (); if (!op->parse_kv (f)) { - delete op; + op->destroy (true); return 0; } @@ -1245,7 +1257,8 @@ f.put (KW_lore, KW_endlore, op->lore); CMP_OUT (other_arch); - CMP_OUT (face); + + if (op->face != tmp->face) f.put (KW_face, op->face ? &faces [op->face] : 0); if (op->animation_id != tmp->animation_id) if (op->animation_id) @@ -1388,6 +1401,8 @@ ///////////////////////////////////////////////////////////////////////////// +// generic resource file load, +// currently supports: region, treasures bool load_resource_file (const char *filename) { object_thawer f (filename); @@ -1403,6 +1418,12 @@ return false; break; + case KW_treasure: + case KW_treasureone: + if (!treasurelist::read (f)) + return false; + break; + case KW_EOF: return true; @@ -1410,8 +1431,6 @@ if (!f.parse_error ("resource file")) return false; } - - f.next (); } }