[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
This commit is contained in:
Kinglykrab 2021-12-02 10:09:15 -05:00 committed by GitHub
parent 29dfe9d404
commit 4a154686e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 4 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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),
/*

View File

@ -1036,6 +1036,10 @@ std::string QuestManager::getskillname(int skill_id) {
return EQ::skills::GetSkillName(static_cast<EQ::skills::SkillType>(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);
}

View File

@ -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);

View File

@ -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<struct NPCFaction*> *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();