Add getcharidbyname(name) to Perl/Lua.

This commit is contained in:
Alex 2020-04-05 20:41:49 -04:00
parent 3c71e2c91d
commit 41d0b1a947
4 changed files with 28 additions and 0 deletions

View File

@ -3231,6 +3231,23 @@ XS(XS__saylink) {
XSRETURN(1);
}
XS(XS__getcharidbyname);
XS(XS__getcharidbyname) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: quest::getcharidbyname(string name)");
dXSTARG;
uint32 RETVAL;
const char *name = (const char *) SvPV_nolen(ST(0));
RETVAL = quest_manager.getcharidbyname(name);
XSprePUSH;
PUSHu((UV)RETVAL);
XSRETURN(1);
}
XS(XS__getguildnamebyid);
XS(XS__getguildnamebyid) {
dXSARGS;
@ -4072,6 +4089,7 @@ EXTERN_C XS(boot_quest) {
newXS(strcpy(buf, "follow"), XS__follow, file);
newXS(strcpy(buf, "forcedoorclose"), XS__forcedoorclose, file);
newXS(strcpy(buf, "forcedooropen"), XS__forcedooropen, file);
newXS(strcpy(buf, "getcharidbyname"), XS__getcharidbyname, file);
newXS(strcpy(buf, "getinventoryslotid"), XS__getinventoryslotid, file);
newXS(strcpy(buf, "getitemname"), XS__getitemname, file);
newXS(strcpy(buf, "getItemName"), XS_qc_getItemName, file);

View File

@ -870,6 +870,10 @@ bool lua_delete_data(std::string bucket_key) {
return DataBucket::DeleteData(bucket_key);
}
uint32 lua_get_char_id_by_name(const char* name) {
return quest_manager.getcharidbyname(name);
}
const char *lua_get_guild_name_by_id(uint32 guild_id) {
return quest_manager.getguildnamebyid(guild_id);
}
@ -1763,6 +1767,7 @@ luabind::scope lua_register_general() {
luabind::def("set_data", (void(*)(std::string, std::string))&lua_set_data),
luabind::def("set_data", (void(*)(std::string, std::string, std::string))&lua_set_data),
luabind::def("delete_data", (bool(*)(std::string))&lua_delete_data),
luabind::def("get_char_id_by_name", (uint32(*)(const char*))&lua_get_char_id_by_name),
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

@ -2928,6 +2928,10 @@ std::string QuestManager::saylink(char *saylink_text, bool silent, const char *l
return EQEmu::SayLinkEngine::GenerateQuestSaylink(saylink_text, silent, link_name);
}
uint32 QuestManager::getcharidbyname(const char* name) {
return database.GetCharacterID(name);
}
const char* QuestManager::getguildnamebyid(int guild_id) {
if (guild_id > 0)
return guild_mgr.GetGuildName(guild_id);

View File

@ -255,6 +255,7 @@ public:
void FlagInstanceByRaidLeader(uint32 zone, int16 version);
const char* varlink(char* perltext, int item_id);
std::string saylink(char *saylink_text, bool silent, const char *link_name);
uint32 getcharidbyname(const char* name);
const char* getguildnamebyid(int guild_id);
int getguildidbycharid(uint32 char_id);
int getgroupidbycharid(uint32 char_id);