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.199 by root, Tue May 4 22:26:49 2010 UTC vs.
Revision 1.202 by root, Fri Apr 22 06:10:32 2011 UTC

311 case KW_arch: 311 case KW_arch:
312 if (object *op = object::read (f, this)) 312 if (object *op = object::read (f, this))
313 { 313 {
314 // TODO: why? 314 // TODO: why?
315 if (op->inv) 315 if (op->inv)
316 {
317 op->carrying = 0;
316 op->update_weight (); 318 op->update_weight ();
319 }
317 320
318 if (IN_RANGE_EXC (op->x, 0, width) && IN_RANGE_EXC (op->y, 0, height)) 321 if (IN_RANGE_EXC (op->x, 0, width) && IN_RANGE_EXC (op->y, 0, height))
319 { 322 {
320 // we insert manually because 323 // we insert manually because
321 // a) its way faster 324 // a) its way faster
611 { 614 {
612 case KW_msg: 615 case KW_msg:
613 thawer.get_ml (KW_endmsg, msg); 616 thawer.get_ml (KW_endmsg, msg);
614 break; 617 break;
615 618
616 case KW_lore: // CF+ extension 619 case KW_lore: // deliantra extension
617 thawer.get_ml (KW_endlore, maplore); 620 thawer.get_ml (KW_endlore, maplore);
618 break; 621 break;
619 622
620 case KW_maplore: 623 case KW_maplore:
621 thawer.get_ml (KW_endmaplore, maplore); 624 thawer.get_ml (KW_endmaplore, maplore);
662 665
663 case KW_tile_path_1: thawer.get (tile_path [0]); break; 666 case KW_tile_path_1: thawer.get (tile_path [0]); break;
664 case KW_tile_path_2: thawer.get (tile_path [1]); break; 667 case KW_tile_path_2: thawer.get (tile_path [1]); break;
665 case KW_tile_path_3: thawer.get (tile_path [2]); break; 668 case KW_tile_path_3: thawer.get (tile_path [2]); break;
666 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;
667 672
668 case KW_ERROR: 673 case KW_ERROR:
669 set_key_text (thawer.kw_str, thawer.value); 674 set_key_text (thawer.kw_str, thawer.value);
670 break; 675 break;
671 676
754 759
755 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]);
756 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]);
757 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]);
758 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]);
759 766
760 freezer.put (this); 767 freezer.put (this);
761 freezer.put (KW(end)); 768 freezer.put (KW(end));
762 769
763 return true; 770 return true;
820 msg = 0; 827 msg = 0;
821 maplore = 0; 828 maplore = 0;
822 shoprace = 0; 829 shoprace = 0;
823 delete [] shopitems, shopitems = 0; 830 delete [] shopitems, shopitems = 0;
824 831
825 for (int i = 0; i < 4; i++) 832 for (int i = 0; i < TILE_NUM; i++)
826 tile_path [i] = 0; 833 tile_path [i] = 0;
827} 834}
828 835
829maptile::~maptile () 836maptile::~maptile ()
830{ 837{
1190maptile * 1197maptile *
1191maptile::tile_available (int dir, bool load) 1198maptile::tile_available (int dir, bool load)
1192{ 1199{
1193 if (tile_path[dir]) 1200 if (tile_path[dir])
1194 { 1201 {
1202 // map is there and we don't need to load it OR it's loaded => return what we have
1195 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))
1196 return tile_map[dir]; 1204 return tile_map[dir];
1197 1205
1206 // well, try to locate it then, if possible - maybe it's there already
1198 if ((tile_map[dir] = find_async (tile_path[dir], this, load))) 1207 if ((tile_map[dir] = find_async (tile_path[dir], this, load)))
1199 return tile_map[dir]; 1208 return tile_map[dir];
1200 } 1209 }
1201 1210
1202 return 0; 1211 return 0;
1326 if (map1 == map2) 1335 if (map1 == map2)
1327 { 1336 {
1328 *dx = 0; 1337 *dx = 0;
1329 *dy = 0; 1338 *dy = 0;
1330 } 1339 }
1331 else if (map1->tile_available (0, false) == map2) 1340 else if (map1->tile_available (TILE_NORTH, false) == map2)
1332 { /* up */ 1341 {
1333 *dx = 0; 1342 *dx = 0;
1334 *dy = -map2->height; 1343 *dy = -map2->height;
1335 } 1344 }
1336 else if (map1->tile_available (1, false) == map2) 1345 else if (map1->tile_available (TILE_EAST , false) == map2)
1337 { /* right */ 1346 {
1338 *dx = map1->width; 1347 *dx = map1->width;
1339 *dy = 0; 1348 *dy = 0;
1340 } 1349 }
1341 else if (map1->tile_available (2, false) == map2) 1350 else if (map1->tile_available (TILE_SOUTH, false) == map2)
1342 { /* down */ 1351 {
1343 *dx = 0; 1352 *dx = 0;
1344 *dy = map1->height; 1353 *dy = map1->height;
1345 } 1354 }
1346 else if (map1->tile_available (3, false) == map2) 1355 else if (map1->tile_available (TILE_WEST , false) == map2)
1347 { /* left */ 1356 {
1348 *dx = -map2->width; 1357 *dx = -map2->width;
1349 *dy = 0; 1358 *dy = 0;
1350 } 1359 }
1351 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)
1352 { /* up right */ 1361 { /* up right */
1353 *dx = map1->tile_map[0]->width; 1362 *dx = +map1->tile_map[TILE_NORTH]->width;
1354 *dy = -map1->tile_map[0]->height; 1363 *dy = -map1->tile_map[TILE_NORTH]->height;
1355 } 1364 }
1356 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)
1357 { /* up left */ 1366 { /* up left */
1358 *dx = -map2->width; 1367 *dx = -map2->width;
1359 *dy = -map1->tile_map[0]->height; 1368 *dy = -map1->tile_map[TILE_NORTH]->height;
1360 } 1369 }
1361 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)
1362 { /* right up */ 1371 { /* right up */
1363 *dx = map1->width; 1372 *dx = +map1->width;
1364 *dy = -map2->height; 1373 *dy = -map2->height;
1365 } 1374 }
1366 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)
1367 { /* right down */ 1376 { /* right down */
1368 *dx = map1->width; 1377 *dx = +map1->width;
1369 *dy = map1->tile_map[1]->height; 1378 *dy = +map1->tile_map[TILE_EAST]->height;
1370 } 1379 }
1371 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)
1372 { /* down right */ 1381 { /* down right */
1373 *dx = map1->tile_map[2]->width; 1382 *dx = +map1->tile_map[TILE_SOUTH]->width;
1374 *dy = map1->height; 1383 *dy = +map1->height;
1375 } 1384 }
1376 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)
1377 { /* down left */ 1386 { /* down left */
1378 *dx = -map2->width; 1387 *dx = -map2->width;
1379 *dy = map1->height; 1388 *dy = +map1->height;
1380 } 1389 }
1381 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)
1382 { /* left up */ 1391 { /* left up */
1383 *dx = -map1->tile_map[3]->width; 1392 *dx = -map1->tile_map[TILE_WEST]->width;
1384 *dy = -map2->height; 1393 *dy = -map2->height;
1385 } 1394 }
1386 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)
1387 { /* left down */ 1396 { /* left down */
1388 *dx = -map1->tile_map[3]->width; 1397 *dx = -map1->tile_map[TILE_WEST]->width;
1389 *dy = map1->tile_map[3]->height; 1398 *dy = +map1->tile_map[TILE_WEST]->height;
1390 } 1399 }
1391 else 1400 else
1392 return 0; 1401 return 0;
1393 1402
1394 return 1; 1403 return 1;
1626split_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)
1627{ 1636{
1628 // clip to map to the left 1637 // clip to map to the left
1629 if (x0 < 0) 1638 if (x0 < 0)
1630 { 1639 {
1631 if (maptile *tile = m->tile_available (TILE_LEFT, 1)) 1640 if (maptile *tile = m->tile_available (TILE_WEST, 1))
1632 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);
1633 1642
1634 if (x1 < 0) // entirely to the left 1643 if (x1 < 0) // entirely to the left
1635 return; 1644 return;
1636 1645
1638 } 1647 }
1639 1648
1640 // clip to map to the right 1649 // clip to map to the right
1641 if (x1 > m->width) 1650 if (x1 > m->width)
1642 { 1651 {
1643 if (maptile *tile = m->tile_available (TILE_RIGHT, 1)) 1652 if (maptile *tile = m->tile_available (TILE_EAST, 1))
1644 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);
1645 1654
1646 if (x0 > m->width) // entirely to the right 1655 if (x0 > m->width) // entirely to the right
1647 return; 1656 return;
1648 1657
1650 } 1659 }
1651 1660
1652 // clip to map above 1661 // clip to map above
1653 if (y0 < 0) 1662 if (y0 < 0)
1654 { 1663 {
1655 if (maptile *tile = m->tile_available (TILE_UP, 1)) 1664 if (maptile *tile = m->tile_available (TILE_NORTH, 1))
1656 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);
1657 1666
1658 if (y1 < 0) // entirely above 1667 if (y1 < 0) // entirely above
1659 return; 1668 return;
1660 1669
1662 } 1671 }
1663 1672
1664 // clip to map below 1673 // clip to map below
1665 if (y1 > m->height) 1674 if (y1 > m->height)
1666 { 1675 {
1667 if (maptile *tile = m->tile_available (TILE_DOWN, 1)) 1676 if (maptile *tile = m->tile_available (TILE_SOUTH, 1))
1668 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);
1669 1678
1670 if (y0 > m->height) // entirely below 1679 if (y0 > m->height) // entirely below
1671 return; 1680 return;
1672 1681

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines