Fix rejoin opponent GUID + CDN skybox null/logging
- GameReadyResponse: add OpponentDisplayName? (populated only on AlreadyStarted) - GameReadyHandler: inject SorIdentityDbContext; fetch opponent display name when session is already Active so rejoining clients get the name immediately - Game.gd: on AlreadyStarted ack, read opponentDisplayName and set Game.opponent_name before calling _fetch_state() — fixes opponent showing as GUID on rejoin - game_screen.gd: replace typed-Dictionary null assignment with safe Variant check to avoid silent GDScript coercion when no skybox is configured; strip query-string from URL before extension check (_fetch_skybox); add print logging throughout CDN skybox flow to surface download/decode failures 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:
@@ -177,6 +177,10 @@ func send_ready() -> void:
|
||||
print("[Game] <<< game.ready.ack ", JSON.stringify(p))
|
||||
var d := p as Dictionary
|
||||
if d.get("status", "") == "AlreadyStarted":
|
||||
# Restore opponent name on rejoin — the server includes it in the ack.
|
||||
var oname: String = str(d.get("opponentDisplayName", ""))
|
||||
if not oname.is_empty():
|
||||
opponent_name = oname
|
||||
_fetch_state(),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[Game] ERR game.ready code=", code, " msg=", msg))
|
||||
|
||||
@@ -520,16 +520,21 @@ func _clear_stars() -> void:
|
||||
func _fetch_skybox() -> void:
|
||||
Network.request("content.get_skybox_config", {},
|
||||
func(_type: String, resp: Variant) -> void:
|
||||
var d := resp as Dictionary
|
||||
var skybox : Dictionary = d.get("skybox", null)
|
||||
if skybox == null:
|
||||
return # no active skybox — keep procedural sky
|
||||
var d := resp as Dictionary
|
||||
# Use a Variant to safely detect null before treating as Dictionary.
|
||||
var skybox_raw : Variant = d.get("skybox", null)
|
||||
if skybox_raw == null or not skybox_raw is Dictionary:
|
||||
print("[GameScreen] No active skybox configured — keeping procedural sky.")
|
||||
return
|
||||
var skybox := skybox_raw as Dictionary
|
||||
var cdn_path : String = str(skybox.get("cdnPath", ""))
|
||||
var is_animated : bool = bool(skybox.get("isAnimated", false))
|
||||
var frame_count : int = int(skybox.get("frameCount", 1))
|
||||
var fps : float = float(skybox.get("fps", 24.0))
|
||||
if cdn_path.is_empty():
|
||||
push_warning("[GameScreen] Skybox has empty cdnPath — skipping.")
|
||||
return
|
||||
print("[GameScreen] Loading CDN skybox: animated=%s url=%s" % [is_animated, cdn_path])
|
||||
if is_animated:
|
||||
_load_animated_skybox(cdn_path, frame_count, fps)
|
||||
else:
|
||||
@@ -547,7 +552,9 @@ func _load_static_skybox(url: String) -> void:
|
||||
push_warning("[GameScreen] Failed to download skybox: HTTP %d" % code)
|
||||
return
|
||||
var img := Image.new()
|
||||
var ext := url.get_extension().to_lower()
|
||||
# Strip query string before checking extension (CDN URLs may include ?v=… etc.)
|
||||
var clean_url := url.split("?")[0]
|
||||
var ext := clean_url.get_extension().to_lower()
|
||||
var err : int
|
||||
if ext in ["jpg", "jpeg"]:
|
||||
err = img.load_jpg_from_buffer(data)
|
||||
@@ -556,13 +563,14 @@ func _load_static_skybox(url: String) -> void:
|
||||
else:
|
||||
err = img.load_png_from_buffer(data)
|
||||
if err != OK:
|
||||
push_warning("[GameScreen] Failed to decode skybox image")
|
||||
push_warning("[GameScreen] Failed to decode skybox image (ext=%s)" % ext)
|
||||
return
|
||||
var tex := ImageTexture.create_from_image(img)
|
||||
var mat := PanoramaSkyMaterial.new()
|
||||
mat.panorama = tex
|
||||
if is_instance_valid(_skybox_sky):
|
||||
_skybox_sky.sky_material = mat)
|
||||
_skybox_sky.sky_material = mat
|
||||
print("[GameScreen] CDN skybox applied."))
|
||||
http.request(url)
|
||||
|
||||
func _load_animated_skybox(base_url: String, frame_count: int, fps: float) -> void:
|
||||
|
||||
@@ -190,8 +190,10 @@ public sealed record RejectRuleSuggestionRequest(Guid LobbyId);
|
||||
|
||||
// ── Responses ─────────────────────────────────────────────────────────────────
|
||||
|
||||
public sealed record GameReadyResponse(Guid SessionId, string Status);
|
||||
// Status: "WaitingForOpponent" | "AlreadyStarted" | "Started"
|
||||
public sealed record GameReadyResponse(
|
||||
Guid SessionId,
|
||||
string Status, // "WaitingForOpponent" | "AlreadyStarted" | "Started"
|
||||
string? OpponentDisplayName = null); // populated only when Status == "AlreadyStarted"
|
||||
|
||||
public sealed record GameGetStateResponse(GameStateDto State);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ internal sealed class GameReadyHandler : GameHandlerBase, IMessageHandler
|
||||
{
|
||||
private readonly IMessageSerializer _serializer;
|
||||
private readonly GameDbContext _gameDb;
|
||||
private readonly SorIdentityDbContext _identityDb;
|
||||
private readonly CollectionDbContext _collectionDb;
|
||||
private readonly CatalogDbContext _catalogDb;
|
||||
private readonly IClientPush _clientPush;
|
||||
@@ -27,12 +28,14 @@ internal sealed class GameReadyHandler : GameHandlerBase, IMessageHandler
|
||||
public GameReadyHandler(
|
||||
IMessageSerializer serializer,
|
||||
GameDbContext gameDb,
|
||||
SorIdentityDbContext identityDb,
|
||||
CollectionDbContext collectionDb,
|
||||
CatalogDbContext catalogDb,
|
||||
IClientPush clientPush)
|
||||
{
|
||||
_serializer = serializer;
|
||||
_gameDb = gameDb;
|
||||
_identityDb = identityDb;
|
||||
_collectionDb = collectionDb;
|
||||
_catalogDb = catalogDb;
|
||||
_clientPush = clientPush;
|
||||
@@ -71,8 +74,19 @@ internal sealed class GameReadyHandler : GameHandlerBase, IMessageHandler
|
||||
if (session.Status == GameSessionStatus.Active)
|
||||
{
|
||||
await _gameDb.Database.CommitTransactionAsync(ct);
|
||||
|
||||
// Fetch the opponent's display name so the client can show it correctly on rejoin.
|
||||
var opponentId = session.PlayerOneAccountId == accountId
|
||||
? session.PlayerTwoAccountId
|
||||
: session.PlayerOneAccountId;
|
||||
var oppName = await _identityDb.Users
|
||||
.AsNoTracking()
|
||||
.Where(a => a.Id == opponentId)
|
||||
.Select(a => a.DisplayName ?? a.UserName ?? a.Id.ToString().Substring(0, 8))
|
||||
.FirstOrDefaultAsync(ct);
|
||||
|
||||
return ServerMessage.Reply("game.ready.ack", message.Seq,
|
||||
new GameReadyResponse(session.Id, "AlreadyStarted"));
|
||||
new GameReadyResponse(session.Id, "AlreadyStarted", oppName));
|
||||
}
|
||||
|
||||
if (session.Status != GameSessionStatus.Initializing)
|
||||
|
||||
Reference in New Issue
Block a user