diff --git a/Client/origin-client/autoloads/ModelCache.gd b/Client/origin-client/autoloads/ModelCache.gd index 2d4df97..57694f1 100644 --- a/Client/origin-client/autoloads/ModelCache.gd +++ b/Client/origin-client/autoloads/ModelCache.gd @@ -11,7 +11,12 @@ extends Node ## user://remote_model_cache/.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: diff --git a/Server/src/SOR.Game/Abilities/AbilitySystem.cs b/Server/src/SOR.Game/Abilities/AbilitySystem.cs index 4e08077..3f4c48b 100644 --- a/Server/src/SOR.Game/Abilities/AbilitySystem.cs +++ b/Server/src/SOR.Game/Abilities/AbilitySystem.cs @@ -1411,6 +1411,15 @@ public static class AbilitySystem IsExactSelfFilter => ctx.Source is not null && card.InstanceId == ctx.Source.InstanceId, HealthBelowFilter hbf => (card.CurrentHealth ?? 0) < hbf.N, HealthAboveFilter haf => (card.CurrentHealth ?? 0) > haf.N, + IsAdjacentToSourceFilter => + ctx.Source is FieldCard srcAdj && srcAdj.Position.HasValue && + card is FieldCard adjTgt && adjTgt.Position.HasValue && + srcAdj.Position.Value.IsOrthogonallyAdjacentTo(adjTgt.Position.Value), + WithinRangeFilter wrf => + ctx.Source is FieldCard srcWr && srcWr.Position.HasValue && + card is FieldCard wrTgt && wrTgt.Position.HasValue && + srcWr.Position.Value.ManhattanDistance(wrTgt.Position.Value) >= wrf.Min && + srcWr.Position.Value.ManhattanDistance(wrTgt.Position.Value) <= wrf.Max, _ => true, }; diff --git a/Server/src/SOR.Host/Program.cs b/Server/src/SOR.Host/Program.cs index 5ec0a6c..5a2296c 100644 --- a/Server/src/SOR.Host/Program.cs +++ b/Server/src/SOR.Host/Program.cs @@ -127,6 +127,15 @@ builder.Services.AddNats(configureOpts: opts => // TODO: add dependency health checks (Redis, NATS, Postgres) per service. builder.Services.AddHealthChecks(); +// ── CDN proxy ───────────────────────────────────────────────────────────────── +// Proxies CDN asset requests and adds CORS headers. +// Required for web (browser) clients: Ceph RadosGW (cdn.aeternalisgames.com) does not +// emit Access-Control-Allow-Origin, so browsers block direct CDN fetches. +// The web client routes model requests through https://hub.aeternalisgames.com/cdn/… +// instead of https://cdn.aeternalisgames.com/… to work around the restriction. +var cdnProxyBase = (builder.Configuration["Cdn:PublicBaseUrl"] ?? "https://cdn.aeternalisgames.com").TrimEnd('/'); +builder.Services.AddHttpClient("cdn"); + // ── Networking transports ───────────────────────────────────────────────────── // These are the CONCRETE implementations of the networking abstractions. // This section is the "wiring" point. To swap a transport, change only here. @@ -200,6 +209,17 @@ if (IsEnabled("auth")) // Health check endpoint: Kubernetes probes GET /health to check liveness. app.MapHealthChecks("/health"); +// CDN asset proxy: adds CORS so browser web clients can fetch models/assets. +app.MapGet("/cdn/{**path}", async (string path, HttpContext httpCtx, IHttpClientFactory factory) => +{ + using var up = await factory.CreateClient("cdn").GetAsync($"{cdnProxyBase}/{path}"); + httpCtx.Response.Headers["Access-Control-Allow-Origin"] = "*"; + httpCtx.Response.StatusCode = (int)up.StatusCode; + httpCtx.Response.ContentType = + up.Content.Headers.ContentType?.MediaType ?? "application/octet-stream"; + await up.Content.CopyToAsync(httpCtx.Response.Body); +}); + // ── RUN ─────────────────────────────────────────────────────────────────────── Log.Information("SOR Host starting. Services: {Services}", rawServices);