Cleanup from db31558
This commit is contained in:
@@ -85,12 +85,6 @@ WrongPass.BanType = 0
|
|||||||
# LoginDatabaseInfo
|
# LoginDatabaseInfo
|
||||||
# Description: Database connection settings for the realm server.
|
# Description: Database connection settings for the realm server.
|
||||||
# Example: "hostname;port;username;password;database"
|
# Example: "hostname;port;username;password;database"
|
||||||
# ".;somenumber;username;password;database" - (Use named pipes on Windows
|
|
||||||
# "enable-named-pipe" to [mysqld]
|
|
||||||
# section my.ini)
|
|
||||||
# ".;/path/to/unix_socket;username;password;database" - (use Unix sockets on
|
|
||||||
# Unix/Linux)
|
|
||||||
# Default: "127.0.0.1;3306;username;password;auth"
|
|
||||||
|
|
||||||
LoginDatabaseInfo.Host = "127.0.0.1"
|
LoginDatabaseInfo.Host = "127.0.0.1"
|
||||||
LoginDatabaseInfo.Port = "3306"
|
LoginDatabaseInfo.Port = "3306"
|
||||||
|
|||||||
@@ -35,16 +35,16 @@ namespace Framework.Database
|
|||||||
bool updatesEnabled = database.IsAutoUpdateEnabled(_updateFlags);
|
bool updatesEnabled = database.IsAutoUpdateEnabled(_updateFlags);
|
||||||
_open.Add(() =>
|
_open.Add(() =>
|
||||||
{
|
{
|
||||||
ConnectionObject co = new ConnectionObject
|
ConnectionObject connectionObject = new ConnectionObject
|
||||||
{
|
{
|
||||||
Database = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Database", ""),
|
Database = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Database", ""),
|
||||||
Host = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Host", ""),
|
Host = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Host", ""),
|
||||||
Password = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Password", ""),
|
Password = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Password", ""),
|
||||||
Port = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Port", ""),
|
Port = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Port", ""),
|
||||||
Username = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Username", "")
|
Username = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Username", "")
|
||||||
};
|
};
|
||||||
|
|
||||||
var error = database.Initialize(co);
|
var error = database.Initialize(connectionObject);
|
||||||
if (error != MySqlErrorCode.None)
|
if (error != MySqlErrorCode.None)
|
||||||
{
|
{
|
||||||
// Database does not exist
|
// Database does not exist
|
||||||
@@ -59,7 +59,7 @@ namespace Framework.Database
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Creating database \"{0}\"...", name);
|
Log.outInfo(LogFilter.ServerLoading, "Creating database \"{0}\"...", name);
|
||||||
string sqlString = string.Format("CREATE DATABASE `{0}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", name);
|
string sqlString = string.Format("CREATE DATABASE `{0}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", name);
|
||||||
// Try to create the database and connect again if auto setup is enabled
|
// Try to create the database and connect again if auto setup is enabled
|
||||||
if (database.Apply(sqlString) && database.Initialize(co) == MySqlErrorCode.None)
|
if (database.Apply(sqlString) && database.Initialize(connectionObject) == MySqlErrorCode.None)
|
||||||
error = MySqlErrorCode.None;
|
error = MySqlErrorCode.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,17 +28,6 @@ namespace Framework.Database
|
|||||||
{
|
{
|
||||||
public class MySqlConnectionInfo
|
public class MySqlConnectionInfo
|
||||||
{
|
{
|
||||||
public MySqlConnectionInfo(string info, int poolSize = 10)
|
|
||||||
{
|
|
||||||
var lines = new StringArray(info, ';');
|
|
||||||
Host = lines[0];
|
|
||||||
Port = lines[1];
|
|
||||||
Username = lines[2];
|
|
||||||
Password = lines[3];
|
|
||||||
Database = lines[4];
|
|
||||||
Poolsize = poolSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MySqlConnectionInfo(ConnectionObject connectionObject, int poolSize = 10)
|
public MySqlConnectionInfo(ConnectionObject connectionObject, int poolSize = 10)
|
||||||
{
|
{
|
||||||
Host = connectionObject.Host;
|
Host = connectionObject.Host;
|
||||||
@@ -71,26 +60,6 @@ namespace Framework.Database
|
|||||||
|
|
||||||
public abstract class MySqlBase<T>
|
public abstract class MySqlBase<T>
|
||||||
{
|
{
|
||||||
public MySqlErrorCode Initialize(string infoString)
|
|
||||||
{
|
|
||||||
_connectionInfo = new MySqlConnectionInfo(infoString);
|
|
||||||
_updater = new DatabaseUpdater<T>(this);
|
|
||||||
|
|
||||||
using (var connection = _connectionInfo.GetConnection())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
Log.outInfo(LogFilter.SqlDriver, "Connected to MySQL(ver: {0}) Database: {1}", connection.ServerVersion, _connectionInfo.Database);
|
|
||||||
return MySqlErrorCode.None;
|
|
||||||
}
|
|
||||||
catch (MySqlException ex)
|
|
||||||
{
|
|
||||||
return (MySqlErrorCode)((MySqlException)ex.InnerException).Number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MySqlErrorCode Initialize(ConnectionObject connectionObject)
|
public MySqlErrorCode Initialize(ConnectionObject connectionObject)
|
||||||
{
|
{
|
||||||
_connectionInfo = new MySqlConnectionInfo(connectionObject);
|
_connectionInfo = new MySqlConnectionInfo(connectionObject);
|
||||||
|
|||||||
@@ -35,12 +35,6 @@ LogsDir = "./Logs"
|
|||||||
# WorldDatabaseInfo
|
# WorldDatabaseInfo
|
||||||
# CharacterDatabaseInfo
|
# CharacterDatabaseInfo
|
||||||
# Description: Database connection settings for the world server.
|
# Description: Database connection settings for the world server.
|
||||||
# Example: "hostname;port;username;password;database"
|
|
||||||
|
|
||||||
# Default: "127.0.0.1;3306;username;password;auth" - (LoginDatabaseInfo)
|
|
||||||
# "127.0.0.1;3306;username;password;world" - (WorldDatabaseInfo)
|
|
||||||
# "127.0.0.1;3306;username;password;characters" - (CharacterDatabaseInfo)
|
|
||||||
# "127.0.0.1;3306;username;password;hotfixes" - (HotfixDatabaseInfo)
|
|
||||||
|
|
||||||
LoginDatabaseInfo.Host = "127.0.0.1"
|
LoginDatabaseInfo.Host = "127.0.0.1"
|
||||||
LoginDatabaseInfo.Port = "3306"
|
LoginDatabaseInfo.Port = "3306"
|
||||||
|
|||||||
Reference in New Issue
Block a user