mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
[Quest API] Add GetBotListByCharacterID() to Perl/Lua. (#2069)
This commit is contained in:
parent
ccd0713b33
commit
a39a825045
@ -5062,6 +5062,23 @@ void EntityList::GetBotList(std::list<Bot *> &b_list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Bot *> EntityList::GetBotListByCharacterID(uint32 character_id)
|
||||||
|
{
|
||||||
|
std::vector<Bot *> client_bot_list;
|
||||||
|
|
||||||
|
if (!character_id) {
|
||||||
|
return client_bot_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto bot : bot_list) {
|
||||||
|
if (bot->GetOwner() && bot->GetBotOwnerCharacterID() == character_id) {
|
||||||
|
client_bot_list.push_back(bot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return client_bot_list;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Bot *> EntityList::GetBotListByClientName(std::string client_name)
|
std::vector<Bot *> EntityList::GetBotListByClientName(std::string client_name)
|
||||||
{
|
{
|
||||||
std::vector<Bot *> client_bot_list;
|
std::vector<Bot *> client_bot_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 *> GetBotListByCharacterID(uint32 character_id);
|
||||||
std::vector<Bot *> GetBotListByClientName(std::string client_name);
|
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; }
|
||||||
|
|||||||
@ -375,9 +375,26 @@ 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();
|
||||||
|
|
||||||
|
if (bot_list.size()) {
|
||||||
for (auto bot : bot_list) {
|
for (auto bot : bot_list) {
|
||||||
ret.entries.push_back(Lua_Bot(bot));
|
ret.entries.push_back(Lua_Bot(bot));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
Lua_Bot_List Lua_EntityList::GetBotListByCharacterID(uint32 character_id) {
|
||||||
|
Lua_Safe_Call_Class(Lua_Bot_List);
|
||||||
|
Lua_Bot_List ret;
|
||||||
|
auto bot_list = self->GetBotListByCharacterID(character_id);
|
||||||
|
|
||||||
|
if (bot_list.size()) {
|
||||||
|
for (auto bot : bot_list) {
|
||||||
|
ret.entries.push_back(Lua_Bot(bot));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -386,9 +403,12 @@ Lua_Bot_List Lua_EntityList::GetBotListByClientName(std::string client_name) {
|
|||||||
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->GetBotListByClientName(client_name);
|
auto bot_list = self->GetBotListByClientName(client_name);
|
||||||
|
|
||||||
|
if (bot_list.size()) {
|
||||||
for (auto bot : bot_list) {
|
for (auto bot : bot_list) {
|
||||||
ret.entries.push_back(Lua_Bot(bot));
|
ret.entries.push_back(Lua_Bot(bot));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -530,6 +550,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("GetBotListByCharacterID", (Lua_Bot_List(Lua_EntityList::*)(uint32))&Lua_EntityList::GetBotListByCharacterID)
|
||||||
.def("GetBotListByClientName", (Lua_Bot_List(Lua_EntityList::*)(std::string))&Lua_EntityList::GetBotListByClientName)
|
.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)
|
||||||
|
|||||||
@ -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 GetBotListByCharacterID(uint32 character_id);
|
||||||
Lua_Bot_List GetBotListByClientName(std::string client_name);
|
Lua_Bot_List GetBotListByClientName(std::string client_name);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1347,6 +1347,35 @@ XS(XS_EntityList_GetBotList) {
|
|||||||
XSRETURN(bot_count);
|
XSRETURN(bot_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XS(XS_EntityList_GetBotListByCharacterID);
|
||||||
|
XS(XS_EntityList_GetBotListByCharacterID) {
|
||||||
|
dXSARGS;
|
||||||
|
if (items != 2) {
|
||||||
|
Perl_croak(aTHX_ "Usage: EntityList::GetBotListByCharacterID(THIS, uint32 character_id)"); // @categories Script Utility, Bot
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityList *THIS;
|
||||||
|
uint32 character_id = (uint32) SvUV(ST(1));
|
||||||
|
VALIDATE_THIS_IS_ENTITY;
|
||||||
|
|
||||||
|
auto current_bot_list = THIS->GetBotListByCharacterID(character_id);
|
||||||
|
auto bot_count = current_bot_list.size();
|
||||||
|
|
||||||
|
if (bot_count) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
XS(XS_EntityList_GetBotListByClientName);
|
XS(XS_EntityList_GetBotListByClientName);
|
||||||
XS(XS_EntityList_GetBotListByClientName) {
|
XS(XS_EntityList_GetBotListByClientName) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
@ -1361,7 +1390,7 @@ XS(XS_EntityList_GetBotListByClientName) {
|
|||||||
auto current_bot_list = THIS->GetBotListByClientName(client_name);
|
auto current_bot_list = THIS->GetBotListByClientName(client_name);
|
||||||
auto bot_count = current_bot_list.size();
|
auto bot_count = current_bot_list.size();
|
||||||
|
|
||||||
if (bot_count > 0) {
|
if (bot_count) {
|
||||||
EXTEND(sp, bot_count);
|
EXTEND(sp, bot_count);
|
||||||
for (int index = 0; index < bot_count; ++index) {
|
for (int index = 0; index < bot_count; ++index) {
|
||||||
ST(index) = sv_newmortal();
|
ST(index) = sv_newmortal();
|
||||||
@ -1370,6 +1399,7 @@ XS(XS_EntityList_GetBotListByClientName) {
|
|||||||
}
|
}
|
||||||
XSRETURN(bot_count);
|
XSRETURN(bot_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
SV* return_value = &PL_sv_undef;
|
SV* return_value = &PL_sv_undef;
|
||||||
ST(0) = return_value;
|
ST(0) = return_value;
|
||||||
XSRETURN(1);
|
XSRETURN(1);
|
||||||
@ -1576,6 +1606,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, "GetBotListByCharacterID"), XS_EntityList_GetBotListByCharacterID, file, "$$");
|
||||||
newXSproto(strcpy(buf, "GetBotListByClientName"), XS_EntityList_GetBotListByClientName, 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, "$$");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user