Merge pull request #1023 from KinglyKrab/getcurrencyitemid

Add getcurrencyitemid(currency_id) to Perl/Lua.
This commit is contained in:
Alex 2020-04-06 16:22:50 -04:00 committed by GitHub
commit 928070e994
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 2 deletions

View File

@ -3313,6 +3313,23 @@ XS(XS__getcharidbyname) {
XSRETURN(1);
}
XS(XS__getcurrencyitemid);
XS(XS__getcurrencyitemid) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: quest::getcurrencyitemid(int currency_id)");
dXSTARG;
int RETVAL;
int currency_id = (int) SvUV(ST(0));
RETVAL = quest_manager.getcurrencyitemid(currency_id);
XSprePUSH;
PUSHi((IV)RETVAL);
XSRETURN(1);
}
XS(XS__getcurrencyid);
XS(XS__getcurrencyid) {
dXSARGS;
@ -3326,7 +3343,6 @@ XS(XS__getcurrencyid) {
RETVAL = quest_manager.getcurrencyid(item_id);
XSprePUSH;
PUSHi((IV)RETVAL);
XSRETURN(1);
}
@ -4179,6 +4195,7 @@ EXTERN_C XS(boot_quest) {
newXS(strcpy(buf, "getnpcnamebyid"), XS__getnpcnamebyid, file);
newXS(strcpy(buf, "get_spawn_condition"), XS__get_spawn_condition, file);
newXS(strcpy(buf, "getcharnamebyid"), XS__getcharnamebyid, file);
newXS(strcpy(buf, "getcurrencyitemid"), XS__getcurrencyitemid, file);
newXS(strcpy(buf, "getguildnamebyid"), XS__getguildnamebyid, file);
newXS(strcpy(buf, "getguildidbycharid"), XS__getguildidbycharid, file);
newXS(strcpy(buf, "getgroupidbycharid"), XS__getgroupidbycharid, file);

View File

@ -887,7 +887,11 @@ uint32 lua_get_char_id_by_name(const char* name) {
}
int lua_get_currency_id(uint32 item_id) {
return quest_manager.getcurrencyid(item_id);
return quest_manager.getcurrencyid(item_id)
}
int lua_get_currency_item_id(int currency_id) {
return quest_manager.getcurrencyitemid(currency_id);
}
const char *lua_get_guild_name_by_id(uint32 guild_id) {
@ -1792,6 +1796,7 @@ luabind::scope lua_register_general() {
luabind::def("get_char_name_by_id", &lua_get_char_name_by_id),
luabind::def("get_char_id_by_name", (uint32(*)(const char*))&lua_get_char_id_by_name),
luabind::def("get_currency_id", &lua_get_currency_id),
luabind::def("get_currency_item_id", &lua_get_currency_item_id),
luabind::def("get_guild_name_by_id", &lua_get_guild_name_by_id),
luabind::def("get_guild_id_by_char_id", &lua_get_guild_id_by_char_id),
luabind::def("get_group_id_by_char_id", &lua_get_group_id_by_char_id),

View File

@ -2973,6 +2973,18 @@ int QuestManager::getcurrencyid(uint32 item_id) {
return 0;
}
int QuestManager::getcurrencyitemid(int currency_id) {
if (currency_id > 0) {
auto iter = zone->AlternateCurrencies.begin();
while (iter != zone->AlternateCurrencies.end()) {
if (currency_id == (*iter).id) {
return (*iter).item_id;
}
++iter;
}
return 0;
}
const char* QuestManager::getguildnamebyid(int guild_id) {
if (guild_id > 0)
return guild_mgr.GetGuildName(guild_id);

View File

@ -260,6 +260,7 @@ public:
const char* getcharnamebyid(uint32 char_id);
uint32 getcharidbyname(const char* name);
int getcurrencyid(uint32 item_id);
int getcurrencyitemid(int currency_id);
const char* getguildnamebyid(int guild_id);
int getguildidbycharid(uint32 char_id);
int getgroupidbycharid(uint32 char_id);