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))
|
print("[Game] <<< game.ready.ack ", JSON.stringify(p))
|
||||||
var d := p as Dictionary
|
var d := p as Dictionary
|
||||||
if d.get("status", "") == "AlreadyStarted":
|
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(),
|
_fetch_state(),
|
||||||
func(code: String, msg: String) -> void:
|
func(code: String, msg: String) -> void:
|
||||||
print("[Game] ERR game.ready code=", code, " msg=", msg))
|
print("[Game] ERR game.ready code=", code, " msg=", msg))
|
||||||
|
|||||||
@@ -520,16 +520,21 @@ func _clear_stars() -> void:
|
|||||||
func _fetch_skybox() -> void:
|
func _fetch_skybox() -> void:
|
||||||
Network.request("content.get_skybox_config", {},
|
Network.request("content.get_skybox_config", {},
|
||||||
func(_type: String, resp: Variant) -> void:
|
func(_type: String, resp: Variant) -> void:
|
||||||
var d := resp as Dictionary
|
var d := resp as Dictionary
|
||||||
var skybox : Dictionary = d.get("skybox", null)
|
# Use a Variant to safely detect null before treating as Dictionary.
|
||||||
if skybox == null:
|
var skybox_raw : Variant = d.get("skybox", null)
|
||||||
return # no active skybox — keep procedural sky
|
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 cdn_path : String = str(skybox.get("cdnPath", ""))
|
||||||
var is_animated : bool = bool(skybox.get("isAnimated", false))
|
var is_animated : bool = bool(skybox.get("isAnimated", false))
|
||||||
var frame_count : int = int(skybox.get("frameCount", 1))
|
var frame_count : int = int(skybox.get("frameCount", 1))
|
||||||
var fps : float = float(skybox.get("fps", 24.0))
|
var fps : float = float(skybox.get("fps", 24.0))
|
||||||
if cdn_path.is_empty():
|
if cdn_path.is_empty():
|
||||||
|
push_warning("[GameScreen] Skybox has empty cdnPath — skipping.")
|
||||||
return
|
return
|
||||||
|
print("[GameScreen] Loading CDN skybox: animated=%s url=%s" % [is_animated, cdn_path])
|
||||||
if is_animated:
|
if is_animated:
|
||||||
_load_animated_skybox(cdn_path, frame_count, fps)
|
_load_animated_skybox(cdn_path, frame_count, fps)
|
||||||
else:
|
else:
|
||||||
@@ -547,7 +552,9 @@ func _load_static_skybox(url: String) -> void:
|
|||||||
push_warning("[GameScreen] Failed to download skybox: HTTP %d" % code)
|
push_warning("[GameScreen] Failed to download skybox: HTTP %d" % code)
|
||||||
return
|
return
|
||||||
var img := Image.new()
|
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
|
var err : int
|
||||||
if ext in ["jpg", "jpeg"]:
|
if ext in ["jpg", "jpeg"]:
|
||||||
err = img.load_jpg_from_buffer(data)
|
err = img.load_jpg_from_buffer(data)
|
||||||
@@ -556,13 +563,14 @@ func _load_static_skybox(url: String) -> void:
|
|||||||
else:
|
else:
|
||||||
err = img.load_png_from_buffer(data)
|
err = img.load_png_from_buffer(data)
|
||||||
if err != OK:
|
if err != OK:
|
||||||
push_warning("[GameScreen] Failed to decode skybox image")
|
push_warning("[GameScreen] Failed to decode skybox image (ext=%s)" % ext)
|
||||||
return
|
return
|
||||||
var tex := ImageTexture.create_from_image(img)
|
var tex := ImageTexture.create_from_image(img)
|
||||||
var mat := PanoramaSkyMaterial.new()
|
var mat := PanoramaSkyMaterial.new()
|
||||||
mat.panorama = tex
|
mat.panorama = tex
|
||||||
if is_instance_valid(_skybox_sky):
|
if is_instance_valid(_skybox_sky):
|
||||||
_skybox_sky.sky_material = mat)
|
_skybox_sky.sky_material = mat
|
||||||
|
print("[GameScreen] CDN skybox applied."))
|
||||||
http.request(url)
|
http.request(url)
|
||||||
|
|
||||||
func _load_animated_skybox(base_url: String, frame_count: int, fps: float) -> void:
|
func _load_animated_skybox(base_url: String, frame_count: int, fps: float) -> void:
|
||||||
|
|||||||
@@ -190,8 +190,10 @@ public sealed record RejectRuleSuggestionRequest(Guid LobbyId);
|
|||||||
|
|
||||||
// ── Responses ─────────────────────────────────────────────────────────────────
|
// ── Responses ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
public sealed record GameReadyResponse(Guid SessionId, string Status);
|
public sealed record GameReadyResponse(
|
||||||
// Status: "WaitingForOpponent" | "AlreadyStarted" | "Started"
|
Guid SessionId,
|
||||||
|
string Status, // "WaitingForOpponent" | "AlreadyStarted" | "Started"
|
||||||
|
string? OpponentDisplayName = null); // populated only when Status == "AlreadyStarted"
|
||||||
|
|
||||||
public sealed record GameGetStateResponse(GameStateDto State);
|
public sealed record GameGetStateResponse(GameStateDto State);
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ internal sealed class GameReadyHandler : GameHandlerBase, IMessageHandler
|
|||||||
{
|
{
|
||||||
private readonly IMessageSerializer _serializer;
|
private readonly IMessageSerializer _serializer;
|
||||||
private readonly GameDbContext _gameDb;
|
private readonly GameDbContext _gameDb;
|
||||||
|
private readonly SorIdentityDbContext _identityDb;
|
||||||
private readonly CollectionDbContext _collectionDb;
|
private readonly CollectionDbContext _collectionDb;
|
||||||
private readonly CatalogDbContext _catalogDb;
|
private readonly CatalogDbContext _catalogDb;
|
||||||
private readonly IClientPush _clientPush;
|
private readonly IClientPush _clientPush;
|
||||||
@@ -27,12 +28,14 @@ internal sealed class GameReadyHandler : GameHandlerBase, IMessageHandler
|
|||||||
public GameReadyHandler(
|
public GameReadyHandler(
|
||||||
IMessageSerializer serializer,
|
IMessageSerializer serializer,
|
||||||
GameDbContext gameDb,
|
GameDbContext gameDb,
|
||||||
|
SorIdentityDbContext identityDb,
|
||||||
CollectionDbContext collectionDb,
|
CollectionDbContext collectionDb,
|
||||||
CatalogDbContext catalogDb,
|
CatalogDbContext catalogDb,
|
||||||
IClientPush clientPush)
|
IClientPush clientPush)
|
||||||
{
|
{
|
||||||
_serializer = serializer;
|
_serializer = serializer;
|
||||||
_gameDb = gameDb;
|
_gameDb = gameDb;
|
||||||
|
_identityDb = identityDb;
|
||||||
_collectionDb = collectionDb;
|
_collectionDb = collectionDb;
|
||||||
_catalogDb = catalogDb;
|
_catalogDb = catalogDb;
|
||||||
_clientPush = clientPush;
|
_clientPush = clientPush;
|
||||||
@@ -71,8 +74,19 @@ internal sealed class GameReadyHandler : GameHandlerBase, IMessageHandler
|
|||||||
if (session.Status == GameSessionStatus.Active)
|
if (session.Status == GameSessionStatus.Active)
|
||||||
{
|
{
|
||||||
await _gameDb.Database.CommitTransactionAsync(ct);
|
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,
|
return ServerMessage.Reply("game.ready.ack", message.Seq,
|
||||||
new GameReadyResponse(session.Id, "AlreadyStarted"));
|
new GameReadyResponse(session.Id, "AlreadyStarted", oppName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.Status != GameSessionStatus.Initializing)
|
if (session.Status != GameSessionStatus.Initializing)
|
||||||
|
|||||||
Reference in New Issue
Block a user