summaryrefslogtreecommitdiff
path: root/src/world.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.cpp')
-rw-r--r--src/world.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/world.cpp b/src/world.cpp
index 06369f6..c18a7ab 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -192,7 +192,7 @@ void entity_t::link(world_t *world)
for (int64_t y = 0; y < (int64_t)ysecs; y++)
for (int64_t x = 0; x < (int64_t)xsecs; x++) {
- sector_index_t index = sector_index_at(v2f_t(base[0] + x, base[1] + y));
+ sector_index_t index = base + sector_index_t(x, y);
sector_t *sector;
sector = world->get_sector(index);
@@ -202,8 +202,15 @@ void entity_t::link(world_t *world)
void entity_t::unlink(void)
{
- for (sector_t *sector : parents)
+ for (sector_t *sector : parents) {
+ if (sector->ents.find(this) == sector->ents.end()) {
+ printf("entity_t::unlink: %p should belong to %p (%" PRIi64", %" PRIi64") but it doesn't\n",
+ this, sector, sector->index[0], sector->index[1]);
+ continue;
+ }
+
sector->ents.erase(sector->ents.find(this));
+ }
parents.clear();
parent_world = nullptr;