mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-05 07:16:37 +00:00
[Feature] Add Character Auto Login (#4216)
* [Feature] Add Character Auto Login * Add commands and finalize. * Add methods without character name. * Update perl_client.cpp * Add other methods. * Repository methods. * Update account_repository.h * Update command_subsettings_repository.h * Update command_subsettings_repository.h * Update client.cpp
This commit is contained in:
@@ -1130,6 +1130,9 @@ public:
|
||||
const bool GetGMInvul() const { return gminvul; }
|
||||
bool CanUseReport;
|
||||
|
||||
const std::string GetAutoLoginCharacterName();
|
||||
bool SetAutoLoginCharacterName(const std::string& character_name);
|
||||
|
||||
//This is used to later set the buff duration of the spell, in slot to duration.
|
||||
//Doesn't appear to work directly after the client recieves an action packet.
|
||||
void SendBuffDurationPacket(Buffs_Struct &buff, int slot);
|
||||
|
||||
@@ -5855,6 +5855,16 @@ uint16 Perl__get_race_bitmask(uint16 race_id)
|
||||
return GetPlayerRaceBit(race_id);
|
||||
}
|
||||
|
||||
std::string Perl__GetAutoLoginCharacterNameByAccountID(uint32 account_id)
|
||||
{
|
||||
return quest_manager.GetAutoLoginCharacterNameByAccountID(account_id);
|
||||
}
|
||||
|
||||
bool Perl__SetAutoLoginCharacterNameByAccountID(uint32 account_id, std::string character_name)
|
||||
{
|
||||
return quest_manager.SetAutoLoginCharacterNameByAccountID(account_id, character_name);
|
||||
}
|
||||
|
||||
void perl_register_quest()
|
||||
{
|
||||
perl::interpreter perl(PERL_GET_THX);
|
||||
@@ -5885,6 +5895,7 @@ void perl_register_quest()
|
||||
package.add("FlagInstanceByGroupLeader", &Perl__FlagInstanceByGroupLeader);
|
||||
package.add("FlagInstanceByRaidLeader", &Perl__FlagInstanceByRaidLeader);
|
||||
package.add("FlyMode", &Perl__FlyMode);
|
||||
package.add("GetAutoLoginCharacterNameByAccountID", &Perl__GetAutoLoginCharacterNameByAccountID);
|
||||
package.add("GetBotClassByID", &Perl__GetBotClassByID);
|
||||
package.add("GetBotGenderByID", &Perl__GetBotGenderByID);
|
||||
package.add("GetBotIDsByCharacterID", (perl::array(*)(uint32))&Perl__GetBotIDsByCharacterID);
|
||||
@@ -6159,6 +6170,7 @@ void perl_register_quest()
|
||||
package.add("RemoveFromInstanceByCharID", &Perl__RemoveFromInstanceByCharID);
|
||||
package.add("CheckInstanceByCharID", &Perl__CheckInstanceByCharID);
|
||||
package.add("SendMail", &Perl__SendMail);
|
||||
package.add("SetAutoLoginCharacterNameByAccountID", &Perl__SetAutoLoginCharacterNameByAccountID);
|
||||
package.add("SetRunning", &Perl__SetRunning);
|
||||
package.add("activespeakactivity", &Perl__activespeakactivity);
|
||||
package.add("activespeaktask", &Perl__activespeaktask);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "set/alternate_currency.cpp"
|
||||
#include "set/animation.cpp"
|
||||
#include "set/anon.cpp"
|
||||
#include "set/auto_login.cpp"
|
||||
#include "set/bind_point.cpp"
|
||||
#include "set/checksum.cpp"
|
||||
#include "set/class_permanent.cpp"
|
||||
@@ -71,6 +72,7 @@ void command_set(Client *c, const Seperator *sep)
|
||||
Cmd{.cmd = "alternate_currency", .u = "alternate_currency [Currency ID] [Amount]", .fn = SetAlternateCurrency, .a = {"#setaltcurrency"}},
|
||||
Cmd{.cmd = "animation", .u = "animation [Animation ID]", .fn = SetAnimation, .a = {"#setanim"}},
|
||||
Cmd{.cmd = "anon", .u = "anon [Character ID] [Anonymous Flag] or #set anon [Anonymous Flag]", .fn = SetAnon, .a = {"#setanon"}},
|
||||
Cmd{.cmd = "auto_login", .u = "auto_login [0|1]", .fn = SetAutoLogin, .a = {"#setautologin"}},
|
||||
Cmd{.cmd = "bind_point", .u = "bind_point", .fn = SetBindPoint, .a = {"#setbind"}},
|
||||
Cmd{.cmd = "checksum", .u = "checksum", .fn = SetChecksum, .a = {"#updatechecksum"}},
|
||||
Cmd{.cmd = "class_permanent", .u = "class_permanent [Class ID]", .fn = SetClassPermanent, .a = {"#permaclass"}},
|
||||
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#include "../../client.h"
|
||||
#include "../../groups.h"
|
||||
#include "../../raids.h"
|
||||
#include "../../raids.h"
|
||||
#include "../../common/repositories/account_repository.h"
|
||||
|
||||
void SetAutoLogin(Client* c, const Seperator* sep)
|
||||
{
|
||||
if (!RuleB(World, EnableAutoLogin)) {
|
||||
c->Message(Chat::White, "Auto login is disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint16 arguments = sep->argnum;
|
||||
if (arguments < 2 || !sep->IsNumber(2)) {
|
||||
c->Message(Chat::White, "Usage: #set auto_login [0|1]");
|
||||
c->Message(Chat::White, "0 = Disable auto login for your account");
|
||||
c->Message(Chat::White, "1 = Set auto login character to your current character");
|
||||
return;
|
||||
}
|
||||
|
||||
Client* t = c;
|
||||
if (c->GetGM() && c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||
t = c->GetTarget()->CastToClient();
|
||||
}
|
||||
|
||||
auto e = AccountRepository::FindOne(database, t->AccountID());
|
||||
|
||||
if (!e.id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Failed to find an account entry for {}.",
|
||||
c->GetTargetDescription(t)
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool set_login = Strings::ToBool(sep->arg[2]);
|
||||
|
||||
e.auto_login_charname = set_login ? t->GetCleanName() : std::string();
|
||||
|
||||
AccountRepository::UpdateOne(database, e);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Auto login character has been set to '{}' for {}.",
|
||||
e.auto_login_charname,
|
||||
c->GetTargetDescription(t)
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "show/aas.cpp"
|
||||
#include "show/aa_points.cpp"
|
||||
#include "show/aggro.cpp"
|
||||
#include "show/auto_login.cpp"
|
||||
#include "show/buffs.cpp"
|
||||
#include "show/buried_corpse_count.cpp"
|
||||
#include "show/client_version_summary.cpp"
|
||||
@@ -62,6 +63,7 @@ void command_show(Client *c, const Seperator *sep)
|
||||
Cmd{.cmd = "aas", .u = "aas", .fn = ShowAAs, .a = {"#showaas"}},
|
||||
Cmd{.cmd = "aa_points", .u = "aa_points", .fn = ShowAAPoints, .a = {"#showaapoints", "#showaapts"}},
|
||||
Cmd{.cmd = "aggro", .u = "aggro [Distance] [-v] (-v is verbose Faction Information)", .fn = ShowAggro, .a = {"#aggro"}},
|
||||
Cmd{.cmd = "auto_login", .u = "auto_login", .fn = ShowAutoLogin, .a = {"#showautologin"}},
|
||||
Cmd{.cmd = "buffs", .u = "buffs", .fn = ShowBuffs, .a = {"#showbuffs"}},
|
||||
Cmd{.cmd = "buried_corpse_count", .u = "buried_corpse_count", .fn = ShowBuriedCorpseCount, .a = {"#getplayerburiedcorpsecount"}},
|
||||
Cmd{.cmd = "client_version_summary", .u = "client_version_summary", .fn = ShowClientVersionSummary, .a = {"#cvs"}},
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "../../client.h"
|
||||
#include "../../common/repositories/account_repository.h"
|
||||
|
||||
void ShowAutoLogin(Client* c, const Seperator* sep)
|
||||
{
|
||||
if (!RuleB(World, EnableAutoLogin)) {
|
||||
c->Message(Chat::White, "Auto login is disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
Client* t = c;
|
||||
if (c->GetGM() && c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||
t = c->GetTarget()->CastToClient();
|
||||
}
|
||||
|
||||
const auto& e = AccountRepository::FindOne(database, t->AccountID());
|
||||
|
||||
if (!e.id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Failed to find an account entry for {}.",
|
||||
c->GetTargetDescription(t)
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Auto login character for {} is set to '{}'.",
|
||||
c->GetTargetDescription(t),
|
||||
e.auto_login_charname
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -3345,6 +3345,24 @@ luabind::object Lua_Client::GetRaidOrGroupOrSelf(lua_State* L, bool clients_only
|
||||
return t;
|
||||
}
|
||||
|
||||
std::string Lua_Client::GetAutoLoginCharacterName()
|
||||
{
|
||||
Lua_Safe_Call_String();
|
||||
return quest_manager.GetAutoLoginCharacterNameByAccountID(self->AccountID());
|
||||
}
|
||||
|
||||
bool Lua_Client::SetAutoLoginCharacterName()
|
||||
{
|
||||
Lua_Safe_Call_Bool();
|
||||
return quest_manager.SetAutoLoginCharacterNameByAccountID(self->AccountID(), self->GetCleanName());
|
||||
}
|
||||
|
||||
bool Lua_Client::SetAutoLoginCharacterName(std::string character_name)
|
||||
{
|
||||
Lua_Safe_Call_Bool();
|
||||
return quest_manager.SetAutoLoginCharacterNameByAccountID(self->AccountID(), character_name);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_client() {
|
||||
return luabind::class_<Lua_Client, Lua_Mob>("Client")
|
||||
.def(luabind::constructor<>())
|
||||
@@ -3481,6 +3499,7 @@ luabind::scope lua_register_client() {
|
||||
.def("GetAnon", (int(Lua_Client::*)(void))&Lua_Client::GetAnon)
|
||||
.def("GetAugmentIDAt", (int(Lua_Client::*)(int,int))&Lua_Client::GetAugmentIDAt)
|
||||
.def("GetAugmentIDsBySlotID", (luabind::object(Lua_Client::*)(lua_State* L,int16))&Lua_Client::GetAugmentIDsBySlotID)
|
||||
.def("GetAutoLoginCharacterName", (std::string(Lua_Client::*)(void))&Lua_Client::GetAutoLoginCharacterName)
|
||||
.def("GetBaseAGI", (int(Lua_Client::*)(void))&Lua_Client::GetBaseAGI)
|
||||
.def("GetBaseCHA", (int(Lua_Client::*)(void))&Lua_Client::GetBaseCHA)
|
||||
.def("GetBaseDEX", (int(Lua_Client::*)(void))&Lua_Client::GetBaseDEX)
|
||||
@@ -3774,6 +3793,8 @@ luabind::scope lua_register_client() {
|
||||
.def("SetAccountFlag", (void(Lua_Client::*)(const std::string&,const std::string&))&Lua_Client::SetAccountFlag)
|
||||
.def("SetAlternateCurrencyValue", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::SetAlternateCurrencyValue)
|
||||
.def("SetAnon", (void(Lua_Client::*)(uint8))&Lua_Client::SetAnon)
|
||||
.def("SetAutoLoginCharacterName", (bool(Lua_Client::*)(void))&Lua_Client::SetAutoLoginCharacterName)
|
||||
.def("SetAutoLoginCharacterName", (bool(Lua_Client::*)(std::string))&Lua_Client::SetAutoLoginCharacterName)
|
||||
.def("SetBaseClass", (void(Lua_Client::*)(int))&Lua_Client::SetBaseClass)
|
||||
.def("SetBaseGender", (void(Lua_Client::*)(int))&Lua_Client::SetBaseGender)
|
||||
.def("SetBaseRace", (void(Lua_Client::*)(int))&Lua_Client::SetBaseRace)
|
||||
|
||||
@@ -499,6 +499,9 @@ public:
|
||||
bool IsInAGuild();
|
||||
luabind::object GetRaidOrGroupOrSelf(lua_State* L);
|
||||
luabind::object GetRaidOrGroupOrSelf(lua_State* L, bool clients_only);
|
||||
std::string GetAutoLoginCharacterName();
|
||||
bool SetAutoLoginCharacterName();
|
||||
bool SetAutoLoginCharacterName(std::string character_name);
|
||||
|
||||
void ApplySpell(int spell_id);
|
||||
void ApplySpell(int spell_id, int duration);
|
||||
|
||||
@@ -5488,6 +5488,14 @@ uint16 lua_get_race_bitmask(uint16 race_id) {
|
||||
return GetPlayerRaceBit(race_id);
|
||||
}
|
||||
|
||||
std::string lua_get_auto_login_character_name_by_account_id(uint32 account_id) {
|
||||
return quest_manager.GetAutoLoginCharacterNameByAccountID(account_id);
|
||||
}
|
||||
|
||||
bool lua_set_auto_login_character_name_by_account_id(uint32 account_id, std::string character_name) {
|
||||
return quest_manager.SetAutoLoginCharacterNameByAccountID(account_id, character_name);
|
||||
}
|
||||
|
||||
#define LuaCreateNPCParse(name, c_type, default_value) do { \
|
||||
cur = table[#name]; \
|
||||
if(luabind::type(cur) != LUA_TNIL) { \
|
||||
@@ -6287,6 +6295,8 @@ luabind::scope lua_register_general() {
|
||||
luabind::def("get_class_bitmask", &lua_get_class_bitmask),
|
||||
luabind::def("get_deity_bitmask", &lua_get_deity_bitmask),
|
||||
luabind::def("get_race_bitmask", &lua_get_race_bitmask),
|
||||
luabind::def("get_auto_login_character_name_by_account_id", &lua_get_auto_login_character_name_by_account_id),
|
||||
luabind::def("set_auto_login_character_name_by_account_id", &lua_set_auto_login_character_name_by_account_id),
|
||||
/*
|
||||
Cross Zone
|
||||
*/
|
||||
|
||||
@@ -3148,6 +3148,21 @@ perl::array Perl_Client_GetRaidOrGroupOrSelf(Client* self, bool clients_only)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string Perl_Client_GetAutoLoginCharacterName(Client* self)
|
||||
{
|
||||
return quest_manager.GetAutoLoginCharacterNameByAccountID(self->AccountID());
|
||||
}
|
||||
|
||||
bool Perl_Client_SetAutoLoginCharacterName(Client* self)
|
||||
{
|
||||
return quest_manager.SetAutoLoginCharacterNameByAccountID(self->AccountID(), self->GetCleanName());
|
||||
}
|
||||
|
||||
bool Perl_Client_SetAutoLoginCharacterName(Client* self, std::string character_name)
|
||||
{
|
||||
return quest_manager.SetAutoLoginCharacterNameByAccountID(self->AccountID(), character_name);
|
||||
}
|
||||
|
||||
void perl_register_client()
|
||||
{
|
||||
perl::interpreter perl(PERL_GET_THX);
|
||||
@@ -3280,6 +3295,7 @@ void perl_register_client()
|
||||
package.add("GetAugmentAt", &Perl_Client_GetAugmentAt);
|
||||
package.add("GetAugmentIDAt", &Perl_Client_GetAugmentIDAt);
|
||||
package.add("GetAugmentIDsBySlotID", &Perl_Client_GetAugmentIDsBySlotID);
|
||||
package.add("GetAutoLoginCharacterName", &Perl_Client_GetAutoLoginCharacterName);
|
||||
package.add("GetBaseAGI", &Perl_Client_GetBaseAGI);
|
||||
package.add("GetBaseCHA", &Perl_Client_GetBaseCHA);
|
||||
package.add("GetBaseDEX", &Perl_Client_GetBaseDEX);
|
||||
@@ -3572,6 +3588,8 @@ void perl_register_client()
|
||||
package.add("SetAccountFlag", &Perl_Client_SetAccountFlag);
|
||||
package.add("SetAlternateCurrencyValue", &Perl_Client_SetAlternateCurrencyValue);
|
||||
package.add("SetAnon", &Perl_Client_SetAnon);
|
||||
package.add("SetAutoLoginCharacterName", (bool(*)(Client*))&Perl_Client_SetAutoLoginCharacterName);
|
||||
package.add("SetAutoLoginCharacterName", (bool(*)(Client*, std::string))&Perl_Client_SetAutoLoginCharacterName);
|
||||
package.add("SetBaseClass", &Perl_Client_SetBaseClass);
|
||||
package.add("SetBaseGender", &Perl_Client_SetBaseGender);
|
||||
package.add("SetBaseRace", &Perl_Client_SetBaseRace);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "zonedb.h"
|
||||
#include "dialogue_window.h"
|
||||
|
||||
#include "../common/repositories/account_repository.h"
|
||||
#include "../common/repositories/tradeskill_recipe_repository.h"
|
||||
#include "../common/repositories/instance_list_repository.h"
|
||||
#include "../common/repositories/grid_entries_repository.h"
|
||||
@@ -4893,3 +4894,13 @@ void QuestManager::SendPlayerHandinEvent() {
|
||||
RecordPlayerEventLogWithClient(initiator, PlayerEvent::NPC_HANDIN, e);
|
||||
}
|
||||
}
|
||||
|
||||
std::string QuestManager::GetAutoLoginCharacterNameByAccountID(uint32 account_id)
|
||||
{
|
||||
return AccountRepository::GetAutoLoginCharacterNameByAccountID(database, account_id);
|
||||
}
|
||||
|
||||
bool QuestManager::SetAutoLoginCharacterNameByAccountID(uint32 account_id, const std::string& character_name)
|
||||
{
|
||||
return AccountRepository::SetAutoLoginCharacterNameByAccountID(database, account_id, character_name);
|
||||
}
|
||||
|
||||
@@ -353,6 +353,8 @@ public:
|
||||
void SendChannelMessage(uint8 channel_number, uint32 guild_id, uint8 language_id, uint8 language_skill, const char* message);
|
||||
void SendChannelMessage(Client* from, uint8 channel_number, uint32 guild_id, uint8 language_id, uint8 language_skill, const char* message);
|
||||
void SendChannelMessage(Client* from, const char* to, uint8 channel_number, uint32 guild_id, uint8 language_id, uint8 language_skill, const char* message);
|
||||
std::string GetAutoLoginCharacterNameByAccountID(uint32 account_id);
|
||||
bool SetAutoLoginCharacterNameByAccountID(uint32 account_id, const std::string& character_name);
|
||||
|
||||
Bot *GetBot() const;
|
||||
Client *GetInitiator() const;
|
||||
|
||||
Reference in New Issue
Block a user