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.201 by root, Sat Jul 10 21:07:47 2010 UTC vs.
Revision 1.202 by root, Fri Apr 22 06:10:32 2011 UTC

665 665
666 case KW_tile_path_1: thawer.get (tile_path [0]); break; 666 case KW_tile_path_1: thawer.get (tile_path [0]); break;
667 case KW_tile_path_2: thawer.get (tile_path [1]); break; 667 case KW_tile_path_2: thawer.get (tile_path [1]); break;
668 case KW_tile_path_3: thawer.get (tile_path [2]); break; 668 case KW_tile_path_3: thawer.get (tile_path [2]); break;
669 case KW_tile_path_4: thawer.get (tile_path [3]); break; 669 case KW_tile_path_4: thawer.get (tile_path [3]); break;
670 case KW_tile_path_5: thawer.get (tile_path [4]); break;
671 case KW_tile_path_6: thawer.get (tile_path [5]); break;
670 672
671 case KW_ERROR: 673 case KW_ERROR:
672 set_key_text (thawer.kw_str, thawer.value); 674 set_key_text (thawer.kw_str, thawer.value);
673 break; 675 break;
674 676
757 759
758 if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]); 760 if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]);
759 if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]); 761 if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]);
760 if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); 762 if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]);
761 if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); 763 if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]);
764 if (tile_path [4]) MAP_OUT2 (tile_path_5, tile_path [4]);
765 if (tile_path [5]) MAP_OUT2 (tile_path_6, tile_path [5]);
762 766
763 freezer.put (this); 767 freezer.put (this);
764 freezer.put (KW(end)); 768 freezer.put (KW(end));
765 769
766 return true; 770 return true;
823 msg = 0; 827 msg = 0;
824 maplore = 0; 828 maplore = 0;
825 shoprace = 0; 829 shoprace = 0;
826 delete [] shopitems, shopitems = 0; 830 delete [] shopitems, shopitems = 0;
827 831
828 for (int i = 0; i < 4; i++) 832 for (int i = 0; i < TILE_NUM; i++)
829 tile_path [i] = 0; 833 tile_path [i] = 0;
830} 834}
831 835
832maptile::~maptile () 836maptile::~maptile ()
833{ 837{
1193maptile * 1197maptile *
1194maptile::tile_available (int dir, bool load) 1198maptile::tile_available (int dir, bool load)
1195{ 1199{
1196 if (tile_path[dir]) 1200 if (tile_path[dir])
1197 { 1201 {
1202 // map is there and we don't need to load it OR it's loaded => return what we have
1198 if (tile_map[dir] && (!load || tile_map[dir]->in_memory == MAP_ACTIVE)) 1203 if (tile_map[dir] && (!load || tile_map[dir]->in_memory == MAP_ACTIVE))
1199 return tile_map[dir]; 1204 return tile_map[dir];
1200 1205
1206 // well, try to locate it then, if possible - maybe it's there already
1201 if ((tile_map[dir] = find_async (tile_path[dir], this, load))) 1207 if ((tile_map[dir] = find_async (tile_path[dir], this, load)))
1202 return tile_map[dir]; 1208 return tile_map[dir];
1203 } 1209 }
1204 1210
1205 return 0; 1211 return 0;
1329 if (map1 == map2) 1335 if (map1 == map2)
1330 { 1336 {
1331 *dx = 0; 1337 *dx = 0;
1332 *dy = 0; 1338 *dy = 0;
1333 } 1339 }
1334 else if (map1->tile_available (0, false) == map2) 1340 else if (map1->tile_available (TILE_NORTH, false) == map2)
1335 { /* up */ 1341 {
1336 *dx = 0; 1342 *dx = 0;
1337 *dy = -map2->height; 1343 *dy = -map2->height;
1338 } 1344 }
1339 else if (map1->tile_available (1, false) == map2) 1345 else if (map1->tile_available (TILE_EAST , false) == map2)
1340 { /* right */ 1346 {
1341 *dx = map1->width; 1347 *dx = map1->width;
1342 *dy = 0; 1348 *dy = 0;
1343 } 1349 }
1344 else if (map1->tile_available (2, false) == map2) 1350 else if (map1->tile_available (TILE_SOUTH, false) == map2)
1345 { /* down */ 1351 {
1346 *dx = 0; 1352 *dx = 0;
1347 *dy = map1->height; 1353 *dy = map1->height;
1348 } 1354 }
1349 else if (map1->tile_available (3, false) == map2) 1355 else if (map1->tile_available (TILE_WEST , false) == map2)
1350 { /* left */ 1356 {
1351 *dx = -map2->width; 1357 *dx = -map2->width;
1352 *dy = 0; 1358 *dy = 0;
1353 } 1359 }
1354 else if (map1->tile_map[0] && map1->tile_map[0]->tile_available (1, false) == map2) 1360 else if (map1->tile_map[TILE_NORTH] && map1->tile_map[TILE_NORTH]->tile_available (TILE_EAST , false) == map2)
1355 { /* up right */ 1361 { /* up right */
1356 *dx = map1->tile_map[0]->width; 1362 *dx = +map1->tile_map[TILE_NORTH]->width;
1357 *dy = -map1->tile_map[0]->height; 1363 *dy = -map1->tile_map[TILE_NORTH]->height;
1358 } 1364 }
1359 else if (map1->tile_map[0] && map1->tile_map[0]->tile_available (3, false) == map2) 1365 else if (map1->tile_map[TILE_NORTH] && map1->tile_map[TILE_NORTH]->tile_available (TILE_WEST , false) == map2)
1360 { /* up left */ 1366 { /* up left */
1361 *dx = -map2->width; 1367 *dx = -map2->width;
1362 *dy = -map1->tile_map[0]->height; 1368 *dy = -map1->tile_map[TILE_NORTH]->height;
1363 } 1369 }
1364 else if (map1->tile_map[1] && map1->tile_map[1]->tile_available (0, false) == map2) 1370 else if (map1->tile_map[TILE_EAST ] && map1->tile_map[TILE_EAST ]->tile_available (TILE_NORTH, false) == map2)
1365 { /* right up */ 1371 { /* right up */
1366 *dx = map1->width; 1372 *dx = +map1->width;
1367 *dy = -map2->height; 1373 *dy = -map2->height;
1368 } 1374 }
1369 else if (map1->tile_map[1] && map1->tile_map[1]->tile_available (2, false) == map2) 1375 else if (map1->tile_map[TILE_EAST ] && map1->tile_map[TILE_EAST ]->tile_available (TILE_SOUTH, false) == map2)
1370 { /* right down */ 1376 { /* right down */
1371 *dx = map1->width; 1377 *dx = +map1->width;
1372 *dy = map1->tile_map[1]->height; 1378 *dy = +map1->tile_map[TILE_EAST]->height;
1373 } 1379 }
1374 else if (map1->tile_map[2] && map1->tile_map[2]->tile_available (1, false) == map2) 1380 else if (map1->tile_map[TILE_SOUTH] && map1->tile_map[TILE_SOUTH]->tile_available (TILE_EAST , false) == map2)
1375 { /* down right */ 1381 { /* down right */
1376 *dx = map1->tile_map[2]->width; 1382 *dx = +map1->tile_map[TILE_SOUTH]->width;
1377 *dy = map1->height; 1383 *dy = +map1->height;
1378 } 1384 }
1379 else if (map1->tile_map[2] && map1->tile_map[2]->tile_available (3, false) == map2) 1385 else if (map1->tile_map[TILE_SOUTH] && map1->tile_map[TILE_SOUTH]->tile_available (TILE_WEST , false) == map2)
1380 { /* down left */ 1386 { /* down left */
1381 *dx = -map2->width; 1387 *dx = -map2->width;
1382 *dy = map1->height; 1388 *dy = +map1->height;
1383 } 1389 }
1384 else if (map1->tile_map[3] && map1->tile_map[3]->tile_available (0, false) == map2) 1390 else if (map1->tile_map[TILE_WEST ] && map1->tile_map[TILE_WEST ]->tile_available (TILE_NORTH, false) == map2)
1385 { /* left up */ 1391 { /* left up */
1386 *dx = -map1->tile_map[3]->width; 1392 *dx = -map1->tile_map[TILE_WEST]->width;
1387 *dy = -map2->height; 1393 *dy = -map2->height;
1388 } 1394 }
1389 else if (map1->tile_map[3] && map1->tile_map[3]->tile_available (2, false) == map2) 1395 else if (map1->tile_map[TILE_WEST ] && map1->tile_map[TILE_WEST ]->tile_available (TILE_SOUTH, false) == map2)
1390 { /* left down */ 1396 { /* left down */
1391 *dx = -map1->tile_map[3]->width; 1397 *dx = -map1->tile_map[TILE_WEST]->width;
1392 *dy = map1->tile_map[3]->height; 1398 *dy = +map1->tile_map[TILE_WEST]->height;
1393 } 1399 }
1394 else 1400 else
1395 return 0; 1401 return 0;
1396 1402
1397 return 1; 1403 return 1;
1629split_to_tiles (dynbuf &buf, maptile *m, int x0, int y0, int x1, int y1, int dx, int dy) 1635split_to_tiles (dynbuf &buf, maptile *m, int x0, int y0, int x1, int y1, int dx, int dy)
1630{ 1636{
1631 // clip to map to the left 1637 // clip to map to the left
1632 if (x0 < 0) 1638 if (x0 < 0)
1633 { 1639 {
1634 if (maptile *tile = m->tile_available (TILE_LEFT, 1)) 1640 if (maptile *tile = m->tile_available (TILE_WEST, 1))
1635 split_to_tiles (buf, tile, x0 + tile->width, y0, min (x1 + tile->width, tile->width), y1, dx - tile->width, dy); 1641 split_to_tiles (buf, tile, x0 + tile->width, y0, min (x1 + tile->width, tile->width), y1, dx - tile->width, dy);
1636 1642
1637 if (x1 < 0) // entirely to the left 1643 if (x1 < 0) // entirely to the left
1638 return; 1644 return;
1639 1645
1641 } 1647 }
1642 1648
1643 // clip to map to the right 1649 // clip to map to the right
1644 if (x1 > m->width) 1650 if (x1 > m->width)
1645 { 1651 {
1646 if (maptile *tile = m->tile_available (TILE_RIGHT, 1)) 1652 if (maptile *tile = m->tile_available (TILE_EAST, 1))
1647 split_to_tiles (buf, tile, max (x0 - m->width, 0), y0, x1 - m->width, y1, dx + m->width, dy); 1653 split_to_tiles (buf, tile, max (x0 - m->width, 0), y0, x1 - m->width, y1, dx + m->width, dy);
1648 1654
1649 if (x0 > m->width) // entirely to the right 1655 if (x0 > m->width) // entirely to the right
1650 return; 1656 return;
1651 1657
1653 } 1659 }
1654 1660
1655 // clip to map above 1661 // clip to map above
1656 if (y0 < 0) 1662 if (y0 < 0)
1657 { 1663 {
1658 if (maptile *tile = m->tile_available (TILE_UP, 1)) 1664 if (maptile *tile = m->tile_available (TILE_NORTH, 1))
1659 split_to_tiles (buf, tile, x0, y0 + tile->height, x1, min (y1 + tile->height, tile->height), dx, dy - tile->height); 1665 split_to_tiles (buf, tile, x0, y0 + tile->height, x1, min (y1 + tile->height, tile->height), dx, dy - tile->height);
1660 1666
1661 if (y1 < 0) // entirely above 1667 if (y1 < 0) // entirely above
1662 return; 1668 return;
1663 1669
1665 } 1671 }
1666 1672
1667 // clip to map below 1673 // clip to map below
1668 if (y1 > m->height) 1674 if (y1 > m->height)
1669 { 1675 {
1670 if (maptile *tile = m->tile_available (TILE_DOWN, 1)) 1676 if (maptile *tile = m->tile_available (TILE_SOUTH, 1))
1671 split_to_tiles (buf, tile, x0, max (y0 - m->height, 0), x1, y1 - m->height, dx, dy + m->height); 1677 split_to_tiles (buf, tile, x0, max (y0 - m->height, 0), x1, y1 - m->height, dx, dy + m->height);
1672 1678
1673 if (y0 > m->height) // entirely below 1679 if (y0 > m->height) // entirely below
1674 return; 1680 return;
1675 1681

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines