[Quest API] Add GetBotListByCharacterID() to Perl/Lua. (#2069)

This commit is contained in:
Kinglykrab
2022-04-02 17:51:26 -04:00
committed by GitHub
parent ccd0713b33
commit a39a825045
5 changed files with 76 additions and 5 deletions
+32 -1
View File
@@ -1347,6 +1347,35 @@ XS(XS_EntityList_GetBotList) {
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) {
dXSARGS;
@@ -1361,7 +1390,7 @@ XS(XS_EntityList_GetBotListByClientName) {
auto current_bot_list = THIS->GetBotListByClientName(client_name);
auto bot_count = current_bot_list.size();
if (bot_count > 0) {
if (bot_count) {
EXTEND(sp, bot_count);
for (int index = 0; index < bot_count; ++index) {
ST(index) = sv_newmortal();
@@ -1370,6 +1399,7 @@ XS(XS_EntityList_GetBotListByClientName) {
}
XSRETURN(bot_count);
}
SV* return_value = &PL_sv_undef;
ST(0) = return_value;
XSRETURN(1);
@@ -1576,6 +1606,7 @@ XS(boot_EntityList) {
newXSproto(strcpy(buf, "GetBotByID"), XS_EntityList_GetBotByID, file, "$$");
newXSproto(strcpy(buf, "GetBotByName"), XS_EntityList_GetBotByName, 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, "$$");
#endif
newXSproto(strcpy(buf, "GetClientByAccID"), XS_EntityList_GetClientByAccID, file, "$$");