Fix: _schedule_rebuild race condition kills movement animation
Rapid echo state-updates (phase-change, turn-tick) arriving with delay=0 used to cancel the pending movement tween, making unit travel instant. Now a delay=0 call only updates _pending_rebuild so the latest state is applied when the existing tween fires; the tween is only cancelled when a new positive delay arrives. Also: password min-length 12→8 (auth), anchor preset cleanup (tscn). Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -30,7 +30,7 @@ transform = Transform3D(1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044,
|
||||
layer = 10
|
||||
|
||||
[node name="TopBar" type="HBoxContainer" parent="HUD"]
|
||||
anchors_preset = -1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 48.0
|
||||
theme_override_constants/separation = 0
|
||||
@@ -176,7 +176,7 @@ text = "Settings"
|
||||
[node name="ContextPopup" type="PanelContainer" parent="HUD"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
anchors_preset = -1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
@@ -308,17 +308,6 @@ text = "Return to Main Menu"
|
||||
|
||||
[node name="InGameSettings" parent="HUD" instance=ExtResource("2_igs")]
|
||||
unique_name_in_owner = true
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -220.0
|
||||
offset_top = -260.0
|
||||
offset_right = 220.0
|
||||
offset_bottom = 260.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HoldTimer" type="Timer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -922,16 +922,22 @@ func _play_move_animations(state: Dictionary) -> float:
|
||||
|
||||
|
||||
## Schedule a delayed call to _rebuild_units.
|
||||
## Cancels any previous pending rebuild. If delay <= 0 rebuilds synchronously.
|
||||
## If delay <= 0 and a tween is already pending, just update the target state
|
||||
## but DO NOT cancel the running tween — this prevents rapid echo state-updates
|
||||
## (phase changes, turn ticks) from killing an in-progress movement animation.
|
||||
func _schedule_rebuild(state: Dictionary, delay: float) -> void:
|
||||
print("[Rebuild] _schedule_rebuild delay=%.2f" % delay)
|
||||
_pending_rebuild = state
|
||||
print("[Rebuild] _schedule_rebuild delay=%.2f tween_pending=%s" \
|
||||
% [delay, str(_rebuild_tween != null)])
|
||||
_pending_rebuild = state # always target the latest state
|
||||
if delay <= 0.0:
|
||||
if _rebuild_tween != null:
|
||||
return # let the existing animation tween finish; it will use _pending_rebuild
|
||||
_rebuild_units(state)
|
||||
return
|
||||
# A new positive delay: cancel any old tween and start a fresh one.
|
||||
if _rebuild_tween != null:
|
||||
_rebuild_tween.kill()
|
||||
_rebuild_tween = null
|
||||
if delay <= 0.0:
|
||||
_rebuild_units(state)
|
||||
return
|
||||
_rebuild_tween = create_tween()
|
||||
_rebuild_tween.tween_callback(func() -> void:
|
||||
_rebuild_tween = null
|
||||
|
||||
Reference in New Issue
Block a user