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>
This commit is contained in:
@@ -11,7 +11,12 @@ extends Node
|
||||
## user://remote_model_cache/<sha256>.bin
|
||||
## so subsequent app launches skip the download.
|
||||
|
||||
const _CACHE_DIR := "user://remote_model_cache"
|
||||
const _CACHE_DIR := "user://remote_model_cache"
|
||||
|
||||
# On web exports, direct CDN fetches are blocked by CORS (Ceph RadosGW doesn't send
|
||||
# Access-Control-Allow-Origin). Route through the game server proxy instead.
|
||||
const _CDN_BASE := "https://cdn.aeternalisgames.com"
|
||||
const _PROXY_BASE := "https://hub.aeternalisgames.com/cdn"
|
||||
|
||||
# url (String) → PackedScene or null (null means "tried and failed")
|
||||
static var _mem: Dictionary = {}
|
||||
@@ -59,8 +64,17 @@ func load_model(url: String, callback: Callable) -> void:
|
||||
_download(url, disk)
|
||||
|
||||
|
||||
## Returns the URL to actually fetch — on web, rewrites CDN URLs to go through
|
||||
## the game server proxy so CORS headers are added.
|
||||
func _fetch_url(url: String) -> String:
|
||||
if OS.has_feature("web") and url.begins_with(_CDN_BASE + "/"):
|
||||
return _PROXY_BASE + "/" + url.substr(_CDN_BASE.length() + 1)
|
||||
return url
|
||||
|
||||
|
||||
func _download(url: String, disk: String) -> void:
|
||||
print("ModelCache: downloading — %s" % url)
|
||||
var fetch := _fetch_url(url)
|
||||
print("ModelCache: downloading — %s" % fetch)
|
||||
var http := HTTPRequest.new()
|
||||
http.body_size_limit = -1 # unlimited
|
||||
add_child(http)
|
||||
@@ -120,9 +134,9 @@ func _download(url: String, disk: String) -> void:
|
||||
cb.call(packed.instantiate() if packed != null else null)
|
||||
)
|
||||
|
||||
var err := http.request(url)
|
||||
var err := http.request(fetch)
|
||||
if err != OK:
|
||||
push_warning("ModelCache: request() error %d — %s" % [err, url])
|
||||
push_warning("ModelCache: request() error %d — %s" % [err, fetch])
|
||||
var callbacks: Array = _pending.get(url, [])
|
||||
_pending.erase(url)
|
||||
for cb: Callable in callbacks:
|
||||
|
||||
Reference in New Issue
Block a user