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