--- deliantra/server/common/loader.C 2007/07/31 17:33:14 1.93 +++ deliantra/server/common/loader.C 2007/09/10 12:44:06 1.102 @@ -31,6 +31,8 @@ ///////////////////////////////////////////////////////////////////////////// +extern archetype *loading_arch; + /* This table is only necessary to convert objects that existed before the * spell object conversion to the new object. It was not practical * to go through every mapping looking for every potion, rod, wand, etc @@ -251,8 +253,6 @@ NULL }; -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 * deal with legacy objects where fields may have changed. It can also be used @@ -396,7 +396,7 @@ /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ ((type == POTION || type == ALTAR) && stats.sp)) && !inv && !loading_arch) { - /* Fireall is bizarre in that spell type was stored in dam. Rest are 'normal' + /* Firewall is bizarre in that spell type was stored in dam. Rest are 'normal' * in that spell was stored in sp. */ object *tmp = get_archetype (spell_mapping[type == FIREWALL ? stats.dam : stats.sp]); @@ -558,6 +558,7 @@ case KW_skill: f.get_ornull (skill); break; case KW_race: f.get_ornull (race); break; case KW_slaying: f.get_ornull (slaying); break; + case KW_tag: f.get_ornull (tag); break; case KW_arch: { @@ -603,6 +604,10 @@ LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ()); break; + case KW_owner: + f.delayed_deref (this, owner, f.get_str ()); + break; + case KW_animation: { CLEAR_FLAG (this, FLAG_ANIMATE); @@ -642,7 +647,13 @@ case KW_sound: sound = sound_find (f.get_str ()); if (!sound) - sound = face_find (f.get_str ());//TODO: really fall back to face name? + f.parse_warn ("sound not found"); + break; + + case KW_sound_destroy: + sound_destroy = sound_find (f.get_str ()); + if (!sound_destroy) + f.parse_warn ("sound not found"); break; case KW_x: f.get (x); break; @@ -1043,7 +1054,6 @@ { object_thawer f (buf, (AV *)0); - f.next (); return op->parse_kv (f); } @@ -1265,8 +1275,11 @@ f.put (KW_uuid, (const char *)uids); } -#define CMP_OUT(v) if (op->v != tmp->v) f.put (KW_ ## v, op->v) -#define CMP_OUT2(k,v) if (op->v != tmp->v) f.put (KW_ ## k, op->v) +#define CMP_OUT(v) if (expect_false (op->v != tmp->v)) f.put (KW_ ## v, op->v) +#define CMP_OUT2(k,v) if (expect_false (op->v != tmp->v)) f.put (KW_ ## k, op->v) + + if (object *owner = op->owner) + f.put (KW_owner, static_cast(owner->ref ())); CMP_OUT (name); CMP_OUT (name_pl); @@ -1274,13 +1287,15 @@ CMP_OUT (title); CMP_OUT (race); CMP_OUT (slaying); + CMP_OUT (tag); CMP_OUT (other_arch); if (op->msg != tmp->msg ) f.put (KW_msg , KW_endmsg , op->msg ); if (op->lore != tmp->lore) f.put (KW_lore, KW_endlore, op->lore); - if (op->sound != tmp->sound) f.put (KW_sound, op->sound ? &faces [op->sound] : 0); - if (op->face != tmp->face ) f.put (KW_face , op->face ? &faces [op->face ] : 0); + if (op->face != tmp->face ) f.put (KW_face , op->face ? &faces [op->face ] : 0); + if (op->sound != tmp->sound ) f.put (KW_sound , op->sound ? &faces [op->sound ] : 0); + if (op->sound_destroy != tmp->sound_destroy) f.put (KW_sound_destroy, op->sound_destroy ? &faces [op->sound_destroy] : 0); if (op->animation_id != tmp->animation_id) if (op->animation_id) @@ -1332,7 +1347,7 @@ CMP_OUT (attacktype); for (i = 0; i < NROFATTACKS; i++) - if (op->resist[i] != tmp->resist[i]) + if (expect_false (op->resist[i] != tmp->resist[i])) f.put (resist_save[i], op->resist[i]); CMP_OUT (path_attuned); @@ -1384,12 +1399,12 @@ if (op->flag != tmp->flag) for (i = 0; i <= NUM_FLAGS; i++) - if (flag_names [i] && op->flag [i] != tmp->flag [i]) + if (expect_false (flag_names [i] && op->flag [i] != tmp->flag [i])) f.put (flag_names [i], op->flag [i] ? "1" : "0"); // save body locations for (i = 0; i < NUM_BODY_LOCATIONS; i++) - if (op->slot[i].info != tmp->slot[i].info) + if (expect_false (op->slot[i].info != tmp->slot[i].info)) f.put (body_locations[i].save_name, op->slot[i].info); } @@ -1401,12 +1416,6 @@ bool object::write (object_freezer &f) { - /* Even if the object does have an owner, it would seem that we should - * still save it. - */ - if (owner) - return true; - archetype *at = arch ? (archetype *)arch : empty_archetype; f.put (KW_arch, at->archname); @@ -1432,8 +1441,6 @@ bool success = false; bool seen_arch = false; - f.next (); - for (;;) { switch (f.kw)