Banjobeni / DerailValley-PersistentJobs

Derail Valley Peristent Jobs Mod
https://www.nexusmods.com/derailvalley/mods/794
MIT License
2 stars 1 forks source link

Shunting unload jobs spawning with more drop offs than cars. Game is prevented from saving after this happens #4

Closed ben-vanderlinde closed 1 year ago

ben-vanderlinde commented 1 year ago

Hi, thanks for a great mod I enjoy it.

I've noticed the following issue :

Sometimes shunting unload jobs spawn with more drop offs than cars. image image

In my case a single car was assigned to a job with three drop offs. Once the job spawns the game can no longer be saved. When saving the console shows the error : Saving Manual failed: "Couldn't extract carGuidsPerDestinationTrack" image

If I accept the job, I cannot complete it, but if I bin the job after accepting it immediately I am able to save again.

After leaving MF with another job, the troublesome job spawns again, and prevents saving. This time I cannot accept the job. The job machine makes the job denied sound (fees have been cleared), but no reason is printed. The save game issue is then resolved by clearing all the cars attached to this job.

The exception & stack trace I found in the player.log is: Exception: Couldn't extract carGuidsPerDestinationTrack at StaticShuntingUnloadJobDefinition.GetJobDefinitionSaveData () [0x0012e] in <4dd6bf05cc8c4e4288a4683024f156b0>:0 at JobChainController.GetJobChainSaveData () [0x00059] in <4dd6bf05cc8c4e4288a4683024f156b0>:0 at JobSaveManager.GetJobsSaveGameData () [0x00028] in <4dd6bf05cc8c4e4288a4683024f156b0>:0 at SaveGameManager.UpdateInternalData () [0x001bb] in <4dd6bf05cc8c4e4288a4683024f156b0>:0 at (wrapper dynamic-method) SaveGameManager.SaveGameManager.Save_Patch1(SaveGameManager,DV.Common.SaveType,DV.Common.ISaveGame) at DV.UI.UserProfileProvider.SaveGame (DV.Common.SaveType type) [0x00005] in <4dd6bf05cc8c4e4288a4683024f156b0>:0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) DV.UI.UserProfileProvider:SaveGame(SaveType) DV.UI.SaveLoadController:OnSaveClicked() UnityEngine.Events.InvokableCall:Invoke() UnityEngine.Events.UnityEvent:Invoke() UnityEngine.UI.Button:Press() UnityEngine.UI.Button:OnPointerClick(PointerEventData) DV.UIFramework.ButtonDV:OnPointerClick(PointerEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) UnityEngine.EventSystems.StandaloneInputModule:ReleaseMouse(PointerEventData, GameObject) UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32) UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent() UnityEngine.EventSystems.StandaloneInputModule:Process() UnityEngine.EventSystems.EventSystem:Update()

Attached is the full log: Player.zip

Banjobeni commented 1 year ago

Hi, many thanks for the bug report. I will look into it, but I need some more information:

ben-vanderlinde commented 1 year ago

Hi,

Unfortunately I cannot quite give you a save that has the job spawned, because I found as soon as a faulty job spawned somewhere in the game, it then cannot save. I have attached a save of the game just prior to the issue job spawning.

00021_2023-09-05_10_49_34.zip

The car that the job spawned with was CFF982, and is parked in C1L Machine Factory & Town. I think the reason why I could not accept the job after it spawned the second time is because the car is parked in the loading track (which I have since learned is possibly a deliberate feature?).

It is a re-used car from a Freight Haul Job from Steel Mill to Machine factory and town.

Perhaps some additional detail that may help you reproduce the issue :

  1. after completing the freight haul job from SM I remained in the MF, and completed some other shunting load jobs.
  2. after completing some shunting load jobs, a shunt unload job spawned for the cars I had delivered, but only for half the consist.
  3. I picked up and completed the job for the shunt unload job (for half the consist). (I think 5/10 of the original cars).
  4. This is when the trouble job spawned, it spawned using 1 out of the remaining 5 cars from the split consist.

Some other behaviour I noted that may be relevant. When completing a job, the new jobs that spawn on the re-used cars seem to behave differently depending on if you stay in or close to the same town, or head to another town and come back.

I wonder if it's the splitting of the consists behaviour that maybe leading to the spawning of shunting unload jobs with more parts than cars.

Please let me know if there's any more info I can provide.

Banjobeni commented 1 year ago

Thank you for the detailed explanation. The save will do, I will look into it.

Regarding some points that you mention, for clarification:

For (a), it should never be the case that less cars are used for the subsequent part, i.e. the total number of cars for SL, subsequent FH, subsequent SU should always be the same.

For (b) and (c), there should be no difference in behaviour regarding splitting of a consist.

While you are inside a station and not fast traveling, aside from normal job chain job generation (a), jobless cars should never be reallocated to new jobs. If you see that happen, I need to look into it.

Banjobeni commented 1 year ago

So it seems the shunting unload generator never really paid attention to the number of cars possibly being smaller than the targetted number of tracks. I'm just clamping the max. number of tracks to the number of cars now. I split up the consist in MF-C1L into 4 pieces, one waggon each, and this is the result after new jobs are generated.

grafik

I guess that fixes it, and the fix will be in the next release.