From 53603da8365a2b455a8d020e2ff3b58b23077f6f Mon Sep 17 00:00:00 2001 From: Vladimir Olteanu Date: Tue, 1 Jun 2021 08:48:35 +0300 Subject: [PATCH] Use Point::Absolute in sync_monster --- Source/sync.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/sync.cpp b/Source/sync.cpp index caa2d699d..042b0ab5b 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -201,8 +201,7 @@ uint32_t sync_all_monsters(const byte *pbBuf, uint32_t dwMaxLen) static void sync_monster(int pnum, const TSyncMonster *p) { - int ndx, mdx, mdy; - ndx = p->_mndx; + int ndx = p->_mndx; if (monster[ndx]._mhitpoints <= 0) { return; @@ -223,9 +222,8 @@ static void sync_monster(int pnum, const TSyncMonster *p) return; } - mdx = abs(monster[ndx].position.tile.x - p->_mx); - mdy = abs(monster[ndx].position.tile.y - p->_my); - if (mdx <= 2 && mdy <= 2) { + Point md = (monster[ndx].position.tile - Point { p->_mx, p->_my }).Absolute(); + 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 }); if (DirOK(ndx, md)) {