Fixed the TrainCargoManager's initilization of the allItems variable #8215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses issue #7609, which concerns the train schedule logic specific to the "Cargo idle" condition. Previously, the train's idle timer only waited the specified amount of time upon arriving at a station, instead of waiting until no cargo changes occurred for the given duration.
Upon investigation, I found that during the initialization of the TrainCargoManager, a CargoInvWrapper subobject is created using the MountedItemStorageWrapper's constructor and set within the MountedStorageManager's
item
variable. HOWEVER, the MountedStorageManager's/TrainCargoManager'sallItems
variable, which is used to interact with and fetch the collective contraption's item inventories, remains set to the original MountedItemStorageWrapper class. This prevents the CargoInvWrapper's overwritten methods from being invoked, as a result the changeDetected method, responsible for resetting the train's idle timer whenever an update to the cargo occurs, is never called, causing the train to leave after the set time of "inactivity"This fix ensures that the
allItems
variable is correctly updated during initialization to a CargoInvWrapper class and allows the changeDetected method to function as intended to restore the proper behavior of the train's idle timer within the "Cargo idle" condition.