fix: Fixes BitArray serialization (#1027)
Fixes bit array serialization. This may cause objects that were serialized by bit array to fail to deserialize. I am sorry, please accept my condolences. It is probably easiest to just delete those objects. If it becomes a major problem, contact me and I'll help with a hacky per-case solution.
This commit is contained in:
parent
6ea5508f5f
commit
6b3617b08f
4 changed files with 207 additions and 167 deletions
29
Projects/Server.Tests/Tests/Collections/BitArrayTests.cs
Normal file
29
Projects/Server.Tests/Tests/Collections/BitArrayTests.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using Server.Collections;
|
||||
using Xunit;
|
||||
|
||||
namespace Server.Tests;
|
||||
|
||||
public class BitArrayTests
|
||||
{
|
||||
[Fact]
|
||||
public void TestBitArray()
|
||||
{
|
||||
var bitArray = new BitArray(700); // Restricted Spells;
|
||||
bitArray.Set(5, true);
|
||||
bitArray.Set(39, true);
|
||||
bitArray.Set(125, true);
|
||||
|
||||
// Simulate World Saving
|
||||
var writer = new BufferWriter(1024, false);
|
||||
writer.Write(bitArray); // Save it to a file
|
||||
|
||||
// Simulate World Loading
|
||||
var reader = new BufferReader(writer.Buffer);
|
||||
var bitArrayTest = reader.ReadBitArray();
|
||||
Assert.Equal(700, bitArrayTest.Length);
|
||||
for (var i = 0; i < bitArrayTest.Length; i++)
|
||||
{
|
||||
Assert.Equal(i is 5 or 39 or 125, bitArrayTest.Get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue