ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.57 by root, Sat Dec 30 15:07:58 2006 UTC vs.
Revision 1.60 by root, Sun Dec 31 10:28:35 2006 UTC

331 archetype *tmp; 331 archetype *tmp;
332 int flag; 332 int flag;
333 maptile *m1; 333 maptile *m1;
334 sint16 sx, sy; 334 sint16 sx, sy;
335 335
336 if (ob == NULL) 336 if (!ob)
337 { 337 {
338 flag = get_map_flags (m, &m1, x, y, &sx, &sy); 338 flag = get_map_flags (m, &m1, x, y, &sx, &sy);
339 if (flag & P_OUT_OF_MAP) 339 if (flag & P_OUT_OF_MAP)
340 return P_OUT_OF_MAP; 340 return P_OUT_OF_MAP;
341 341
1333 * so that it is easier for calling functions to verify success. 1333 * so that it is easier for calling functions to verify success.
1334 */ 1334 */
1335static maptile * 1335static maptile *
1336load_and_link_tiled_map (maptile *orig_map, int tile_num) 1336load_and_link_tiled_map (maptile *orig_map, int tile_num)
1337{ 1337{
1338 maptile *mp = orig_map->find_map (orig_map->tile_path[tile_num]); 1338 maptile *mp = orig_map->load_map_sync (orig_map->tile_path [tile_num], orig_map);
1339 mp->load (); 1339
1340 if (!mp || mp->in_memory != MAP_IN_MEMORY)
1341 {
1342 // emergency mode, manufacture a dummy map, this creates a memleak, but thats fine
1343 LOG (llevError, "FATAL: cannot load tiled map %s from %s, leaking memory and worse!\n",
1344 &orig_map->tile_path[tile_num], &orig_map->path);
1345 mp = new maptile (1, 1);
1346 mp->alloc ();
1347 mp->in_memory = MAP_IN_MEMORY;
1348 }
1340 1349
1341 int dest_tile = (tile_num + 2) % 4; 1350 int dest_tile = (tile_num + 2) % 4;
1342 1351
1343 orig_map->tile_map[tile_num] = mp; 1352 orig_map->tile_map[tile_num] = mp;
1344 1353
1345 /* need to do a strcmp here as the orig_map->path is not a shared string */ 1354 // optimisation: back-link map to origin map if euclidean
1346 if (orig_map->tile_map[tile_num]->tile_path[dest_tile] && orig_map->tile_map[tile_num]->tile_path[dest_tile] == orig_map->path) 1355 //TODO: non-euclidean maps MUST GO
1356 if (orig_map->tile_map[tile_num]->tile_path[dest_tile] == orig_map->path)
1347 orig_map->tile_map[tile_num]->tile_map[dest_tile] = orig_map; 1357 orig_map->tile_map[tile_num]->tile_map[dest_tile] = orig_map;
1348 1358
1349 return mp; 1359 return mp;
1350} 1360}
1351 1361
1477 } 1487 }
1478 1488
1479 /* Simple case - coordinates are within this local 1489 /* Simple case - coordinates are within this local
1480 * map. 1490 * map.
1481 */ 1491 */
1482
1483 m->last_access = runtime;
1484 return m; 1492 return m;
1485} 1493}
1486 1494
1487/** 1495/**
1488 * Return whether map2 is adjacent to map1. If so, store the distance from 1496 * Return whether map2 is adjacent to map1. If so, store the distance from

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines