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.61 by root, Sun Dec 31 17:17:22 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
528 if (!spaces) 528 if (!spaces)
529 return; 529 return;
530 530
531 for (mapspace *ms = spaces + size (); ms-- > spaces; ) 531 for (mapspace *ms = spaces + size (); ms-- > spaces; )
532 for (object *op = ms->bot; op; op = op->above) 532 for (object *op = ms->bot; op; op = op->above)
533 op->activate (1); 533 op->activate_recursive ();
534} 534}
535 535
536void 536void
537maptile::deactivate () 537maptile::deactivate ()
538{ 538{
539 if (!spaces) 539 if (!spaces)
540 return; 540 return;
541 541
542 for (mapspace *ms = spaces + size (); ms-- > spaces; ) 542 for (mapspace *ms = spaces + size (); ms-- > spaces; )
543 for (object *op = ms->bot; op; op = op->above) 543 for (object *op = ms->bot; op; op = op->above)
544 op->deactivate (1); 544 op->deactivate_recursive ();
545} 545}
546 546
547bool 547bool
548maptile::save_objects (object_freezer &freezer, int flags) 548maptile::save_objects (object_freezer &freezer, int flags)
549{ 549{
789 keyword kw = thawer.get_kv (); 789 keyword kw = thawer.get_kv ();
790 790
791 switch (kw) 791 switch (kw)
792 { 792 {
793 case KW_EOF: 793 case KW_EOF:
794 LOG (llevError, "%s: end of file while reading map header, aborting header load.", &path); 794 LOG (llevError, "%s: end of file while reading map header, aborting header load.\n", &path);
795 return false; 795 return false;
796 796
797 case KW_end: 797 case KW_end:
798 return true; 798 return true;
799 799
957 if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]); 957 if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]);
958 if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]); 958 if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]);
959 if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); 959 if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]);
960 if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); 960 if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]);
961 961
962 MAP_OUT2 (end, 0); 962 freezer.put (KW_end);
963 963
964 return true; 964 return true;
965} 965}
966 966
967bool 967bool
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