Skip to content

Commit

Permalink
Fix InnerShipStatus deserializing
Browse files Browse the repository at this point in the history
3.31 now distributes them as multiple messages

This also explains the two weird bytes in HeliSabotage, so these can be
removed too
  • Loading branch information
miniduikboot committed Apr 2, 2021
1 parent 66c2434 commit 47aebe7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
28 changes: 5 additions & 23 deletions src/Impostor.Server/Net/Inner/Objects/InnerShipStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,13 @@ public override async ValueTask DeserializeAsync(IClientPlayer sender, IClientPl
return;
}

if (initialState)
while (reader.Position < reader.Length)
{
// TODO: (_systems[SystemTypes.Doors] as DoorsSystemType).SetDoors();
foreach (var systemType in SystemTypeHelpers.AllTypes)
IMessageReader msgReader = reader.ReadMessage();
SystemTypes type = (SystemTypes)msgReader.Tag;
if (_systems.TryGetValue(type, out var value))
{
if (_systems.TryGetValue(systemType, out var system))
{
system.Deserialize(reader, true);
}
}
}
else
{
var count = reader.ReadPackedUInt32();

foreach (var systemType in SystemTypeHelpers.AllTypes)
{
// TODO: Not sure what is going on here, check.
if ((count & 1 << (int)(systemType & (SystemTypes.ShipTasks | SystemTypes.Doors))) != 0L)
{
if (_systems.TryGetValue(systemType, out var system))
{
system.Deserialize(reader, false);
}
}
value.Deserialize(msgReader, initialState);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public void Serialize(IMessageWriter writer, bool initialState)

public void Deserialize(IMessageReader reader, bool initialState)
{
// TODO: Find out what these 2 bytes are used for
_ = reader.ReadByte();
_ = reader.ReadByte();
Countdown = reader.ReadSingle();
Timer = reader.ReadSingle();
ActiveConsoles.Clear(); // TODO: Thread safety
Expand Down

0 comments on commit 47aebe7

Please sign in to comment.