--- deliantra/server/common/map.C 2006/12/30 20:32:30 1.59 +++ deliantra/server/common/map.C 2006/12/31 17:17:22 1.61 @@ -530,7 +530,7 @@ for (mapspace *ms = spaces + size (); ms-- > spaces; ) for (object *op = ms->bot; op; op = op->above) - op->activate (1); + op->activate_recursive (); } void @@ -541,7 +541,7 @@ for (mapspace *ms = spaces + size (); ms-- > spaces; ) for (object *op = ms->bot; op; op = op->above) - op->deactivate (1); + op->deactivate_recursive (); } bool @@ -791,7 +791,7 @@ switch (kw) { case KW_EOF: - LOG (llevError, "%s: end of file while reading map header, aborting header load.", &path); + LOG (llevError, "%s: end of file while reading map header, aborting header load.\n", &path); return false; case KW_end: @@ -959,7 +959,7 @@ if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); - MAP_OUT2 (end, 0); + freezer.put (KW_end); return true; } @@ -1335,15 +1335,25 @@ static maptile * load_and_link_tiled_map (maptile *orig_map, int tile_num) { - maptile *mp = orig_map->find_map (orig_map->tile_path[tile_num]); - mp->load (); + maptile *mp = orig_map->load_map_sync (orig_map->tile_path [tile_num], orig_map); + + if (!mp || mp->in_memory != MAP_IN_MEMORY) + { + // emergency mode, manufacture a dummy map, this creates a memleak, but thats fine + LOG (llevError, "FATAL: cannot load tiled map %s from %s, leaking memory and worse!\n", + &orig_map->tile_path[tile_num], &orig_map->path); + mp = new maptile (1, 1); + mp->alloc (); + mp->in_memory = MAP_IN_MEMORY; + } int dest_tile = (tile_num + 2) % 4; orig_map->tile_map[tile_num] = mp; - /* need to do a strcmp here as the orig_map->path is not a shared string */ - if (orig_map->tile_map[tile_num]->tile_path[dest_tile] && orig_map->tile_map[tile_num]->tile_path[dest_tile] == orig_map->path) + // optimisation: back-link map to origin map if euclidean + //TODO: non-euclidean maps MUST GO + if (orig_map->tile_map[tile_num]->tile_path[dest_tile] == orig_map->path) orig_map->tile_map[tile_num]->tile_map[dest_tile] = orig_map; return mp;