Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/LuaEngine/methods/CreatureMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,18 +649,18 @@ namespace LuaCreature
float dist = ALE::CHECKVAL<float>(L, 5, 0.0f);
int32 aura = ALE::CHECKVAL<int32>(L, 6, 0);

auto const& threatlist = creature->GetThreatMgr().GetThreatList();
ThreatManager const& threatMgr = creature->GetThreatMgr();

if (threatlist.empty())
if (threatMgr.IsThreatListEmpty())
return 1;
if (position >= threatlist.size())
if (position >= threatMgr.GetThreatListSize())
return 1;

std::list<Unit*> targetList;

for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr)
for (ThreatReference const* ref : threatMgr.GetSortedThreatList())
{
Unit* target = (*itr)->getTarget();
Unit* target = ref->GetVictim();

if (!target)
continue;
Expand Down Expand Up @@ -730,19 +730,14 @@ namespace LuaCreature
*/
int GetAITargets(lua_State* L, Creature* creature)
{
auto const& threatlist = creature->GetThreatMgr().GetThreatList();
ThreatManager const& threatMgr = creature->GetThreatMgr();

lua_createtable(L, threatlist.size(), 0);
lua_createtable(L, threatMgr.GetThreatListSize(), 0);
int tbl = lua_gettop(L);
uint32 i = 0;
for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr)
for (ThreatReference const* ref : threatMgr.GetSortedThreatList())
{
Unit* target = (*itr)->getTarget();

if (!target)
continue;

ALE::Push(L, target);
ALE::Push(L, ref->GetVictim());
lua_rawseti(L, tbl, ++i);
}

Expand Down
8 changes: 1 addition & 7 deletions src/LuaEngine/methods/UnitMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -1885,17 +1885,11 @@ namespace LuaUnit
return 1;
}

ThreatContainer::StorageType const& list = unit->GetThreatMgr().GetThreatList();

lua_newtable(L);
int table = lua_gettop(L);
uint32 i = 1;
for (ThreatReference* item : list)
for (ThreatReference const* item : unit->GetThreatMgr().GetSortedThreatList())
{
if (!item)
{
continue;
}
Unit* victim = item->GetVictim();
if (!victim)
{
Expand Down
Loading