From 68fe95786e554dd7a66802f12eab2fc4d727db8b Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 16 Jun 2021 11:49:02 -0400 Subject: [PATCH] [Quest API] Add getgendername(gender_id) to Perl/Lua. (#1405) - Add quest::getgendername(gender_id) to Perl. - Add eq.get_gender_name(gender_id) to Lua. Co-authored-by: Chris Miles --- zone/embparser_api.cpp | 12 ++++++++++++ zone/lua_general.cpp | 4 ++++ zone/questmgr.cpp | 13 +++++++++++++ zone/questmgr.h | 1 + 4 files changed, 30 insertions(+) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 1ab1f05df..cc992199f 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -6774,6 +6774,17 @@ XS(XS__getcleannpcnamebyid) { XSRETURN(1); } +XS(XS__getgendername); +XS(XS__getgendername) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: quest::getgendername(uint32 gender_id)"); + + dXSTARG; + uint32 gender_id = (uint32) SvUV(ST(0)); + auto gender_name = quest_manager.getgendername(gender_id); + sv_setpv(TARG, gender_name.c_str()); +} XS(XS__getdeityname); XS(XS__getdeityname) { @@ -7054,6 +7065,7 @@ EXTERN_C XS(boot_quest) { 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, "getgendername"), XS__getgendername, file); newXS(strcpy(buf, "getdeityname"), XS__getdeityname, file); newXS(strcpy(buf, "getguildnamebyid"), XS__getguildnamebyid, file); newXS(strcpy(buf, "getguildidbycharid"), XS__getguildidbycharid, file); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 9bfd0b9fb..15e89e2d3 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -2459,6 +2459,9 @@ std::string lua_get_clean_npc_name_by_id(uint32 npc_id) { return quest_manager.getcleannpcnamebyid(npc_id); } +std::string lua_get_gender_name(uint32 gender_id) { + return quest_manager.getgendername(gender_id); +} std::string lua_get_deity_name(uint32 deity_id) { return quest_manager.getdeityname(deity_id); @@ -3037,6 +3040,7 @@ luabind::scope lua_register_general() { luabind::def("cross_zone_add_ldon_loss_by_expedition_id", &lua_cross_zone_add_ldon_loss_by_expedition_id), luabind::def("cross_zone_add_ldon_points_by_expedition_id", &lua_cross_zone_add_ldon_points_by_expedition_id), luabind::def("cross_zone_add_ldon_win_by_expedition_id", &lua_cross_zone_add_ldon_win_by_expedition_id), + luabind::def("get_gender_name", &lua_get_gender_name), luabind::def("get_deity_name", &lua_get_deity_name), luabind::def("get_inventory_slot_name", &lua_get_inventory_slot_name), luabind::def("rename", &lua_rename), diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index b796834bc..b0297a3c9 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -4626,6 +4626,18 @@ void QuestManager::CrossZoneLDoNUpdate(uint8 type, uint8 subtype, int identifier safe_delete(pack); } +std::string QuestManager::getgendername(uint32 gender_id) { + auto gender_name = "Unknown"; + if (gender_id == MALE) { + gender_name = "Male"; + } else if (gender_id == FEMALE) { + gender_name = "Female"; + } else if (gender_id == NEUTER) { + gender_name = "Neuter"; + } + return gender_name; +} + std::string QuestManager::getdeityname(uint32 deity_id) { return EQ::deity::DeityName(static_cast(deity_id)); } @@ -4634,3 +4646,4 @@ std::string QuestManager::getinventoryslotname(int16 slot_id) { return EQ::invslot::GetInvPossessionsSlotName(slot_id); } + diff --git a/zone/questmgr.h b/zone/questmgr.h index f58337cbf..094e2ceef 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -381,6 +381,7 @@ public: double GetEXPModifierByCharID(uint32 character_id, uint32 zone_id) const; void SetAAEXPModifierByCharID(uint32 character_id, uint32 zone_id, double aa_modifier); void SetEXPModifierByCharID(uint32 character_id, uint32 zone_id, double exp_modifier); + std::string getgendername(uint32 gender_id); std::string getdeityname(uint32 deity_id); std::string getinventoryslotname(int16 slot_id);