Skip to content

Commit

Permalink
improve: prevent crash in checkCreatures (#3073)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mehah authored Nov 7, 2024
1 parent e2e57f6 commit e6c0995
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> &creature) {
std::erase_if(checkCreatureLists[index], [this](const std::shared_ptr<Creature> creature) {
if (creature->creatureCheck && creature->isAlive()) {
creature->onThink(EVENT_CREATURE_THINK_INTERVAL);
creature->onAttacking(EVENT_CREATURE_THINK_INTERVAL);
Expand Down

0 comments on commit e6c0995

Please sign in to comment.