mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Quest API] Add GetBotListByClientName(client_name) to Perl/Lua. (#2064)
* [Quest API] Add GetBotListByClientName(client_name) to Perl/Lua. - Add $entity_list->GetBotListByClientName(client_name) to Perl. - Add eq.get_entity_list():GetBotListByClientName(client_name) to Lua. - Allows you to get a bot list comprised solely of a specific character's bots. * Update lua_entity_list.cpp
This commit is contained in:
parent
b6b662f1c7
commit
5dc76e595b
@ -5057,10 +5057,27 @@ void EntityList::GetClientList(std::list<Client *> &c_list)
|
|||||||
void EntityList::GetBotList(std::list<Bot *> &b_list)
|
void EntityList::GetBotList(std::list<Bot *> &b_list)
|
||||||
{
|
{
|
||||||
b_list.clear();
|
b_list.clear();
|
||||||
for (auto bot_iterator : bot_list) {
|
for (auto bot : bot_list) {
|
||||||
b_list.push_back(bot_iterator);
|
b_list.push_back(bot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Bot *> EntityList::GetBotListByClientName(std::string client_name)
|
||||||
|
{
|
||||||
|
std::vector<Bot *> client_bot_list;
|
||||||
|
|
||||||
|
if (client_name.empty()) {
|
||||||
|
return client_bot_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto bot : bot_list) {
|
||||||
|
if (bot->GetOwner() && str_tolower(bot->GetOwner()->GetCleanName()) == str_tolower(client_name)) {
|
||||||
|
client_bot_list.push_back(bot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return client_bot_list;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void EntityList::GetCorpseList(std::list<Corpse *> &c_list)
|
void EntityList::GetCorpseList(std::list<Corpse *> &c_list)
|
||||||
|
|||||||
@ -526,6 +526,7 @@ public:
|
|||||||
inline const std::unordered_map<uint16, Client *> &GetClientList() { return client_list; }
|
inline const std::unordered_map<uint16, Client *> &GetClientList() { return client_list; }
|
||||||
#ifdef BOTS
|
#ifdef BOTS
|
||||||
inline const std::list<Bot *> &GetBotList() { return bot_list; }
|
inline const std::list<Bot *> &GetBotList() { return bot_list; }
|
||||||
|
std::vector<Bot *> GetBotListByClientName(std::string client_name);
|
||||||
#endif
|
#endif
|
||||||
inline const std::unordered_map<uint16, Corpse *> &GetCorpseList() { return corpse_list; }
|
inline const std::unordered_map<uint16, Corpse *> &GetCorpseList() { return corpse_list; }
|
||||||
inline const std::unordered_map<uint16, Object *> &GetObjectList() { return object_list; }
|
inline const std::unordered_map<uint16, Object *> &GetObjectList() { return object_list; }
|
||||||
|
|||||||
@ -375,8 +375,19 @@ Lua_Bot_List Lua_EntityList::GetBotList() {
|
|||||||
Lua_Safe_Call_Class(Lua_Bot_List);
|
Lua_Safe_Call_Class(Lua_Bot_List);
|
||||||
Lua_Bot_List ret;
|
Lua_Bot_List ret;
|
||||||
auto &bot_list = self->GetBotList();
|
auto &bot_list = self->GetBotList();
|
||||||
for (auto bot_iterator : bot_list) {
|
for (auto bot : bot_list) {
|
||||||
ret.entries.push_back(Lua_Bot(bot_iterator));
|
ret.entries.push_back(Lua_Bot(bot));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
Lua_Bot_List Lua_EntityList::GetBotListByClientName(std::string client_name) {
|
||||||
|
Lua_Safe_Call_Class(Lua_Bot_List);
|
||||||
|
Lua_Bot_List ret;
|
||||||
|
auto bot_list = self->GetBotListByClientName(client_name);
|
||||||
|
for (auto bot : bot_list) {
|
||||||
|
ret.entries.push_back(Lua_Bot(bot));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -519,6 +530,7 @@ luabind::scope lua_register_entity_list() {
|
|||||||
.def("GetBotByID", (Lua_Bot(Lua_EntityList::*)(uint32))&Lua_EntityList::GetBotByID)
|
.def("GetBotByID", (Lua_Bot(Lua_EntityList::*)(uint32))&Lua_EntityList::GetBotByID)
|
||||||
.def("GetBotByName", (Lua_Bot(Lua_EntityList::*)(std::string))&Lua_EntityList::GetBotByName)
|
.def("GetBotByName", (Lua_Bot(Lua_EntityList::*)(std::string))&Lua_EntityList::GetBotByName)
|
||||||
.def("GetBotList", (Lua_Bot_List(Lua_EntityList::*)(void))&Lua_EntityList::GetBotList)
|
.def("GetBotList", (Lua_Bot_List(Lua_EntityList::*)(void))&Lua_EntityList::GetBotList)
|
||||||
|
.def("GetBotListByClientName", (Lua_Bot_List(Lua_EntityList::*)(std::string))&Lua_EntityList::GetBotListByClientName)
|
||||||
#endif
|
#endif
|
||||||
.def("GetClientByAccID", (Lua_Client(Lua_EntityList::*)(uint32))&Lua_EntityList::GetClientByAccID)
|
.def("GetClientByAccID", (Lua_Client(Lua_EntityList::*)(uint32))&Lua_EntityList::GetClientByAccID)
|
||||||
.def("GetClientByCharID", (Lua_Client(Lua_EntityList::*)(uint32))&Lua_EntityList::GetClientByCharID)
|
.def("GetClientByCharID", (Lua_Client(Lua_EntityList::*)(uint32))&Lua_EntityList::GetClientByCharID)
|
||||||
|
|||||||
@ -128,6 +128,7 @@ public:
|
|||||||
Lua_Bot GetBotByID(uint32 bot_id);
|
Lua_Bot GetBotByID(uint32 bot_id);
|
||||||
Lua_Bot GetBotByName(std::string bot_name);
|
Lua_Bot GetBotByName(std::string bot_name);
|
||||||
Lua_Bot_List GetBotList();
|
Lua_Bot_List GetBotList();
|
||||||
|
Lua_Bot_List GetBotListByClientName(std::string client_name);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1346,6 +1346,34 @@ XS(XS_EntityList_GetBotList) {
|
|||||||
}
|
}
|
||||||
XSRETURN(bot_count);
|
XSRETURN(bot_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XS(XS_EntityList_GetBotListByClientName);
|
||||||
|
XS(XS_EntityList_GetBotListByClientName) {
|
||||||
|
dXSARGS;
|
||||||
|
if (items != 2) {
|
||||||
|
Perl_croak(aTHX_ "Usage: EntityList::GetBotListByClientName(THIS, string client_name)"); // @categories Script Utility, Bot
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityList *THIS;
|
||||||
|
std::string client_name = (std::string) SvPV_nolen(ST(1));
|
||||||
|
VALIDATE_THIS_IS_ENTITY;
|
||||||
|
|
||||||
|
auto current_bot_list = THIS->GetBotListByClientName(client_name);
|
||||||
|
auto bot_count = current_bot_list.size();
|
||||||
|
|
||||||
|
if (bot_count > 0) {
|
||||||
|
EXTEND(sp, bot_count);
|
||||||
|
for (int index = 0; index < bot_count; ++index) {
|
||||||
|
ST(index) = sv_newmortal();
|
||||||
|
sv_setref_pv(ST(index), "Bot", (void *) current_bot_list[index]);
|
||||||
|
XPUSHs(ST(index));
|
||||||
|
}
|
||||||
|
XSRETURN(bot_count);
|
||||||
|
}
|
||||||
|
SV* return_value = &PL_sv_undef;
|
||||||
|
ST(0) = return_value;
|
||||||
|
XSRETURN(1);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XS(XS_EntityList_GetNPCList); /* prototype to pass -Wmissing-prototypes */
|
XS(XS_EntityList_GetNPCList); /* prototype to pass -Wmissing-prototypes */
|
||||||
@ -1548,6 +1576,7 @@ XS(boot_EntityList) {
|
|||||||
newXSproto(strcpy(buf, "GetBotByID"), XS_EntityList_GetBotByID, file, "$$");
|
newXSproto(strcpy(buf, "GetBotByID"), XS_EntityList_GetBotByID, file, "$$");
|
||||||
newXSproto(strcpy(buf, "GetBotByName"), XS_EntityList_GetBotByName, file, "$$");
|
newXSproto(strcpy(buf, "GetBotByName"), XS_EntityList_GetBotByName, file, "$$");
|
||||||
newXSproto(strcpy(buf, "GetBotList"), XS_EntityList_GetBotList, file, "$");
|
newXSproto(strcpy(buf, "GetBotList"), XS_EntityList_GetBotList, file, "$");
|
||||||
|
newXSproto(strcpy(buf, "GetBotListByClientName"), XS_EntityList_GetBotListByClientName, file, "$$");
|
||||||
#endif
|
#endif
|
||||||
newXSproto(strcpy(buf, "GetClientByAccID"), XS_EntityList_GetClientByAccID, file, "$$");
|
newXSproto(strcpy(buf, "GetClientByAccID"), XS_EntityList_GetClientByAccID, file, "$$");
|
||||||
newXSproto(strcpy(buf, "GetClientByCharID"), XS_EntityList_GetClientByCharID, file, "$$");
|
newXSproto(strcpy(buf, "GetClientByCharID"), XS_EntityList_GetClientByCharID, file, "$$");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user