Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Lord, LordJob, LordToil sync workers to handle null #396

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading