mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 05:15:44 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ed9982822 | ||
|
|
dc351a48b8 |
+14
@@ -196,6 +196,20 @@ namespace eagle {
|
||||
/// </summary>
|
||||
private async Task<bool> StreamOneGameAsync(IClientConnectionSubscriber subscriber) {
|
||||
var gameId = subscriber.GameId;
|
||||
|
||||
// Send JoinGameRequest first to ensure game is loaded on server.
|
||||
// For already-started games, this returns GAME_FULL but still triggers
|
||||
// game loading, which prevents "key not found" errors on subsequent commands.
|
||||
var joinRequest = new UpdateStreamRequest {
|
||||
JoinGameRequest = new JoinGameRequest { GameId = gameId }
|
||||
};
|
||||
await DoWithStreamingCall(async (sc) => {
|
||||
await sc.RequestStream.WriteAsync(joinRequest);
|
||||
_remoteEagleClientLogger.LogLine(
|
||||
$"[SUBSCRIBE] Sent JoinGameRequest for game {gameId} to ensure game is loaded");
|
||||
return true;
|
||||
});
|
||||
|
||||
var streamGameRequest = new StreamGameRequest {
|
||||
GameId = gameId,
|
||||
UnfilteredResultCount = subscriber.LastUnfilteredResultCount
|
||||
|
||||
@@ -778,6 +778,11 @@ class GamesManager(
|
||||
token: Long
|
||||
): Unit =
|
||||
this.synchronized {
|
||||
// Lazy load: ensure game is in memory before processing command
|
||||
EagleRequire.clientRequire(
|
||||
ensureGameLoaded(gameId),
|
||||
s"No game found with ID ${gameId.toHexString}"
|
||||
)
|
||||
val _ = synchronizedHandlePostResults(
|
||||
gameControllerInfos(gameId).controller
|
||||
.postHumanCommand(
|
||||
@@ -802,6 +807,11 @@ class GamesManager(
|
||||
index: Int,
|
||||
roll: Option[Int]
|
||||
): Unit = this.synchronized {
|
||||
// Lazy load: ensure game is in memory before processing command
|
||||
EagleRequire.clientRequire(
|
||||
ensureGameLoaded(eagleGameId),
|
||||
s"No game found with ID ${eagleGameId.toHexString}"
|
||||
)
|
||||
// FIXME: need to verify username match
|
||||
SimpleTimedLogger
|
||||
.fileLogger(eagleGameId, "timings")
|
||||
@@ -831,6 +841,11 @@ class GamesManager(
|
||||
placementCommands: Vector[ShardokPlacementCommand],
|
||||
shardokToken: Long
|
||||
): Unit = this.synchronized {
|
||||
// Lazy load: ensure game is in memory before processing command
|
||||
EagleRequire.clientRequire(
|
||||
ensureGameLoaded(eagleGameId),
|
||||
s"No game found with ID ${eagleGameId.toHexString}"
|
||||
)
|
||||
// FIXME: need to verify username match
|
||||
shardokClient.postPlacementCommands(
|
||||
eagleGameId = eagleGameId,
|
||||
@@ -987,6 +1002,8 @@ class GamesManager(
|
||||
gameId = gameId
|
||||
)
|
||||
case None =>
|
||||
// Game not in lobby - try to load it (useful for reconnection scenarios)
|
||||
ensureGameLoaded(gameId)
|
||||
JoinGameResponse(
|
||||
JoinGameResult.GAME_FULL_JOIN_GAME_RESULT,
|
||||
gameId = gameId
|
||||
|
||||
Reference in New Issue
Block a user