From 528179cb02aa7f720453c9eae40d4e2bdfd74cf1 Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Sat, 1 Jun 2019 11:48:12 -0400 Subject: [PATCH 1/2] Fix seg fault on bots rolling Using group->GetRolls() brings back a vector that gives a segmentation fault on one of the iterations when iterated. --- .../strategy/actions/LootRollAction.cpp | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/modules/Bots/playerbot/strategy/actions/LootRollAction.cpp b/src/modules/Bots/playerbot/strategy/actions/LootRollAction.cpp index f2a5c874..68a36ef6 100644 --- a/src/modules/Bots/playerbot/strategy/actions/LootRollAction.cpp +++ b/src/modules/Bots/playerbot/strategy/actions/LootRollAction.cpp @@ -23,27 +23,20 @@ bool LootRollAction::Execute(Event event) return false; RollVote vote = ROLL_PASS; - for (vector::iterator i = group->GetRolls().begin(); i != group->GetRolls().end(); ++i) - { - if ((*i)->isValid() && (*i)->lootedTargetGUID == guid && (*i)->itemSlot == slot) - { - uint32 itemId = (*i)->itemid; - ItemPrototype const *proto = sItemStorage.LookupEntry(itemId); - if (!proto) - continue; - switch (proto->Class) - { - case ITEM_CLASS_WEAPON: - case ITEM_CLASS_ARMOR: - if (QueryItemUsage(proto)) - vote = ROLL_NEED; - break; - default: - if (IsLootAllowed(itemId)) - vote = ROLL_NEED; - break; - } + ItemPrototype const *proto = sItemStorage.LookupEntry(guid.GetEntry()); + if(proto) + { + switch (proto->Class) + { + case ITEM_CLASS_WEAPON: + case ITEM_CLASS_ARMOR: + if (QueryItemUsage(proto)) + vote = ROLL_NEED; + break; + default: + if (IsLootAllowed(guid.GetEntry())) + vote = ROLL_NEED; break; } } From f6fc8b65555153efbe450174b511233406a504a9 Mon Sep 17 00:00:00 2001 From: Vale the Violet Mote Date: Sat, 1 Jun 2019 11:51:07 -0400 Subject: [PATCH 2/2] GetRolls no longer needed, caused seg fault --- src/game/WorldHandlers/Group.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/game/WorldHandlers/Group.h b/src/game/WorldHandlers/Group.h index f0ba5799..0a833105 100644 --- a/src/game/WorldHandlers/Group.h +++ b/src/game/WorldHandlers/Group.h @@ -463,7 +463,6 @@ class Group #ifdef ENABLE_PLAYERBOTS ObjectGuid GetTargetIcon(int index) { return m_targetIcons[index]; } - Rolls GetRolls() { return RollId; } #endif protected: