--- deliantra/server/common/map.C 2006/12/27 09:28:01 1.53 +++ deliantra/server/common/map.C 2006/12/27 13:13:46 1.54 @@ -21,7 +21,6 @@ The authors can be reached via e-mail at */ - #include #include @@ -614,10 +613,7 @@ if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]) unique = 1; - if (op->type == PLAYER) - continue; - - if (op->head || op->owner) + if (!op->can_map_save ()) continue; if (unique || op->flag [FLAG_UNIQUE]) @@ -631,6 +627,7 @@ maptile::maptile () { in_memory = MAP_SWAPPED; + /* The maps used to pick up default x and y values from the * map archetype. Mimic that behaviour. */ @@ -645,6 +642,27 @@ worldparty = -1; } +void +maptile::link () +{ + next = first_map; + first_map = this; +} + +void +maptile::unlink () +{ + if (first_map == this) + first_map = next; + else + for_all_maps (m) + if (m->next = this) + { + m->next = next; + break; + } +} + /* * Allocates, initialises, and returns a pointer to a maptile. * Modified to no longer take a path option which was not being @@ -654,10 +672,7 @@ get_linked_map (void) { maptile *map = new maptile; - - map->next = first_map; - first_map = map; - + map->link (); return map; } @@ -724,6 +739,7 @@ if (p) p++; } + p = shop_string; strip_endline (p); items = new shopitems[number_of_entries + 1]; @@ -734,6 +750,7 @@ LOG (llevError, "parse_shop_string: I seem to have run out of string, that shouldn't happen.\n"); break; } + next_semicolon = strchr (p, ';'); next_colon = strchr (p, ':'); /* if there is a stregth specified, figure out what it is, we'll need it soon. */ @@ -770,12 +787,14 @@ LOG (llevError, "invalid type %s defined in shopitems in string %s\n", p, input_string); } } + items[i].index = number_of_entries; if (next_semicolon) p = ++next_semicolon; else p = NULL; } + free (shop_string); return items; } @@ -794,21 +813,18 @@ if (m->shopitems[i].typenum) { if (m->shopitems[i].strength) - { - sprintf (tmp, "%s:%d;", m->shopitems[i].name, m->shopitems[i].strength); - } + sprintf (tmp, "%s:%d;", m->shopitems[i].name, m->shopitems[i].strength); else sprintf (tmp, "%s;", m->shopitems[i].name); } else { if (m->shopitems[i].strength) - { - sprintf (tmp, "*:%d;", m->shopitems[i].strength); - } + sprintf (tmp, "*:%d;", m->shopitems[i].strength); else sprintf (tmp, "*"); } + strcat (output_string, tmp); } } @@ -1086,7 +1102,6 @@ * MAP_STYLE: style map - don't add active objects, don't add to server * managed map list. */ - maptile * load_original_map (const char *filename, int flags) { @@ -1135,7 +1150,6 @@ * Return the map object we load into (this can change from the passed * option if we can't find the original map) */ - static maptile * load_temporary_map (maptile *m) { @@ -1189,7 +1203,6 @@ * Return the map object we load into (this can change from the passed * option if we can't find the original map) */ - maptile * load_overlay_map (const char *filename, maptile *m) { @@ -1502,6 +1515,8 @@ { attachable::do_destroy (); + unlink (); + free_map (this, 1); free (tmpname), tmpname = 0; @@ -1515,16 +1530,6 @@ for (int i = 0; i < 4; i++) if (m->tile_map[i] == this) m->tile_map[i] = 0; - - if (first_map == this) - first_map = next; - else - for_all_maps (m) - if (m->next = this) - { - m->next = next; - break; - } } //TODO: must go @@ -1582,10 +1587,8 @@ else LOG (llevDebug, "Trying to load map %s.\n", create_pathname (name)); - //eval_pv ("$x = Event::time", 1);//D if (!(m = load_original_map (name, (flags & MAP_PLAYER_UNIQUE)))) return (NULL); - //eval_pv ("warn \"LOAD \", Event::time - $x", 1);//D fix_auto_apply (m); /* Chests which open as default */