2018-06-29 14:54:37 -04:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2021-06-12 16:10:21 -04:00
|
|
|
using System.Linq;
|
2018-06-29 14:54:37 -04:00
|
|
|
|
2019-01-18 17:07:58 -05:00
|
|
|
using ACE.Database.Models.Shard;
|
|
|
|
|
|
2018-06-29 14:54:37 -04:00
|
|
|
namespace ACE.Server.Network.Structure
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// HashTable which is packable for network
|
|
|
|
|
/// </summary>
|
2018-09-06 11:26:26 -04:00
|
|
|
public static class PackableHashTable
|
|
|
|
|
{
|
2021-06-12 16:03:19 -04:00
|
|
|
public static void WriteHeader(BinaryWriter writer, int count, int numBuckets)
|
|
|
|
|
{
|
|
|
|
|
writer.Write((ushort)count);
|
|
|
|
|
writer.Write((ushort)numBuckets);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-12 16:10:21 -04:00
|
|
|
public static void WriteOld(this BinaryWriter writer, List<CharacterPropertiesFillCompBook> fillComps)
|
2018-09-06 11:26:26 -04:00
|
|
|
{
|
2021-06-12 16:10:21 -04:00
|
|
|
const int numBuckets = 256; // constant from retail pcaps
|
2018-09-06 11:26:26 -04:00
|
|
|
|
2021-06-12 16:10:21 -04:00
|
|
|
WriteHeader(writer, fillComps.Count, numBuckets);
|
2018-09-06 11:26:26 -04:00
|
|
|
|
2021-06-12 16:10:21 -04:00
|
|
|
var sorted = fillComps.OrderBy(i => i.SpellComponentId % numBuckets);
|
|
|
|
|
|
|
|
|
|
foreach (var fillComp in sorted)
|
2019-01-18 17:07:58 -05:00
|
|
|
{
|
2021-06-12 16:10:21 -04:00
|
|
|
writer.Write(fillComp.SpellComponentId);
|
|
|
|
|
writer.Write(fillComp.QuantityToRebuy);
|
2019-01-18 17:07:58 -05:00
|
|
|
}
|
|
|
|
|
}
|
2018-06-29 14:54:37 -04:00
|
|
|
}
|
|
|
|
|
}
|