This commit is contained in:
Akkadius 2019-07-09 02:10:10 -05:00
parent 8c75cf1ff5
commit 8eaeda5ec5
10 changed files with 217 additions and 108 deletions

View File

@ -147,9 +147,6 @@ SET(EQEMU_LOG_LEVEL_DEBUG 3 CACHE STRING "EQEmu logging level for [Debug]:
) )
OPTION(EQEMU_LSPX "" OFF) OPTION(EQEMU_LSPX "" OFF)
IF(EQEMU_LSPX)
ADD_DEFINITIONS(-DLSPX=ON)
ENDIF(EQEMU_LSPX)
MARK_AS_ADVANCED(EQEMU_LSPX) MARK_AS_ADVANCED(EQEMU_LSPX)
MARK_AS_ADVANCED(EQEMU_LOG_LEVEL_DEBUG) MARK_AS_ADVANCED(EQEMU_LOG_LEVEL_DEBUG)
@ -164,6 +161,10 @@ IF(EQEMU_COMMANDS_LOGGING)
ADD_DEFINITIONS(-DCOMMANDS_LOGGING) ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
ENDIF(EQEMU_COMMANDS_LOGGING) ENDIF(EQEMU_COMMANDS_LOGGING)
IF(EQEMU_LSPX)
ADD_DEFINITIONS(-DLSPX=ON)
ENDIF(EQEMU_LSPX)
IF(EQEMU_ENABLE_BOTS) IF(EQEMU_ENABLE_BOTS)
ADD_DEFINITIONS(-DBOTS) ADD_DEFINITIONS(-DBOTS)
ENDIF(EQEMU_ENABLE_BOTS) ENDIF(EQEMU_ENABLE_BOTS)

View File

@ -472,7 +472,7 @@ struct ServerLSAccountUpdate_Struct { // for updating info on login server
uint32 useraccountid; // player account ID uint32 useraccountid; // player account ID
char useraccount[31]; // player account name char useraccount[31]; // player account name
char userpassword[51]; // player account password char userpassword[51]; // player account password
char useremail[101]; // player account email address char user_email[101]; // player account email address
}; };
struct ServerLSStatus_Struct { struct ServerLSStatus_Struct {

View File

@ -383,11 +383,10 @@ void Client::AttemptLoginAccountCreation(
const std::string &loginserver const std::string &loginserver
) )
{ {
LogInfo("Attempting login account creation via '{0}'", loginserver);
#ifdef LSPX #ifdef LSPX
if (loginserver == "eqemu") { if (loginserver == "eqemu") {
LogInfo("Attempting login account creation via '{0}'", loginserver);
if (!server.options.CanAutoLinkAccounts()) { if (!server.options.CanAutoLinkAccounts()) {
LogInfo("CanAutoLinkAccounts disabled - sending failed login"); LogInfo("CanAutoLinkAccounts disabled - sending failed login");
DoFailedLogin(); DoFailedLogin();
@ -452,6 +451,7 @@ void Client::AttemptLoginAccountCreation(
#endif #endif
if (server.options.CanAutoCreateAccounts() && loginserver == "local") { if (server.options.CanAutoCreateAccounts() && loginserver == "local") {
LogInfo("CanAutoCreateAccounts enabled, attempting to creating account [{0}]", user);
CreateLocalAccount(user, pass); CreateLocalAccount(user, pass);
return; return;
} }

View File

@ -503,7 +503,7 @@ std::string Database::CreateLoginserverApiToken(
{ {
std::string token = EQ::Util::UUID::Generate().ToString(); std::string token = EQ::Util::UUID::Generate().ToString();
auto query = fmt::format( auto query = fmt::format(
"INSERT INTO loginserver_api_tokens (token, can_write, can_read, created_at) VALUES ('{0}', {1}, {2}, NOW())", "INSERT INTO login_api_tokens (token, can_write, can_read, created_at) VALUES ('{0}', {1}, {2}, NOW())",
token, token,
(write_mode ? "1" : "0"), (write_mode ? "1" : "0"),
(read_mode ? "1" : "0") (read_mode ? "1" : "0")

View File

@ -65,6 +65,15 @@ public:
std::string &password, std::string &password,
unsigned int &id unsigned int &id
); );
/**
* @param token
* @param ip
* @param db_account_id
* @param db_loginserver
* @param user
* @return
*/
bool GetLoginTokenDataFromToken( bool GetLoginTokenDataFromToken(
const std::string &token, const std::string &token,
const std::string &ip, const std::string &ip,
@ -72,13 +81,34 @@ public:
std::string &db_loginserver, std::string &db_loginserver,
std::string &user std::string &user
); );
/**
* @param loginserver
* @return
*/
unsigned int GetFreeID(const std::string &loginserver); unsigned int GetFreeID(const std::string &loginserver);
/**
* @param name
* @param password
* @param loginserver
* @param id
* @return
*/
bool CreateLoginData( bool CreateLoginData(
const std::string &name, const std::string &name,
const std::string &password, const std::string &password,
const std::string &loginserver, const std::string &loginserver,
unsigned int &id unsigned int &id
); );
/**
* @param in_account_name
* @param in_account_password
* @param loginserver
* @param id
* @return
*/
bool CreateLoginDataWithID( bool CreateLoginDataWithID(
const std::string &in_account_name, const std::string &in_account_name,
const std::string &in_account_password, const std::string &in_account_password,
@ -86,8 +116,20 @@ public:
unsigned int id unsigned int id
); );
/**
* @param name
* @param loginserver
* @param hash
*/
void UpdateLoginHash(const std::string &name, const std::string &loginserver, const std::string &hash); void UpdateLoginHash(const std::string &name, const std::string &loginserver, const std::string &hash);
/**
* @param name
* @param password
* @param loginserver
* @param id
* @return
*/
bool DoesLoginServerAccountExist( bool DoesLoginServerAccountExist(
const std::string &name, const std::string &name,
const std::string &password, const std::string &password,
@ -122,10 +164,38 @@ public:
const std::string& local_ip const std::string& local_ip
); );
/**
* @param id
* @param ip_address
*/
void UpdateLSAccountData(unsigned int id, std::string ip_address); void UpdateLSAccountData(unsigned int id, std::string ip_address);
/**
* @param id
* @param name
* @param password
* @param email
*/
void UpdateLSAccountInfo(unsigned int id, std::string name, std::string password, std::string email); void UpdateLSAccountInfo(unsigned int id, std::string name, std::string password, std::string email);
/**
* @param id
* @param long_name
* @param ip_address
*/
void UpdateWorldRegistration(unsigned int id, std::string long_name, std::string ip_address); void UpdateWorldRegistration(unsigned int id, std::string long_name, std::string ip_address);
/**
* @param long_name
* @param short_name
* @param id
* @return
*/
bool CreateWorldRegistration(std::string long_name, std::string short_name, unsigned int &id); bool CreateWorldRegistration(std::string long_name, std::string short_name, unsigned int &id);
/**
* @param log_settings
*/
void LoadLogSettings(EQEmuLogSys::LogSettings *log_settings); void LoadLogSettings(EQEmuLogSys::LogSettings *log_settings);
/** /**

View File

@ -63,6 +63,7 @@ int main(int argc, char** argv)
server.options.AutoCreateAccounts(server.config.GetVariableBool("general", "auto_create_accounts", true)); server.options.AutoCreateAccounts(server.config.GetVariableBool("general", "auto_create_accounts", true));
server.options.AutoLinkAccounts(server.config.GetVariableBool("general", "auto_link_accounts", true)); server.options.AutoLinkAccounts(server.config.GetVariableBool("general", "auto_link_accounts", true));
#ifdef LSPX
server.options.EQEmuLoginServerAddress( server.options.EQEmuLoginServerAddress(
server.config.GetVariableString( server.config.GetVariableString(
"general", "general",
@ -78,6 +79,7 @@ int main(int argc, char** argv)
"local" "local"
) )
); );
#endif
#ifdef ENABLE_SECURITY #ifdef ENABLE_SECURITY
@ -137,7 +139,7 @@ int main(int argc, char** argv)
* create client manager * create client manager
*/ */
LogInfo("Client Manager Init"); LogInfo("Client Manager Init");
server.client_manager = new ClientManager(); server.client_manager = new ClientManager();
if (!server.client_manager) { if (!server.client_manager) {
LogError("Client Manager Failed to Start"); LogError("Client Manager Failed to Start");
LogInfo("Server Manager Shutdown"); LogInfo("Server Manager Shutdown");
@ -175,6 +177,19 @@ int main(int argc, char** argv)
LoginserverCommandHandler::CommandHandler(argc, argv); LoginserverCommandHandler::CommandHandler(argc, argv);
LogInfo("[Config] IsTraceOn [{0}]", server.options.IsTraceOn());
LogInfo("[Config] IsWorldTraceOn [{0}]", server.options.IsWorldTraceOn());
LogInfo("[Config] IsDumpInPacketsOn [{0}]", server.options.IsDumpInPacketsOn());
LogInfo("[Config] IsDumpOutPacketsOn [{0}]", server.options.IsDumpOutPacketsOn());
LogInfo("[Config] IsRejectingDuplicateServers [{0}]", server.options.IsRejectingDuplicateServers());
LogInfo("[Config] CanAutoCreateAccounts [{0}]", server.options.CanAutoCreateAccounts());
LogInfo("[Config] CanAutoLinkAccounts [{0}]", server.options.CanAutoLinkAccounts());
LogInfo("[Config] GetEncryptionMode [{0}]", server.options.GetEncryptionMode());
LogInfo("[Config] IsUnregisteredAllowed [{0}]", server.options.IsUnregisteredAllowed());
LogInfo("[Config] IsTokenLoginAllowed [{0}]", server.options.IsTokenLoginAllowed());
LogInfo("[Config] IsPasswordLoginAllowed [{0}]", server.options.IsPasswordLoginAllowed());
LogInfo("[Config] IsUpdatingInsecurePasswords [{0}]", server.options.IsUpdatingInsecurePasswords());
while (run_server) { while (run_server) {
Timer::SetCurrentTime(); Timer::SetCurrentTime();
server.client_manager->Process(); server.client_manager->Process();

View File

@ -121,7 +121,7 @@ EQApplicationPacket *ServerManager::CreateServerListPacket(Client *client, uint3
{ {
unsigned int packet_size = sizeof(ServerListHeader_Struct); unsigned int packet_size = sizeof(ServerListHeader_Struct);
unsigned int server_count = 0; unsigned int server_count = 0;
in_addr in; in_addr in{};
in.s_addr = client->GetConnection()->GetRemoteIP(); in.s_addr = client->GetConnection()->GetRemoteIP();
std::string client_ip = inet_ntoa(in); std::string client_ip = inet_ntoa(in);
@ -174,13 +174,13 @@ EQApplicationPacket *ServerManager::CreateServerListPacket(Client *client, uint3
iter = world_servers.begin(); iter = world_servers.begin();
while (iter != world_servers.end()) { while (iter != world_servers.end()) {
if ((*iter)->IsAuthorized() == false) { if (!(*iter)->IsAuthorized()) {
++iter; ++iter;
continue; continue;
} }
std::string world_ip = (*iter)->GetConnection()->Handle()->RemoteIP(); std::string world_ip = (*iter)->GetConnection()->Handle()->RemoteIP();
if (world_ip.compare(client_ip) == 0) { if (world_ip == client_ip) {
memcpy(data_pointer, (*iter)->GetLocalIP().c_str(), (*iter)->GetLocalIP().size()); memcpy(data_pointer, (*iter)->GetLocalIP().c_str(), (*iter)->GetLocalIP().size());
data_pointer += ((*iter)->GetLocalIP().size() + 1); data_pointer += ((*iter)->GetLocalIP().size() + 1);
} }

View File

@ -32,16 +32,16 @@ extern LoginServer server;
*/ */
WorldServer::WorldServer(std::shared_ptr<EQ::Net::ServertalkServerConnection> worldserver_connection) WorldServer::WorldServer(std::shared_ptr<EQ::Net::ServertalkServerConnection> worldserver_connection)
{ {
connection = worldserver_connection; connection = worldserver_connection;
zones_booted = 0; zones_booted = 0;
players_online = 0; players_online = 0;
server_status = 0; server_status = 0;
server_id = 0; server_id = 0;
server_list_type_id = 0; server_list_type_id = 0;
server_process_type = 0; server_process_type = 0;
is_server_authorized = false; is_server_authorized = false;
is_server_trusted = false; is_server_trusted = false;
is_server_logged_in = false; is_server_logged_in = false;
worldserver_connection->OnMessage( worldserver_connection->OnMessage(
ServerOP_NewLSInfo, ServerOP_NewLSInfo,
@ -79,13 +79,13 @@ WorldServer::~WorldServer() = default;
void WorldServer::Reset() void WorldServer::Reset()
{ {
server_id; server_id;
zones_booted = 0; zones_booted = 0;
players_online = 0; players_online = 0;
server_status = 0; server_status = 0;
server_list_type_id = 0; server_list_type_id = 0;
server_process_type = 0; server_process_type = 0;
is_server_authorized = false; is_server_authorized = false;
is_server_logged_in = false; is_server_logged_in = false;
} }
/** /**
@ -219,13 +219,13 @@ void WorldServer::ProcessUserToWorldResponseLegacy(uint16_t opcode, const EQ::Ne
auto *user_to_world_response = (UsertoWorldResponseLegacy_Struct *) packet.Data(); auto *user_to_world_response = (UsertoWorldResponseLegacy_Struct *) packet.Data();
LogDebug("Trying to find client with user id of [{0}]", user_to_world_response->lsaccountid); LogDebug("Trying to find client with user id of [{0}]", user_to_world_response->lsaccountid);
Client *c = server.client_manager->GetClient(user_to_world_response->lsaccountid, "eqemu"); Client *client = server.client_manager->GetClient(user_to_world_response->lsaccountid, "eqemu");
if (c) { if (client) {
LogDebug( LogDebug(
"Found client with user id of [{0}] and account name of [{1}]", "Found client with user id of [{0}] and account name of [{1}]",
user_to_world_response->lsaccountid, user_to_world_response->lsaccountid,
c->GetAccountName() client->GetAccountName()
); );
auto *outapp = new EQApplicationPacket( auto *outapp = new EQApplicationPacket(
@ -234,17 +234,17 @@ void WorldServer::ProcessUserToWorldResponseLegacy(uint16_t opcode, const EQ::Ne
); );
auto *per = (PlayEverquestResponse_Struct *) outapp->pBuffer; auto *per = (PlayEverquestResponse_Struct *) outapp->pBuffer;
per->Sequence = c->GetPlaySequence(); per->Sequence = client->GetPlaySequence();
per->ServerNumber = c->GetPlayServerID(); per->ServerNumber = client->GetPlayServerID();
if (user_to_world_response->response > 0) { if (user_to_world_response->response > 0) {
per->Allowed = 1; per->Allowed = 1;
SendClientAuth( SendClientAuth(
c->GetConnection()->GetRemoteAddr(), client->GetConnection()->GetRemoteAddr(),
c->GetAccountName(), client->GetAccountName(),
c->GetKey(), client->GetKey(),
c->GetAccountID(), client->GetAccountID(),
c->GetLoginServerName() client->GetLoginServerName()
); );
} }
@ -281,7 +281,7 @@ void WorldServer::ProcessUserToWorldResponseLegacy(uint16_t opcode, const EQ::Ne
DumpPacket(outapp); DumpPacket(outapp);
} }
c->SendPlayResponse(outapp); client->SendPlayResponse(outapp);
delete outapp; delete outapp;
} }
else { else {
@ -311,10 +311,11 @@ void WorldServer::ProcessUserToWorldResponse(uint16_t opcode, const EQ::Net::Pac
} }
if (packet.Length() < sizeof(UsertoWorldResponse_Struct)) { if (packet.Length() < sizeof(UsertoWorldResponse_Struct)) {
Log(Logs::General, LogError(
Logs::Error,
"Received application packet from server that had opcode ServerOP_UsertoWorldResp, " "Received application packet from server that had opcode ServerOP_UsertoWorldResp, "
"but was too small. Discarded to avoid buffer overrun"); "but was too small. Discarded to avoid buffer overrun"
);
return; return;
} }
@ -326,11 +327,13 @@ void WorldServer::ProcessUserToWorldResponse(uint16_t opcode, const EQ::Net::Pac
} }
auto user_to_world_response = (UsertoWorldResponse_Struct *) packet.Data(); auto user_to_world_response = (UsertoWorldResponse_Struct *) packet.Data();
Log(Logs::General, Logs::Debug, "Trying to find client with user id of %u.", user_to_world_response->lsaccountid); LogDebug("Trying to find client with user id of [{0}]", user_to_world_response->lsaccountid);
Client *client = server.client_manager->GetClient( Client *client = server.client_manager->GetClient(
user_to_world_response->lsaccountid, user_to_world_response->lsaccountid,
user_to_world_response->login user_to_world_response->login
); );
if (client) { if (client) {
LogDebug("Found client with user id of {0} and account name of {1}", LogDebug("Found client with user id of {0} and account name of {1}",
user_to_world_response->lsaccountid, user_to_world_response->lsaccountid,
@ -345,9 +348,9 @@ void WorldServer::ProcessUserToWorldResponse(uint16_t opcode, const EQ::Net::Pac
auto *per = (PlayEverquestResponse_Struct *) outapp->pBuffer; auto *per = (PlayEverquestResponse_Struct *) outapp->pBuffer;
per->Sequence = client->GetPlaySequence(); per->Sequence = client->GetPlaySequence();
per->ServerNumber = client->GetPlayServerID(); per->ServerNumber = client->GetPlayServerID();
Log(Logs::General,
Logs::Debug, LogDebug(
"Found sequence and play of %u %u", "Found sequence and play of [{0}] [{1}]",
client->GetPlaySequence(), client->GetPlaySequence(),
client->GetPlayServerID() client->GetPlayServerID()
); );
@ -402,8 +405,10 @@ void WorldServer::ProcessUserToWorldResponse(uint16_t opcode, const EQ::Net::Pac
delete outapp; delete outapp;
} }
else { else {
LogError("Received User-To-World Response for {0} but could not find the client referenced!.", LogError(
user_to_world_response->lsaccountid); "Received User-To-World Response for {0} but could not find the client referenced!.",
user_to_world_response->lsaccountid
);
} }
} }
@ -437,22 +442,25 @@ void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet
Log(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate packet received from: %s", short_name.c_str()); Log(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate packet received from: %s", short_name.c_str());
auto *loginserver_update = (ServerLSAccountUpdate_Struct *) packet.Data(); auto *loginserver_update = (ServerLSAccountUpdate_Struct *) packet.Data();
if (is_server_trusted) { if (IsServerTrusted()) {
Log(Logs::General, LogDebug("ServerOP_LSAccountUpdate update processed for: [{0}]", loginserver_update->useraccount);
Logs::Netcode, std::string name;
"ServerOP_LSAccountUpdate update processed for: %s", std::string password;
loginserver_update->useraccount); std::string email;
std::string name = "";
std::string password = "";
std::string email = "";
name.assign(loginserver_update->useraccount); name.assign(loginserver_update->useraccount);
password.assign(loginserver_update->userpassword); password.assign(loginserver_update->userpassword);
if (loginserver_update->useremail) { if (loginserver_update->user_email) {
email.assign(loginserver_update->useremail); email.assign(loginserver_update->user_email);
} }
server.db->UpdateLSAccountInfo(loginserver_update->useraccountid, name, password, email); server.db->UpdateLSAccountInfo(
loginserver_update->useraccountid,
name,
password,
email
);
} }
} }
@ -473,8 +481,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
return; return;
} }
this this->SetAccountPassword(new_world_server_info_packet->account_password)
->SetAccountPassword(new_world_server_info_packet->account_password)
->SetLongName(new_world_server_info_packet->server_long_name) ->SetLongName(new_world_server_info_packet->server_long_name)
->SetShortName(new_world_server_info_packet->server_short_name) ->SetShortName(new_world_server_info_packet->server_short_name)
->SetLocalIp(new_world_server_info_packet->local_ip_address) ->SetLocalIp(new_world_server_info_packet->local_ip_address)
@ -486,30 +493,40 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
->SetAccountName(new_world_server_info_packet->account_name); ->SetAccountName(new_world_server_info_packet->account_name);
if (server.options.IsRejectingDuplicateServers()) { if (server.options.IsRejectingDuplicateServers()) {
if (server.server_manager->ServerExists(long_name, short_name, this)) { if (server.server_manager->ServerExists(GetServerLongName(), GetServerShortName(), this)) {
LogError("World tried to login but there already exists a server that has that name"); LogError("World tried to login but there already exists a server that has that name");
return; return;
} }
} }
else { else {
if (server.server_manager->ServerExists(long_name, short_name, this)) { if (server.server_manager->ServerExists(GetServerLongName(), GetServerShortName(), this)) {
LogError("World tried to login but there already exists a server that has that name"); LogInfo("World tried to login but there already exists a server that has that name");
server.server_manager->DestroyServerByName(long_name, short_name, this); server.server_manager->DestroyServerByName(long_name, short_name, this);
} }
} }
Database::DbWorldRegistration Database::DbWorldRegistration
world_registration = server.db->GetWorldRegistration(short_name, remote_ip_address, local_ip); world_registration = server.db->GetWorldRegistration(
GetServerShortName(),
GetRemoteIp(),
GetLocalIp()
);
if (!server.options.IsUnregisteredAllowed()) { if (!server.options.IsUnregisteredAllowed()) {
if (!this->HandleNewLoginserverRegisteredOnly(world_registration)){ if (!this->HandleNewLoginserverRegisteredOnly(world_registration)) {
LogError("WorldServer::HandleNewLoginserverRegisteredOnly checks failed"); LogError(
"WorldServer::HandleNewLoginserverRegisteredOnly checks failed with server [{0}]",
this->GetServerLongName()
);
return; return;
} }
} }
else { else {
if (!this->HandleNewLoginserverInfoUnregisteredAllowed(world_registration)){ if (!this->HandleNewLoginserverInfoUnregisteredAllowed(world_registration)) {
LogError("WorldServer::HandleNewLoginserverInfoUnregisteredAllowed checks failed"); LogError(
"WorldServer::HandleNewLoginserverInfoUnregisteredAllowed checks failed with server [{0}]",
this->GetServerLongName()
);
return; return;
} }
} }
@ -526,9 +543,9 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
*/ */
void WorldServer::Handle_LSStatus(ServerLSStatus_Struct *server_login_status) void WorldServer::Handle_LSStatus(ServerLSStatus_Struct *server_login_status)
{ {
players_online = server_login_status->num_players; SetPlayersOnline(server_login_status->num_players);
zones_booted = server_login_status->num_zones; SetZonesBooted(server_login_status->num_zones);
server_status = server_login_status->status; SetServerStatus(server_login_status->status);
} }
/** /**
@ -663,7 +680,7 @@ bool WorldServer::HandleNewLoginserverInfoValidation(
if (strlen(new_world_server_info_packet->remote_ip_address) == 0) { if (strlen(new_world_server_info_packet->remote_ip_address) == 0) {
this->SetRemoteIp(GetConnection()->Handle()->RemoteIP()); this->SetRemoteIp(GetConnection()->Handle()->RemoteIP());
LogError( LogWarning(
"Remote address was null, defaulting to stream address {0}", "Remote address was null, defaulting to stream address {0}",
remote_ip_address remote_ip_address
); );
@ -675,8 +692,8 @@ bool WorldServer::HandleNewLoginserverInfoValidation(
else { else {
this->SetRemoteIp(GetConnection()->Handle()->RemoteIP()); this->SetRemoteIp(GetConnection()->Handle()->RemoteIP());
LogError( LogWarning(
"Handle_NewLSInfo error, remote address was too long, defaulting to stream address [{0}]", "Handle_NewLSInfo remote address was too long, defaulting to stream address [{0}]",
remote_ip_address remote_ip_address
); );
} }
@ -690,7 +707,8 @@ bool WorldServer::HandleNewLoginserverInfoValidation(
*/ */
bool WorldServer::HandleNewLoginserverRegisteredOnly( bool WorldServer::HandleNewLoginserverRegisteredOnly(
Database::DbWorldRegistration &world_registration Database::DbWorldRegistration &world_registration
) { )
{
if (!this->GetAccountName().empty() && !this->GetAccountPassword().empty()) { if (!this->GetAccountName().empty() && !this->GetAccountPassword().empty()) {
if (world_registration.loaded) { if (world_registration.loaded) {
bool does_world_server_not_require_authentication = ( bool does_world_server_not_require_authentication = (
@ -775,7 +793,8 @@ bool WorldServer::HandleNewLoginserverRegisteredOnly(
*/ */
bool WorldServer::HandleNewLoginserverInfoUnregisteredAllowed( bool WorldServer::HandleNewLoginserverInfoUnregisteredAllowed(
Database::DbWorldRegistration &world_registration Database::DbWorldRegistration &world_registration
) { )
{
if (world_registration.loaded) { if (world_registration.loaded) {
this this
@ -872,7 +891,7 @@ bool WorldServer::HandleNewLoginserverInfoUnregisteredAllowed(
* @param in_server_list_id * @param in_server_list_id
* @return * @return
*/ */
WorldServer * WorldServer::SetServerListTypeId(unsigned int in_server_list_id) WorldServer *WorldServer::SetServerListTypeId(unsigned int in_server_list_id)
{ {
server_list_type_id = in_server_list_id; server_list_type_id = in_server_list_id;
@ -890,7 +909,7 @@ const std::string &WorldServer::GetServerDescription() const
/** /**
* @param in_server_description * @param in_server_description
*/ */
WorldServer * WorldServer::SetServerDescription(const std::string &in_server_description) WorldServer *WorldServer::SetServerDescription(const std::string &in_server_description)
{ {
WorldServer::server_description = in_server_description; WorldServer::server_description = in_server_description;
@ -908,7 +927,7 @@ bool WorldServer::IsServerAuthorized() const
/** /**
* @param in_is_server_authorized * @param in_is_server_authorized
*/ */
WorldServer * WorldServer::SetIsServerAuthorized(bool in_is_server_authorized) WorldServer *WorldServer::SetIsServerAuthorized(bool in_is_server_authorized)
{ {
WorldServer::is_server_authorized = in_is_server_authorized; WorldServer::is_server_authorized = in_is_server_authorized;
@ -926,7 +945,7 @@ bool WorldServer::IsServerLoggedIn() const
/** /**
* @param in_is_server_logged_in * @param in_is_server_logged_in
*/ */
WorldServer * WorldServer::SetIsServerLoggedIn(bool in_is_server_logged_in) WorldServer *WorldServer::SetIsServerLoggedIn(bool in_is_server_logged_in)
{ {
WorldServer::is_server_logged_in = in_is_server_logged_in; WorldServer::is_server_logged_in = in_is_server_logged_in;
@ -944,7 +963,7 @@ bool WorldServer::IsServerTrusted() const
/** /**
* @param in_is_server_trusted * @param in_is_server_trusted
*/ */
WorldServer * WorldServer::SetIsServerTrusted(bool in_is_server_trusted) WorldServer *WorldServer::SetIsServerTrusted(bool in_is_server_trusted)
{ {
WorldServer::is_server_trusted = in_is_server_trusted; WorldServer::is_server_trusted = in_is_server_trusted;
@ -954,7 +973,7 @@ WorldServer * WorldServer::SetIsServerTrusted(bool in_is_server_trusted)
/** /**
* @param in_zones_booted * @param in_zones_booted
*/ */
WorldServer * WorldServer::SetZonesBooted(unsigned int in_zones_booted) WorldServer *WorldServer::SetZonesBooted(unsigned int in_zones_booted)
{ {
WorldServer::zones_booted = in_zones_booted; WorldServer::zones_booted = in_zones_booted;
@ -964,7 +983,7 @@ WorldServer * WorldServer::SetZonesBooted(unsigned int in_zones_booted)
/** /**
* @param in_players_online * @param in_players_online
*/ */
WorldServer * WorldServer::SetPlayersOnline(unsigned int in_players_online) WorldServer *WorldServer::SetPlayersOnline(unsigned int in_players_online)
{ {
WorldServer::players_online = in_players_online; WorldServer::players_online = in_players_online;
@ -974,7 +993,7 @@ WorldServer * WorldServer::SetPlayersOnline(unsigned int in_players_online)
/** /**
* @param in_server_status * @param in_server_status
*/ */
WorldServer * WorldServer::SetServerStatus(int in_server_status) WorldServer *WorldServer::SetServerStatus(int in_server_status)
{ {
WorldServer::server_status = in_server_status; WorldServer::server_status = in_server_status;
@ -984,7 +1003,7 @@ WorldServer * WorldServer::SetServerStatus(int in_server_status)
/** /**
* @param in_server_process_type * @param in_server_process_type
*/ */
WorldServer * WorldServer::SetServerProcessType(unsigned int in_server_process_type) WorldServer *WorldServer::SetServerProcessType(unsigned int in_server_process_type)
{ {
WorldServer::server_process_type = in_server_process_type; WorldServer::server_process_type = in_server_process_type;
@ -994,7 +1013,7 @@ WorldServer * WorldServer::SetServerProcessType(unsigned int in_server_process_t
/** /**
* @param in_long_name * @param in_long_name
*/ */
WorldServer * WorldServer::SetLongName(const std::string &in_long_name) WorldServer *WorldServer::SetLongName(const std::string &in_long_name)
{ {
WorldServer::long_name = in_long_name; WorldServer::long_name = in_long_name;
@ -1004,7 +1023,7 @@ WorldServer * WorldServer::SetLongName(const std::string &in_long_name)
/** /**
* @param in_short_name * @param in_short_name
*/ */
WorldServer * WorldServer::SetShortName(const std::string &in_short_name) WorldServer *WorldServer::SetShortName(const std::string &in_short_name)
{ {
WorldServer::short_name = in_short_name; WorldServer::short_name = in_short_name;
@ -1014,7 +1033,7 @@ WorldServer * WorldServer::SetShortName(const std::string &in_short_name)
/** /**
* @param in_account_name * @param in_account_name
*/ */
WorldServer * WorldServer::SetAccountName(const std::string &in_account_name) WorldServer *WorldServer::SetAccountName(const std::string &in_account_name)
{ {
WorldServer::account_name = in_account_name; WorldServer::account_name = in_account_name;
@ -1024,7 +1043,7 @@ WorldServer * WorldServer::SetAccountName(const std::string &in_account_name)
/** /**
* @param in_account_password * @param in_account_password
*/ */
WorldServer * WorldServer::SetAccountPassword(const std::string &in_account_password) WorldServer *WorldServer::SetAccountPassword(const std::string &in_account_password)
{ {
WorldServer::account_password = in_account_password; WorldServer::account_password = in_account_password;
@ -1034,7 +1053,7 @@ WorldServer * WorldServer::SetAccountPassword(const std::string &in_account_pass
/** /**
* @param in_remote_ip * @param in_remote_ip
*/ */
WorldServer * WorldServer::SetRemoteIp(const std::string &in_remote_ip) WorldServer *WorldServer::SetRemoteIp(const std::string &in_remote_ip)
{ {
WorldServer::remote_ip_address = in_remote_ip; WorldServer::remote_ip_address = in_remote_ip;
@ -1044,7 +1063,7 @@ WorldServer * WorldServer::SetRemoteIp(const std::string &in_remote_ip)
/** /**
* @param in_local_ip * @param in_local_ip
*/ */
WorldServer * WorldServer::SetLocalIp(const std::string &in_local_ip) WorldServer *WorldServer::SetLocalIp(const std::string &in_local_ip)
{ {
WorldServer::local_ip = in_local_ip; WorldServer::local_ip = in_local_ip;
@ -1054,7 +1073,7 @@ WorldServer * WorldServer::SetLocalIp(const std::string &in_local_ip)
/** /**
* @param in_protocol * @param in_protocol
*/ */
WorldServer * WorldServer::SetProtocol(const std::string &in_protocol) WorldServer *WorldServer::SetProtocol(const std::string &in_protocol)
{ {
WorldServer::protocol = in_protocol; WorldServer::protocol = in_protocol;
@ -1064,7 +1083,7 @@ WorldServer * WorldServer::SetProtocol(const std::string &in_protocol)
/** /**
* @param in_version * @param in_version
*/ */
WorldServer * WorldServer::SetVersion(const std::string &in_version) WorldServer *WorldServer::SetVersion(const std::string &in_version)
{ {
WorldServer::version = in_version; WorldServer::version = in_version;

View File

@ -36,6 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "clientlist.h" #include "clientlist.h"
#include "world_config.h" #include "world_config.h"
extern ZSList zoneserver_list; extern ZSList zoneserver_list;
extern ClientList client_list; extern ClientList client_list;
extern uint32 numzones; extern uint32 numzones;
@ -544,24 +545,27 @@ void LoginServer::SendStatus()
pack->size = sizeof(ServerLSStatus_Struct); pack->size = sizeof(ServerLSStatus_Struct);
pack->pBuffer = new uchar[pack->size]; pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, pack->size); memset(pack->pBuffer, 0, pack->size);
ServerLSStatus_Struct *lss = (ServerLSStatus_Struct *) pack->pBuffer; auto loginserver_status = (ServerLSStatus_Struct *) pack->pBuffer;
if (WorldConfig::get()->Locked) { if (WorldConfig::get()->Locked) {
lss->status = -2; loginserver_status->status = -2;
} }
else if (numzones <= 0) { else if (numzones <= 0) {
lss->status = -2; loginserver_status->status = -2;
} }
else { else {
lss->status = numplayers; loginserver_status->status = numplayers;
} }
lss->num_zones = numzones; loginserver_status->num_zones = numzones;
lss->num_players = numplayers; loginserver_status->num_players = numplayers;
SendPacket(pack); SendPacket(pack);
delete pack; delete pack;
} }
/**
* @param pack
*/
void LoginServer::SendPacket(ServerPacket *pack) void LoginServer::SendPacket(ServerPacket *pack)
{ {
if (IsLegacy) { if (IsLegacy) {
@ -578,15 +582,15 @@ void LoginServer::SendPacket(ServerPacket *pack)
void LoginServer::SendAccountUpdate(ServerPacket *pack) void LoginServer::SendAccountUpdate(ServerPacket *pack)
{ {
ServerLSAccountUpdate_Struct *s = (ServerLSAccountUpdate_Struct *) pack->pBuffer; auto *ls_account_update = (ServerLSAccountUpdate_Struct *) pack->pBuffer;
if (CanUpdate()) { if (CanUpdate()) {
Log(Logs::Detail, LogInfo(
Logs::World_Server, "Sending ServerOP_LSAccountUpdate packet to loginserver: [{0}]:[{1}]",
"Sending ServerOP_LSAccountUpdate packet to loginserver: %s:%d",
LoginServerAddress, LoginServerAddress,
LoginServerPort); LoginServerPort
strn0cpy(s->worldaccount, LoginAccount.c_str(), 30); );
strn0cpy(s->worldpassword, LoginPassword.c_str(), 30); strn0cpy(ls_account_update->worldaccount, LoginAccount.c_str(), 30);
strn0cpy(ls_account_update->worldpassword, LoginPassword.c_str(), 30);
SendPacket(pack); SendPacket(pack);
} }
} }

View File

@ -2361,7 +2361,7 @@ void command_setlsinfo(Client *c, const Seperator *sep)
ServerLSAccountUpdate_Struct* s = (ServerLSAccountUpdate_Struct *) pack->pBuffer; ServerLSAccountUpdate_Struct* s = (ServerLSAccountUpdate_Struct *) pack->pBuffer;
s->useraccountid = c->LSAccountID(); s->useraccountid = c->LSAccountID();
strn0cpy(s->useraccount, c->AccountName(), 30); strn0cpy(s->useraccount, c->AccountName(), 30);
strn0cpy(s->useremail, sep->arg[1], 100); strn0cpy(s->user_email, sep->arg[1], 100);
strn0cpy(s->userpassword, sep->arg[2], 50); strn0cpy(s->userpassword, sep->arg[2], 50);
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
c->Message(0, "Login Server update packet sent."); c->Message(0, "Login Server update packet sent.");