11 Commits
Author SHA1 Message Date
c8c3666d26 Fix 5: iOS Safari scoped asset loading and memory management
- New Platform.gd autoload: is_ios_safari() detects iPhone/iPad Safari
  via JavaScriptBridge UA check (no Chrome/CriOS), gating all iOS memory paths
- ModelCache.release_model(url, etag): evicts a model from in-memory cache
  on iOS Safari when a unit leaves the board; no-op on other platforms so
  disk cache is always preserved for fast reload
- unit_mesh_builder: stores resolved model URL+ETag per unit (_unit_model_urls,
  _unit_model_etags); calls ModelCache.release_model in the to_remove loop so
  PackedScene refs are freed as soon as the unit is pooled or freed
- ContentCache.get_model_url_for_definition: stub for looking up a card's
  Model3D CDN URL without a loaded unit dict (foundation for future eviction paths)

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>
2026-05-20 22:35:05 -04:00
f3e5363c13 Fix SummonToken tile-filter validation: reject bad picks before costs are paid
Three bugs fixed for abilities like Demonate Leviathan (SummonToken + TileFilter):

1. Server: AbilityUsesThisTurn was incremented (and costs paid) before effect-level
   TileFilter validation ran. Added PreValidateClientTileTargets() called before the
   use-count increment so an invalid tile pick wastes no uses and no sacrificed tokens.

2. Server: SummonToken silently break'd when TileFilter or token-affinity check failed,
   giving the client no error. Changed both to throw GameException("INVALID_TILE").

3. Client: tile_passes_filters() only checked the target selector's filters, not the
   effect-level TileFilter (e.g. SummonToken.tileFilter). Added _collect_effect_tile_filters()
   and TileAffinityMatches handling so invalid tiles are never highlighted or accepted.

Also includes: Art2dUrl/ModelUrl deltas in GameStateDiffer/GameMessages/GameEngine,
unit_mesh_builder token-model URL fallback + shader/tint helpers, ModelCache v3 bump,
Game.gd unit delta merging for art2dUrl/modelUrl.

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>
2026-05-12 07:06:54 -04:00
b926957329 Apply Fix 2: evict ModelCache on game exit, flush pending callbacks
Adds evict_all() to ModelCache which sets _shutting_down before flushing
_pending with null callbacks, then clears _mem and _job_queue. This
prevents in-flight HTTP completions from firing into a freed game scene
and ensures each new game starts with a clean WASM heap. Called from
game_screen._exit_tree() after all signal disconnections.

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>
2026-05-09 19:18:10 -04:00
30a4211276 Apply Fix 1: throttle ModelCache parse/download jobs
Caps simultaneous GLB parses and HTTP downloads at _MAX_JOBS=4 via a
shared job budget. Disk-cache hits when slots are full queue as
parse_from_disk:true and drain correctly without re-downloading. Replaces
the no-op get_signal_connection_list().clear() with CONNECT_ONE_SHOT.
Adds _shutting_down flag so evict_all() can null-out pending callbacks.
Adds debug-gated logging on all hot paths.

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>
2026-05-09 18:26:01 -04:00
73c3a71194 Feature: ETag-based CDN model cache invalidation
When admin replaces a model/art file via the CDN browser, the S3 ETag is
now captured and stored on CardAsset.ContentETag. The ETag is included in
the content sync DTO (CardAssetDto) so clients receive it on every sync.

Client-side ModelCache now keys its disk cache on sha256(url + "#" + etag)
instead of sha256(url), so updating a file at the same CDN path busts the
disk cache automatically. A _CACHE_VER="v2" sentinel purges old-scheme
.bin files on first launch after the client update.

Changes:
- CdnUploadResult: add string? ETag field
- S3CdnClient: capture ETag from PutObjectAsync response
- CardAsset: add string? ContentETag property
- Migration 20260318000001_AddAssetContentETag: add content_etag text column
- ContentMessages: add string? ContentETag to CardAssetDto
- ContentDtoMapper: map ContentETag in CardAsset → CardAssetDto
- CdnBrowser.razor: UploadFileToKeyAsync returns Task<string?> (ETag);
  ReplaceAsync calls PropagateAssetETagAsync which updates CardAsset rows
  and touches CardDefinition.UpdatedAt to trigger a version bump
- ModelCache.gd: versioned disk key + cache migration + etag parameter on
  load_model() and evict()
- game_screen.gd: pass model_asset.contentETag to load_model / retry chain

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>
2026-03-18 09:38:17 -04:00
3ba33275e3 Feature: model retry + rejoin on login + 5-min inactivity detection
**Feature 1 — Model retry (client)**
- `ModelCache.gd`: add `evict(url)` to remove failed entries so re-download is possible
- `game_screen.gd`: when GLB load fails, `_schedule_model_retry` queues a 60-second
  retry (up to 10 attempts); `_do_model_retry` evicts + re-downloads and swaps the
  placeholder mesh for the real model if/when it succeeds

**Feature 2 — Rejoin on login (server + client)**
- Server: `GameGetActiveSessionHandler` (`game.get_active_session`) — returns the
  caller's active session ID + phase, or null when no session exists
- Client: `init_screen.gd` checks for an active session after content sync; shows
  a "Rejoin / Concede" dialog when one is found; rejoin navigates to GameScreen with
  the session ID already set so `send_ready` → `AlreadyStarted` → `_fetch_state`

**Feature 3 — 5-minute inactivity detection (server + client)**
- `GameSession`: add `LastActionAt` column + EF migration
  (`20260317000001_AddLastActionAt`)
- `GameHandlerBase.SaveStateAsync`: sets `session.LastActionAt` on every action
- `GameInactivityMonitorService`: background poll every 60 s; when a session hasn't
  had an action in ≥ 5 min, pushes `game.inactive_warning` to the stalled player and
  `game.opponent_inactive` to their opponent (once per session per server lifetime)
- `GameForceConcedeHandler` (`game.force_concede`): lets the waiting player claim
  the win; validates caller is not the active player and `LastActionAt` is stale
- `Game.gd`: new `opponent_inactive` / `inactive_warning` signals + push handlers +
  `send_force_concede()` helper
- `game_screen.gd`: handles `opponent_inactive` with Accept/Wait dialog;
  handles `inactive_warning` with informational popup

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>
2026-03-17 09:05:05 -04:00
8e3f64d9d1 Fix: ability WithinRange/IsAdjacentToSource filters + ModelCache web CORS
- AbilitySystem: implement WithinRangeFilter (Manhattan distance min/max) and
  IsAdjacentToSourceFilter in FilterMatches — both were falling through to
  _ => true, so range constraints on targeting were silently ignored
- Program.cs: add GET /cdn/{**path} proxy endpoint with
  Access-Control-Allow-Origin: * so browser web clients can fetch GLB models
  (Ceph RadosGW / cdn.aeternalisgames.com has no CORS headers)
- ModelCache.gd: on web export, rewrite cdn.aeternalisgames.com URLs to go
  through hub.aeternalisgames.com/cdn proxy; disk/memory cache still keyed
  on the original CDN URL for consistency across platforms

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>
2026-03-10 10:39:13 -04:00
c94fe4204d Fix: ModelCache gives actionable error when OBJ/non-GLB file is loaded
Shows the first 20 printable bytes and explains that only binary .glb
is supported at runtime, with a Blender re-export hint.

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>
2026-03-09 14:15:18 -04:00
03b553feab Debug: log ModelCache HTTP result/headers/bytes; fix weakref captures
- ModelCache._download: log result enum, HTTP code, body size,
  Content-Type header, and first 16 bytes for every download — enough
  to diagnose why Godot receives non-GLB data despite CDN serving valid GLB
- Moved disk-cache write to AFTER a successful parse so corrupt bytes
  are never written; disk cache read now deletes + re-downloads on bad parse
- game_screen: replace raw `body` lambda captures with weakref to
  eliminate "Lambda capture freed" noise (behavior unchanged)

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>
2026-03-09 14:06:23 -04:00
6dda0edf17 Fix: 3D model loading for units/tiles + tile model server pipeline
- ModelCache: switch GLTFDocument.append_from_buffer (was append_from_file
  which returned ERR_BUSY/43); validate GLB magic bytes; explicit signal
  disconnect before queue_free to avoid freed-lambda errors
- ContentCache: add tile model fetch (content.tile_models), disk cache at
  user://content/tile_models.json, get_tile_model_url() API
- game_screen: _add_tile now loads tile CDN model via ModelCache when bound
- Server: ContentGetTileModelsHandler (content.tile_models msg), registered
  in ServiceRegistration; TileModelDto / GetTileModelsResponse added to
  ContentMessages

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>
2026-03-09 13:34:17 -04:00
e815dd708f Feat: load 3D models from card definition assets on game board
Client:
- Added ModelCache autoload (autoloads/ModelCache.gd)
  - Downloads .glb files from CDN via HTTPRequest
  - Disk cache: user://remote_model_cache/<sha256>.glb
  - Memory cache: PackedScene per URL for instant re-instantiation
  - Concurrent requests for same URL queue and share one download
  - Loads via GLTFDocument.append_from_file + generate_scene
- game_screen.gd: _add_unit_mesh now looks up cardDefinitionId
  → ContentCache.get_definition() → finds Model3D asset URL
  → calls ModelCache.load_model() to async replace placeholder geometry
  - Placeholder (sphere/cylinder/box) shown immediately
  - Real model swaps in on download completion
  - Guards against body being freed before model arrives
  - Added _unit_bodies dict for O(1) body lookup
- project.godot: registered ModelCache autoload

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>
2026-03-09 12:37:25 -04:00