Skip to content

Commit 6bea704

Browse files
fix: spell range on south walls (#3412)
1 parent 714fd2f commit 6bea704

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/utils/tools.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "lua/lua_definitions.hpp"
1616
#include "utils/const.hpp"
1717
#include "config/configmanager.hpp"
18+
#include "game/movement/position.hpp"
1819

1920
#include "absl/debugging/stacktrace.h"
2021
#include "absl/debugging/symbolize.h"
@@ -570,6 +571,10 @@ Position getNextPosition(Direction direction, Position pos) {
570571
}
571572

572573
Direction getDirectionTo(const Position &from, const Position &to, bool exactDiagonalOnly /* =true*/) {
574+
if (from == to) {
575+
return DIRECTION_NONE;
576+
}
577+
573578
const int_fast32_t dx = Position::getOffsetX(from, to);
574579
const int_fast32_t dy = Position::getOffsetY(from, to);
575580

tests/unit/utils/position_functions_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ suite<"utils"> getDirectionToTest = [] {
1818
};
1919

2020
std::vector getDirectionToTestCases {
21-
GetDirectionToTestCase { Position {}, Position {}, DIRECTION_SOUTH, DIRECTION_SOUTH },
22-
GetDirectionToTestCase { Position { 0, 0, 0 }, Position { 0, 0, 0 }, DIRECTION_SOUTH, DIRECTION_SOUTH },
23-
GetDirectionToTestCase { Position { 100, 100, 100 }, Position { 100, 100, 100 }, DIRECTION_SOUTH, DIRECTION_SOUTH },
21+
GetDirectionToTestCase { Position {}, Position {}, DIRECTION_NONE, DIRECTION_NONE },
22+
GetDirectionToTestCase { Position { 0, 0, 0 }, Position { 0, 0, 0 }, DIRECTION_NONE, DIRECTION_NONE },
23+
GetDirectionToTestCase { Position { 100, 100, 100 }, Position { 100, 100, 100 }, DIRECTION_NONE, DIRECTION_NONE },
2424
GetDirectionToTestCase { Position { 125, 1123, 5 }, Position { 125, 1153, 5 }, DIRECTION_SOUTH, DIRECTION_SOUTH },
2525
GetDirectionToTestCase { Position { 5555, 3212, 15 }, Position { 5555, 3211, 15 }, DIRECTION_NORTH, DIRECTION_NORTH },
2626
GetDirectionToTestCase { Position { 32132, 65000, 11 }, Position { 31512, 65000, 11 }, DIRECTION_WEST, DIRECTION_WEST },

0 commit comments

Comments
 (0)