--- deliantra/server/common/loader.C 2006/12/30 21:07:46 1.32 +++ deliantra/server/common/loader.C 2007/01/18 19:42:09 1.47 @@ -1,25 +1,26 @@ /* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 2002 Mark Wedel & Crossfire Development Team - Copyright (C) 1992 Frank Tore Johansen - - This program 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 - (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 - 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 -*/ + * CrossFire, A Multiplayer game for X-windows + * + * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team + * Copyright (C) 2002 Mark Wedel & Crossfire Development Team + * Copyright (C) 1992 Frank Tore Johansen + * + * This program 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 + * (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 + * 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 + */ /* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects. sub/add_weight will transcend the environment updating the carrying @@ -265,9 +266,9 @@ { int ip; - /* We do some specialized handling to handle legacy cases of name_pl. + /* We do some specialised handling to handle legacy cases of name_pl. * If the object doesn't have a name_pl, we just use the object name - - * this isn't perfect (things won't be properly pluralized), but works to + * this isn't perfect (things won't be properly pluralised), but works to * that degree (5 heart is still quite understandable). But the case we * also have to catch is if this object is not using the normal name for * the object. In that case, we also want to use the loaded name. @@ -322,10 +323,8 @@ op->gen_sp_armour = op->last_heal; op->last_heal = 0; } - if (editor) - ip = 0; - else - ip = calc_item_power (op, 0); + + ip = calc_item_power (op, 0); /* Legacy objects from before item power was in the game */ if (!op->item_power && ip) { @@ -553,7 +552,7 @@ object *tmp; - if (arch != NULL) + if (arch) tmp = arch_to_object (arch); else { @@ -565,7 +564,7 @@ // decativate the object we, as we are still going // to read the speed value. Objects should be activated // when the map, object or player is completly loaded. - tmp->deactivate (false); + tmp->deactivate (); parse_object (tmp, thawer, map_flags); @@ -608,7 +607,11 @@ op->arch = archetype::find (str); if (op->arch) - op->arch->clone.copy_to (op); + { + op->arch->clone.copy_to (op); + // copy_to activates, this should be fixed properly + op->deactivate (); + } else if (!arch_init) /* record the name of the broken object */ op->name = str; @@ -629,11 +632,8 @@ op->animation_id = 0; CLEAR_FLAG (op, FLAG_ANIMATE); } - else - { - op->animation_id = find_animation (str); - SET_FLAG (op, FLAG_ANIMATE); - } + else if ((op->animation_id = find_animation (str))) + SET_FLAG (op, FLAG_ANIMATE); } break; @@ -650,7 +650,7 @@ //TODO: maybe do in check_object // removed check for style maps if (op->speed < 0) - op->speed_left = op->speed_left - RANDOM () % 100 / 100.0; + op->speed_left = op->speed_left - rndm (); break; @@ -814,16 +814,17 @@ break; case KW_friendly: - GET_FLAG (op, FLAG_FRIENDLY); - //TODO: move to check_object or so - if (op->type != PLAYER && QUERY_FLAG (op, FLAG_FRIENDLY)) - add_friendly_object (op); + if (thawer.get_sint32 ()) + if (op->type != PLAYER) + add_friendly_object (op); + break; case KW_monster: GET_FLAG (op, FLAG_MONSTER); break; case KW_neutral: GET_FLAG (op, FLAG_NEUTRAL); break; case KW_no_attack: GET_FLAG (op, FLAG_NO_ATTACK); break; case KW_no_damage: GET_FLAG (op, FLAG_NO_DAMAGE); break; + case KW_obj_original: GET_FLAG (op, FLAG_OBJ_ORIGINAL); break; case KW_generator: GET_FLAG (op, FLAG_GENERATOR); break; case KW_use_content_on_gen: GET_FLAG (op, FLAG_CONTENT_ON_GEN); break; case KW_is_thrown: GET_FLAG (op, FLAG_IS_THROWN); break; @@ -904,6 +905,7 @@ case KW_one_hit: GET_FLAG (op, FLAG_ONE_HIT); break; case KW_berserk: GET_FLAG (op, FLAG_BERSERK); break; case KW_is_buildable: GET_FLAG (op, FLAG_IS_BUILDABLE); break; + case KW_destroy_on_death: GET_FLAG (op, FLAG_DESTROY_ON_DEATH); break; case KW_armour: thawer.get (op->resist[ATNR_PHYSICAL]); break; case KW_resist_physical: thawer.get (op->resist[ATNR_PHYSICAL]); break; @@ -987,7 +989,7 @@ //TODO: allow longer messages if (strlen (op->msg) >= HUGE_BUF) { - LOG (llevDebug, "\n\tError message length >= %d: %d\n>%.80s<\n", HUGE_BUF, strlen (op->msg), &op->msg); + LOG (llevDebug, "\tError message length >= %d: %d\n>%.80s<\n", HUGE_BUF, strlen (op->msg), &op->msg); op->msg = "ERROR, please report: string too long, winged.\n"; } break; @@ -999,7 +1001,7 @@ * about not overflowing the buffer. */ if (strlen (op->lore) > (HUGE_BUF / 2)) - LOG (llevDebug, "\n\tWarning lore length > %d (max allowed=%d): %d\n>%.80s<\n", + LOG (llevDebug, "\tWarning lore length > %d (max allowed=%d): %d\n>%.80s<\n", HUGE_BUF / 2, HUGE_BUF, strlen (op->lore), &op->lore); break; @@ -1055,17 +1057,7 @@ int load_object (object_thawer &fp, object *op, int map_flags) { - // cede every 500 objects loaded - { - static int cede_counter = 0; - - if (++cede_counter >= 500) - { - cede_counter = 0; - if (coroapi::nready ()) - coroapi::cede (); - } - } + coroapi::cede_every (1000); // cede once in a while return parse_object (op, fp, map_flags); } @@ -1274,7 +1266,7 @@ /* 100 */ KW_no_attack, KW_no_damage, - KW_NULL, + KW_obj_original, KW_NULL, KW_activate_on_push, KW_activate_on_release, @@ -1283,6 +1275,8 @@ KW_NULL, KW_is_buildable, /* 110 */ + KW_destroy_on_death, + KW_NULL, }; int i; @@ -1290,7 +1284,7 @@ /* This saves the key/value lists. We do it first so that any * keys that match field names will be overwritten by the loader. */ - for (key_value *my_field = op->key_values; my_field != NULL; my_field = my_field->next) + for (key_value *my_field = op->key_values; my_field; my_field = my_field->next) { /* Find the field in the opposing member. */ key_value *arch_field = get_ob_key_link (tmp, my_field->key); @@ -1468,6 +1462,6 @@ save_object (fp, tmp, flag); fp.put (op); - fp.put (KW_end, 0); + fp.put (KW_end); }