ace/Source/ACE.Server/Network/Structure/PHashTable.cs
gmriggs aa9bc542ba
fix some client memory leaks from incorrectly ordered hashtables on login (#3576)
* fix some client memory leaks with appraisals

* fix some client memory leaks from incorrectly ordered hashtables on login

* more organization for PackableHashTable vs. deprecated PHashTable

* fully deprecate PHashTable -- 0 references now

* refactor RestrictionDB.Write() to use PackableHashTable common method. trying to ensure all places in the system that send PackableHashTables go through common method, for consistency and tracing

* cleanup

* finding more references

* update HouseAccess to match client

* add full explanation where numBuckets=89 originates from

* update code for empty collection in AllegianceHierarchy for reference
2021-06-12 16:10:21 -04:00

28 lines
705 B
C#

using System;
using System.IO;
namespace ACE.Server.Network.Structure
{
public static class PHashTable
{
/// <summary>
/// Deprecated
/// </summary>
public static void WriteHeader(BinaryWriter writer, uint count)
{
var numBits = GetNumBits(count);
var numBuckets = 1 << ((int)numBits - 1);
writer.Write((ushort)count);
writer.Write((ushort)numBuckets);
}
/// <summary>
/// Returns the number of bits required to store the input number
/// </summary>
private static uint GetNumBits(uint num)
{
return (uint)Math.Log(num, 2) + 1;
}
}
}