Loot: remove a finished roll from every player that held it (#75)

LootRoll's destructor only dropped the pointer from players who had not voted
yet. A player who had voted (or who had left the map) kept a dangling
LootRoll* in Player::m_lootRolls, and the next Player::GetLootRoll lookup (a
roll vote packet arriving after the roll ended) read the destroyed roll.

The destructor now removes the roll from every player in the vote map, and
finds a player who left the map through the connected players.
This commit is contained in:
Karrz1
2026-10-20 09:04:11 +08:00
committed by GitHub
parent c27f3ad884
commit 32fa7794c9
+5 -4
View File
@@ -447,12 +447,13 @@ LootRoll::~LootRoll()
if (m_isStarted)
SendAllPassed();
// every player that was handed this roll must drop the pointer, voters included: a voter keeps it in Player::m_lootRolls
// until now, and the next lookup (Player::GetLootRoll from a roll vote packet) would read a destroyed roll
for (auto const& [playerGuid, roll] : m_rollVoteMap)
{
if (roll.Vote != RollVote::NotEmitedYet)
continue;
Player* player = ObjectAccessor::GetPlayer(m_map, playerGuid);
Player* player = m_map ? ObjectAccessor::GetPlayer(m_map, playerGuid) : nullptr;
if (!player)
player = ObjectAccessor::FindConnectedPlayer(playerGuid); // left the map since the roll started
if (!player)
continue;