mirror of
https://gitcode.com/GitHub_Trending/az/azerothcore-wotlk.git
synced 2026-10-10 07:06:38 +08:00
fix(Scripts/World): guard server mail login callback against logged-o… (#27827)
This commit is contained in:
@@ -35,7 +35,8 @@ public:
|
||||
if (!session)
|
||||
return;
|
||||
|
||||
uint32 playerGUID = player->GetGUID().GetCounter();
|
||||
ObjectGuid playerGuid = player->GetGUID();
|
||||
uint32 playerGUID = playerGuid.GetCounter();
|
||||
bool isAlliance = player->GetTeamId() == TEAM_ALLIANCE;
|
||||
|
||||
for (auto const& [mailId, servMail] : serverMailStore)
|
||||
@@ -45,10 +46,14 @@ public:
|
||||
stmt->SetData(1, mailId);
|
||||
|
||||
// Capture servMail by value
|
||||
auto callback = [session, servMailWrapper = std::reference_wrapper<ServerMail const>(servMail), isAlliance](PreparedQueryResult result)
|
||||
auto callback = [session, playerGuid, servMailWrapper = std::reference_wrapper<ServerMail const>(servMail), isAlliance](PreparedQueryResult result)
|
||||
{
|
||||
ServerMail const& servMail = servMailWrapper.get(); // Dereference the wrapper to get the original object
|
||||
|
||||
Player* sessionPlayer = session->GetPlayer();
|
||||
if (!sessionPlayer || sessionPlayer->GetGUID() != playerGuid)
|
||||
return;
|
||||
|
||||
if (!result)
|
||||
{
|
||||
uint32 money = isAlliance ? servMail.moneyA : servMail.moneyH;
|
||||
@@ -56,7 +61,7 @@ public:
|
||||
std::vector<ServerMailCondition> const& conditions = servMail.conditions;
|
||||
|
||||
sServerMailMgr->SendServerMail(
|
||||
session->GetPlayer(),
|
||||
sessionPlayer,
|
||||
servMail.id,
|
||||
servMail.senderEntry,
|
||||
money,
|
||||
|
||||
Reference in New Issue
Block a user