mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 06:21:28 +00:00
[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:
parent
4c7f2391cd
commit
b9d8fb0d91
@ -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);
|
||||
|
||||
@ -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
|
||||
*/
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user