rwmt / Multiplayer

Zetrith's Multiplayer mod for RimWorld

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Prioritize teaching" interaction not synced

Feliphysics opened this issue · comments

This was tested on the latest Rimworld version (1.4.3563 rev533) and the latest mp version (release 0.7.2, workshop).
Using harmony, core, all DLCs, and multiplayer.

If a child sits at a school desk and starts the "learning a lesson" activity (assuming no adult is either already participating or moving to the desk to participate) you can select any adult assigned to childcare, right click the child at the desk and the "Prioritize teaching" interaction will pop-up.
Said interaction is not synced and as such causes issues when selected.
[children seem to only start a lesson if an adult is available to teach, in which case this issue would affect exclusively people that want to choose who a specific children is being taught by, and doing so requires drafting the current teacher]

I also noticed that sometimes the desync would happen when right-clicking instead of when selecting "Prioritize teaching", though I couldn't reproduce that consistently, I'll see if I can also find the logs for that case.

Relevant logs attached.
Desync-04.zip

Some investigation on the issue. The culprit is RimWorld.WorkGiver_Teach:JobOnThing.

The issue is that the method sets the target (teacher) for the child's job in that method. However, the method can be called from UI (RimWorld.FloatMenuMakerMap:AddJobGiverWorkOrders), which explains the desync without actually clicking the option.

Potential fix: prevent WorkGiver_Teach from setting the target for the child. Add PreInvoke for SyncMethod for Pawn_JobTracker.TryTakeOrderedJobPrioritizedWork, where we check if the job is JobDefOf.Lessongiving, and if this is the case - set the target for the child in there.