Guard spec.loadVolume access in doUpdate to avoid nil-index crash#499
Guard spec.loadVolume access in doUpdate to avoid nil-index crash#499206airmail wants to merge 1 commit into
Conversation
spec.loadVolume is only created in initialiseTransformGroups, which is called from onLoad only when self.isServer and the vehicle is not in SHOP_CONFIG. On a multiplayer client, or for vehicles UAL detects as autoload-capable but that lack a configured loadArea, spec.loadVolume is therefore nil. The customOffset/customRotation block in doUpdate dereferences spec.loadVolume.length unconditionally, producing repeated "UAL - FATAL ERROR: <vehicle>" log spam via the pcall in onUpdate/onUpdateTick and permanently disabling UAL on the vehicle. Wrap the offset/rotation block with `if spec.loadVolume then ... end`. The action-event update block above is unaffected and continues to run.
|
I'm away from home so I can't look until later in the week, but we should identify why the loading volume object was used by the client. Guarding access is a sticking plaster rather than a fix. |
|
Good catch — diving in further, the Tracing the customOffset/customRotation feature end-to-end:
No event ever syncs
(Worth noting up front: this is all about the runtime So the real fix is one of:
Happy to do whichever direction you prefer when you're back — option 1 feels right to me. The guard in this PR keeps logs clean in the meantime without changing functional behavior (it's already a no-op on MP clients). |
|
Okay ChatGPT. |
|
Yes, your not wrong..... I only have so much time in life to devote to hobbies, and while i wish i had the time to properly learn coding i have more important IRL things that take up my time. I'm just trying to help solve an issue on a really cool mod! |
This should have been SP only for now. MP requires synchronisation of server only values with client. Also needed for debug display.
|
No problem, just reporting the issue is good enough, but I appreciate the extra effort :D Should be fixed now in https://github.com/loki79uk/FS25_UniversalAutoload/releases/tag/v1.0.2.8 Please test and let me know. |
|
I was gone for a couple days, i'll test it in a bit. |
Problem
doUpdatecrashes for vehicles wherespec.loadVolumeis nil — either on a multiplayer client (whereinitialiseTransformGroupsnever runs because it's gated onself.isServer) or for vehicles UAL detects as autoload-capable but that lack a configuredloadArea. ThepcallinonUpdate/onUpdateTickcatches it, printsUAL - FATAL ERROR: <vehicle>once, and permanently disables UAL on that vehicle for the rest of the session.Example log entries:
Root cause
spec.loadVolumeis only created ininitialiseTransformGroups, called fromonLoadonly when:So on a multiplayer client
spec.loadVolumeis always nil; on the server it's also nil whenever a vehicle has no validloadAreaconfig. The customOffset/customRotation block indoUpdatedereferencesspec.loadVolume.lengthunconditionally (lines 2588 and 2592), hence the crash.Fix
Wrap the offset/rotation block with
if spec.loadVolume then ... end. The action-event update block above it (toggle loading, cycle material, etc.) does not depend onloadVolumeand continues to run. No behavior change for vehicles whereloadVolumeis correctly populated.