diff --git a/ArcheAge/ArcheAge/Holders/AccountHolder.cs b/ArcheAge/ArcheAge/Holders/AccountHolder.cs index 83593042..92b89dab 100644 --- a/ArcheAge/ArcheAge/Holders/AccountHolder.cs +++ b/ArcheAge/ArcheAge/Holders/AccountHolder.cs @@ -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 { diff --git a/ArcheAge/ArcheAge/Holders/CharacterHolder.cs b/ArcheAge/ArcheAge/Holders/CharacterHolder.cs index d7ea133a..371fcafc 100644 --- a/ArcheAge/ArcheAge/Holders/CharacterHolder.cs +++ b/ArcheAge/ArcheAge/Holders/CharacterHolder.cs @@ -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 { diff --git a/ArcheAgeLogin/ArcheAge/Database/LoginDb.cs b/ArcheAgeLogin/ArcheAge/Database/LoginDb.cs index 4d92432a..25215718 100644 --- a/ArcheAgeLogin/ArcheAge/Database/LoginDb.cs +++ b/ArcheAgeLogin/ArcheAge/Database/LoginDb.cs @@ -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(); } diff --git a/ArcheAgeLogin/ArcheAge/Holders/AccountHolder.cs b/ArcheAgeLogin/ArcheAge/Holders/AccountHolder.cs index ab3b7b67..8adcc8cc 100644 --- a/ArcheAgeLogin/ArcheAge/Holders/AccountHolder.cs +++ b/ArcheAgeLogin/ArcheAge/Holders/AccountHolder.cs @@ -48,9 +48,10 @@ 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"); @@ -58,8 +59,7 @@ public static uint MaxAccountUid() { uid = account.AccountId; } - } - + } while (reader.Read()); command.Dispose(); reader.Close(); } diff --git a/ArcheAgeLogin/ArcheAge/Holders/CharacterHolder.cs b/ArcheAgeLogin/ArcheAge/Holders/CharacterHolder.cs index e26da606..2b79c82b 100644 --- a/ArcheAgeLogin/ArcheAge/Holders/CharacterHolder.cs +++ b/ArcheAgeLogin/ArcheAge/Holders/CharacterHolder.cs @@ -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 {