Compare commits

...
Author SHA1 Message Date
adminandClaude Opus 4.5 6bd859c2eb Ensure game is loaded before processing commands
Add ensureGameLoaded() calls to postCommand, postShardokCommand, and
postPlacementCommands. This handles the case where a command arrives
before the game subscription has loaded the game into memory.

This is cheap (just a map contains check) if the game is already loaded,
but prevents "key not found" errors when commands arrive before or
without a subscription.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 17:19:57 -08:00
@@ -778,6 +778,12 @@ class GamesManager(
token: Long
): Unit =
this.synchronized {
// Lazy load: ensure game is in memory before processing command
// This handles the case where a command arrives before subscription after reconnect
EagleRequire.clientRequire(
ensureGameLoaded(gameId),
s"No game found with ID ${gameId.toHexString}"
)
val _ = synchronizedHandlePostResults(
gameControllerInfos(gameId).controller
.postHumanCommand(
@@ -802,6 +808,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 +842,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,