Fix dynamic dialogue race condition with CustomUnits DEPLOY actor#710
Open
Fix dynamic dialogue race condition with CustomUnits DEPLOY actor#710
Conversation
…708) BindAbstractActorToBindingKey() used positional indexing to map binding keys to actors. When CustomUnits injects a temporary DEPLOY actor at position 0 of the player lance, all indices shift by one, binding the wrong actors to dialogue cast keys. After deployment, the dead DEPLOY actor causes an infinite loop in HandleDeadActorFromDialogueContent(). Changes: - Match actors by pilot identity in BindAbstractActorToBindingKey(), with bounds-checked index fallback - Add iteration guards to both dead-actor rebinding loops in HandleDeadActorFromDialogueContent(), scaling with lance size - Clean up stale BoundAbstractActorsFullIndex entries on Darius fallback to prevent re-binding dead actors Also fixes #709: RebindDeadUnitCastDef passed a bare bindKey to HandleFallback without the castDef_ prefix, so IsBindableRandomCastDefID always returned false on the rebinding path. DynamicCastDefs and BoundAbstractActorsFullIndex were never updated during fallback, causing an infinite loop when all lance pilots are dead — even without CU.
The PureRandom dead-actor loop sampled positions with replacement, meaning it could repeatedly pick the same dead pilot and miss a live one. With the iteration guard this caused a ~24% false Darius fallback on a 4-pilot lance with 1 survivor. Shuffle positions using Fisher-Yates so each pilot is tried exactly once, guaranteeing a survivor is found if one exists.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
HandleFallbackreceived barebindKeywithoutcastDef_prefix)Changes
BindAbstractActorToBindingKey()now matches actors by pilot identity (same pattern asGetSpeakerUnitand commander binding), with bounds-checked index fallbackwhileloops inHandleDeadActorFromDialogueContent()have iteration guards scaled to lance sizeHandleFallbackremoves staleBoundAbstractActorsFullIndexentries on Darius fallbackRebindDeadUnitCastDefnow wrapsbindKeywithGetDynamicCastDefIDFromBindKey()when callingHandleFallback