mirror of
https://gitcode.com/GitHub_Trending/az/azerothcore-wotlk.git
synced 2026-07-11 03:13:10 +00:00
fix(Core/Arena): Save player stats before removing score on leave (#24404)
Co-authored-by: victor <vngodoyr@unap.cl> Co-authored-by: sudlud <sudlud@users.noreply.github.com>
This commit is contained in:
@@ -246,9 +246,13 @@ void Arena::EndBattleground(TeamId winnerTeamId)
|
||||
trans->Append(stmt2);
|
||||
|
||||
uint8 memberId = 0;
|
||||
for (auto const& [playerGuid, arenaLogEntryData] : ArenaLogEntries)
|
||||
for (auto& [playerGuid, arenaLogEntryData] : ArenaLogEntries)
|
||||
{
|
||||
auto const& score = PlayerScores.find(playerGuid.GetCounter());
|
||||
// Update stats from PlayerScores if player is still in arena
|
||||
if (score != PlayerScores.end())
|
||||
arenaLogEntryData.SaveStats(score->second->GetDamageDone(), score->second->GetHealingDone(), score->second->GetKillingBlows());
|
||||
|
||||
stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
|
||||
stmt2->SetData(0, fightId);
|
||||
stmt2->SetData(1, ++memberId);
|
||||
@@ -257,18 +261,9 @@ void Arena::EndBattleground(TeamId winnerTeamId)
|
||||
stmt2->SetData(4, arenaLogEntryData.ArenaTeamId);
|
||||
stmt2->SetData(5, arenaLogEntryData.Acc);
|
||||
stmt2->SetData(6, arenaLogEntryData.IP);
|
||||
if (score != PlayerScores.end())
|
||||
{
|
||||
stmt2->SetData(7, score->second->GetDamageDone());
|
||||
stmt2->SetData(8, score->second->GetHealingDone());
|
||||
stmt2->SetData(9, score->second->GetKillingBlows());
|
||||
}
|
||||
else
|
||||
{
|
||||
stmt2->SetData(7, 0);
|
||||
stmt2->SetData(8, 0);
|
||||
stmt2->SetData(9, 0);
|
||||
}
|
||||
stmt2->SetData(7, arenaLogEntryData.DamageDone);
|
||||
stmt2->SetData(8, arenaLogEntryData.HealingDone);
|
||||
stmt2->SetData(9, arenaLogEntryData.KillingBlows);
|
||||
trans->Append(stmt2);
|
||||
}
|
||||
|
||||
|
||||
@@ -1061,6 +1061,11 @@ void Battleground::RemovePlayerAtLeave(Player* player)
|
||||
auto const& itr2 = PlayerScores.find(player->GetGUID().GetCounter());
|
||||
if (itr2 != PlayerScores.end())
|
||||
{
|
||||
// Save stats to ArenaLogEntries before deleting score (for arena logging)
|
||||
auto itr3 = ArenaLogEntries.find(player->GetGUID());
|
||||
if (itr3 != ArenaLogEntries.end())
|
||||
itr3->second.SaveStats(itr2->second->GetDamageDone(), itr2->second->GetHealingDone(), itr2->second->GetKillingBlows());
|
||||
|
||||
delete itr2->second;
|
||||
PlayerScores.erase(itr2);
|
||||
}
|
||||
|
||||
@@ -258,11 +258,21 @@ public:
|
||||
IP = ip;
|
||||
}
|
||||
|
||||
void SaveStats(uint32 damageDone, uint32 healingDone, uint32 killingBlows)
|
||||
{
|
||||
DamageDone = damageDone;
|
||||
HealingDone = healingDone;
|
||||
KillingBlows = killingBlows;
|
||||
}
|
||||
|
||||
std::string Name{};
|
||||
ObjectGuid::LowType Guid{0};
|
||||
uint32 Acc{0};
|
||||
uint32 ArenaTeamId{0};
|
||||
std::string IP{};
|
||||
uint32 DamageDone{0};
|
||||
uint32 HealingDone{0};
|
||||
uint32 KillingBlows{0};
|
||||
};
|
||||
|
||||
enum BGHonorMode
|
||||
|
||||
Reference in New Issue
Block a user