Core/PacketIO: Fixed receiving and sending db2 hotfix packets
Port From (https://github.com/TrinityCore/TrinityCore/commit/5fce3604fc9613299f8780d30abbbe69c0c7e531)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,7 @@
|
|||||||
using Framework.Constants;
|
using Framework.Constants;
|
||||||
using Framework.Database;
|
using Framework.Database;
|
||||||
using Framework.GameMath;
|
using Framework.GameMath;
|
||||||
|
using Game.Network;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -657,7 +658,11 @@ namespace Game.DataStorage
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hotfixData.Add(id, Tuple.Create(tableHash, recordId));
|
HotfixRecord hotfixRecord = new HotfixRecord();
|
||||||
|
hotfixRecord.TableHash = tableHash;
|
||||||
|
hotfixRecord.RecordID = recordId;
|
||||||
|
hotfixRecord.HotfixID = id;
|
||||||
|
_hotfixData.Add(hotfixRecord);
|
||||||
++_hotfixCount;
|
++_hotfixCount;
|
||||||
deletedRecords[Tuple.Create(tableHash, recordId)] = deleted;
|
deletedRecords[Tuple.Create(tableHash, recordId)] = deleted;
|
||||||
|
|
||||||
@@ -707,7 +712,7 @@ namespace Game.DataStorage
|
|||||||
}
|
}
|
||||||
|
|
||||||
public uint GetHotfixCount() { return _hotfixCount; }
|
public uint GetHotfixCount() { return _hotfixCount; }
|
||||||
public MultiMap<int, Tuple<uint, int>> GetHotfixData() { return _hotfixData; }
|
public List<HotfixRecord> GetHotfixData() { return _hotfixData; }
|
||||||
|
|
||||||
public byte[] GetHotfixBlobData(uint tableHash, int recordId)
|
public byte[] GetHotfixBlobData(uint tableHash, int recordId)
|
||||||
{
|
{
|
||||||
@@ -2050,7 +2055,7 @@ namespace Game.DataStorage
|
|||||||
|
|
||||||
Dictionary<uint, IDB2Storage> _storage = new Dictionary<uint, IDB2Storage>();
|
Dictionary<uint, IDB2Storage> _storage = new Dictionary<uint, IDB2Storage>();
|
||||||
uint _hotfixCount = 0;
|
uint _hotfixCount = 0;
|
||||||
MultiMap<int, Tuple<uint, int>> _hotfixData = new MultiMap<int, Tuple<uint, int>>();
|
List<HotfixRecord> _hotfixData = new List<HotfixRecord>();
|
||||||
Dictionary<Tuple<uint, int>, byte[]> _hotfixBlob = new Dictionary<Tuple<uint, int>, byte[]>();
|
Dictionary<Tuple<uint, int>, byte[]> _hotfixBlob = new Dictionary<Tuple<uint, int>, byte[]>();
|
||||||
|
|
||||||
MultiMap<uint, uint> _areaGroupMembers = new MultiMap<uint, uint>();
|
MultiMap<uint, uint> _areaGroupMembers = new MultiMap<uint, uint>();
|
||||||
@@ -2282,6 +2287,27 @@ namespace Game.DataStorage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct HotfixRecord
|
||||||
|
{
|
||||||
|
public uint TableHash;
|
||||||
|
public int RecordID;
|
||||||
|
public int HotfixID;
|
||||||
|
|
||||||
|
public void Write(WorldPacket data)
|
||||||
|
{
|
||||||
|
data.WriteUInt32(TableHash);
|
||||||
|
data.WriteInt32(RecordID);
|
||||||
|
data.WriteInt32(HotfixID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Read(WorldPacket data)
|
||||||
|
{
|
||||||
|
TableHash = data.ReadUInt32();
|
||||||
|
RecordID = data.ReadInt32();
|
||||||
|
HotfixID = data.ReadInt32();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ChrClassesXPowerTypesRecordComparer : IComparer<ChrClassesXPowerTypesRecord>
|
class ChrClassesXPowerTypesRecordComparer : IComparer<ChrClassesXPowerTypesRecord>
|
||||||
{
|
{
|
||||||
public int Compare(ChrClassesXPowerTypesRecord left, ChrClassesXPowerTypesRecord right)
|
public int Compare(ChrClassesXPowerTypesRecord left, ChrClassesXPowerTypesRecord right)
|
||||||
|
|||||||
@@ -70,24 +70,21 @@ namespace Game
|
|||||||
HotfixResponse hotfixQueryResponse = new HotfixResponse();
|
HotfixResponse hotfixQueryResponse = new HotfixResponse();
|
||||||
foreach (HotfixRecord hotfixRecord in hotfixQuery.Hotfixes)
|
foreach (HotfixRecord hotfixRecord in hotfixQuery.Hotfixes)
|
||||||
{
|
{
|
||||||
var hotfixedRecords = hotfixes.LookupByKey(hotfixRecord.HotfixID);
|
if (hotfixes.Contains(hotfixRecord))
|
||||||
if (!hotfixedRecords.Empty())
|
|
||||||
{
|
|
||||||
foreach (var tableRecord in hotfixedRecords)
|
|
||||||
{
|
{
|
||||||
var storage = Global.DB2Mgr.GetStorage(hotfixRecord.TableHash);
|
var storage = Global.DB2Mgr.GetStorage(hotfixRecord.TableHash);
|
||||||
|
|
||||||
HotfixResponse.HotfixData hotfixData = new HotfixResponse.HotfixData();
|
HotfixResponse.HotfixData hotfixData = new HotfixResponse.HotfixData();
|
||||||
hotfixData.Record = hotfixRecord;
|
hotfixData.Record = hotfixRecord;
|
||||||
if (storage != null && storage.HasRecord((uint)hotfixData.Record.RecordID))
|
if (storage != null && storage.HasRecord((uint)hotfixRecord.RecordID))
|
||||||
{
|
{
|
||||||
uint pos = hotfixQueryResponse.HotfixContent.GetSize();
|
uint pos = hotfixQueryResponse.HotfixContent.GetSize();
|
||||||
storage.WriteRecord((uint)hotfixData.Record.RecordID, GetSessionDbcLocale(), hotfixQueryResponse.HotfixContent);
|
storage.WriteRecord((uint)hotfixRecord.RecordID, GetSessionDbcLocale(), hotfixQueryResponse.HotfixContent);
|
||||||
hotfixData.Size.Set(hotfixQueryResponse.HotfixContent.GetSize() - pos);
|
hotfixData.Size.Set(hotfixQueryResponse.HotfixContent.GetSize() - pos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte[] blobData = Global.DB2Mgr.GetHotfixBlobData(hotfixData.Record.TableHash, hotfixData.Record.RecordID);
|
byte[] blobData = Global.DB2Mgr.GetHotfixBlobData(hotfixRecord.TableHash, hotfixRecord.RecordID);
|
||||||
if (blobData != null)
|
if (blobData != null)
|
||||||
{
|
{
|
||||||
hotfixData.Size.Set((uint)blobData.Length);
|
hotfixData.Size.Set((uint)blobData.Length);
|
||||||
@@ -98,7 +95,6 @@ namespace Game
|
|||||||
hotfixQueryResponse.Hotfixes.Add(hotfixData);
|
hotfixQueryResponse.Hotfixes.Add(hotfixData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SendPacket(hotfixQueryResponse);
|
SendPacket(hotfixQueryResponse);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,6 +240,6 @@ namespace Game.Network
|
|||||||
byteBuffer.WriteBytes(Tag, 12);
|
byteBuffer.WriteBytes(Tag, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsValidSize() { return Size < 0x10000; }
|
public bool IsValidSize() { return Size < 0x40000; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using Framework.IO;
|
|||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
|
using Game.DataStorage;
|
||||||
|
|
||||||
namespace Game.Network.Packets
|
namespace Game.Network.Packets
|
||||||
{
|
{
|
||||||
@@ -77,7 +78,7 @@ namespace Game.Network.Packets
|
|||||||
|
|
||||||
class AvailableHotfixes : ServerPacket
|
class AvailableHotfixes : ServerPacket
|
||||||
{
|
{
|
||||||
public AvailableHotfixes(int hotfixCacheVersion, uint hotfixCount, MultiMap<int, Tuple<uint, int>> hotfixes) : base(ServerOpcodes.AvailableHotfixes)
|
public AvailableHotfixes(int hotfixCacheVersion, uint hotfixCount, List<HotfixRecord> hotfixes) : base(ServerOpcodes.AvailableHotfixes)
|
||||||
{
|
{
|
||||||
HotfixCacheVersion = hotfixCacheVersion;
|
HotfixCacheVersion = hotfixCacheVersion;
|
||||||
HotfixCount = hotfixCount;
|
HotfixCount = hotfixCount;
|
||||||
@@ -89,20 +90,13 @@ namespace Game.Network.Packets
|
|||||||
_worldPacket.WriteInt32(HotfixCacheVersion);
|
_worldPacket.WriteInt32(HotfixCacheVersion);
|
||||||
_worldPacket.WriteUInt32(HotfixCount);
|
_worldPacket.WriteUInt32(HotfixCount);
|
||||||
|
|
||||||
foreach (var key in Hotfixes.Keys)
|
foreach (HotfixRecord hotfixRecord in Hotfixes)
|
||||||
{
|
hotfixRecord.Write(_worldPacket);
|
||||||
foreach (var tableRecord in Hotfixes[key])
|
|
||||||
{
|
|
||||||
_worldPacket.WriteUInt32(tableRecord.Item1);
|
|
||||||
_worldPacket.WriteInt32(tableRecord.Item2);
|
|
||||||
_worldPacket.WriteInt32(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int HotfixCacheVersion;
|
public int HotfixCacheVersion;
|
||||||
public uint HotfixCount;
|
public uint HotfixCount;
|
||||||
public MultiMap<int, Tuple<uint, int>> Hotfixes;
|
public List<HotfixRecord> Hotfixes;
|
||||||
}
|
}
|
||||||
|
|
||||||
class HotfixRequest : ClientPacket
|
class HotfixRequest : ClientPacket
|
||||||
@@ -116,7 +110,11 @@ namespace Game.Network.Packets
|
|||||||
|
|
||||||
uint hotfixCount = _worldPacket.ReadUInt32();
|
uint hotfixCount = _worldPacket.ReadUInt32();
|
||||||
for (var i = 0; i < hotfixCount; ++i)
|
for (var i = 0; i < hotfixCount; ++i)
|
||||||
Hotfixes.Add(new HotfixRecord(_worldPacket));
|
{
|
||||||
|
HotfixRecord hotfixRecord = new HotfixRecord();
|
||||||
|
hotfixRecord.Read(_worldPacket);
|
||||||
|
Hotfixes.Add(hotfixRecord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint ClientBuild;
|
public uint ClientBuild;
|
||||||
@@ -163,25 +161,4 @@ namespace Game.Network.Packets
|
|||||||
public Optional<uint> Size;
|
public Optional<uint> Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct HotfixRecord
|
|
||||||
{
|
|
||||||
public HotfixRecord(WorldPacket data)
|
|
||||||
{
|
|
||||||
TableHash = data.ReadUInt32();
|
|
||||||
RecordID = data.ReadInt32();
|
|
||||||
HotfixID = data.ReadInt32();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Write(WorldPacket data)
|
|
||||||
{
|
|
||||||
data.WriteUInt32(TableHash);
|
|
||||||
data.WriteInt32(RecordID);
|
|
||||||
data.WriteInt32(HotfixID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint TableHash;
|
|
||||||
public int RecordID;
|
|
||||||
public int HotfixID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user