Fix: CORS header before upstream await + movement debug prints
CORS: Access-Control-Allow-Origin must be set before the CDN GetAsync call so it is present even if the upstream throws (ASP.NET Core exception handling resets responses, dropping headers set after an exception). Added try/catch to return 502 cleanly on upstream failures. Debug: [Move] prints in _play_move_animations and _schedule_rebuild to diagnose why movement animation appears instant. 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:
@@ -886,6 +886,8 @@ func _animate_unit_move(iid: String, from_coord: Vector2i, to_coord: Vector2i,
|
||||
## Detect position changes vs _prev_unit_pos and start move animations.
|
||||
## Returns the maximum movement duration across all movers (seconds).
|
||||
func _play_move_animations(state: Dictionary) -> float:
|
||||
print("[Move] _play_move_animations called. _prev_unit_pos.size=%d _unit_bodies.size=%d" \
|
||||
% [_prev_unit_pos.size(), _unit_bodies.size()])
|
||||
if _prev_unit_pos.is_empty():
|
||||
return 0.0
|
||||
# Build the set of blocked tiles from old unit positions.
|
||||
@@ -902,19 +904,27 @@ func _play_move_animations(state: Dictionary) -> float:
|
||||
if not (pd is Dictionary) or (pd as Dictionary).is_empty(): continue
|
||||
var new_coord := Vector2i((pd as Dictionary).get("x", 0),
|
||||
(pd as Dictionary).get("y", 0))
|
||||
if not _prev_unit_pos.has(iid): continue
|
||||
if not _prev_unit_pos.has(iid):
|
||||
print("[Move] iid=%s not in _prev_unit_pos — skipping" % iid)
|
||||
continue
|
||||
var old_coord : Vector2i = _prev_unit_pos[iid]
|
||||
if old_coord == new_coord: continue
|
||||
print("[Move] iid=%s moved %s→%s body_valid=%s" % [
|
||||
iid, str(old_coord), str(new_coord),
|
||||
str(is_instance_valid(_unit_bodies.get(iid) as StaticBody3D))])
|
||||
# Mover has left its old tile — unblock it for BFS.
|
||||
blocked.erase(old_coord)
|
||||
var dur := _animate_unit_move(iid, old_coord, new_coord, blocked)
|
||||
print("[Move] _animate_unit_move returned dur=%.2f" % dur)
|
||||
max_dur = maxf(max_dur, dur)
|
||||
print("[Move] max_dur=%.2f" % max_dur)
|
||||
return max_dur
|
||||
|
||||
|
||||
## Schedule a delayed call to _rebuild_units.
|
||||
## Cancels any previous pending rebuild. If delay <= 0 rebuilds synchronously.
|
||||
func _schedule_rebuild(state: Dictionary, delay: float) -> void:
|
||||
print("[Rebuild] _schedule_rebuild delay=%.2f" % delay)
|
||||
_pending_rebuild = state
|
||||
if _rebuild_tween != null:
|
||||
_rebuild_tween.kill()
|
||||
|
||||
Reference in New Issue
Block a user