EntityList::GetRandomClient converted to xyz_location

This commit is contained in:
Arthur Ice 2014-11-30 22:28:17 -08:00
parent 8b7a09dbc1
commit 54f3f7f343
4 changed files with 8 additions and 10 deletions

View File

@ -1561,16 +1561,14 @@ Client *EntityList::GetClientByWID(uint32 iWID)
return nullptr;
}
Client *EntityList::GetRandomClient(float x, float y, float z, float Distance, Client *ExcludeClient)
Client *EntityList::GetRandomClient(const xyz_location& location, float Distance, Client *ExcludeClient)
{
std::vector<Client *> ClientsInRange;
auto it = client_list.begin();
while (it != client_list.end()) {
if ((it->second != ExcludeClient) && (it->second->DistNoRoot(x, y, z) <= Distance))
for (auto it = client_list.begin();it != client_list.end(); ++it)
if ((it->second != ExcludeClient) && (it->second->DistNoRoot(location.m_X, location.m_Y, location.m_Z) <= Distance))
ClientsInRange.push_back(it->second);
++it;
}
if (ClientsInRange.empty())
return nullptr;

View File

@ -150,7 +150,7 @@ public:
Client *GetClientByCharID(uint32 iCharID);
Client *GetClientByWID(uint32 iWID);
Client *GetClient(uint32 ip, uint16 port);
Client *GetRandomClient(float x, float y, float z, float Distance, Client *ExcludeClient = nullptr);
Client *GetRandomClient(const xyz_location& location, float Distance, Client *ExcludeClient = nullptr);
Group *GetGroupByMob(Mob* mob);
Group *GetGroupByClient(Client* client);
Group *GetGroupByID(uint32 id);

View File

@ -298,12 +298,12 @@ void Lua_EntityList::MessageGroup(Lua_Mob who, bool skip_close, uint32 type, con
Lua_Client Lua_EntityList::GetRandomClient(float x, float y, float z, float dist) {
Lua_Safe_Call_Class(Lua_Client);
return self->GetRandomClient(x, y, z, dist);
return self->GetRandomClient(xyz_location(x, y, z), dist);
}
Lua_Client Lua_EntityList::GetRandomClient(float x, float y, float z, float dist, Lua_Client exclude) {
Lua_Safe_Call_Class(Lua_Client);
return self->GetRandomClient(x, y, z, dist, exclude);
return self->GetRandomClient(xyz_location(x, y, z), dist, exclude);
}
Lua_Mob_List Lua_EntityList::GetMobList() {

View File

@ -1875,7 +1875,7 @@ XS(XS_EntityList_GetRandomClient)
c = INT2PTR(Client *,tmp);
}
}
RETVAL = entity_list.GetRandomClient(x, y, z, d * d, c);
RETVAL = entity_list.GetRandomClient(xyz_location(x, y, z), d * d, c);
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "Client", (void*)RETVAL);
}