Fix 3 multiplayer bugs: type error, reconnect, lobby count
- game_screen.gd: fix Parser Error on line 270 — use 'as Environment' cast instead of ': Variant' annotation for WorldEnvironment.environment - Game.gd: auto-resend game.ready on auth_success reconnect so the game session is restored when the WebSocket reconnects mid-game - lobby_browser_row.gd: show real N/Max player count instead of hardcoded "1/2" / "2/2" - CustomLobbyDto: add MaxPlayers, CurrentPlayerCount, GameMode, TeamCount - GameListCustomLobbiesHandler: compute currentPlayerCount from GuestAccountId + AdditionalPlayersJson; pass new fields to DTO 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:
@@ -622,7 +622,11 @@ public sealed record CustomLobbyDto(
|
||||
bool HasGuest,
|
||||
string? GuestDisplayName,
|
||||
CustomRulesDto Rules,
|
||||
DateTimeOffset CreatedAt);
|
||||
DateTimeOffset CreatedAt,
|
||||
int MaxPlayers = 2,
|
||||
int CurrentPlayerCount = 1,
|
||||
string GameMode = "FFA",
|
||||
int TeamCount = 1);
|
||||
|
||||
/// <summary>Summary of an in-progress custom game, shown in the Active Games browser.</summary>
|
||||
public sealed record ActiveLobbyDto(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace SOR.Game.Handlers;
|
||||
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SOR.Database.Contexts;
|
||||
using SOR.Database.Enums;
|
||||
@@ -72,7 +73,23 @@ internal sealed class GameListCustomLobbiesHandler : GameHandlerBase, IMessageHa
|
||||
.Select(a => new { a.Id, Name = a.DisplayName ?? a.UserName ?? a.Id.ToString() })
|
||||
.ToDictionaryAsync(a => a.Id, a => a.Name, ct);
|
||||
|
||||
var dtos = lobbies.Select(l => new CustomLobbyDto(
|
||||
var dtos = lobbies.Select(l =>
|
||||
{
|
||||
var additionalCount = 0;
|
||||
if (l.AdditionalPlayersJson is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var arr = JsonSerializer.Deserialize<JsonElement[]>(l.AdditionalPlayersJson);
|
||||
additionalCount = arr?.Length ?? 0;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
var currentPlayerCount = 1
|
||||
+ (l.GuestAccountId.HasValue ? 1 : 0)
|
||||
+ additionalCount;
|
||||
|
||||
return new CustomLobbyDto(
|
||||
LobbyId : l.Id,
|
||||
LobbyName : l.Name,
|
||||
HostAccountId : l.HostAccountId,
|
||||
@@ -101,7 +118,12 @@ internal sealed class GameListCustomLobbiesHandler : GameHandlerBase, IMessageHa
|
||||
MpBuff : l.MpBuffOverride ?? GameRules.Default.MpBuff,
|
||||
StartingRandomTilePct : l.StartingRandomTilePctOverride ?? GameRules.Default.StartingRandomTilePct,
|
||||
HasPassword : l.Password != null),
|
||||
CreatedAt : l.CreatedAt));
|
||||
CreatedAt : l.CreatedAt,
|
||||
MaxPlayers : l.MaxPlayers,
|
||||
CurrentPlayerCount : currentPlayerCount,
|
||||
GameMode : l.GameMode,
|
||||
TeamCount : l.TeamCount);
|
||||
});
|
||||
|
||||
return ServerMessage.Reply("game.custom.list.ack", message.Seq,
|
||||
new ListCustomLobbiesResponse(
|
||||
|
||||
Reference in New Issue
Block a user