mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
Few more updates [skip ci]
This commit is contained in:
parent
54ea7d7c4b
commit
1a577014d9
@ -642,10 +642,9 @@ void Client::DoSuccessfulLogin(
|
||||
*/
|
||||
void Client::CreateLocalAccount(const std::string &username, const std::string &password)
|
||||
{
|
||||
auto mode = server.options.GetEncryptionMode();
|
||||
auto hash = eqcrypt_hash(username, password, mode);
|
||||
|
||||
unsigned int db_id = 0;
|
||||
auto mode = server.options.GetEncryptionMode();
|
||||
auto hash = eqcrypt_hash(username, password, mode);
|
||||
unsigned int db_id = 0;
|
||||
if (!server.db->CreateLoginData(username, hash, "local", db_id)) {
|
||||
DoFailedLogin();
|
||||
}
|
||||
|
||||
@ -332,20 +332,18 @@ Database::DbWorldRegistration Database::GetWorldRegistration(
|
||||
{
|
||||
auto query = fmt::format(
|
||||
"SELECT\n"
|
||||
" ifnull(WSR.id, 999999) AS server_id,\n"
|
||||
" WSR.id,\n"
|
||||
" WSR.tag_description,\n"
|
||||
" ifnull(WSR.is_server_trusted, 0) AS is_server_trusted,\n"
|
||||
" ifnull(SLT.id, 3) AS login_server_list_type_id,\n"
|
||||
" WSR.is_server_trusted,\n"
|
||||
" SLT.id,\n"
|
||||
" SLT.description,\n"
|
||||
" ifnull(WSR.login_server_admin_id, 0) AS login_server_admin_id\n"
|
||||
"FROM\n"
|
||||
" login_world_servers AS WSR\n"
|
||||
" JOIN login_server_list_types AS SLT ON WSR.login_server_list_type_id = SLT.id\n"
|
||||
"WHERE\n"
|
||||
" WSR.short_name = '{0}' AND (WSR.last_ip_address = '{1}' OR WSR.last_ip_address = '{2}') LIMIT 1",
|
||||
EscapeString(short_name),
|
||||
EscapeString(remote_ip),
|
||||
EscapeString(local_ip)
|
||||
" WSR.short_name = '{0}' LIMIT 1",
|
||||
EscapeString(short_name)
|
||||
);
|
||||
|
||||
Database::DbWorldRegistration world_registration{};
|
||||
@ -442,46 +440,41 @@ void Database::UpdateWorldRegistration(unsigned int id, std::string long_name, s
|
||||
}
|
||||
|
||||
/**
|
||||
* @param long_name
|
||||
* @param short_name
|
||||
* @param server_long_name
|
||||
* @param server_short_name
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
bool Database::CreateWorldRegistration(
|
||||
std::string long_name,
|
||||
std::string short_name,
|
||||
std::string server_long_name,
|
||||
std::string server_short_name,
|
||||
std::string server_remote_ip,
|
||||
unsigned int &id
|
||||
)
|
||||
{
|
||||
auto query = fmt::format(
|
||||
"SELECT ifnull(max(id),0) + 1 FROM login_world_servers"
|
||||
);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
auto results = QueryDatabase("SELECT max(id) + 1 FROM login_world_servers");
|
||||
if (!results.Success() || results.RowCount() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
id = atoi(row[0]);
|
||||
|
||||
id = std::stoi(row[0]);
|
||||
auto insert_query = fmt::format(
|
||||
"INSERT INTO login_world_servers SET id = {0}, long_name = '{1}', short_name = '{2}', \n"
|
||||
"INSERT INTO login_world_servers SET id = {0}, long_name = '{1}', short_name = '{2}', last_ip_address = '{3}', \n"
|
||||
"login_server_list_type_id = 3, login_server_admin_id = 0, is_server_trusted = 0, tag_description = ''",
|
||||
id,
|
||||
long_name,
|
||||
short_name
|
||||
server_long_name,
|
||||
server_short_name,
|
||||
server_remote_ip
|
||||
);
|
||||
|
||||
auto insert_results = QueryDatabase(insert_query);
|
||||
if (!insert_results.Success()) {
|
||||
LogF(
|
||||
Logs::General,
|
||||
Logs::Error,
|
||||
"World registration did not exist in the database for {0} - {1}",
|
||||
long_name,
|
||||
short_name
|
||||
LogError(
|
||||
"Failed to register world server {0} - {1}",
|
||||
server_long_name,
|
||||
server_short_name
|
||||
);
|
||||
|
||||
return false;
|
||||
|
||||
@ -186,12 +186,17 @@ public:
|
||||
void UpdateWorldRegistration(unsigned int id, std::string long_name, std::string ip_address);
|
||||
|
||||
/**
|
||||
* @param long_name
|
||||
* @param short_name
|
||||
* @param server_long_name
|
||||
* @param server_short_name
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
bool CreateWorldRegistration(std::string long_name, std::string short_name, unsigned int &id);
|
||||
bool CreateWorldRegistration(
|
||||
std::string server_long_name,
|
||||
std::string server_short_name,
|
||||
std::string server_remote_ip,
|
||||
unsigned int &id
|
||||
);
|
||||
|
||||
/**
|
||||
* @param log_settings
|
||||
|
||||
@ -300,8 +300,7 @@ bool ServerManager::ServerExists(
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((*iter)->GetServerLongName().compare(server_long_name) == 0 &&
|
||||
(*iter)->GetServerShortName().compare(server_short_name) == 0) {
|
||||
if ((*iter)->GetServerLongName() == server_long_name && (*iter)->GetServerShortName() == server_short_name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -471,7 +471,7 @@ void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet
|
||||
*/
|
||||
void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info_packet)
|
||||
{
|
||||
if (is_server_logged_in) {
|
||||
if (IsServerLoggedIn()) {
|
||||
LogError("WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting");
|
||||
return;
|
||||
}
|
||||
@ -796,7 +796,6 @@ bool WorldServer::HandleNewLoginserverInfoUnregisteredAllowed(
|
||||
)
|
||||
{
|
||||
if (world_registration.loaded) {
|
||||
|
||||
this
|
||||
->SetServerDescription(world_registration.server_description)
|
||||
->SetServerId(world_registration.server_id)
|
||||
@ -824,7 +823,7 @@ bool WorldServer::HandleNewLoginserverInfoUnregisteredAllowed(
|
||||
this->GetServerShortName()
|
||||
);
|
||||
|
||||
if (IsServerTrusted()) {
|
||||
if (this->IsServerTrusted()) {
|
||||
LogDebug("WorldServer::HandleNewLoginserverRegisteredOnly | ServerOP_LSAccountUpdate sent to world");
|
||||
EQ::Net::DynamicPacket outapp;
|
||||
connection->Send(ServerOP_LSAccountUpdate, outapp);
|
||||
@ -879,7 +878,12 @@ bool WorldServer::HandleNewLoginserverInfoUnregisteredAllowed(
|
||||
/**
|
||||
* Auto create a registration
|
||||
*/
|
||||
if (!server.db->CreateWorldRegistration(long_name, short_name, server_id)) {
|
||||
if (!server.db->CreateWorldRegistration(
|
||||
GetServerLongName(),
|
||||
GetServerShortName(),
|
||||
GetRemoteIp(),
|
||||
server_id
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user