aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp4
-rw-r--r--src/mob.cpp1
-rw-r--r--src/world.cpp4
3 files changed, 5 insertions, 4 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 8299e2c..b417f11 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 efafa55..e6c5f0d 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -1030,7 +1030,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;
@@ -1040,7 +1040,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;