diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 7e47adc8e..736f01164 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -76,7 +76,7 @@ int GetRotaryDistance(int x, int y) int GetMinDistance(Point position) { auto &myPlayer = plr[myplr]; - Point delta = (myPlayer.position.future - position).Absolute(); + Point delta = abs(myPlayer.position.future - position); return std::max(delta.x, delta.y); } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 15fec1e80..fbdfe3ef3 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -807,7 +807,7 @@ static bool LeftMouseCmd(bool bShift) return true; } else { auto &myPlayer = plr[myplr]; - Point delta = (myPlayer.position.tile - Point { cursmx, cursmy }).Absolute(); + Point delta = abs(myPlayer.position.tile - Point { cursmx, cursmy }); bNear = delta.x < 2 && delta.y < 2; if (pcursitem != -1 && pcurs == CURSOR_HAND && !bShift) { NetSendCmdLocParam1(true, invflag ? CMD_GOTOGETITEM : CMD_GOTOAGETITEM, { cursmx, cursmy }, pcursitem); diff --git a/Source/engine.h b/Source/engine.h index a5042a478..a965b2844 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -191,14 +191,14 @@ struct Point { return (approx + 512) / 1024; } - Point Absolute() const + constexpr friend Point abs(Point a) { - return { abs(x), abs(y) }; + return { std::abs(a.x), std::abs(a.y) }; } int ManhattanDistance(Point other) const { - Point offset = (*this - other).Absolute(); + Point offset = abs(*this - other); return offset.x + offset.y; } diff --git a/Source/msg.cpp b/Source/msg.cpp index 9c171fb08..8b6017c16 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1763,7 +1763,7 @@ static DWORD On_ATTACKID(TCmd *pCmd, int pnum) auto *p = (TCmdParam1 *)pCmd; if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - Point dist = (plr[pnum].position.tile - monster[p->wParam1].position.future).Absolute(); + Point dist = abs(plr[pnum].position.tile - monster[p->wParam1].position.future); if (dist.x > 1 || dist.y > 1) MakePlrPath(pnum, monster[p->wParam1].position.future, false); plr[pnum].destAction = ACTION_ATTACKMON; diff --git a/Source/sync.cpp b/Source/sync.cpp index 042b0ab5b..7ef5f085e 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -222,7 +222,7 @@ static void sync_monster(int pnum, const TSyncMonster *p) return; } - Point md = (monster[ndx].position.tile - Point { p->_mx, p->_my }).Absolute(); + Point md = abs(monster[ndx].position.tile - Point { p->_mx, p->_my }); if (md.x <= 2 && md.y <= 2) { if (monster[ndx]._mmode < MM_WALK || monster[ndx]._mmode > MM_WALK3) { Direction md = GetDirection(monster[ndx].position.tile, { p->_mx, p->_my });