Skip to content

Commit

Permalink
When serializing terrain positions for an order, serialize a 0-length…
Browse files Browse the repository at this point in the history
… array in a way that roundtrips.

Previously, a 0 length array would not roundtrip and would deserialize as a center position instead.
  • Loading branch information
RoosterDragon authored and PunkPun committed Sep 19, 2023
1 parent e41279f commit a67320e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions OpenRA.Game/Network/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ public static Order Deserialize(World world, BinaryReader r)
{
var pos = new WPos(r.ReadInt32(), r.ReadInt32(), r.ReadInt32());

var numberOfTerrainPositions = r.ReadByte();
if (numberOfTerrainPositions == 0)
var numberOfTerrainPositions = r.ReadInt16();
if (numberOfTerrainPositions == -1)
target = Target.FromPos(pos);
else
{
Expand Down Expand Up @@ -403,10 +403,10 @@ public byte[] Serialize()
// Don't send extra data over the network that will be restored by the Target ctor
var terrainPositions = targetState.TerrainPositions.Length;
if (terrainPositions == 1 && targetState.TerrainPositions[0] == targetState.Pos)
w.Write((byte)0);
w.Write((short)-1);
else
{
w.Write((byte)terrainPositions);
w.Write((short)terrainPositions);
foreach (var position in targetState.TerrainPositions)
{
w.Write(position.X);
Expand Down

0 comments on commit a67320e

Please sign in to comment.