From f8bceecf3a6fc6b3d8d5bb7473f6771c21fe7a44 Mon Sep 17 00:00:00 2001 From: Vsevolod Kremianskii Date: Mon, 16 Nov 2020 01:26:40 +0700 Subject: [PATCH] fix: Delay trigger's onExit script execution --- src/game/object/trigger.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/game/object/trigger.cpp b/src/game/object/trigger.cpp index 0c659374..860c0a82 100644 --- a/src/game/object/trigger.cpp +++ b/src/game/object/trigger.cpp @@ -74,16 +74,16 @@ void Trigger::update(float dt) { set> tenantsToRemove; for (auto &tenant : _tenants) { - glm::vec2 position2d(tenant->position()); - if (isIn(position2d)) continue; - + if (tenant) { + glm::vec2 position2d(tenant->position()); + if (isIn(position2d)) continue; + } tenantsToRemove.insert(tenant); - + } + for (auto &tenant : tenantsToRemove) { if (!_blueprint->onExit().empty()) { runScript(_blueprint->onExit(), id(), tenant->id(), -1); } - } - for (auto &tenant : tenantsToRemove) { _tenants.erase(tenant); } }