Core/Realms: Realmlist refactors

* Removed global realm variable from World and use RealmList everywhere
* Match auth build key with client version
* Restored allowedSecurityLevel checks for realmlist packet building
* Restored updating population field
Port From (https://github.com/TrinityCore/TrinityCore/commit/c4b710446d62c95eb8124175203fa5f394912594)
This commit is contained in:
Hondacrx
2024-09-26 12:53:15 -04:00
parent 8341244e4d
commit d70529bc19
36 changed files with 393 additions and 298 deletions
+8 -4
View File
@@ -207,7 +207,7 @@ namespace Game.Chat
{
ulong high = 0;
high |= (ulong)HighGuid.ChatChannel << 58;
high |= (ulong)Global.WorldMgr.GetRealmId().Index << 42;
high |= (ulong)Global.RealmMgr.GetCurrentRealmId().Index << 42;
high |= (ulong)(_team == Team.Alliance ? 3 : 5) << 4;
ObjectGuid channelGuid = new();
@@ -224,9 +224,13 @@ namespace Game.Chat
if (channelEntry.HasFlag(ChatChannelFlags.GlobalForTournament))
{
var category = CliDB.CfgCategoriesStorage.LookupByKey(Global.WorldMgr.GetRealm().Timezone);
if (category != null && category.HasFlag(CfgCategoriesFlags.Tournament))
zoneId = 0;
var currentRealm = Global.RealmMgr.GetCurrentRealm();
if (currentRealm != null)
{
var category = CliDB.CfgCategoriesStorage.LookupByKey(currentRealm.Timezone);
if (category != null && category.HasFlag(CfgCategoriesFlags.Tournament))
zoneId = 0;
}
}
return ObjectGuid.Create(HighGuid.ChatChannel, true, channelEntry.HasFlag(ChatChannelFlags.LinkedChannel), (ushort)zoneId, (byte)(_team == Team.Alliance ? 3 : 5), channelId);
+1 -1
View File
@@ -454,7 +454,7 @@ namespace Game.Chat
if (target != null)
target_ac_sec = target.GetSecurity();
else if (target_account != 0)
target_ac_sec = Global.AccountMgr.GetSecurity(target_account, (int)Global.WorldMgr.GetRealmId().Index);
target_ac_sec = Global.AccountMgr.GetSecurity(target_account, (int)Global.RealmMgr.GetCurrentRealmId().Index);
else
return true; // caller must report error for (target == NULL && target_account == 0)
+1 -1
View File
@@ -112,7 +112,7 @@ namespace Game.Chat
// Get the accounts with GM Level >0
PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_GM_ACCOUNTS);
stmt.AddValue(0, (byte)AccountTypes.Moderator);
stmt.AddValue(1, Global.WorldMgr.GetRealm().Id.Index);
stmt.AddValue(1, Global.RealmMgr.GetCurrentRealmId().Index);
SQLResult result = DB.Login.Query(stmt);
if (!result.IsEmpty())
+1 -1
View File
@@ -1250,7 +1250,7 @@ namespace Game.Chat
// Query the prepared statement for login data
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_PINFO);
stmt.AddValue(0, Global.WorldMgr.GetRealm().Id.Index);
stmt.AddValue(0, Global.RealmMgr.GetCurrentRealmId().Index);
stmt.AddValue(1, accId);
SQLResult result0 = DB.Login.Query(stmt);
+2 -1
View File
@@ -230,7 +230,8 @@ namespace Game.Chat.Commands
if (account.IsConnected())
return new RBACCommandData() { rbac = account.GetConnectedSession().GetRBACData(), needDelete = false };
RBACData rbac = new(account.GetID(), account.GetName(), (int)Global.WorldMgr.GetRealmId().Index, (byte)Global.AccountMgr.GetSecurity(account.GetID(), (int)Global.WorldMgr.GetRealmId().Index));
int realmId = (int)Global.RealmMgr.GetCurrentRealmId().Index;
RBACData rbac = new(account.GetID(), account.GetName(), realmId, (byte)Global.AccountMgr.GetSecurity(account.GetID(), realmId));
rbac.LoadFromDB();
return new RBACCommandData() { rbac = rbac, needDelete = true };
+4 -8
View File
@@ -26,15 +26,11 @@ namespace Game.Chat
{
string dbPortOutput;
ushort dbPort = 0;
SQLResult res = DB.Login.Query($"SELECT port FROM realmlist WHERE id = {Global.WorldMgr.GetRealmId().Index}");
if (!res.IsEmpty())
dbPort = res.Read<ushort>(0);
if (dbPort != 0)
dbPortOutput = $"Realmlist (Realm Id: {Global.WorldMgr.GetRealmId().Index}) configured in port {dbPort}";
var currentRealm = Global.RealmMgr.GetCurrentRealm();
if (currentRealm != null)
dbPortOutput = $"Realmlist (Realm Id: {currentRealm.Id.Index}) configured in port {currentRealm.Port}";
else
dbPortOutput = $"Realm Id: {Global.WorldMgr.GetRealmId().Index} not found in `realmlist` table. Please check your setup";
dbPortOutput = $"Realm Id: {Global.RealmMgr.GetCurrentRealmId().Index} not found in `realmlist` table. Please check your setup";
DatabaseTypeFlags updateFlags = ConfigMgr.GetDefaultValue("Updates.EnableDatabases", DatabaseTypeFlags.None);
if (updateFlags == 0)
+3 -3
View File
@@ -241,7 +241,7 @@ namespace Game.Chat.Commands
ObjectGuid targetGuid = Global.CharacterCacheStorage.GetCharacterGuidByName(targetName);
uint accountId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(targetGuid);
// Target must exist and have administrative rights
if (!Global.AccountMgr.HasPermission(accountId, RBACPermissions.CommandsBeAssignedTicket, Global.WorldMgr.GetRealm().Id.Index))
if (!Global.AccountMgr.HasPermission(accountId, RBACPermissions.CommandsBeAssignedTicket, Global.RealmMgr.GetCurrentRealmId().Index))
{
handler.SendSysMessage(CypherStrings.CommandTicketassignerrorA);
return true;
@@ -264,7 +264,7 @@ namespace Game.Chat.Commands
}
// Assign ticket
ticket.SetAssignedTo(targetGuid, Global.AccountMgr.IsAdminAccount(Global.AccountMgr.GetSecurity(accountId, (int)Global.WorldMgr.GetRealm().Id.Index)));
ticket.SetAssignedTo(targetGuid, Global.AccountMgr.IsAdminAccount(Global.AccountMgr.GetSecurity(accountId, (int)Global.RealmMgr.GetCurrentRealmId().Index)));
ticket.SaveToDB();
string msg = ticket.FormatViewMessageString(handler, null, targetName, null, null);
@@ -411,7 +411,7 @@ namespace Game.Chat.Commands
{
ObjectGuid guid = ticket.GetAssignedToGUID();
uint accountId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(guid);
security = Global.AccountMgr.GetSecurity(accountId, (int)Global.WorldMgr.GetRealm().Id.Index);
security = Global.AccountMgr.GetSecurity(accountId, (int)Global.RealmMgr.GetCurrentRealmId().Index);
}
// Check security