--- deliantra/server/common/map.C 2006/12/30 18:45:27 1.58 +++ deliantra/server/common/map.C 2006/12/31 10:28:35 1.60 @@ -333,7 +333,7 @@ maptile *m1; sint16 sx, sy; - if (ob == NULL) + if (!ob) { flag = get_map_flags (m, &m1, x, y, &sx, &sy); if (flag & P_OUT_OF_MAP) @@ -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;