diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-10-17 23:13:04 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-10-17 23:13:04 +0200 |
commit | 7d43c4e7ad6b83a23516b26b4aebf74f398c251b (patch) | |
tree | a6bd3b9f8e52c33615291ec4dc19f5ee9c9bb789 /src/world.cpp | |
parent | f66cf28c8b4d80122896c87dba8af74ea1872eba (diff) |
Fix a bug in entity linking.
Diffstat (limited to 'src/world.cpp')
-rw-r--r-- | src/world.cpp | 11 |
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; |