--- deliantra/server/common/map.C 2007/02/15 21:07:48 1.87 +++ deliantra/server/common/map.C 2007/02/16 22:16:16 1.89 @@ -356,10 +356,8 @@ return; for (mapspace *ms = spaces + size (); ms-- > spaces; ) - for (object *tmp = ms->bot; tmp; ) + for (object *tmp = ms->bot; tmp; tmp = tmp->above) { - object *above = tmp->above; - /* already multipart - don't do anything more */ if (!tmp->head && !tmp->more) { @@ -391,77 +389,45 @@ insert_ob_in_map (op, op->map, tmp, INS_NO_MERGE | INS_ABOVE_FLOOR_ONLY | INS_NO_WALK_ON); } } - - tmp = above; } } /* * Loads (ands parses) the objects into a given map from the specified * file pointer. - * mapflags is the same as we get with load_original_map */ bool -maptile::_load_objects (object_thawer &thawer) +maptile::_load_objects (object_thawer &f) { - int unique; - object *op, *prev = NULL, *last_more = NULL, *otmp; - - op = object::create (); - op->map = this; /* To handle buttons correctly */ - - while (int i = load_object (thawer, op, 0)) + for (;;) { - /* if the archetype for the object is null, means that we - * got an invalid object. Don't do anything with it - the game - * or editor will not be able to do anything with it either. - */ - if (op->arch == NULL) - { - LOG (llevDebug, "Discarding object without arch: %s\n", op->name ? (const char *) op->name : "(null)"); - continue; - } + coroapi::cede_every (1000); // cede once in a while - switch (i) + switch (f.kw) { - case LL_NORMAL: - insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD); + case KW_arch: + if (object *op = object::read (f)) + { + if (op->inv) + sum_weight (op); - if (op->inv) - sum_weight (op); + insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD); + } - prev = op, last_more = op; - break; + continue; + + case KW_EOF: + return true; - case LL_MORE: - insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY); - op->head = prev, last_more->more = op, last_more = op; + default: + if (!f.parse_error ("map file")) + return false; break; } - op = object::create (); - op->map = this; + f.next (); } - op->destroy (); - -#if 0 - for (i = 0; i < width; i++) - for (j = 0; j < height; j++) - { - unique = 0; - /* check for unique items, or unique squares */ - for (otmp = GET_MAP_OB (m, i, j); otmp; otmp = otmp->above) - { - if (QUERY_FLAG (otmp, FLAG_UNIQUE) || QUERY_FLAG (otmp, FLAG_OBJ_SAVE_ON_OVL)) - unique = 1; - - if (!(mapflags & (MAP_OVERLAY | MAP_PLAYER_UNIQUE) || unique)) - SET_FLAG (otmp, FLAG_OBJ_ORIGINAL); - } - } -#endif - return true; } @@ -488,12 +454,12 @@ } bool -maptile::_save_objects (object_freezer &freezer, int flags) +maptile::_save_objects (object_freezer &f, int flags) { static int cede_count = 0; if (flags & IO_HEADER) - _save_header (freezer); + _save_header (f); if (!spaces) return false; @@ -523,10 +489,10 @@ if (unique || op->flag [FLAG_UNIQUE]) { if (flags & IO_UNIQUES) - save_object (freezer, op, 1); + op->write (f); } else if (flags & IO_OBJECTS) - save_object (freezer, op, 1); + op->write (f); } } @@ -536,21 +502,23 @@ bool maptile::_load_objects (const char *path, bool skip_header) { - object_thawer thawer (path); + object_thawer f (path); - if (!thawer) + if (!f) return false; + f.next (); + if (skip_header) for (;;) { - if (thawer.kw == KW_end) + keyword kw = f.kw; + f.skip (); + if (kw == KW_end) break; - - thawer.skip_kv (); } - return _load_objects (thawer); + return _load_objects (f); } bool