From fab071d9da4617f9c60f4154394820e4579b0bff Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 6 Apr 2020 02:02:20 -0400 Subject: [PATCH] Add getracename(race_id) to Perl/Lua. --- zone/embparser_api.cpp | 17 +++++++++++++++++ zone/lua_general.cpp | 5 +++++ zone/questmgr.cpp | 4 ++++ zone/questmgr.h | 1 + 4 files changed, 27 insertions(+) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index dfb23ddc8..9e7b11b52 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -822,6 +822,22 @@ XS(XS__isdisctome) { XSRETURN(1); } +XS(XS__getracename); +XS(XS__getracename) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: quest::getracename(uint16 race_id)"); + + dXSTARG; + uint16 race_id = (int) SvIV(ST(0)); + std::string race_name = quest_manager.getracename(race_id); + + sv_setpv(TARG, race_name.c_str()); + XSprePUSH; + PUSHTARG; + XSRETURN(1); +} + XS(XS__getspellname); XS(XS__getspellname) { dXSARGS; @@ -4116,6 +4132,7 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "getguildidbycharid"), XS__getguildidbycharid, file); newXS(strcpy(buf, "getgroupidbycharid"), XS__getgroupidbycharid, file); newXS(strcpy(buf, "getraididbycharid"), XS__getraididbycharid, file); + newXS(strcpy(buf, "getracename"), XS__getracename, file); newXS(strcpy(buf, "getspellname"), XS__getspellname, file); newXS(strcpy(buf, "getlevel"), XS__getlevel, file); newXS(strcpy(buf, "getplayerburiedcorpsecount"), XS__getplayerburiedcorpsecount, file); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 848348fbf..0659605e3 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -393,6 +393,10 @@ bool lua_is_disc_tome(int item_id) { return quest_manager.isdisctome(item_id); } +std::string lua_get_race_name(uint32 race_id) { + return quest_manager.getracename(race_id); +} + std::string lua_get_spell_name(uint32 spell_id) { return quest_manager.getspellname(spell_id); } @@ -1672,6 +1676,7 @@ luabind::scope lua_register_general() { luabind::def("depop_zone", &lua_depop_zone), luabind::def("repop_zone", &lua_repop_zone), luabind::def("is_disc_tome", &lua_is_disc_tome), + luabind::def("get_race_name", (std::string(*)(uint16))&lua_get_race_name), luabind::def("get_spell_name", (std::string(*)(uint32))&lua_get_spell_name), luabind::def("safe_move", &lua_safe_move), luabind::def("rain", &lua_rain), diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 0a61361c6..c4de76f14 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -906,6 +906,10 @@ bool QuestManager::isdisctome(int item_id) { return(true); } +std::string QuestManager::getracename(uint16 race_id) { + return GetRaceIDName(race_id); +} + std::string QuestManager::getspellname(uint32 spell_id) { if (!IsValidSpell(spell_id)) { return "INVALID SPELL ID IN GETSPELLNAME"; diff --git a/zone/questmgr.h b/zone/questmgr.h index a3c7eab3d..24cbcc825 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -107,6 +107,7 @@ public: void level(int newlevel); void traindisc(int discipline_tome_item_id); bool isdisctome(int item_id); + std::string getracename(uint16 race_id); std::string getspellname(uint32 spell_id); void safemove(); void rain(int weather);