Core/SAI: Apply include cleanups to cherry-picked changes
This commit is contained in:
@@ -425,7 +425,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_RANDOM_EMOTE:
|
||||
{
|
||||
std::vector<uint32> emotes;
|
||||
std::copy_if(e.action.randomEmote.emotes.begin(), e.action.randomEmote.emotes.end(),
|
||||
std::copy_if(std::begin(e.action.randomEmote.emotes), std::end(e.action.randomEmote.emotes),
|
||||
std::back_inserter(emotes), [](uint32 emote) { return emote != 0; });
|
||||
|
||||
for (WorldObject* target : targets)
|
||||
@@ -869,7 +869,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
|
||||
std::vector<uint32> phases;
|
||||
std::copy_if(e.action.randomPhase.phases.begin(), e.action.randomPhase.phases.end(),
|
||||
std::copy_if(std::begin(e.action.randomPhase.phases), std::end(e.action.randomPhase.phases),
|
||||
std::back_inserter(phases), [](uint32 phase) { return phase != 0; });
|
||||
|
||||
uint32 phase = Trinity::Containers::SelectRandomContainerElement(phases);
|
||||
@@ -1497,9 +1497,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
else
|
||||
{
|
||||
slot[0].ItemId = e.action.equip.slots[0];
|
||||
slot[1].ItemId = e.action.equip.slots[1];
|
||||
slot[2].ItemId = e.action.equip.slots[2];
|
||||
slot[0].ItemId = e.action.equip.slot1;
|
||||
slot[1].ItemId = e.action.equip.slot2;
|
||||
slot[2].ItemId = e.action.equip.slot3;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
|
||||
@@ -1683,7 +1683,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
|
||||
{
|
||||
std::vector<uint32> actionLists;
|
||||
std::copy_if(e.action.randTimedActionList.actionLists.begin(), e.action.randTimedActionList.actionLists.end(),
|
||||
std::copy_if(std::begin(e.action.randTimedActionList.actionLists), std::end(e.action.randTimedActionList.actionLists),
|
||||
std::back_inserter(actionLists), [](uint32 actionList) { return actionList != 0; });
|
||||
|
||||
uint32 id = Trinity::Containers::SelectRandomContainerElement(actionLists);
|
||||
@@ -2046,7 +2046,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_START_CLOSEST_WAYPOINT:
|
||||
{
|
||||
std::vector<uint32> waypoints;
|
||||
std::copy_if(e.action.closestWaypointFromList.wps.begin(), e.action.closestWaypointFromList.wps.end(),
|
||||
std::copy_if(std::begin(e.action.closestWaypointFromList.wps), std::end(e.action.closestWaypointFromList.wps),
|
||||
std::back_inserter(waypoints), [](uint32 wp) { return wp != 0; });
|
||||
|
||||
float distanceToClosest = std::numeric_limits<float>::max();
|
||||
|
||||
@@ -1094,7 +1094,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
}
|
||||
case SMART_ACTION_RANDOM_EMOTE:
|
||||
{
|
||||
if (std::all_of(e.action.randomEmote.emotes.begin(), e.action.randomEmote.emotes.end(), [](uint32 emote) { return emote == 0; }))
|
||||
if (std::all_of(std::begin(e.action.randomEmote.emotes), std::end(e.action.randomEmote.emotes), [](uint32 emote) { return emote == 0; }))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u does not have any non-zero emote",
|
||||
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
@@ -1108,7 +1108,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
}
|
||||
case SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
|
||||
{
|
||||
if (std::all_of(e.action.randTimedActionList.actionLists.begin(), e.action.randTimedActionList.actionLists.end(), [](uint32 actionList) { return actionList == 0; }))
|
||||
if (std::all_of(std::begin(e.action.randTimedActionList.actionLists), std::end(e.action.randTimedActionList.actionLists), [](uint32 actionList) { return actionList == 0; }))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u does not have any non-zero action list",
|
||||
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
@@ -1118,7 +1118,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
}
|
||||
case SMART_ACTION_START_CLOSEST_WAYPOINT:
|
||||
{
|
||||
if (std::all_of(e.action.closestWaypointFromList.wps.begin(), e.action.closestWaypointFromList.wps.end(), [](uint32 wp) { return wp == 0; }))
|
||||
if (std::all_of(std::begin(e.action.closestWaypointFromList.wps), std::end(e.action.closestWaypointFromList.wps), [](uint32 wp) { return wp == 0; }))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u does not have any non-zero waypoint id",
|
||||
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
@@ -1210,14 +1210,14 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
break;
|
||||
case SMART_ACTION_RANDOM_PHASE:
|
||||
{
|
||||
if (std::all_of(e.action.randomPhase.phases.begin(), e.action.randomPhase.phases.end(), [](uint32 phase) { return phase == 0; }))
|
||||
if (std::all_of(std::begin(e.action.randomPhase.phases), std::end(e.action.randomPhase.phases), [](uint32 phase) { return phase == 0; }))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u does not have any non-zero phase",
|
||||
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (std::any_of(e.action.randomPhase.phases.begin(), e.action.randomPhase.phases.end(), [](uint32 phase) { return phase >= SMART_EVENT_PHASE_MAX; }))
|
||||
if (std::any_of(std::begin(e.action.randomPhase.phases), std::end(e.action.randomPhase.phases), [](uint32 phase) { return phase >= SMART_EVENT_PHASE_MAX; }))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u attempts to set invalid phase, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
return false;
|
||||
@@ -1716,3 +1716,19 @@ CacheSpellContainerBounds SmartAIMgr::GetCreateItemSpellContainerBounds(uint32 i
|
||||
{
|
||||
return CreateItemSpellStore.equal_range(itemId);
|
||||
}
|
||||
|
||||
ObjectGuidVector::ObjectGuidVector(ObjectVector const& objectVector) : _objectVector(objectVector)
|
||||
{
|
||||
_guidVector.reserve(_objectVector.size());
|
||||
for (WorldObject* obj : _objectVector)
|
||||
_guidVector.push_back(obj->GetGUID());
|
||||
}
|
||||
|
||||
void ObjectGuidVector::UpdateObjects(WorldObject const& ref) const
|
||||
{
|
||||
_objectVector.clear();
|
||||
|
||||
for (ObjectGuid const& guid : _guidVector)
|
||||
if (WorldObject* obj = ObjectAccessor::GetWorldObject(ref, guid))
|
||||
_objectVector.push_back(obj);
|
||||
}
|
||||
@@ -18,15 +18,13 @@
|
||||
#ifndef TRINITY_SMARTSCRIPTMGR_H
|
||||
#define TRINITY_SMARTSCRIPTMGR_H
|
||||
|
||||
#include "Creature.h"
|
||||
#include "Define.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "UnitDefines.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class WorldObject;
|
||||
enum SpellEffIndex : uint8;
|
||||
|
||||
struct WayPoint
|
||||
@@ -660,7 +658,7 @@ struct SmartAction
|
||||
|
||||
struct
|
||||
{
|
||||
std::array<uint32, SMART_ACTION_PARAM_COUNT> emotes;
|
||||
uint32 emotes[SMART_ACTION_PARAM_COUNT];
|
||||
} randomEmote;
|
||||
|
||||
struct
|
||||
@@ -753,7 +751,7 @@ struct SmartAction
|
||||
|
||||
struct
|
||||
{
|
||||
std::array<uint32, SMART_ACTION_PARAM_COUNT> phases;
|
||||
uint32 phases[SMART_ACTION_PARAM_COUNT];
|
||||
} randomPhase;
|
||||
|
||||
struct
|
||||
@@ -952,7 +950,9 @@ struct SmartAction
|
||||
{
|
||||
uint32 entry;
|
||||
uint32 mask;
|
||||
std::array<uint32, MAX_EQUIPMENT_ITEMS> slots;
|
||||
uint32 slot1;
|
||||
uint32 slot2;
|
||||
uint32 slot3;
|
||||
} equip;
|
||||
|
||||
struct
|
||||
@@ -986,7 +986,7 @@ struct SmartAction
|
||||
|
||||
struct
|
||||
{
|
||||
std::array<uint32, SMART_ACTION_PARAM_COUNT> actionLists;
|
||||
uint32 actionLists[SMART_ACTION_PARAM_COUNT];
|
||||
} randTimedActionList;
|
||||
|
||||
struct
|
||||
@@ -1096,7 +1096,7 @@ struct SmartAction
|
||||
|
||||
struct
|
||||
{
|
||||
std::array<uint32, SMART_ACTION_PARAM_COUNT> wps;
|
||||
uint32 wps[SMART_ACTION_PARAM_COUNT];
|
||||
} closestWaypointFromList;
|
||||
|
||||
struct
|
||||
@@ -1554,12 +1554,7 @@ typedef std::vector<WorldObject*> ObjectVector;
|
||||
class ObjectGuidVector
|
||||
{
|
||||
public:
|
||||
explicit ObjectGuidVector(ObjectVector const& objectVector) : _objectVector(objectVector)
|
||||
{
|
||||
_guidVector.reserve(_objectVector.size());
|
||||
for (WorldObject* obj : _objectVector)
|
||||
_guidVector.push_back(obj->GetGUID());
|
||||
}
|
||||
explicit ObjectGuidVector(ObjectVector const& objectVector);
|
||||
|
||||
ObjectVector const* GetObjectVector(WorldObject const& ref) const
|
||||
{
|
||||
@@ -1574,14 +1569,7 @@ class ObjectGuidVector
|
||||
mutable ObjectVector _objectVector;
|
||||
|
||||
//sanitize vector using _guidVector
|
||||
void UpdateObjects(WorldObject const& ref) const
|
||||
{
|
||||
_objectVector.clear();
|
||||
|
||||
for (ObjectGuid const& guid : _guidVector)
|
||||
if (WorldObject* obj = ObjectAccessor::GetWorldObject(ref, guid))
|
||||
_objectVector.push_back(obj);
|
||||
}
|
||||
void UpdateObjects(WorldObject const& ref) const;
|
||||
};
|
||||
typedef std::unordered_map<uint32, ObjectGuidVector> ObjectVectorMap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user