bugfix: Preserve occupants when transferring assets to allies - #3124
bugfix: Preserve occupants when transferring assets to allies#3124Stubbjax wants to merge 1 commit into
Conversation
PR Summary by QodoPreserve transport occupants when assets transfer to allied players
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Mixed-owner passengers preserved
|
Can we continue to eject if the passengers do not match the containers team after capture? That would solve the edge case. |
I don’t think we can reliably check that here. transferAssetsFromThat() transfers objects one at a time, so the container could be processed before its passengers and temporarily appear mismatched. Could we pass an explicit transfer reason, eg CT_TRANSFER_ALL_ASSETS? Or expose a temporary bulk-transfer target on the source player and only preserve occupants when it matches newOwner? That would avoid changing every onCapture() signature while keeping individual scripted transfers on the existing behavior |
|
So does this change need more work or not? It is not clear to me. |
It depends if we're okay with the minuscule possibility that a map script transfers a contained unit to an ally. Covering this one scenario introduces quite a bit of complexity. |
|
If it is technically possible then it better be handled at some point. |
I think a contained unit should not be transferable to an ally. The script should fail (i.e. do nothing) at that point. |
This change preserves contained occupants when a player's assets are transferred to an ally player.
Transferred assets run through the
onCapturelogic, which features safeguards against weird circumstances like enemy occupants being left inside a captured building or vehicle. However, this does not take assets transferred to allies on surrender into consideration, in which case preserved containment is always desirable*. Also note that not all occupants are consistently evacuated (at least prior to #1885).*This change does leave a possible scenario where a container object is transferred to an ally under different circumstances, such as via a scripting event. In such cases, any of the original owner's occupants would hypothetically remain inside the container rather than being ejected, which might cause weird or unexpected behaviour.
I'm thinking it might be necessary to implement an optional capture path / reason into the
onCapturesignatures and make the change conditional on that reason.Or we could simply ignore such scenarios; they might not even be valid and they're certainly not likely. I'm open to suggestions.
Before
Units are evacuated when transferred to an ally
YES_EVAC.mp4
And with #1885 applied:
https://github.com/user-attachments/assets/7ee1b10b-4d9e-4eac-848d-6ff71622ceec
After
Units remain contained when transferred to an ally
NO_EVAC.mp4
And with #1885 applied:
https://github.com/user-attachments/assets/adbcf7f1-5fa2-49dc-b614-bddc9d8804a5