--- deliantra/server/common/loader.C 2007/05/17 14:14:54 1.82 +++ deliantra/server/common/loader.C 2007/07/10 05:51:37 1.92 @@ -1,25 +1,24 @@ /* - * CrossFire, A Multiplayer game + * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. * - * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team - * Copyright (C) 2002 Mark Wedel & Crossfire Development Team - * Copyright (C) 1992 Frank Tore Johansen + * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992,2007 Frank Tore Johansen * - * This program is free software; you can redistribute it and/or modify + * Crossfire TRT 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 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * The authors can be reached via e-mail at + * along with this program. If not, see . + * + * The authors can be reached via e-mail to */ /* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects. @@ -262,6 +261,12 @@ void object::post_load_check () { + if (type >= NUM_TYPES) + { + LOG (llevError, "%s: type out of range, resetting to 0.\n", debug_desc ()); + type = 0; + } + switch (type) { case BOW: @@ -321,7 +326,7 @@ * Otherwise, what happens is that the the plural name will lose * information (appear as just 'hearts' and not 'goblins heart') */ - if (arch && name != arch->clone.name && name_pl == arch->clone.name_pl) + if (arch && name != arch->object::name && name_pl == arch->object::name_pl) name_pl = 0; if (!name_pl) @@ -380,8 +385,10 @@ * similarly, it item_power is 0, the first check will always pass, * but not the second one. */ +#if 0 //TODO if (ip > 2 * item_power && ip > (item_power + 3)) LOG (llevDebug, "Object %s seems to have too low item power? %d > %d\n", debug_desc (), ip, item_power); +#endif } /* Old spellcasting object - need to load in the appropiate object */ @@ -404,7 +411,7 @@ insert_ob_in_ob (tmp, this); randomitems = NULL; /* So another spell isn't created for this object */ /* without this, value is all screwed up */ - value = arch->clone.value * inv->value; + value = arch->value * inv->value; } if (QUERY_FLAG (this, FLAG_MONSTER)) @@ -511,11 +518,7 @@ } } -#define GET_FLAG(op,flag) \ - if (f.get_sint32 ()) \ - SET_FLAG (op, flag); \ - else \ - CLEAR_FLAG (op, flag) \ +#define GET_FLAG(op,flg) op->flag [flg] = f.get_bool () bool object::parse_kv (object_thawer &f) @@ -771,7 +774,7 @@ break; case KW_friendly: - if (f.get_sint32 ()) + if (f.get_bool ()) if (type != PLAYER) add_friendly_object (this); @@ -957,23 +960,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: @@ -1022,7 +1012,7 @@ object *op = object::create (); op->map = map; - arch->clone.copy_to (op); + arch->copy_to (op); // copy_to activates, this should be fixed properly op->deactivate (); @@ -1294,10 +1284,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); @@ -1415,8 +1405,8 @@ archetype *at = arch ? (archetype *)arch : empty_archetype; - f.put (KW_arch, at->name); - write_diff (f, this, &at->clone); + f.put (KW_arch, at->archname); + write_diff (f, this, at); for (object *tmp = inv; tmp; tmp = tmp->below) tmp->write (f);