Skip to content

Commit bee3910

Browse files
committed
Improvements
+ Fixed Enter on Hotel + Fixed some Castings + Fixed Creating Rooms + Fixed PathFinder FindPath + Fixed Buy Item + Cleaned some Code + Improved Database things + Continued Database improvement + Continued Core Refactoring
1 parent 7777464 commit bee3910

41 files changed

Lines changed: 6110 additions & 5892 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

SQL/Database.sql

Lines changed: 5205 additions & 5143 deletions
Large diffs are not rendered by default.

Yupi/Build/Variables/Cache/FurniDataCache.xml

Lines changed: 427 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
welcome.message.enabled=true
1+
welcome.message.enabled=false
22
welcome.message.title=Notification
33
welcome.message.image=builders_club_membership_extended

Yupi/Build/Variables/Settings/main.ini

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
## Azure Emulator System Configuration File
2-
## Must be edited for the server to work
1+
## Yupi Server Settings
32

43
## MySQL Configuration
5-
db.hostname=172.16.9.69
4+
db.hostname=172.16.9.84
65
db.port=3306
76
db.username=azure
87
db.password=123
98
db.name=teste
10-
db.type=MySQL
119

1210
## MySQL pooling setup (controls amount of connections)
1311
db.pool.minsize=1
@@ -19,15 +17,10 @@ game.tcp.port=30000
1917
game.tcp.conlimit=11000
2018
game.tcp.enablenagles=true
2119

22-
##Tcp Flood AntiDDoS Comment: For proxy antiddos=false
20+
## Tcp Flood AntiDDoS Comment: For proxy antiddos=false
2321
game.tcp.antiddos=false
2422
game.tcp.conperip=30
2523

26-
## MUS TCP/IP Configuration
27-
mus.tcp.bindip=127.0.0.1
28-
mus.tcp.port=30008
29-
mus.tcp.allowedaddr=127.0.0.1
30-
3124
## Client configuration
3225
client.ping.enabled=1
3326
client.ping.interval=20000

Yupi/Build/Variables/Settings/other.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,5 @@ stories.api.thumbnail.url=http://azure-stories-content.azurewebsites.net/servert
3232
# Interactive stuff #
3333
everyone.use.floor=true
3434
admin.can.useHTML=true
35-
commands.new.page=true
36-
figuredata.url=http://localhost/gamedata/figuredata/1.xml
3735
furnidata.url=http://www.maniahotel.com.br/source/gamedata/furnidata_xml/furnidata_xml.xml
3836
youtube.thumbnail.suburl=youtubethumbnail.php?Video

Yupi/Core/Settings/ConsoleCommandHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ internal static void InvokeCommand(string inputData)
167167
switch (strArray[1])
168168
{
169169
case "database":
170-
Yupi.GetDatabaseManager().Destroy();
171170
Console.WriteLine("Database destroyed");
172171
Console.WriteLine();
173172
break;

Yupi/Data/Base/Connections/ConnectionManager.cs

Lines changed: 28 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,109 +14,75 @@ namespace Yupi.Data.Base.Connections
1414
{
1515
public class ConnectionManager
1616
{
17-
public static string DatabaseConnectionType = "MySQL";
1817
public static bool DbEnabled = true;
18+
1919
private readonly uint _beginClientAmount;
2020
private readonly uint _maxPoolSize;
21+
2122
private readonly Queue _connections;
23+
2224
private string _connectionString;
25+
2326
private List<MySqlClient> _databaseClients;
24-
private bool _isConnected;
27+
2528
private DatabaseServer _server;
2629

2730
public ConnectionManager(uint maxPoolSize, uint clientAmount)
2831
{
2932
if (maxPoolSize < clientAmount)
3033
throw new DatabaseException("The poolsize can not be larger than the client amount!");
34+
3135
_beginClientAmount = clientAmount;
3236
_maxPoolSize = maxPoolSize;
37+
3338
_connections = new Queue();
3439
}
3540

3641
public void Destroy()
3742
{
38-
var flag = false;
39-
try
40-
{
41-
Monitor.Enter(this, ref flag);
42-
_isConnected = false;
43-
if (_databaseClients == null)
44-
return;
45-
foreach (var current in _databaseClients)
46-
{
47-
if (!current.IsAvailable())
48-
current.Dispose();
49-
current.Disconnect();
50-
}
51-
_databaseClients.Clear();
52-
}
53-
finally
43+
if (_databaseClients == null)
44+
return;
45+
46+
foreach (MySqlClient current in _databaseClients)
5447
{
55-
if (flag)
56-
Monitor.Exit(this);
48+
if (!current.IsAvailable())
49+
current.Dispose();
50+
51+
current.Disconnect();
5752
}
58-
}
5953

60-
public string GetConnectionString()
61-
{
62-
return _connectionString;
54+
_databaseClients.Clear();
6355
}
6456

57+
public string GetConnectionString() => _connectionString;
58+
6559
public IQueryAdapter GetQueryReactor()
6660
{
6761
IDatabaseClient databaseClient = new MySqlClient(this);
62+
6863
databaseClient.Connect();
69-
databaseClient.Prepare();
64+
7065
return databaseClient.GetQueryReactor();
7166
}
7267

7368
public void FreeConnection(IDatabaseClient dbClient)
7469
{
7570
lock (_connections.SyncRoot)
76-
{
7771
_connections.Enqueue(dbClient);
78-
}
7972
}
8073

8174
public void Init()
8275
{
83-
try
84-
{
85-
CreateNewConnectionString();
86-
_databaseClients = new List<MySqlClient>((int)_maxPoolSize);
87-
}
88-
catch (MySqlException ex)
89-
{
90-
_isConnected = false;
91-
throw new Exception($"Could not connect the clients to the database: {ex.Message}");
92-
}
93-
_isConnected = true;
94-
}
76+
CreateNewConnectionString();
9577

96-
public bool IsConnectedToDatabase()
97-
{
98-
return _isConnected;
78+
_databaseClients = new List<MySqlClient>((int)_maxPoolSize);
9979
}
10080

101-
public bool SetServerDetails(string host, uint port, string username, string password, string databaseName)
102-
{
103-
bool result;
104-
try
105-
{
106-
_server = new DatabaseServer(host, port, username, password, databaseName);
107-
result = true;
108-
}
109-
catch (DatabaseException)
110-
{
111-
_isConnected = false;
112-
result = false;
113-
}
114-
return result;
115-
}
81+
public void SetServerDetails(string host, uint port, string username, string password, string databaseName) => _server = new DatabaseServer(host, port, username, password, databaseName);
11682

11783
private void CreateNewConnectionString()
11884
{
119-
var mySqlConnectionStringBuilder = new MySqlConnectionStringBuilder
85+
MySqlConnectionStringBuilder mySqlConnectionStringBuilder = new MySqlConnectionStringBuilder
12086
{
12187
Server = _server.GetHost(),
12288
Port = _server.GetPort(),
@@ -131,13 +97,12 @@ private void CreateNewConnectionString()
13197
DefaultCommandTimeout = 300,
13298
ConnectionTimeout = 10
13399
};
134-
var mySqlConnectionStringBuilder2 = mySqlConnectionStringBuilder;
100+
101+
MySqlConnectionStringBuilder mySqlConnectionStringBuilder2 = mySqlConnectionStringBuilder;
102+
135103
SetConnectionString(mySqlConnectionStringBuilder2.ToString());
136104
}
137105

138-
private void SetConnectionString(string connectionString)
139-
{
140-
_connectionString = connectionString;
141-
}
106+
private void SetConnectionString(string connectionString) => _connectionString = connectionString;
142107
}
143108
}

Yupi/Data/Base/Connections/DatabaseConnection.cs

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,80 +33,43 @@ public class DatabaseConnection : IDatabaseClient
3333
{
3434
private readonly MySqlConnection _mysqlConnection;
3535
private readonly IQueryAdapter _adapter;
36-
private readonly int _type;
3736

38-
public DatabaseConnection(string connectionStr, string connType)
37+
public DatabaseConnection(string connectionStr)
3938
{
40-
switch (connType.ToLower())
41-
{
42-
default: // MySQL
43-
_mysqlConnection = new MySqlConnection(connectionStr);
44-
_adapter = new NormalQueryReactor(this);
45-
_type = 1;
46-
break;
47-
}
39+
_mysqlConnection = new MySqlConnection(connectionStr);
40+
_adapter = new NormalQueryReactor(this);
4841
}
4942

5043
public void Open()
5144
{
52-
if (_type == 1 && _mysqlConnection.State == ConnectionState.Closed)
45+
if (_mysqlConnection.State == ConnectionState.Closed)
5346
_mysqlConnection.Open();
5447
}
5548

5649
public void Close()
5750
{
58-
if (_type == 1 && _mysqlConnection.State == ConnectionState.Open)
51+
if (_mysqlConnection.State == ConnectionState.Open)
5952
_mysqlConnection.Close();
6053
}
6154

6255
public void Dispose()
6356
{
64-
switch (_type)
65-
{
66-
case 1:
67-
if (_mysqlConnection.State == ConnectionState.Open)
68-
_mysqlConnection.Close();
69-
break;
70-
}
57+
if (_mysqlConnection.State == ConnectionState.Open)
58+
_mysqlConnection.Close();
7159
}
7260

73-
public void Connect()
74-
{
75-
Open();
76-
}
61+
public void Connect() => Open();
7762

78-
public void Disconnect()
79-
{
80-
Close();
81-
}
63+
public void Disconnect() => Close();
8264

83-
public IQueryAdapter GetQueryReactor()
84-
{
85-
return _adapter;
86-
}
87-
88-
public bool IsAvailable()
89-
{
90-
return false;
91-
}
65+
public IQueryAdapter GetQueryReactor() => _adapter;
9266

93-
public void Prepare()
94-
{
95-
}
67+
public bool IsAvailable() => _mysqlConnection.State == ConnectionState.Open;
9668

97-
public void ReportDone()
98-
{
99-
Dispose();
100-
}
69+
public void ReportDone() => Dispose();
10170

102-
public MySqlCommand CreateNewCommandMySql()
103-
{
104-
return _mysqlConnection.CreateCommand();
105-
}
71+
public MySqlCommand CreateNewCommandMySql() => _mysqlConnection.CreateCommand();
10672

107-
public MySqlTransaction GetTransactionMySql()
108-
{
109-
return _mysqlConnection.BeginTransaction();
110-
}
73+
public MySqlTransaction GetTransactionMySql() => _mysqlConnection.BeginTransaction();
11174
}
11275
}

Yupi/Data/Base/DatabaseManager.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,22 @@ Corporation Oy. Yupi! has nothing linked with Sulake.
2727

2828
namespace Yupi.Data.Base
2929
{
30-
public sealed class DatabaseManager
30+
public class DatabaseManager
3131
{
3232
private readonly string _connectionStr;
33-
private readonly string _typer;
3433

35-
public DatabaseManager(string connectionStr, string connType)
34+
public DatabaseManager(string connectionStr)
3635
{
3736
_connectionStr = connectionStr;
38-
_typer = connType;
3937
}
4038

4139
public IQueryAdapter GetQueryReactor()
4240
{
43-
IDatabaseClient databaseClient = new DatabaseConnection(_connectionStr, _typer);
41+
IDatabaseClient databaseClient = new DatabaseConnection(_connectionStr);
4442

4543
databaseClient.Connect();
46-
databaseClient.Prepare();
4744

4845
return databaseClient.GetQueryReactor();
4946
}
50-
51-
public void Destroy()
52-
{
53-
// Nothing Implemented
54-
}
5547
}
5648
}

0 commit comments

Comments
 (0)