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.68 by root, Thu Jan 4 16:19:31 2007 UTC vs.
Revision 1.70 by root, Thu Jan 4 20:29:45 2007 UTC

731 * MSW 2001-07-01 731 * MSW 2001-07-01
732 */ 732 */
733bool 733bool
734maptile::load_header (object_thawer &thawer) 734maptile::load_header (object_thawer &thawer)
735{ 735{
736 char buf[HUGE_BUF], msgbuf[HUGE_BUF], maplorebuf[HUGE_BUF], *key = NULL, *value, *end;
737 int msgpos = 0;
738 int maplorepos = 0;
739
740 for (;;) 736 for (;;)
741 { 737 {
742 keyword kw = thawer.get_kv (); 738 keyword kw = thawer.get_kv ();
743 739
744 switch (kw) 740 switch (kw)
747 LOG (llevError, "%s: end of file while reading map header, aborting header load.\n", &path); 743 LOG (llevError, "%s: end of file while reading map header, aborting header load.\n", &path);
748 return false; 744 return false;
749 745
750 case KW_end: 746 case KW_end:
751 return true; 747 return true;
748
749 default:
750 case KW_ERROR:
751 LOG (llevError, "%s: skipping errornous line (%s) while reading map header.\n", &path, thawer.last_keyword);
752 break;
752 753
753 case KW_msg: 754 case KW_msg:
754 thawer.get_ml (KW_endmsg, msg); 755 thawer.get_ml (KW_endmsg, msg);
755 break; 756 break;
756 757
807 808
808 case KW_tile_path_1: thawer.get (tile_path [0]); break; 809 case KW_tile_path_1: thawer.get (tile_path [0]); break;
809 case KW_tile_path_2: thawer.get (tile_path [1]); break; 810 case KW_tile_path_2: thawer.get (tile_path [1]); break;
810 case KW_tile_path_3: thawer.get (tile_path [2]); break; 811 case KW_tile_path_3: thawer.get (tile_path [2]); break;
811 case KW_tile_path_4: thawer.get (tile_path [3]); break; 812 case KW_tile_path_4: thawer.get (tile_path [3]); break;
812
813 default:
814 LOG (llevError, "%s: skipping unknown key in map header: %s\n", &path, keyword_str [kw]);
815 break;
816 } 813 }
817 } 814 }
818 815
819 abort (); 816 abort ();
820} 817}
1286 * the value of orig_map->tile_map[tile_num]. 1283 * the value of orig_map->tile_map[tile_num].
1287 */ 1284 */
1288static inline maptile * 1285static inline maptile *
1289find_and_link (maptile *orig_map, int tile_num) 1286find_and_link (maptile *orig_map, int tile_num)
1290{ 1287{
1291 maptile *mp = orig_map->find_sync (orig_map->tile_path [tile_num], orig_map); 1288 maptile *mp = orig_map->tile_map [tile_num];
1292 1289
1293 if (!mp) 1290 if (!mp)
1294 { 1291 {
1292 mp = orig_map->find_sync (orig_map->tile_path [tile_num], orig_map);
1293
1294 if (!mp)
1295 {
1295 // emergency mode, manufacture a dummy map, this creates a memleak, but thats fine 1296 // emergency mode, manufacture a dummy map, this creates a memleak, but thats fine
1296 LOG (llevError, "FATAL: cannot load tiled map %s from %s, leaking memory and worse!\n", 1297 LOG (llevError, "FATAL: cannot load tiled map %s from %s, leaking memory and worse!\n",
1297 &orig_map->tile_path[tile_num], &orig_map->path); 1298 &orig_map->tile_path[tile_num], &orig_map->path);
1298 mp = new maptile (1, 1); 1299 mp = new maptile (1, 1);
1299 mp->alloc (); 1300 mp->alloc ();
1300 mp->in_memory = MAP_IN_MEMORY; 1301 mp->in_memory = MAP_IN_MEMORY;
1302 }
1301 } 1303 }
1302 1304
1303 int dest_tile = (tile_num + 2) % 4; 1305 int dest_tile = (tile_num + 2) % 4;
1304 1306
1305 orig_map->tile_map[tile_num] = mp; 1307 orig_map->tile_map [tile_num] = mp;
1306 1308
1307 // optimisation: back-link map to origin map if euclidean 1309 // optimisation: back-link map to origin map if euclidean
1308 //TODO: non-euclidean maps MUST GO 1310 //TODO: non-euclidean maps MUST GO
1309 if (orig_map->tile_map[tile_num]->tile_path[dest_tile] == orig_map->path) 1311 if (orig_map->tile_map[tile_num]->tile_path[dest_tile] == orig_map->path)
1310 orig_map->tile_map[tile_num]->tile_map[dest_tile] = orig_map; 1312 orig_map->tile_map[tile_num]->tile_map[dest_tile] = orig_map;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines