Skip to content

Commit 8097f14

Browse files
committed
Fix replicable request
1 parent 878b722 commit 8097f14

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎Concealment/Patches/PatchReplicableRequest.cs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static class PatchReplicableRequest
3030
public static void Patch(PatchContext ctx)
3131
{
3232
//temporarily disabled because BitStream.ResetRead is throwing dumbass exceptions
33-
//ctx.GetPattern(_requestMethod).Prefixes.Add(typeof(PatchReplicableRequest).GetMethod(nameof(PrefixRequest)));
33+
ctx.GetPattern(_requestMethod).Prefixes.Add(typeof(PatchReplicableRequest).GetMethod(nameof(PrefixRequest)));
3434
}
3535

3636
public static void PrefixRequest(MyPacket packet)
@@ -40,11 +40,14 @@ public static void PrefixRequest(MyPacket packet)
4040
var stream = packet.BitStream;
4141
var id = stream.ReadInt64();
4242
bool add = stream.ReadBool();
43+
if (add)
44+
stream.ReadByte();
4345

44-
var g = ConcealmentPlugin.Instance.ConcealedGroups.First(gr => gr.Grids.Any(q => q.EntityId == id));
46+
var g = ConcealmentPlugin.Instance.ConcealedGroups.FirstOrDefault(gr => gr.Grids.Any(q => q.EntityId == id));
4547
if (g != null && add)
4648
ConcealmentPlugin.Instance.RevealGroup(g);
4749

50+
stream.ResetWrite();
4851
stream.ResetRead();
4952
}
5053
catch (Exception ex)
@@ -55,6 +58,7 @@ public static void PrefixRequest(MyPacket packet)
5558
finally
5659
{
5760
//this allows us to fail gracefully
61+
packet.BitStream.ResetWrite();
5862
packet.BitStream.ResetRead();
5963
}
6064
}

0 commit comments

Comments
 (0)