From e6c09957771273ec38b3f42135205ed972c791bd Mon Sep 17 00:00:00 2001 From: Renato Machado Date: Thu, 7 Nov 2024 15:56:27 -0300 Subject: [PATCH] improve: prevent crash in checkCreatures (#3073) Apparently the creature can be destroyed while it is running in checkCreatures, so let's increase the counter to ensure it still exists. Note: It's had a rare crash while doing some testing. --- src/game/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 6e8a3c0eae5..780ce5b7303 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -6456,7 +6456,7 @@ void Game::checkCreatures() { metrics::method_latency measure(__METHOD_NAME__); static size_t index = 0; - std::erase_if(checkCreatureLists[index], [this](const std::shared_ptr &creature) { + std::erase_if(checkCreatureLists[index], [this](const std::shared_ptr creature) { if (creature->creatureCheck && creature->isAlive()) { creature->onThink(EVENT_CREATURE_THINK_INTERVAL); creature->onAttacking(EVENT_CREATURE_THINK_INTERVAL);