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.56 by root, Sat Dec 30 10:16:10 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
1324 faces [0] = top; faces_obj [0] = top != blank_face ? top_obj : 0; 1324 faces [0] = top; faces_obj [0] = top != blank_face ? top_obj : 0;
1325 faces [1] = middle; faces_obj [1] = middle != blank_face ? middle_obj : 0; 1325 faces [1] = middle; faces_obj [1] = middle != blank_face ? middle_obj : 0;
1326 faces [2] = floor; faces_obj [2] = floor != blank_face ? floor_obj : 0; 1326 faces [2] = floor; faces_obj [2] = floor != blank_face ? floor_obj : 0;
1327} 1327}
1328 1328
1329void
1330set_map_reset_time (maptile *map)
1331{
1332 int timeout = map->reset_timeout;
1333
1334 if (timeout <= 0)
1335 timeout = MAP_DEFAULTRESET;
1336 if (timeout >= MAP_MAXRESET)
1337 timeout = MAP_MAXRESET;
1338
1339 map->reset_time = time (0) + timeout;
1340}
1341
1342/* this updates the orig_map->tile_map[tile_num] value after loading 1329/* this updates the orig_map->tile_map[tile_num] value after loading
1343 * the map. It also takes care of linking back the freshly loaded 1330 * the map. It also takes care of linking back the freshly loaded
1344 * maps tile_map values if it tiles back to this one. It returns 1331 * maps tile_map values if it tiles back to this one. It returns
1345 * the value of orig_map->tile_map[tile_num]. It really only does this 1332 * the value of orig_map->tile_map[tile_num]. It really only does this
1346 * so that it is easier for calling functions to verify success. 1333 * so that it is easier for calling functions to verify success.
1347 */ 1334 */
1348static maptile * 1335static maptile *
1349load_and_link_tiled_map (maptile *orig_map, int tile_num) 1336load_and_link_tiled_map (maptile *orig_map, int tile_num)
1350{ 1337{
1351 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);
1352 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 }
1353 1349
1354 int dest_tile = (tile_num + 2) % 4; 1350 int dest_tile = (tile_num + 2) % 4;
1355 1351
1356 orig_map->tile_map[tile_num] = mp; 1352 orig_map->tile_map[tile_num] = mp;
1357 1353
1358 /* 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
1359 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)
1360 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;
1361 1358
1362 return mp; 1359 return mp;
1363} 1360}
1364 1361
1490 } 1487 }
1491 1488
1492 /* Simple case - coordinates are within this local 1489 /* Simple case - coordinates are within this local
1493 * map. 1490 * map.
1494 */ 1491 */
1495
1496 m->last_access = runtime;
1497 return m; 1492 return m;
1498} 1493}
1499 1494
1500/** 1495/**
1501 * 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