Fix unbuilt units staying around when issued with BuildMobile to external factories and cancelled #6702
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.
Issue
First reported by @4z0t.
When a
BuildMobileorder is cancelled,OnStopBuildis called with an unbuilt unit. Carriers will put the unbuilt unit into their storage at that point because there are no checks for this scenario. Fatboy places the unbuilt unit on the ground. ABuildMobileorder can be issued to factories trivially using UI mods. Thankfully it isn't a huge exploit because the unbuilt units are still unbuilt when they come out of storage.put.unbuilt.units.into.carriers.mp4
After deployment:

Description of the proposed changes
OnStopBuildWithStoragein the external factory component.OnStopBuildfunctions.Testing done on the proposed changes
Spawn a carrier, select the external factory, and then issue a buildmobile order within 5 range (default buildrange) near the rear of the carrier where the external factory is actually located. Then move the build order around to cancel it repeatedly. No units should be added to the carrier's storage.
Fatboy test:
Execution is similar to the carrier but Fatboy has animations and delays so those have to be accounted for. It also does not use the same
OnStopBuildWithStoragefunction.Checklist