Commit Graph
7 Commits
Author SHA1 Message Date
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