--- deliantra/server/common/map.C 2007/03/15 14:23:02 1.96 +++ deliantra/server/common/map.C 2007/04/21 16:56:28 1.101 @@ -346,8 +346,7 @@ /* link_multipart_objects go through all the objects on the map looking * for objects whose arch says they are multipart yet according to the * info we have, they only have the head (as would be expected when - * they are saved). We do have to look for the old maps that did save - * the more sections and not re-add sections for them. + * they are saved). */ void maptile::link_multipart_objects () @@ -356,38 +355,14 @@ return; for (mapspace *ms = spaces + size (); ms-- > spaces; ) - for (object *tmp = ms->bot; tmp; tmp = tmp->above) + for (object *op = ms->bot; op; op = op->above) { /* already multipart - don't do anything more */ - if (!tmp->head && !tmp->more) + if (!op->head && !op->more && op->arch->more) { - /* If there is nothing more to this object, this for loop - * won't do anything. - */ - archetype *at; - object *last, *op; - for (at = tmp->arch->more, last = tmp; - at; - at = at->more, last = op) - { - op = arch_to_object (at); - - /* update x,y coordinates */ - op->x += tmp->x; - op->y += tmp->y; - op->head = tmp; - op->map = this; - last->more = op; - op->name = tmp->name; - op->title = tmp->title; - - /* we could link all the parts onto tmp, and then just - * call insert_ob_in_map once, but the effect is the same, - * as insert_ob_in_map will call itself with each part, and - * the coding is simpler to just to it here with each part. - */ - insert_ob_in_map (op, op->map, tmp, INS_NO_MERGE | INS_ABOVE_FLOOR_ONLY | INS_NO_WALK_ON); - } + op->remove (); + op->expand_tail (); + insert (op, op->x, op->y, 0, INS_NO_MERGE | INS_ABOVE_FLOOR_ONLY | INS_NO_WALK_ON); } } } @@ -401,7 +376,7 @@ { for (;;) { - coroapi::cede_every (1000); // cede once in a while + coroapi::cede_to_tick_every (100); // cede once in a while switch (f.kw) { @@ -434,29 +409,29 @@ void maptile::activate () { - if (!spaces) - return; + active = true; - for (mapspace *ms = spaces + size (); ms-- > spaces; ) - for (object *op = ms->bot; op; op = op->above) - op->activate_recursive (); + if (spaces) + for (mapspace *ms = spaces + size (); ms-- > spaces; ) + for (object *op = ms->bot; op; op = op->above) + op->activate_recursive (); } void maptile::deactivate () { - if (!spaces) - return; + active = false; - for (mapspace *ms = spaces + size (); ms-- > spaces; ) - for (object *op = ms->bot; op; op = op->above) - op->deactivate_recursive (); + if (spaces) + for (mapspace *ms = spaces + size (); ms-- > spaces; ) + for (object *op = ms->bot; op; op = op->above) + op->deactivate_recursive (); } bool maptile::_save_objects (object_freezer &f, int flags) { - static int cede_count = 0; + coroapi::cede_to_tick (); if (flags & IO_HEADER) _save_header (f); @@ -466,18 +441,9 @@ for (int i = 0; i < size (); ++i) { - if (cede_count >= 500) - { - cede_count = 0; - coroapi::cede (); - } - int unique = 0; for (object *op = spaces [i].bot; op; op = op->above) { - // count per-object, but cede only when modification-safe - cede_count++; - if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]) unique = 1; @@ -494,6 +460,8 @@ } } + coroapi::cede_to_tick (); + return true; }