From 4a154686e1b71198e89adf0b28efb79dd28d17cb Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Thu, 2 Dec 2021 10:09:15 -0500 Subject: [PATCH] [Quest API] Add GetFactionName() to Perl/Lua. (#1859) * [Quest API] Add GetFactionName() to Perl/Lua. - Add quest::getfactionname(faction_id) to Perl. - Add eq.get_faction_name(faction_id) to Lua. * Update embparser_api.cpp * Update embparser_api.cpp * Update embparser_api.cpp --- zone/client.cpp | 2 +- zone/embparser_api.cpp | 20 +++++++++++++++++++- zone/lua_general.cpp | 5 +++++ zone/questmgr.cpp | 4 ++++ zone/questmgr.h | 1 + zone/zonedb.h | 4 ++-- 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index cd9167ab3..64453cf11 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -6946,7 +6946,7 @@ void Client::SendStatsWindow(Client* client, bool use_window) for (auto iter = item_faction_bonuses.begin(); iter != item_faction_bonuses.end(); ++iter) { memset(&faction_buf, 0, sizeof(faction_buf)); - if(!content_db.GetFactionName((int32)((*iter).first), faction_buf, sizeof(faction_buf))) + if(!content_db.GetFactionName((int)((*iter).first), faction_buf, sizeof(faction_buf))) strcpy(faction_buf, "Not in DB"); if((*iter).second > 0) { diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 7882f5c34..58984cce5 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -8023,6 +8023,23 @@ XS(XS__getspell) { } } +XS(XS__getfactionname); +XS(XS__getfactionname) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: quest::getfactionname(int faction_id)"); + { + dXSTARG; + int faction_id = (int) SvIV(ST(0)); + std::string faction_name = quest_manager.getfactionname(faction_id); + + sv_setpv(TARG, faction_name.c_str()); + XSprePUSH; + PUSHTARG; + XSRETURN(1); + } +} + XS(XS__getlanguagename); XS(XS__getlanguagename) { dXSARGS; @@ -8332,11 +8349,12 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "get_expedition_by_zone_instance"), XS__get_expedition_by_zone_instance, file); newXS(strcpy(buf, "get_expedition_lockout_by_char_id"), XS__get_expedition_lockout_by_char_id, file); newXS(strcpy(buf, "get_expedition_lockouts_by_char_id"), XS__get_expedition_lockouts_by_char_id, file); - newXS(strcpy(buf, "getlanguagename"), XS__getlanguagename, file); + newXS(strcpy(buf, "getfactionname"), XS__getfactionname, file); newXS(strcpy(buf, "getinventoryslotid"), XS__getinventoryslotid, file); newXS(strcpy(buf, "getitemname"), XS__getitemname, file); newXS(strcpy(buf, "getItemName"), XS_qc_getItemName, file); newXS(strcpy(buf, "getitemstat"), XS__getitemstat, file); + newXS(strcpy(buf, "getlanguagename"), XS__getlanguagename, file); 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); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 4703d7657..62777f76b 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -3351,6 +3351,10 @@ Lua_Spell lua_get_spell(uint32 spell_id) { return Lua_Spell(spell_id); } +std::string lua_get_faction_name(int faction_id) { + return quest_manager.getfactionname(faction_id); +} + std::string lua_get_language_name(int language_id) { return quest_manager.getlanguagename(language_id); } @@ -3798,6 +3802,7 @@ luabind::scope lua_register_general() { luabind::def("is_npc_spawned", &lua_is_npc_spawned), luabind::def("count_spawned_npcs", &lua_count_spawned_npcs), luabind::def("get_spell", &lua_get_spell), + luabind::def("get_faction_name", &lua_get_faction_name), luabind::def("get_language_name", &lua_get_language_name), /* diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index ca8bcdca2..92b8b0b37 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1036,6 +1036,10 @@ std::string QuestManager::getskillname(int skill_id) { return EQ::skills::GetSkillName(static_cast(skill_id)); } +std::string QuestManager::getfactionname(int faction_id) { + return content_db.GetFactionName(faction_id); +} + std::string QuestManager::getlanguagename(int language_id) { return EQ::constants::GetLanguageName(language_id); } diff --git a/zone/questmgr.h b/zone/questmgr.h index c9a490e31..205142003 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -115,6 +115,7 @@ public: std::string getracename(uint16 race_id); std::string getspellname(uint32 spell_id); std::string getskillname(int skill_id); + std::string getfactionname(int faction_id); std::string getlanguagename(int language_id); void safemove(); void rain(int weather); diff --git a/zone/zonedb.h b/zone/zonedb.h index 111f1d2c3..e12a0ed19 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -423,8 +423,8 @@ public: /* Faction */ bool GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, int32* value, uint8* temp, int32* primary_faction = 0); bool GetFactionData(FactionMods* fd, uint32 class_mod, uint32 race_mod, uint32 deity_mod, int32 faction_id); //needed for factions Dec, 16 2001 - bool GetFactionName(int32 faction_id, char* name, uint32 buflen); // needed for factions Dec, 16 2001 - std::string GetFactionName(int32 faction_id); + bool GetFactionName(int faction_id, char* name, uint32 buflen); // needed for factions Dec, 16 2001 + std::string GetFactionName(int faction_id); bool GetFactionIdsForNPC(uint32 nfl_id, std::list *faction_list, int32* primary_faction = 0); // improve faction handling bool SetCharacterFactionLevel(uint32 char_id, int32 faction_id, int32 value, uint8 temp, faction_map &val_list); // needed for factions Dec, 16 2001 bool LoadFactionData();