Skip to content

Fixed the TrainCargoManager's initilization of the allItems variable #8215

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

Conversation

Edwin-Baranov
Copy link

@Edwin-Baranov Edwin-Baranov commented Apr 6, 2025

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's allItems 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.

@Edwin-Baranov Edwin-Baranov changed the title Fixed the TrainCargoManager's initilization for allItems Fixed the TrainCargoManager's initilization of the allItems variable Apr 6, 2025
@VoidLeech VoidLeech added pr type: fix PR fixes a bug pr flag: simple PR has minimal changes labels Apr 6, 2025
@xXD4rkDragonXx
Copy link

Ah interesting! Learned something new with this. Thank you for looking into it, hope it gets merged.

@xXD4rkDragonXx
Copy link

Any update on this?

@Edwin-Baranov
Copy link
Author

Any update on this?

Unsure, all checks have passed. The only thing missing is for a review/maintainer to accept it.

@IThundxr
Copy link
Member

IThundxr commented May 9, 2025

Thanks, i've fixed this in-dev

@IThundxr IThundxr closed this May 9, 2025
@Edwin-Baranov
Copy link
Author

Thanks, i've fixed this in-dev

No problem, happy to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr flag: simple PR has minimal changes pr type: fix PR fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants