mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-16 08:42:25 +00:00
Merge pull request #1020 from KinglyKrab/getcharnamebyid
Added getcharnamebyid(char_id) to Perl/Lua.
This commit is contained in:
commit
4c348baabd
@ -925,6 +925,22 @@ void Database::GetCharName(uint32 char_id, char* name) {
|
||||
}
|
||||
}
|
||||
|
||||
const char* Database::GetCharNameByID(uint32 char_id) {
|
||||
std::string query = fmt::format("SELECT `name` FROM `character_data` WHERE id = {}", char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
return row[0];
|
||||
}
|
||||
|
||||
bool Database::LoadVariables() {
|
||||
auto results = QueryDatabase(StringFormat("SELECT varname, value, unix_timestamp() FROM variables where unix_timestamp(ts) >= %d", varcache.last_update));
|
||||
|
||||
|
||||
@ -138,6 +138,7 @@ public:
|
||||
|
||||
void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0);
|
||||
void GetCharName(uint32 char_id, char* name);
|
||||
const char *GetCharNameByID(uint32 char_id);
|
||||
void LoginIP(uint32 AccountID, const char* LoginIP);
|
||||
|
||||
/* Instancing */
|
||||
|
||||
@ -3231,6 +3231,23 @@ XS(XS__saylink) {
|
||||
XSRETURN(1);
|
||||
}
|
||||
|
||||
XS(XS__getcharnamebyid);
|
||||
XS(XS__getcharnamebyid) {
|
||||
dXSARGS;
|
||||
if (items != 1)
|
||||
Perl_croak(aTHX_ "Usage: quest::getcharnamebyid(uint32 char_id)");
|
||||
dXSTARG;
|
||||
|
||||
Const_char *RETVAL;
|
||||
uint32 char_id = (int) SvUV(ST(0));
|
||||
|
||||
RETVAL = quest_manager.getcharnamebyid(char_id);
|
||||
|
||||
sv_setpv(TARG, RETVAL);
|
||||
XSprePUSH;
|
||||
PUSHTARG;
|
||||
}
|
||||
|
||||
XS(XS__getcharidbyname);
|
||||
XS(XS__getcharidbyname) {
|
||||
dXSARGS;
|
||||
@ -4094,6 +4111,7 @@ EXTERN_C XS(boot_quest) {
|
||||
newXS(strcpy(buf, "getitemname"), XS__getitemname, file);
|
||||
newXS(strcpy(buf, "getItemName"), XS_qc_getItemName, file);
|
||||
newXS(strcpy(buf, "get_spawn_condition"), XS__get_spawn_condition, file);
|
||||
newXS(strcpy(buf, "getcharnamebyid"), XS__getcharnamebyid, file);
|
||||
newXS(strcpy(buf, "getguildnamebyid"), XS__getguildnamebyid, file);
|
||||
newXS(strcpy(buf, "getguildidbycharid"), XS__getguildidbycharid, file);
|
||||
newXS(strcpy(buf, "getgroupidbycharid"), XS__getgroupidbycharid, file);
|
||||
|
||||
@ -870,6 +870,10 @@ bool lua_delete_data(std::string bucket_key) {
|
||||
return DataBucket::DeleteData(bucket_key);
|
||||
}
|
||||
|
||||
const char *lua_get_char_name_by_id(uint32 char_id) {
|
||||
return database.GetCharNameByID(char_id);
|
||||
}
|
||||
|
||||
uint32 lua_get_char_id_by_name(const char* name) {
|
||||
return quest_manager.getcharidbyname(name);
|
||||
}
|
||||
@ -1767,6 +1771,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_name_by_id", &lua_get_char_name_by_id),
|
||||
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),
|
||||
|
||||
@ -2928,6 +2928,13 @@ std::string QuestManager::saylink(char *saylink_text, bool silent, const char *l
|
||||
return EQEmu::SayLinkEngine::GenerateQuestSaylink(saylink_text, silent, link_name);
|
||||
}
|
||||
|
||||
const char* QuestManager::getcharnamebyid(uint32 char_id) {
|
||||
if (char_id > 0) {
|
||||
return database.GetCharNameByID(char_id);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
uint32 QuestManager::getcharidbyname(const char* name) {
|
||||
return database.GetCharacterID(name);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
const char* getcharnamebyid(uint32 char_id);
|
||||
uint32 getcharidbyname(const char* name);
|
||||
const char* getguildnamebyid(int guild_id);
|
||||
int getguildidbycharid(uint32 char_id);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user