From 457b19a2682cdca222885ba7d877ce85c44650ec Mon Sep 17 00:00:00 2001 From: mostlikely4r Date: Thu, 14 Dec 2023 22:15:10 +0100 Subject: [PATCH] -Crash fix: When a non-randombot sends back items it sent to itself. --- playerbot/strategy/actions/CheckMailAction.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/playerbot/strategy/actions/CheckMailAction.cpp b/playerbot/strategy/actions/CheckMailAction.cpp index a35c67cb6..3a03edc19 100644 --- a/playerbot/strategy/actions/CheckMailAction.cpp +++ b/playerbot/strategy/actions/CheckMailAction.cpp @@ -13,10 +13,17 @@ bool CheckMailAction::Execute(Event& event) bot->GetSession()->HandleQueryNextMailTime(p); list ids; + + PlayerMails mails; + + //Fetch mails first and then loop over them to prevent needing to check mails sent to self. for (PlayerMails::iterator i = bot->GetMailBegin(); i != bot->GetMailEnd(); ++i) { - Mail* mail = *i; + mails.push_back(*i); + } + for (auto & mail : mails) + { if (!mail || mail->state == MAIL_STATE_DELETED) continue;