Skip to content

Commit

Permalink
fix: reward collect crash
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Sep 15, 2023
1 parent 4b7e268 commit 114d0fb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9821,6 +9821,18 @@ void Game::playerRewardChestCollect(uint32_t playerId, const Position &pos, uint
return;
}

// Updates the parent of the reward chest and reward containers to avoid memory usage after cleaning
RewardChest* myRewardChest = player->getRewardChest();
if (myRewardChest->size() == 0) {
player->sendCancelMessage(RETURNVALUE_REWARDCHESTISEMPTY);
return;
}

myRewardChest->setParent(item->getContainer()->getParent()->getTile());
for (const auto &[mapRewardId, reward] : player->rewardMap) {
reward->setParent(myRewardChest);
}

std::lock_guard<std::mutex> lock(player->quickLootMutex);

ReturnValue returnValue = collectRewardChestItems(player, maxMoveItems);
Expand Down

0 comments on commit 114d0fb

Please sign in to comment.