--- deliantra/server/common/loader.C 2007/07/01 05:00:17 1.90
+++ deliantra/server/common/loader.C 2008/04/11 14:09:56 1.107
@@ -1,11 +1,11 @@
/*
- * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
+ * This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
+ * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
- * Crossfire TRT is free software: you can redistribute it and/or modify
+ * Deliantra is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * The authors can be reached via e-mail to
+ * The authors can be reached via e-mail to
*/
/* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects.
@@ -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
@@ -169,7 +171,7 @@
"spell_disarm", /* 124 */
"spell_cure_confusion", /* 125 */
"spell_restoration", /* 126 */
- "was summon evil monster", /* 127 *//* Not implenented as nothing used it */
+ "spell_summon_devil", /* 127 *//* Not implenented as nothing used it */
"spell_counterwall", /* 128 */
"spell_cause_light_wounds", /* 129 */
"spell_cause_medium_wounds", /* 130 */
@@ -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]);
@@ -531,18 +531,11 @@
{
case KW_uuid:
if (const char *s = f.get_str ())
- {
- unsigned int version;
- unsigned long long seq;
-
- if (2 == sscanf (s, "<%d.%llx>", &version, &seq) && version == 1)
- {
- uuid.seq = seq;
- break;
- }
- }
-
- uuid = gen_uuid ();
+ if (!uuid.parse (s))
+ {
+ f.parse_warn ("unparseable uuid");
+ uuid = UUID::gen ();
+ }
break;
case KW_oid:
@@ -558,6 +551,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:
{
@@ -569,6 +563,7 @@
// but manually adding it can improve map loading times a lot
// also, appending instead of prepending keeps the
// save ordering the same between repeated load/saves.
+ // and finally we do not want any funny effects
CLEAR_FLAG (tmp, FLAG_OBJ_ORIGINAL);
CLEAR_FLAG (tmp, FLAG_REMOVED);
@@ -600,7 +595,11 @@
: archetype::find (f.get_str ());
if (!other_arch)
- LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ());
+ f.parse_warn (format ("%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:
@@ -639,6 +638,18 @@
face = face_find (f.get_str ());
break;
+ case KW_sound:
+ sound = sound_find (f.get_str ());
+ if (!sound)
+ 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;
case KW_y: f.get (y); break;
@@ -960,23 +971,10 @@
case KW_msg:
f.get_ml (KW_endmsg, msg);
- //TODO: allow longer messages
- if (strlen (msg) >= HUGE_BUF)
- {
- LOG (llevDebug, "\tError message length >= %d: %d\n>%.80s<\n", HUGE_BUF, strlen (msg), &msg);
- msg = "ERROR, please report: string too long, winged.\n";
- }
break;
case KW_lore:
f.get_ml (KW_endlore, lore);
- //TODO: allow longer messages
- /* Just print a warning so we can be reasonably safe
- * about not overflowing the buffer.
- */
- if (strlen (lore) > (HUGE_BUF / 2))
- LOG (llevDebug, "\tWarning lore length > %d (max allowed=%d): %d\n>%.80s<\n",
- HUGE_BUF / 2, HUGE_BUF, strlen (lore), &lore);
break;
case KW_editable:
@@ -1050,7 +1048,6 @@
{
object_thawer f (buf, (AV *)0);
- f.next ();
return op->parse_kv (f);
}
@@ -1266,14 +1263,13 @@
* will get taken care of the copy_to method.
*/
- {
- char uids[64];
- snprintf (uids, sizeof (uids), "<1.%llx>", (unsigned long long)op->uuid.seq);
- f.put (KW_uuid, (const char *)uids);
- }
+ f.put (KW_uuid, op->uuid.c_str ());
+
+#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)
-#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)
+ if (object *owner = op->owner)
+ f.put (KW_owner, static_cast(owner->ref ()));
CMP_OUT (name);
CMP_OUT (name_pl);
@@ -1281,15 +1277,15 @@
CMP_OUT (title);
CMP_OUT (race);
CMP_OUT (slaying);
-
- 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);
-
+ CMP_OUT (tag);
CMP_OUT (other_arch);
- if (op->face != tmp->face) f.put (KW_face, op->face ? &faces [op->face] : 0);
+ 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->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)
@@ -1297,10 +1293,10 @@
f.put (KW_animation, animations[GET_ANIM_ID (op)].name);
if (!QUERY_FLAG (op, FLAG_ANIMATE))
- f.put (KW_is_animated, (sint32) 0);
+ f.put (KW_is_animated, (sint32)0);
}
else
- f.put (KW_animation, (const char *) 0);
+ f.put (KW_animation, (const char *)0);
CMP_OUT2 (str, stats.Str);
CMP_OUT2 (dex, stats.Dex);
@@ -1341,7 +1337,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);
@@ -1393,12 +1389,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);
}
@@ -1410,12 +1406,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);
@@ -1441,8 +1431,6 @@
bool success = false;
bool seen_arch = false;
- f.next ();
-
for (;;)
{
switch (f.kw)