[Quest API] Adjust GetCloseMobList calls internally (#3530)

* [Quest API] Adjust GetCloseMobList calls internally

* Tweaks
This commit is contained in:
Chris Miles 2023-08-04 13:05:22 -05:00 committed by GitHub
parent 68b40f0239
commit 8fce86c396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 28 deletions

View File

@ -641,9 +641,7 @@ Lua_Mob_List Lua_EntityList::GetCloseMobList(Lua_Mob mob) {
Lua_Mob_List ret;
const auto& l = self->GetCloseMobList(mob);
ret.entries.reserve(l.size());
for (const auto& e : l) {
ret.entries.emplace_back(Lua_Mob(e.second));
}
@ -653,14 +651,9 @@ Lua_Mob_List Lua_EntityList::GetCloseMobList(Lua_Mob mob) {
Lua_Mob_List Lua_EntityList::GetCloseMobList(Lua_Mob mob, float distance) {
Lua_Safe_Call_Class(Lua_Mob_List);
Lua_Mob_List ret;
const auto& l = self->GetCloseMobList(mob);
ret.entries.reserve(l.size());
for (const auto& e : l) {
for (const auto& e : self->GetCloseMobList(mob)) {
if (mob.CalculateDistance(e.second) <= distance) {
ret.entries.emplace_back(Lua_Mob(e.second));
}
@ -674,11 +667,7 @@ Lua_Mob_List Lua_EntityList::GetCloseMobList(Lua_Mob mob, float distance, bool i
Lua_Mob_List ret;
const auto& l = self->GetCloseMobList(mob);
ret.entries.reserve(l.size());
for (const auto& e : l) {
for (const auto& e : self->GetCloseMobList(mob)) {
if (ignore_self && e.second == mob) {
continue;
}

View File

@ -614,11 +614,8 @@ Bot* Perl_EntityList_GetRandomBot(EntityList* self, float x, float y, float z, f
perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob)
{
perl::array result;
const auto& l = self->GetCloseMobList(mob);
result.reserve(l.size());
for (const auto& e : l) {
result.push_back(e.second);
}
@ -629,12 +626,7 @@ perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob)
perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob, float distance)
{
perl::array result;
const auto& l = self->GetCloseMobList(mob, distance);
result.reserve(l.size());
for (const auto& e : l) {
for (const auto& e : self->GetCloseMobList(mob, distance)) {
if (mob->CalculateDistance(e.second) <= distance) {
result.push_back(e.second);
}
@ -646,12 +638,7 @@ perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob, float di
perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob, float distance, bool ignore_self)
{
perl::array result;
const auto& l = self->GetCloseMobList(mob, distance);
result.reserve(l.size());
for (const auto& e : l) {
for (const auto& e : self->GetCloseMobList(mob, distance)) {
if (ignore_self && e.second == mob) {
continue;
}