mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
DatabaseMySQL -> Database
This commit is contained in:
parent
ff5783965a
commit
bd2836db61
@ -37,7 +37,7 @@ extern LoginServer server;
|
|||||||
* @param port
|
* @param port
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
DatabaseMySQL::DatabaseMySQL(
|
Database::Database(
|
||||||
std::string user,
|
std::string user,
|
||||||
std::string pass,
|
std::string pass,
|
||||||
std::string host,
|
std::string host,
|
||||||
@ -97,7 +97,7 @@ DatabaseMySQL::DatabaseMySQL(
|
|||||||
/**
|
/**
|
||||||
* Deconstructor
|
* Deconstructor
|
||||||
*/
|
*/
|
||||||
DatabaseMySQL::~DatabaseMySQL()
|
Database::~Database()
|
||||||
{
|
{
|
||||||
if (database) {
|
if (database) {
|
||||||
mysql_close(database);
|
mysql_close(database);
|
||||||
@ -111,7 +111,7 @@ DatabaseMySQL::~DatabaseMySQL()
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool DatabaseMySQL::GetLoginDataFromAccountInfo(
|
bool Database::GetLoginDataFromAccountInfo(
|
||||||
const std::string &name,
|
const std::string &name,
|
||||||
const std::string &loginserver,
|
const std::string &loginserver,
|
||||||
std::string &password,
|
std::string &password,
|
||||||
@ -167,7 +167,7 @@ bool DatabaseMySQL::GetLoginDataFromAccountInfo(
|
|||||||
* @param user
|
* @param user
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool DatabaseMySQL::GetLoginTokenDataFromToken(
|
bool Database::GetLoginTokenDataFromToken(
|
||||||
const std::string &token,
|
const std::string &token,
|
||||||
const std::string &ip,
|
const std::string &ip,
|
||||||
unsigned int &db_account_id,
|
unsigned int &db_account_id,
|
||||||
@ -229,7 +229,7 @@ bool DatabaseMySQL::GetLoginTokenDataFromToken(
|
|||||||
* @param loginserver
|
* @param loginserver
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
unsigned int DatabaseMySQL::GetFreeID(const std::string &loginserver)
|
unsigned int Database::GetFreeID(const std::string &loginserver)
|
||||||
{
|
{
|
||||||
if (!database) {
|
if (!database) {
|
||||||
return false;
|
return false;
|
||||||
@ -273,7 +273,7 @@ unsigned int DatabaseMySQL::GetFreeID(const std::string &loginserver)
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool DatabaseMySQL::CreateLoginData(
|
bool Database::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,
|
||||||
@ -290,7 +290,7 @@ bool DatabaseMySQL::CreateLoginData(
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool DatabaseMySQL::CreateLoginDataWithID(
|
bool Database::CreateLoginDataWithID(
|
||||||
const std::string &name,
|
const std::string &name,
|
||||||
const std::string &password,
|
const std::string &password,
|
||||||
const std::string &loginserver,
|
const std::string &loginserver,
|
||||||
@ -326,7 +326,7 @@ bool DatabaseMySQL::CreateLoginDataWithID(
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool DatabaseMySQL::DoesLoginServerAccountExist(
|
bool Database::DoesLoginServerAccountExist(
|
||||||
const std::string &name,
|
const std::string &name,
|
||||||
const std::string &password,
|
const std::string &password,
|
||||||
const std::string &loginserver,
|
const std::string &loginserver,
|
||||||
@ -357,7 +357,7 @@ bool DatabaseMySQL::DoesLoginServerAccountExist(
|
|||||||
* @param loginserver
|
* @param loginserver
|
||||||
* @param hash
|
* @param hash
|
||||||
*/
|
*/
|
||||||
void DatabaseMySQL::UpdateLoginHash(
|
void Database::UpdateLoginHash(
|
||||||
const std::string &name,
|
const std::string &name,
|
||||||
const std::string &loginserver,
|
const std::string &loginserver,
|
||||||
const std::string &hash
|
const std::string &hash
|
||||||
@ -395,7 +395,7 @@ void DatabaseMySQL::UpdateLoginHash(
|
|||||||
* @param password
|
* @param password
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool DatabaseMySQL::GetWorldRegistration(
|
bool Database::GetWorldRegistration(
|
||||||
std::string long_name,
|
std::string long_name,
|
||||||
std::string short_name,
|
std::string short_name,
|
||||||
unsigned int &id,
|
unsigned int &id,
|
||||||
@ -484,7 +484,7 @@ bool DatabaseMySQL::GetWorldRegistration(
|
|||||||
* @param id
|
* @param id
|
||||||
* @param ip_address
|
* @param ip_address
|
||||||
*/
|
*/
|
||||||
void DatabaseMySQL::UpdateLSAccountData(unsigned int id, std::string ip_address)
|
void Database::UpdateLSAccountData(unsigned int id, std::string ip_address)
|
||||||
{
|
{
|
||||||
auto query = fmt::format(
|
auto query = fmt::format(
|
||||||
"UPDATE {0} SET LastIPAddress = '{2}', LastLoginDate = now() where LoginServerId = {3}",
|
"UPDATE {0} SET LastIPAddress = '{2}', LastLoginDate = now() where LoginServerId = {3}",
|
||||||
@ -502,7 +502,7 @@ void DatabaseMySQL::UpdateLSAccountData(unsigned int id, std::string ip_address)
|
|||||||
* @param password
|
* @param password
|
||||||
* @param email
|
* @param email
|
||||||
*/
|
*/
|
||||||
void DatabaseMySQL::UpdateLSAccountInfo(
|
void Database::UpdateLSAccountInfo(
|
||||||
unsigned int id,
|
unsigned int id,
|
||||||
std::string name,
|
std::string name,
|
||||||
std::string password,
|
std::string password,
|
||||||
@ -527,7 +527,7 @@ void DatabaseMySQL::UpdateLSAccountInfo(
|
|||||||
* @param long_name
|
* @param long_name
|
||||||
* @param ip_address
|
* @param ip_address
|
||||||
*/
|
*/
|
||||||
void DatabaseMySQL::UpdateWorldRegistration(unsigned int id, std::string long_name, std::string ip_address)
|
void Database::UpdateWorldRegistration(unsigned int id, std::string long_name, std::string ip_address)
|
||||||
{
|
{
|
||||||
auto query = fmt::format(
|
auto query = fmt::format(
|
||||||
"UPDATE {0} SET ServerLastLoginDate = NOW(), ServerLastIPAddr = '{1}', ServerLongName = '{2}' WHERE ServerID = {3}",
|
"UPDATE {0} SET ServerLastLoginDate = NOW(), ServerLastIPAddr = '{1}', ServerLongName = '{2}' WHERE ServerID = {3}",
|
||||||
@ -546,7 +546,7 @@ void DatabaseMySQL::UpdateWorldRegistration(unsigned int id, std::string long_na
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool DatabaseMySQL::CreateWorldRegistration(std::string long_name, std::string short_name, unsigned int &id)
|
bool Database::CreateWorldRegistration(std::string long_name, std::string short_name, unsigned int &id)
|
||||||
{
|
{
|
||||||
if (!database) {
|
if (!database) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -28,10 +28,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
|
||||||
class DatabaseMySQL : public DBcore {
|
class Database : public DBcore {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DatabaseMySQL() { database = nullptr; }
|
Database() { database = nullptr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor, tries to set our database to connect to the supplied options.
|
* Constructor, tries to set our database to connect to the supplied options.
|
||||||
@ -42,12 +42,12 @@ public:
|
|||||||
* @param port
|
* @param port
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
DatabaseMySQL(std::string user, std::string pass, std::string host, std::string port, std::string name);
|
Database(std::string user, std::string pass, std::string host, std::string port, std::string name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor, frees our database if needed.
|
* Destructor, frees our database if needed.
|
||||||
*/
|
*/
|
||||||
~DatabaseMySQL();
|
~Database();
|
||||||
bool IsConnected() { return (database != nullptr); }
|
bool IsConnected() { return (database != nullptr); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -38,7 +38,7 @@ public:
|
|||||||
LoginServer() : db(nullptr), server_manager(nullptr) { }
|
LoginServer() : db(nullptr), server_manager(nullptr) { }
|
||||||
|
|
||||||
EQ::JsonConfigFile config;
|
EQ::JsonConfigFile config;
|
||||||
DatabaseMySQL *db;
|
Database *db;
|
||||||
Options options;
|
Options options;
|
||||||
ServerManager *server_manager;
|
ServerManager *server_manager;
|
||||||
ClientManager *client_manager;
|
ClientManager *client_manager;
|
||||||
|
|||||||
@ -133,7 +133,7 @@ int main()
|
|||||||
*/
|
*/
|
||||||
Log(Logs::General, Logs::Login_Server, "MySQL Database Init.");
|
Log(Logs::General, Logs::Login_Server, "MySQL Database Init.");
|
||||||
|
|
||||||
server.db = new DatabaseMySQL(
|
server.db = new Database(
|
||||||
server.config.GetVariableString("database", "user", "root"),
|
server.config.GetVariableString("database", "user", "root"),
|
||||||
server.config.GetVariableString("database", "password", ""),
|
server.config.GetVariableString("database", "password", ""),
|
||||||
server.config.GetVariableString("database", "host", "localhost"),
|
server.config.GetVariableString("database", "host", "localhost"),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user