[Quest API] Add rename(name) to Perl/Lua. (#1414)

- Add quest::rename(name) to Perl.
- Add eq.rename(name) to Lua.
This commit is contained in:
Alex 2021-06-16 10:30:32 -04:00 committed by GitHub
parent 4c7f2391cd
commit b9d8fb0d91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 0 deletions

View File

@ -6774,6 +6774,17 @@ XS(XS__getcleannpcnamebyid) {
XSRETURN(1);
}
XS(XS__rename);
XS(XS__rename) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: quest::rename(string name)");
std::string name = (std::string) SvPV_nolen(ST(0));
quest_manager.rename(name);
XSRETURN_EMPTY;
}
/*
This is the callback perl will look for to setup the
quest package's XSUBs
@ -7079,6 +7090,7 @@ EXTERN_C XS(boot_quest) {
newXS(strcpy(buf, "remove_expedition_lockout_by_char_id"), XS__remove_expedition_lockout_by_char_id, file);
newXS(strcpy(buf, "removeitem"), XS__removeitem, file);
newXS(strcpy(buf, "removetitle"), XS__removetitle, file);
newXS(strcpy(buf, "rename"), XS__rename, file);
newXS(strcpy(buf, "repopzone"), XS__repopzone, file);
newXS(strcpy(buf, "resettaskactivity"), XS__resettaskactivity, file);
newXS(strcpy(buf, "respawn"), XS__respawn, file);

View File

@ -2459,6 +2459,10 @@ std::string lua_get_clean_npc_name_by_id(uint32 npc_id) {
return quest_manager.getcleannpcnamebyid(npc_id);
}
void lua_rename(std::string name) {
quest_manager.rename(name);
}
#define LuaCreateNPCParse(name, c_type, default_value) do { \
cur = table[#name]; \
if(luabind::type(cur) != LUA_TNIL) { \
@ -3024,6 +3028,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("rename", &lua_rename),
/**
* Expansions
*/

View File

@ -1044,6 +1044,31 @@ void QuestManager::snow(int weather) {
safe_delete(outapp);
}
void QuestManager::rename(std::string name) {
QuestManagerCurrentQuestVars();
if (initiator && initiator->IsClient()) {
std::string current_name = initiator->GetName();
if (initiator->ChangeFirstName(name.c_str(), current_name.c_str())) {
initiator->Message(
Chat::White,
fmt::format(
"Successfully renamed to {}, kicking to character select.",
name
).c_str()
);
initiator->Kick("Name was changed.");
} else {
initiator->Message(
Chat::Red,
fmt::format(
"Failed to rename {} to {}.",
current_name, name
).c_str()
);
}
}
}
void QuestManager::surname(const char *name) {
QuestManagerCurrentQuestVars();
//Changes the last name.

View File

@ -117,6 +117,7 @@ public:
void safemove();
void rain(int weather);
void snow(int weather);
void rename(std::string name);
void surname(const char *name);
void permaclass(int class_id);
void permarace(int race_id);