… | |
… | |
77 | /* Make sure the coordinates are valid - they should be, as caller should |
77 | /* Make sure the coordinates are valid - they should be, as caller should |
78 | * have already checked this. |
78 | * have already checked this. |
79 | */ |
79 | */ |
80 | if (OUT_OF_REAL_MAP (m, sx, sy)) |
80 | if (OUT_OF_REAL_MAP (m, sx, sy)) |
81 | { |
81 | { |
82 | LOG (llevError, "blocked_link: Passed map, x, y coordinates outside of map\n"); |
82 | LOG (llevError | logBacktrace, "blocked_link: Passed map, x, y coordinates outside of map\n"); |
83 | return 1; |
83 | return 1; |
84 | } |
84 | } |
85 | |
85 | |
86 | mapspace &ms = m->at (sx, sy); |
86 | mapspace &ms = m->at (sx, sy); |
87 | |
87 | |
… | |
… | |
90 | |
90 | |
91 | /* If space is currently not blocked by anything, no need to |
91 | /* If space is currently not blocked by anything, no need to |
92 | * go further. Not true for players - all sorts of special |
92 | * go further. Not true for players - all sorts of special |
93 | * things we need to do for players. |
93 | * things we need to do for players. |
94 | */ |
94 | */ |
95 | if (ob->type != PLAYER && !(mflags & P_IS_ALIVE) && (blocked == 0)) |
95 | if (ob->type != PLAYER && !(mflags & P_IS_ALIVE) && blocked == 0) |
96 | return 0; |
96 | return 0; |
97 | |
97 | |
98 | /* if there isn't anything alive on this space, and this space isn't |
98 | /* if there isn't anything alive on this space, and this space isn't |
99 | * otherwise blocked, we can return now. Only if there is a living |
99 | * otherwise blocked, we can return now. Only if there is a living |
100 | * creature do we need to investigate if it is part of this creature |
100 | * creature do we need to investigate if it is part of this creature |
… | |
… | |
559 | * the map (or something equivilent) into output_string. */ |
559 | * the map (or something equivilent) into output_string. */ |
560 | static const char * |
560 | static const char * |
561 | print_shop_string (maptile *m) |
561 | print_shop_string (maptile *m) |
562 | { |
562 | { |
563 | static dynbuf_text buf; buf.clear (); |
563 | static dynbuf_text buf; buf.clear (); |
|
|
564 | bool first = true; |
564 | |
565 | |
565 | for (int i = 0; i < m->shopitems[0].index; i++) |
566 | for (int i = 0; i < m->shopitems[0].index; i++) |
566 | { |
567 | { |
|
|
568 | if (!first) |
|
|
569 | buf << ';'; |
|
|
570 | |
|
|
571 | first = false; |
|
|
572 | |
567 | if (m->shopitems[i].typenum) |
573 | if (m->shopitems[i].typenum) |
568 | { |
574 | { |
569 | if (m->shopitems[i].strength) |
575 | if (m->shopitems[i].strength) |
570 | buf.printf ("%s:%d;", m->shopitems[i].name, m->shopitems[i].strength); |
576 | buf.printf ("%s:%d", m->shopitems[i].name, m->shopitems[i].strength); |
571 | else |
577 | else |
572 | buf.printf ("%s;", m->shopitems[i].name); |
578 | buf.printf ("%s", m->shopitems[i].name); |
573 | } |
579 | } |
574 | else |
580 | else |
575 | { |
581 | { |
576 | if (m->shopitems[i].strength) |
582 | if (m->shopitems[i].strength) |
577 | buf.printf ("*:%d;", m->shopitems[i].strength); |
583 | buf.printf ("*:%d", m->shopitems[i].strength); |
578 | else |
584 | else |
579 | buf.printf ("*"); |
585 | buf.printf ("*"); |
580 | } |
586 | } |
581 | } |
587 | } |
582 | |
588 | |
… | |
… | |
638 | case KW_per_player: thawer.get (per_player); break; |
644 | case KW_per_player: thawer.get (per_player); break; |
639 | case KW_per_party: thawer.get (per_party); break; |
645 | case KW_per_party: thawer.get (per_party); break; |
640 | case KW_no_reset: thawer.get (no_reset); break; |
646 | case KW_no_reset: thawer.get (no_reset); break; |
641 | case KW_no_drop: thawer.get (no_drop); break; |
647 | case KW_no_drop: thawer.get (no_drop); break; |
642 | |
648 | |
643 | case KW_region: default_region = region::find (thawer.get_str ()); break; |
649 | case KW_region: thawer.get (default_region); break; |
644 | case KW_shopitems: shopitems = parse_shop_string (thawer.get_str ()); break; |
650 | case KW_shopitems: shopitems = parse_shop_string (thawer.get_str ()); break; |
645 | |
651 | |
646 | // old names new names |
652 | // old names new names |
647 | case KW_hp: case KW_enter_x: thawer.get (enter_x); break; |
653 | case KW_hp: case KW_enter_x: thawer.get (enter_x); break; |
648 | case KW_sp: case KW_enter_y: thawer.get (enter_y); break; |
654 | case KW_sp: case KW_enter_y: thawer.get (enter_y); break; |
… | |
… | |
1308 | /** |
1314 | /** |
1309 | * 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 |
1310 | * map1 to map2 in dx/dy. |
1316 | * map1 to map2 in dx/dy. |
1311 | */ |
1317 | */ |
1312 | int |
1318 | int |
1313 | adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy) |
1319 | adjacent_map (maptile *map1, maptile *map2, int *dx, int *dy) |
1314 | { |
1320 | { |
1315 | if (!map1 || !map2) |
1321 | if (!map1 || !map2) |
1316 | return 0; |
1322 | return 0; |
1317 | |
1323 | |
1318 | //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 |
… | |
… | |
1320 | if (map1 == map2) |
1326 | if (map1 == map2) |
1321 | { |
1327 | { |
1322 | *dx = 0; |
1328 | *dx = 0; |
1323 | *dy = 0; |
1329 | *dy = 0; |
1324 | } |
1330 | } |
1325 | else if (map1->tile_map[0] == map2) |
1331 | else if (map1->tile_available (0, false) == map2) |
1326 | { /* up */ |
1332 | { /* up */ |
1327 | *dx = 0; |
1333 | *dx = 0; |
1328 | *dy = -map2->height; |
1334 | *dy = -map2->height; |
1329 | } |
1335 | } |
1330 | else if (map1->tile_map[1] == map2) |
1336 | else if (map1->tile_available (1, false) == map2) |
1331 | { /* right */ |
1337 | { /* right */ |
1332 | *dx = map1->width; |
1338 | *dx = map1->width; |
1333 | *dy = 0; |
1339 | *dy = 0; |
1334 | } |
1340 | } |
1335 | else if (map1->tile_map[2] == map2) |
1341 | else if (map1->tile_available (2, false) == map2) |
1336 | { /* down */ |
1342 | { /* down */ |
1337 | *dx = 0; |
1343 | *dx = 0; |
1338 | *dy = map1->height; |
1344 | *dy = map1->height; |
1339 | } |
1345 | } |
1340 | else if (map1->tile_map[3] == map2) |
1346 | else if (map1->tile_available (3, false) == map2) |
1341 | { /* left */ |
1347 | { /* left */ |
1342 | *dx = -map2->width; |
1348 | *dx = -map2->width; |
1343 | *dy = 0; |
1349 | *dy = 0; |
1344 | } |
1350 | } |
1345 | 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) |
1346 | { /* up right */ |
1352 | { /* up right */ |
1347 | *dx = map1->tile_map[0]->width; |
1353 | *dx = map1->tile_map[0]->width; |
1348 | *dy = -map1->tile_map[0]->height; |
1354 | *dy = -map1->tile_map[0]->height; |
1349 | } |
1355 | } |
1350 | 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) |
1351 | { /* up left */ |
1357 | { /* up left */ |
1352 | *dx = -map2->width; |
1358 | *dx = -map2->width; |
1353 | *dy = -map1->tile_map[0]->height; |
1359 | *dy = -map1->tile_map[0]->height; |
1354 | } |
1360 | } |
1355 | 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) |
1356 | { /* right up */ |
1362 | { /* right up */ |
1357 | *dx = map1->width; |
1363 | *dx = map1->width; |
1358 | *dy = -map2->height; |
1364 | *dy = -map2->height; |
1359 | } |
1365 | } |
1360 | 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) |
1361 | { /* right down */ |
1367 | { /* right down */ |
1362 | *dx = map1->width; |
1368 | *dx = map1->width; |
1363 | *dy = map1->tile_map[1]->height; |
1369 | *dy = map1->tile_map[1]->height; |
1364 | } |
1370 | } |
1365 | 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) |
1366 | { /* down right */ |
1372 | { /* down right */ |
1367 | *dx = map1->tile_map[2]->width; |
1373 | *dx = map1->tile_map[2]->width; |
1368 | *dy = map1->height; |
1374 | *dy = map1->height; |
1369 | } |
1375 | } |
1370 | 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) |
1371 | { /* down left */ |
1377 | { /* down left */ |
1372 | *dx = -map2->width; |
1378 | *dx = -map2->width; |
1373 | *dy = map1->height; |
1379 | *dy = map1->height; |
1374 | } |
1380 | } |
1375 | 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) |
1376 | { /* left up */ |
1382 | { /* left up */ |
1377 | *dx = -map1->tile_map[3]->width; |
1383 | *dx = -map1->tile_map[3]->width; |
1378 | *dy = -map2->height; |
1384 | *dy = -map2->height; |
1379 | } |
1385 | } |
1380 | 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) |
1381 | { /* left down */ |
1387 | { /* left down */ |
1382 | *dx = -map1->tile_map[3]->width; |
1388 | *dx = -map1->tile_map[3]->width; |
1383 | *dy = map1->tile_map[3]->height; |
1389 | *dy = map1->tile_map[3]->height; |
1384 | } |
1390 | } |
1385 | else |
1391 | else |
… | |
… | |
1471 | retval->distance_x += op1->x - best->x; |
1477 | retval->distance_x += op1->x - best->x; |
1472 | retval->distance_y += op1->y - best->y; |
1478 | retval->distance_y += op1->y - best->y; |
1473 | } |
1479 | } |
1474 | } |
1480 | } |
1475 | |
1481 | |
1476 | retval->part = best; |
1482 | retval->part = best; |
1477 | retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); |
1483 | retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); |
1478 | retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y); |
1484 | retval->direction = find_dir_2 (retval->distance_x, retval->distance_y); |
1479 | } |
1485 | } |
1480 | } |
1486 | } |
1481 | |
1487 | |
1482 | /* this is basically the same as get_rangevector above, but instead of |
1488 | /* this is basically the same as get_rangevector above, but instead of |
1483 | * the first parameter being an object, it instead is the map |
1489 | * the first parameter being an object, it instead is the map |
… | |
… | |
1488 | * 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 |
1489 | * 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 |
1490 | * field of the rv_vector is set to NULL. |
1496 | * field of the rv_vector is set to NULL. |
1491 | */ |
1497 | */ |
1492 | void |
1498 | void |
1493 | get_rangevector_from_mapcoord (const maptile *m, int x, int y, const object *op2, rv_vector *retval, int flags) |
1499 | get_rangevector_from_mapcoord (maptile *m, int x, int y, const object *op2, rv_vector *retval, int flags) |
1494 | { |
1500 | { |
1495 | 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)) |
1496 | { |
1502 | { |
1497 | /* be conservative and fill in _some_ data */ |
1503 | /* be conservative and fill in _some_ data */ |
1498 | retval->distance = 100000; |
1504 | retval->distance = 100000; |
1499 | retval->distance_x = 32767; |
1505 | retval->distance_x = 32767; |
1500 | retval->distance_y = 32767; |
1506 | retval->distance_y = 32767; |
1501 | retval->direction = 0; |
1507 | retval->direction = 0; |
1502 | retval->part = 0; |
1508 | retval->part = 0; |
1503 | } |
1509 | } |
1504 | else |
1510 | else |
1505 | { |
1511 | { |
1506 | retval->distance_x += op2->x - x; |
1512 | retval->distance_x += op2->x - x; |
1507 | retval->distance_y += op2->y - y; |
1513 | retval->distance_y += op2->y - y; |
1508 | |
1514 | |
1509 | retval->part = 0; |
1515 | retval->part = 0; |
1510 | retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); |
1516 | retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); |
1511 | retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y); |
1517 | retval->direction = find_dir_2 (retval->distance_x, retval->distance_y); |
1512 | } |
1518 | } |
1513 | } |
1519 | } |
1514 | |
1520 | |
1515 | /* Returns true of op1 and op2 are effectively on the same map |
1521 | /* Returns true of op1 and op2 are effectively on the same map |
1516 | * (as related to map tiling). Note that this looks for a path from |
1522 | * (as related to map tiling). Note that this looks for a path from |