diff --git a/Source/Game/Achievements/CriteriaHandler.cs b/Source/Game/Achievements/CriteriaHandler.cs index 63bea31ef..669e940ab 100644 --- a/Source/Game/Achievements/CriteriaHandler.cs +++ b/Source/Game/Achievements/CriteriaHandler.cs @@ -1105,11 +1105,11 @@ namespace Game.Achievements if (area.AreaBit < 0) continue; - int playerIndexOffset = (int)((uint)area.AreaBit / 64); + int playerIndexOffset = (int)area.AreaBit / ActivePlayerData.ExploredZonesBits; if (playerIndexOffset >= PlayerConst.ExploredZonesSize) continue; - ulong mask = 1ul << (int)((uint)area.AreaBit % 64); + ulong mask = 1ul << (int)((uint)area.AreaBit % ActivePlayerData.ExploredZonesBits); if (Convert.ToBoolean(referencePlayer.m_activePlayerData.ExploredZones[playerIndexOffset] & mask)) { matchFound = true; @@ -1857,11 +1857,11 @@ namespace Game.Achievements if (areaTable.AreaBit <= 0) break; // success - int playerIndexOffset = areaTable.AreaBit / 64; + int playerIndexOffset = areaTable.AreaBit / ActivePlayerData.ExploredZonesBits; if (playerIndexOffset >= PlayerConst.ExploredZonesSize) break; - if ((referencePlayer.m_activePlayerData.ExploredZones[playerIndexOffset] & (1ul << (areaTable.AreaBit % 64))) == 0) + if ((referencePlayer.m_activePlayerData.ExploredZones[playerIndexOffset] & (1ul << (areaTable.AreaBit % ActivePlayerData.ExploredZonesBits))) == 0) return false; break; } diff --git a/Source/Game/Chat/Commands/MiscCommands.cs b/Source/Game/Chat/Commands/MiscCommands.cs index 118b99550..aeac8f8d0 100644 --- a/Source/Game/Chat/Commands/MiscCommands.cs +++ b/Source/Game/Chat/Commands/MiscCommands.cs @@ -765,14 +765,14 @@ namespace Game.Chat return false; } - uint offset = (uint)area.AreaBit / 64; + uint offset = (uint)(area.AreaBit / ActivePlayerData.ExploredZonesBits); if (offset >= PlayerConst.ExploredZonesSize) { handler.SendSysMessage(CypherStrings.BadValue); return false; } - uint val = (1u << (area.AreaBit % 64)); + uint val = 1u << (area.AreaBit % ActivePlayerData.ExploredZonesBits); playerTarget.RemoveExploredZones(offset, val); handler.SendSysMessage(CypherStrings.UnexploreArea); @@ -1750,14 +1750,14 @@ namespace Game.Chat return false; } - uint offset = (uint)area.AreaBit / 64; + uint offset = (uint)(area.AreaBit / ActivePlayerData.ExploredZonesBits); if (offset >= PlayerConst.ExploredZonesSize) { handler.SendSysMessage(CypherStrings.BadValue); return false; } - ulong val = 1ul << (area.AreaBit % 64); + ulong val = 1ul << (area.AreaBit % ActivePlayerData.ExploredZonesBits); playerTarget.AddExploredZones(offset, val); handler.SendSysMessage(CypherStrings.ExploreArea); diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index 40bc6f691..591cd6be2 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -2276,7 +2276,7 @@ namespace Game { AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(condition.Explored[i]); if (area != null) - if (area.AreaBit != -1 && !Convert.ToBoolean(player.m_activePlayerData.ExploredZones[area.AreaBit / 64] & (1ul << ((int)area.AreaBit % 64)))) + if (area.AreaBit != -1 && !Convert.ToBoolean(player.m_activePlayerData.ExploredZones[area.AreaBit / ActivePlayerData.ExploredZonesBits] & (1ul << ((int)area.AreaBit % ActivePlayerData.ExploredZonesBits)))) return false; } } diff --git a/Source/Game/Entities/Object/Update/UpdateFields.cs b/Source/Game/Entities/Object/Update/UpdateFields.cs index b8824c79d..ba32f4324 100644 --- a/Source/Game/Entities/Object/Update/UpdateFields.cs +++ b/Source/Game/Entities/Object/Update/UpdateFields.cs @@ -3469,6 +3469,9 @@ namespace Game.Entities public class ActivePlayerData : BaseUpdateData { + public static int ExploredZonesSize; + public static int ExploredZonesBits; + public UpdateField BackpackAutoSortDisabled = new(0, 1); public UpdateField BankAutoSortDisabled = new(0, 2); public UpdateField SortBagsRightToLeft = new(0, 3); @@ -3595,7 +3598,11 @@ namespace Game.Entities public UpdateFieldArray BankBagSlotFlags = new(7, 670, 671); public UpdateFieldArray QuestCompleted = new(875, 678, 679); - public ActivePlayerData() : base(0, TypeId.ActivePlayer, 1554) { } + public ActivePlayerData() : base(0, TypeId.ActivePlayer, 1554) + { + ExploredZonesSize = ExploredZones.GetSize(); + ExploredZonesBits = sizeof(ulong) * 8; + } public void WriteCreate(WorldPacket data, UpdateFieldFlag fieldVisibilityFlags, Player owner, Player receiver) { diff --git a/Source/Game/Entities/Player/Player.DB.cs b/Source/Game/Entities/Player/Player.DB.cs index 10bab40ed..f40a8d8ea 100644 --- a/Source/Game/Entities/Player/Player.DB.cs +++ b/Source/Game/Entities/Player/Player.DB.cs @@ -2695,9 +2695,8 @@ namespace Game.Entities SetXP(xp); StringArray exploredZonesStrings = new(exploredZones, ' '); - if (exploredZonesStrings.Length == PlayerConst.ExploredZonesSize * 2) - for (int i = 0; i < exploredZonesStrings.Length; ++i) - SetUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.ExploredZones, i / 2), (ulong)((long.Parse(exploredZonesStrings[i])) << (32 * (i % 2)))); + for (int i = 0; i < exploredZonesStrings.Length && i / 2 < ActivePlayerData.ExploredZonesSize; ++i) + SetUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.ExploredZones, i / 2), (ulong)((long.Parse(exploredZonesStrings[i])) << (32 * (i % 2)))); StringArray knownTitlesStrings = new(knownTitles, ' '); if ((knownTitlesStrings.Length % 2) == 0) diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 4c20e7d78..12ab70af0 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -5852,7 +5852,7 @@ namespace Game.Entities return; } - int offset = areaEntry.AreaBit / 64; + int offset = areaEntry.AreaBit / ActivePlayerData.ExploredZonesBits; if (offset >= PlayerConst.ExploredZonesSize) { Log.outError(LogFilter.Player, "Wrong area flag {0} in map data for (X: {1} Y: {2}) point to field PLAYER_EXPLORED_ZONES_1 + {3} ( {4} must be < {5} ).", @@ -5860,7 +5860,7 @@ namespace Game.Entities return; } - ulong val = 1ul << (areaEntry.AreaBit % 64); + ulong val = 1ul << (areaEntry.AreaBit % ActivePlayerData.ExploredZonesBits); ulong currFields = m_activePlayerData.ExploredZones[offset]; if (!Convert.ToBoolean(currFields & val)) diff --git a/Source/Game/Handlers/CharacterHandler.cs b/Source/Game/Handlers/CharacterHandler.cs index 2f75a6b9e..92c582f2f 100644 --- a/Source/Game/Handlers/CharacterHandler.cs +++ b/Source/Game/Handlers/CharacterHandler.cs @@ -945,8 +945,8 @@ namespace Game // start with every map explored if (WorldConfig.GetBoolValue(WorldCfg.StartAllExplored)) { - for (ushort i = 0; i < PlayerConst.ExploredZonesSize; i++) - pCurrChar.SetUpdateFieldValue(ref pCurrChar.m_values.ModifyValue(pCurrChar.m_activePlayerData).ModifyValue(pCurrChar.m_activePlayerData.ExploredZones, i), 0xFFFFFFFFFFFFFFFF); + for (uint i = 0; i < PlayerConst.ExploredZonesSize; i++) + pCurrChar.AddExploredZones(i, 0xFFFFFFFFFFFFFFFF); } //Reputations if "StartAllReputation" is enabled