Core/DataStores: Don't send hotfix ids in SMSG_AVAILABLE_HOTFIXES that don't have a hotfix blob for client locale
Port From (https://github.com/TrinityCore/TrinityCore/commit/973b5f404f5b7115239a81030ad2f8dff8e165ea)
This commit is contained in:
@@ -637,7 +637,7 @@ namespace Game.DataStorage
|
|||||||
return _storage.LookupByKey(type);
|
return _storage.LookupByKey(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadHotfixData()
|
public void LoadHotfixData(BitSet availableDb2Locales)
|
||||||
{
|
{
|
||||||
uint oldMSTime = Time.GetMSTime();
|
uint oldMSTime = Time.GetMSTime();
|
||||||
|
|
||||||
@@ -660,7 +660,17 @@ namespace Game.DataStorage
|
|||||||
HotfixRecord.Status status = (HotfixRecord.Status)result.Read<byte>(4);
|
HotfixRecord.Status status = (HotfixRecord.Status)result.Read<byte>(4);
|
||||||
if (status == HotfixRecord.Status.Valid && !_storage.ContainsKey(tableHash))
|
if (status == HotfixRecord.Status.Valid && !_storage.ContainsKey(tableHash))
|
||||||
{
|
{
|
||||||
if (!_hotfixBlob.Any(p => p.ContainsKey((tableHash, recordId))))
|
var key = (tableHash, recordId);
|
||||||
|
for (int locale = 0; locale < (int)Locale.Total; ++locale)
|
||||||
|
{
|
||||||
|
if (!availableDb2Locales[locale])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!_hotfixBlob[locale].ContainsKey(key))
|
||||||
|
availableDb2Locales[locale] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!availableDb2Locales.Any())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `hotfix_data` references unknown DB2 store by hash 0x{tableHash:X} and has no reference to `hotfix_blob` in hotfix id {id} with RecordID: {recordId}");
|
Log.outError(LogFilter.Sql, $"Table `hotfix_data` references unknown DB2 store by hash 0x{tableHash:X} and has no reference to `hotfix_blob` in hotfix id {id} with RecordID: {recordId}");
|
||||||
continue;
|
continue;
|
||||||
@@ -673,7 +683,13 @@ namespace Game.DataStorage
|
|||||||
hotfixRecord.ID.PushID = id;
|
hotfixRecord.ID.PushID = id;
|
||||||
hotfixRecord.ID.UniqueID = uniqueId;
|
hotfixRecord.ID.UniqueID = uniqueId;
|
||||||
hotfixRecord.HotfixStatus = status;
|
hotfixRecord.HotfixStatus = status;
|
||||||
_hotfixData.Add(id, hotfixRecord);
|
hotfixRecord.AvailableLocalesMask = availableDb2Locales.ToBlockRange()[0];//Ulgy i know
|
||||||
|
|
||||||
|
HotfixPush push = _hotfixData[id];
|
||||||
|
push.Records.Add(hotfixRecord);
|
||||||
|
push.AvailableLocalesMask |= hotfixRecord.AvailableLocalesMask;
|
||||||
|
|
||||||
|
_hotfixData.Add(id, push);
|
||||||
deletedRecords[(tableHash, recordId)] = status == HotfixRecord.Status.RecordRemoved;
|
deletedRecords[(tableHash, recordId)] = status == HotfixRecord.Status.RecordRemoved;
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
@@ -812,7 +828,7 @@ namespace Game.DataStorage
|
|||||||
|
|
||||||
public uint GetHotfixCount() { return (uint)_hotfixData.Count; }
|
public uint GetHotfixCount() { return (uint)_hotfixData.Count; }
|
||||||
|
|
||||||
public MultiMap<int, HotfixRecord> GetHotfixData() { return _hotfixData; }
|
public Dictionary<int, HotfixPush> GetHotfixData() { return _hotfixData; }
|
||||||
|
|
||||||
public byte[] GetHotfixBlobData(uint tableHash, int recordId, Locale locale)
|
public byte[] GetHotfixBlobData(uint tableHash, int recordId, Locale locale)
|
||||||
{
|
{
|
||||||
@@ -2219,7 +2235,7 @@ namespace Game.DataStorage
|
|||||||
delegate bool AllowedHotfixOptionalData(byte[] data);
|
delegate bool AllowedHotfixOptionalData(byte[] data);
|
||||||
|
|
||||||
Dictionary<uint, IDB2Storage> _storage = new();
|
Dictionary<uint, IDB2Storage> _storage = new();
|
||||||
MultiMap<int, HotfixRecord> _hotfixData = new();
|
Dictionary<int, HotfixPush> _hotfixData = new();
|
||||||
Dictionary<(uint tableHash, int recordId), byte[]>[] _hotfixBlob = new Dictionary<(uint tableHash, int recordId), byte[]>[(int)Locale.Total];
|
Dictionary<(uint tableHash, int recordId), byte[]>[] _hotfixBlob = new Dictionary<(uint tableHash, int recordId), byte[]>[(int)Locale.Total];
|
||||||
MultiMap<uint, Tuple<uint, AllowedHotfixOptionalData>> _allowedHotfixOptionalData = new();
|
MultiMap<uint, Tuple<uint, AllowedHotfixOptionalData>> _allowedHotfixOptionalData = new();
|
||||||
MultiMap<(uint tableHash, int recordId), HotfixOptionalData>[] _hotfixOptionalData = new MultiMap<(uint tableHash, int recordId), HotfixOptionalData>[(int)Locale.Total];
|
MultiMap<(uint tableHash, int recordId), HotfixOptionalData>[] _hotfixOptionalData = new MultiMap<(uint tableHash, int recordId), HotfixOptionalData>[(int)Locale.Total];
|
||||||
@@ -2467,6 +2483,7 @@ namespace Game.DataStorage
|
|||||||
public int RecordID;
|
public int RecordID;
|
||||||
public HotfixId ID;
|
public HotfixId ID;
|
||||||
public Status HotfixStatus = Status.Invalid;
|
public Status HotfixStatus = Status.Invalid;
|
||||||
|
public uint AvailableLocalesMask;
|
||||||
|
|
||||||
public void Write(WorldPacket data)
|
public void Write(WorldPacket data)
|
||||||
{
|
{
|
||||||
@@ -2516,6 +2533,12 @@ namespace Game.DataStorage
|
|||||||
public byte[] Data;
|
public byte[] Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class HotfixPush
|
||||||
|
{
|
||||||
|
public List<HotfixRecord> Records = new();
|
||||||
|
public uint AvailableLocalesMask;
|
||||||
|
}
|
||||||
|
|
||||||
class ChrClassesXPowerTypesRecordComparer : IComparer<ChrClassesXPowerTypesRecord>
|
class ChrClassesXPowerTypesRecordComparer : IComparer<ChrClassesXPowerTypesRecord>
|
||||||
{
|
{
|
||||||
public int Compare(ChrClassesXPowerTypesRecord left, ChrClassesXPowerTypesRecord right)
|
public int Compare(ChrClassesXPowerTypesRecord left, ChrClassesXPowerTypesRecord right)
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ using Framework.Constants;
|
|||||||
using Game.DataStorage;
|
using Game.DataStorage;
|
||||||
using Game.Networking;
|
using Game.Networking;
|
||||||
using Game.Networking.Packets;
|
using Game.Networking.Packets;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Game
|
namespace Game
|
||||||
{
|
{
|
||||||
@@ -46,7 +48,18 @@ namespace Game
|
|||||||
|
|
||||||
void SendAvailableHotfixes()
|
void SendAvailableHotfixes()
|
||||||
{
|
{
|
||||||
SendPacket(new AvailableHotfixes(Global.WorldMgr.GetRealmId().GetAddress(), Global.DB2Mgr.GetHotfixData()));
|
AvailableHotfixes availableHotfixes = new();
|
||||||
|
availableHotfixes.VirtualRealmAddress = Global.WorldMgr.GetRealmId().GetAddress();
|
||||||
|
|
||||||
|
foreach (var (_, push) in Global.DB2Mgr.GetHotfixData())
|
||||||
|
{
|
||||||
|
if ((push.AvailableLocalesMask & (1 << (int)GetSessionDbcLocale())) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
availableHotfixes.Hotfixes.Add(push.Records.First().ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
SendPacket(availableHotfixes);
|
||||||
}
|
}
|
||||||
|
|
||||||
[WorldPacketHandler(ClientOpcodes.HotfixRequest, Status = SessionStatus.Authed)]
|
[WorldPacketHandler(ClientOpcodes.HotfixRequest, Status = SessionStatus.Authed)]
|
||||||
@@ -60,8 +73,11 @@ namespace Game
|
|||||||
var hotfixRecords = hotfixes.LookupByKey(hotfixId);
|
var hotfixRecords = hotfixes.LookupByKey(hotfixId);
|
||||||
if (hotfixRecords != null)
|
if (hotfixRecords != null)
|
||||||
{
|
{
|
||||||
foreach (var hotfixRecord in hotfixRecords)
|
foreach (var hotfixRecord in hotfixRecords.Records)
|
||||||
{
|
{
|
||||||
|
if ((hotfixRecord.AvailableLocalesMask & (1 << (int)GetSessionDbcLocale())) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
HotfixConnect.HotfixData hotfixData = new();
|
HotfixConnect.HotfixData hotfixData = new();
|
||||||
hotfixData.Record = hotfixRecord;
|
hotfixData.Record = hotfixRecord;
|
||||||
if (hotfixRecord.HotfixStatus == HotfixRecord.Status.Valid)
|
if (hotfixRecord.HotfixStatus == HotfixRecord.Status.Valid)
|
||||||
|
|||||||
@@ -61,23 +61,19 @@ namespace Game.Networking.Packets
|
|||||||
|
|
||||||
class AvailableHotfixes : ServerPacket
|
class AvailableHotfixes : ServerPacket
|
||||||
{
|
{
|
||||||
public AvailableHotfixes(uint virtualRealmAddress, MultiMap<int, HotfixRecord> hotfixes) : base(ServerOpcodes.AvailableHotfixes)
|
public AvailableHotfixes() : base(ServerOpcodes.AvailableHotfixes) { }
|
||||||
{
|
|
||||||
VirtualRealmAddress = virtualRealmAddress;
|
|
||||||
Hotfixes = hotfixes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write()
|
public override void Write()
|
||||||
{
|
{
|
||||||
_worldPacket.WriteUInt32(VirtualRealmAddress);
|
_worldPacket.WriteUInt32(VirtualRealmAddress);
|
||||||
_worldPacket.WriteInt32(Hotfixes.Keys.Count);
|
_worldPacket.WriteInt32(Hotfixes.Count);
|
||||||
|
|
||||||
foreach (var key in Hotfixes.Keys)
|
foreach (var hotfixId in Hotfixes)
|
||||||
Hotfixes[key][0].ID.Write(_worldPacket);
|
hotfixId.Write(_worldPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint VirtualRealmAddress;
|
public uint VirtualRealmAddress;
|
||||||
public MultiMap<int, HotfixRecord> Hotfixes;
|
public List<HotfixId> Hotfixes = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
class HotfixRequest : ClientPacket
|
class HotfixRequest : ClientPacket
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ namespace Game
|
|||||||
Global.DB2Mgr.LoadHotfixBlob(m_availableDbcLocaleMask);
|
Global.DB2Mgr.LoadHotfixBlob(m_availableDbcLocaleMask);
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading hotfix info...");
|
Log.outInfo(LogFilter.ServerLoading, "Loading hotfix info...");
|
||||||
Global.DB2Mgr.LoadHotfixData();
|
Global.DB2Mgr.LoadHotfixData(m_availableDbcLocaleMask);
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading hotfix optional data...");
|
Log.outInfo(LogFilter.ServerLoading, "Loading hotfix optional data...");
|
||||||
Global.DB2Mgr.LoadHotfixOptionalData(m_availableDbcLocaleMask);
|
Global.DB2Mgr.LoadHotfixOptionalData(m_availableDbcLocaleMask);
|
||||||
|
|||||||
Reference in New Issue
Block a user