Skip to content

Commit 64b567d

Browse files
committed
Fix inconsistent serialization of GlobalTargetInfo
1 parent 7ec867a commit 64b567d

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

Source/Client/Syncing/Dict/SyncDictRimWorld.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
using HarmonyLib;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
24
using Multiplayer.API;
3-
using Multiplayer.Client.Patches;
45
using Multiplayer.Common;
56
using RimWorld;
67
using RimWorld.Planet;
7-
using System;
8-
using System.Collections.Generic;
9-
using System.Linq;
10-
using System.Security.Cryptography;
118
using Verse;
129
using Verse.AI;
1310
using Verse.AI.Group;
1411
using static Multiplayer.Client.CompSerialization;
1512
using static Multiplayer.Client.SyncSerialization;
16-
using static UnityEngine.GraphicsBuffer;
13+
1714
// ReSharper disable RedundantLambdaParameterType
1815

1916
namespace Multiplayer.Client
@@ -1249,10 +1246,16 @@ public static class SyncDictRimWorld
12491246
data.WriteByte(2);
12501247
WriteSync(data, info.WorldObject);
12511248
}
1252-
else {
1249+
else if (info.Tile.Valid) {
12531250
data.WriteByte(3);
12541251
WriteSync(data, info.Tile);
12551252
}
1253+
else
1254+
{
1255+
if (info.IsValid)
1256+
throw new SerializationException($"Unable to serialize GlobalTargetInfo {info}");
1257+
data.WriteByte(byte.MaxValue);
1258+
}
12561259
},
12571260
(ByteReader data) =>
12581261
{
@@ -1263,8 +1266,10 @@ public static class SyncDictRimWorld
12631266
true) // True to prevent errors/warnings if synced map was null
12641267
,
12651268
2 => new GlobalTargetInfo(ReadSync<WorldObject>(data)),
1266-
3 => new GlobalTargetInfo(data.ReadInt32()),
1267-
_ => GlobalTargetInfo.Invalid
1269+
3 => new GlobalTargetInfo(ReadSync<PlanetTile>(data)),
1270+
byte.MaxValue => GlobalTargetInfo.Invalid,
1271+
var type =>
1272+
throw new SerializationException($"Unable to deserialize GlobalTargetInfo with type {type}"),
12681273
};
12691274
}
12701275
},

0 commit comments

Comments
 (0)