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.198 by root, Thu Apr 29 12:24:04 2010 UTC vs.
Revision 1.199 by root, Tue May 4 22:26:49 2010 UTC

1314/** 1314/**
1315 * Return whether map2 is adjacent to map1. If so, store the distance from 1315 * Return whether map2 is adjacent to map1. If so, store the distance from
1316 * map1 to map2 in dx/dy. 1316 * map1 to map2 in dx/dy.
1317 */ 1317 */
1318int 1318int
1319adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy) 1319adjacent_map (maptile *map1, maptile *map2, int *dx, int *dy)
1320{ 1320{
1321 if (!map1 || !map2) 1321 if (!map1 || !map2)
1322 return 0; 1322 return 0;
1323 1323
1324 //TODO: this doesn't actually check correctly when intermediate maps are not loaded 1324 //TODO: this doesn't actually check correctly when intermediate maps are not loaded
1326 if (map1 == map2) 1326 if (map1 == map2)
1327 { 1327 {
1328 *dx = 0; 1328 *dx = 0;
1329 *dy = 0; 1329 *dy = 0;
1330 } 1330 }
1331 else if (map1->tile_map[0] == map2) 1331 else if (map1->tile_available (0, false) == map2)
1332 { /* up */ 1332 { /* up */
1333 *dx = 0; 1333 *dx = 0;
1334 *dy = -map2->height; 1334 *dy = -map2->height;
1335 } 1335 }
1336 else if (map1->tile_map[1] == map2) 1336 else if (map1->tile_available (1, false) == map2)
1337 { /* right */ 1337 { /* right */
1338 *dx = map1->width; 1338 *dx = map1->width;
1339 *dy = 0; 1339 *dy = 0;
1340 } 1340 }
1341 else if (map1->tile_map[2] == map2) 1341 else if (map1->tile_available (2, false) == map2)
1342 { /* down */ 1342 { /* down */
1343 *dx = 0; 1343 *dx = 0;
1344 *dy = map1->height; 1344 *dy = map1->height;
1345 } 1345 }
1346 else if (map1->tile_map[3] == map2) 1346 else if (map1->tile_available (3, false) == map2)
1347 { /* left */ 1347 { /* left */
1348 *dx = -map2->width; 1348 *dx = -map2->width;
1349 *dy = 0; 1349 *dy = 0;
1350 } 1350 }
1351 else if (map1->tile_map[0] && map1->tile_map[0]->tile_map[1] == map2) 1351 else if (map1->tile_map[0] && map1->tile_map[0]->tile_available (1, false) == map2)
1352 { /* up right */ 1352 { /* up right */
1353 *dx = map1->tile_map[0]->width; 1353 *dx = map1->tile_map[0]->width;
1354 *dy = -map1->tile_map[0]->height; 1354 *dy = -map1->tile_map[0]->height;
1355 } 1355 }
1356 else if (map1->tile_map[0] && map1->tile_map[0]->tile_map[3] == map2) 1356 else if (map1->tile_map[0] && map1->tile_map[0]->tile_available (3, false) == map2)
1357 { /* up left */ 1357 { /* up left */
1358 *dx = -map2->width; 1358 *dx = -map2->width;
1359 *dy = -map1->tile_map[0]->height; 1359 *dy = -map1->tile_map[0]->height;
1360 } 1360 }
1361 else if (map1->tile_map[1] && map1->tile_map[1]->tile_map[0] == map2) 1361 else if (map1->tile_map[1] && map1->tile_map[1]->tile_available (0, false) == map2)
1362 { /* right up */ 1362 { /* right up */
1363 *dx = map1->width; 1363 *dx = map1->width;
1364 *dy = -map2->height; 1364 *dy = -map2->height;
1365 } 1365 }
1366 else if (map1->tile_map[1] && map1->tile_map[1]->tile_map[2] == map2) 1366 else if (map1->tile_map[1] && map1->tile_map[1]->tile_available (2, false) == map2)
1367 { /* right down */ 1367 { /* right down */
1368 *dx = map1->width; 1368 *dx = map1->width;
1369 *dy = map1->tile_map[1]->height; 1369 *dy = map1->tile_map[1]->height;
1370 } 1370 }
1371 else if (map1->tile_map[2] && map1->tile_map[2]->tile_map[1] == map2) 1371 else if (map1->tile_map[2] && map1->tile_map[2]->tile_available (1, false) == map2)
1372 { /* down right */ 1372 { /* down right */
1373 *dx = map1->tile_map[2]->width; 1373 *dx = map1->tile_map[2]->width;
1374 *dy = map1->height; 1374 *dy = map1->height;
1375 } 1375 }
1376 else if (map1->tile_map[2] && map1->tile_map[2]->tile_map[3] == map2) 1376 else if (map1->tile_map[2] && map1->tile_map[2]->tile_available (3, false) == map2)
1377 { /* down left */ 1377 { /* down left */
1378 *dx = -map2->width; 1378 *dx = -map2->width;
1379 *dy = map1->height; 1379 *dy = map1->height;
1380 } 1380 }
1381 else if (map1->tile_map[3] && map1->tile_map[3]->tile_map[0] == map2) 1381 else if (map1->tile_map[3] && map1->tile_map[3]->tile_available (0, false) == map2)
1382 { /* left up */ 1382 { /* left up */
1383 *dx = -map1->tile_map[3]->width; 1383 *dx = -map1->tile_map[3]->width;
1384 *dy = -map2->height; 1384 *dy = -map2->height;
1385 } 1385 }
1386 else if (map1->tile_map[3] && map1->tile_map[3]->tile_map[2] == map2) 1386 else if (map1->tile_map[3] && map1->tile_map[3]->tile_available (2, false) == map2)
1387 { /* left down */ 1387 { /* left down */
1388 *dx = -map1->tile_map[3]->width; 1388 *dx = -map1->tile_map[3]->width;
1389 *dy = map1->tile_map[3]->height; 1389 *dy = map1->tile_map[3]->height;
1390 } 1390 }
1391 else 1391 else
1494 * be more consistant with the above function and also in case they are needed 1494 * be more consistant with the above function and also in case they are needed
1495 * for something in the future. Also, since no object is pasted, the best 1495 * for something in the future. Also, since no object is pasted, the best
1496 * field of the rv_vector is set to NULL. 1496 * field of the rv_vector is set to NULL.
1497 */ 1497 */
1498void 1498void
1499get_rangevector_from_mapcoord (const maptile *m, int x, int y, const object *op2, rv_vector *retval, int flags) 1499get_rangevector_from_mapcoord (maptile *m, int x, int y, const object *op2, rv_vector *retval, int flags)
1500{ 1500{
1501 if (!adjacent_map (m, op2->map, &retval->distance_x, &retval->distance_y)) 1501 if (!adjacent_map (m, op2->map, &retval->distance_x, &retval->distance_y))
1502 { 1502 {
1503 /* be conservative and fill in _some_ data */ 1503 /* be conservative and fill in _some_ data */
1504 retval->distance = 100000; 1504 retval->distance = 100000;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines