Skip to content

Commit

Permalink
Update: MaxCharacterUid, MaxAccountUid
Browse files Browse the repository at this point in the history
  • Loading branch information
NL0bP committed Nov 18, 2018
1 parent 50296ba commit 21d61ff
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
17 changes: 14 additions & 3 deletions ArcheAge/ArcheAge/Holders/AccountHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@ public static uint MaxAccountUid()
try
{
conn.Open();
var command = new MySqlCommand("SELECT max( accountid ) FROM `accounts`", conn);
uid = (uint)command.ExecuteScalar();
var command = new MySqlCommand("SELECT `accountid` FROM `accounts`", conn);
var reader = command.ExecuteReader();
if (!reader.Read()) { return uid; }
do
{
var account = new Account();
account.AccountId = reader.GetUInt32("accountid");
if (uid < account.AccountId)
{
uid = account.AccountId;
}
} while (reader.Read());
command.Dispose();
reader.Close();
}
catch (Exception ex)
{
Logger.Trace("Error: characters {0}", ex.Message);
Logger.Trace("Error: {0}", ex.Message);
}
finally
{
Expand Down
17 changes: 14 additions & 3 deletions ArcheAge/ArcheAge/Holders/CharacterHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,24 @@ public static uint MaxCharacterUid()
try
{
conn.Open();
var command = new MySqlCommand("SELECT max( characterid ) FROM `character_records`", conn);
uid = (uint)command.ExecuteScalar();
var command = new MySqlCommand("SELECT `characterid` FROM `character_records`", conn);
var reader = command.ExecuteReader();
if (!reader.Read()) { return uid; }
do
{
var character = new Character();
character.CharacterId = reader.GetUInt32("characterid");
if (uid < character.CharacterId)
{
uid = character.CharacterId;
}
} while (reader.Read());
command.Dispose();
reader.Close();
}
catch (Exception ex)
{
Logger.Trace("Error: characters {0}", ex.Message);
Logger.Trace("Error: {0}", ex.Message);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion ArcheAgeLogin/ArcheAge/Database/LoginDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void RunUpdate(string updateFile)
// Run update
using (var cmd = new MySqlCommand(File.ReadAllText(Path.Combine("sql", updateFile)), conn))
{
Logger.Trace("We are waiting for a long download of large SQL files!\nIt is necessary to wait for loading of SQL and only then to start GameServer!\n Additional: Set parameter max_allowed_packet=16M in c:\\ProgramData\\MySQL\\MySQL Server 8.0\\my.ini");
Logger.Trace("We are waiting for a long download of large SQL files!\nIt is necessary to wait for loading of SQL and only then to start GameServer!\nAdditional: Set parameter max_allowed_packet=16M in c:\\ProgramData\\MySQL\\MySQL Server 8.0\\my.ini");
cmd.CommandTimeout = 3600; //ждем долгой загрузки больших SQL файлов. Обычно, это значение 30 секунд.
cmd.ExecuteNonQuery();
}
Expand Down
8 changes: 4 additions & 4 deletions ArcheAgeLogin/ArcheAge/Holders/AccountHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ public static uint MaxAccountUid()
try
{
conn.Open();
var command = new MySqlCommand("SELECT * FROM `accounts`", conn);
var command = new MySqlCommand("SELECT `accountid` FROM `accounts`", conn);
var reader = command.ExecuteReader();
while (reader.Read())
if (!reader.Read()) { return uid; }
do
{
var account = new Account();
account.AccountId = reader.GetUInt32("accountid");
if (uid < account.AccountId)
{
uid = account.AccountId;
}
}

} while (reader.Read());
command.Dispose();
reader.Close();
}
Expand Down
17 changes: 14 additions & 3 deletions ArcheAgeLogin/ArcheAge/Holders/CharacterHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,24 @@ public static uint MaxCharacterUid()
try
{
conn.Open();
var command = new MySqlCommand("SELECT max( characterid ) FROM `character_records`", conn);
uid = (uint)command.ExecuteScalar();
var command = new MySqlCommand("SELECT `characterid` FROM `character_records`", conn);
var reader = command.ExecuteReader();
if (!reader.Read()) { return uid; }
do
{
var character = new Character();
character.CharacterId = reader.GetUInt32("characterid");
if (uid < character.CharacterId)
{
uid = character.CharacterId;
}
} while (reader.Read());
command.Dispose();
reader.Close();
}
catch (Exception ex)
{
Logger.Trace("Error: characters {0}", ex.Message);
Logger.Trace("Error: {0}", ex.Message);
}
finally
{
Expand Down

0 comments on commit 21d61ff

Please sign in to comment.