Issue #22251: WorkshopParentScript - issue with transferring resources from linked workshops
This is handled by the TransferResourcesFromLinkedWorkshops function which is called by the daily updates (on WorkshopScript) whenever the resources of a workshop (i.e. the sum of daily production and stored resources) is not sufficient to feed the settlers. The daily updates then calculate the differences and pass them as NeededFood and NeededWater to the TransferResourcesFromLinkedWorkshops function.
This function fills all linked workshops (i.e. any workshops connected to the affected workshop by a supply line) in an array, then loops through that array and checks all workshops to get the needed items.
The problem is that the vanilla script doesn't keep track of how many items are transferred, but instead tries to transfer the needed amounts from all workshops in that array. This has two unwanted side effects:
(1) The affected workshop may end up with significantly more food and water in its workbench than needed, and it the worst case, the number of stored items may temporarily exceed the limts beyond which the scripts disallow further production. Simply speaking, the workshop may stop producing for a while although the settlers are starving.
(2) If there's more than one starving workshop in the linked workshop array, resources are permanently swapped forth and back without any need.
In addition, the script wastes performances in that it always loops through the full array even when the job might have been done already after a few linked workshops have been checked (although the gain is admittedly probably minor).