diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/entities.cpp | 4 | ||||
-rw-r--r-- | src/mob.cpp | 1 | ||||
-rw-r--r-- | src/world.cpp | 4 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index b9acc20..9949c1f 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -329,8 +329,8 @@ void Object::reloadTexture(void) height = getItemHeight(iname); } -bool Entity::isNear(Entity e) { - return pow(e.loc.x - loc.x, 2) + pow(e.loc.y - loc.y, 2) <= pow(HLINES(40), 2); +bool Entity::isNear(const Entity *e) { + return pow(e->loc.x - loc.x, 2) + pow(e->loc.y - loc.y, 2) <= pow(HLINES(40), 2); } void NPC::drawThingy(void) const diff --git a/src/mob.cpp b/src/mob.cpp index 1f998f7..d6df3fd 100644 --- a/src/mob.cpp +++ b/src/mob.cpp @@ -11,6 +11,7 @@ Mob::Mob(void) inv = nullptr; rider = nullptr; canMove = true; + loc = 0; } Page::Page(void) : Mob() diff --git a/src/world.cpp b/src/world.cpp index f6df7d6..2931f81 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -1010,7 +1010,7 @@ getNearInteractable(Entity &e) { auto n = std::find_if(std::begin(entity), std::end(entity), [&](Entity *&a) { return ((a->type == MOBT) || (a->type == NPCT) || a->type == MERCHT) && - e.isNear(*a) && (e.left ? (a->loc.x < e.loc.x) : (a->loc.x > e.loc.x)); + e.isNear(a) && (e.left ? (a->loc.x < e.loc.x) : (a->loc.x > e.loc.x)); }); return n == std::end(entity) ? nullptr : *n; @@ -1020,7 +1020,7 @@ Mob *World:: getNearMob(Entity &e) { auto n = std::find_if(std::begin(mob), std::end(mob), [&](Mob *&a) { - return e.isNear(*a) && (e.left ? (a->loc.x < e.loc.x + e.width / 2) : (a->loc.x > e.loc.x + e.width / 2)); + return e.isNear(a) && (e.left ? (a->loc.x < e.loc.x + e.width / 2) : (a->loc.x > e.loc.x + e.width / 2)); }); return n == std::end(mob) ? nullptr : *n; |