Skip to content

Commit

Permalink
Change Lord, LordJob, LordToil sync workers to handle null (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
SokyranTheDragon authored Oct 17, 2023
1 parent 332a868 commit cbdbdd8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Source/Client/Syncing/Dict/SyncDictRimWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,19 +345,26 @@ public static class SyncDictRimWorld
#region AI
{
(ByteWriter data, Lord lord) => {
MpContext context = data.MpContext();
context.map = lord.Map;
data.WriteInt32(lord.loadID);
if (lord == null) {
data.WriteInt32(int.MaxValue);
}
else {
data.WriteInt32(lord.loadID);
MpContext context = data.MpContext();
context.map = lord.Map;
}
},
(ByteReader data) => {
var map = data.MpContext().map;
int lordId = data.ReadInt32();
if (lordId == int.MaxValue)
return null;
var map = data.MpContext().map;
return map.lordManager.lords.Find(l => l.loadID == lordId);
}
},
{
(ByteWriter data, LordJob job) => {
WriteSync(data, job.lord);
WriteSync(data, job?.lord);
},
(ByteReader data) => {
var lord = ReadSync<Lord>(data);
Expand All @@ -366,7 +373,7 @@ public static class SyncDictRimWorld
},
{
(ByteWriter data, LordToil toil) => {
WriteSync(data, toil.lord);
WriteSync(data, toil?.lord);
},
(ByteReader data) => {
var lord = ReadSync<Lord>(data);
Expand Down

0 comments on commit cbdbdd8

Please sign in to comment.