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.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
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