mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 05:35:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04895c65bc | ||
|
|
e1e8c0abe7 | ||
|
|
2b8a32b6e0 |
@@ -348,6 +348,10 @@ namespace eagle {
|
||||
case GameUpdate.GameUpdateDetailsOneofCase.ShardokActionResultResponse:
|
||||
var specResponse = updateItem.ShardokActionResultResponse.ShardokGameResponses;
|
||||
|
||||
// Collect ended games to remove AFTER the UI callback, so the UI
|
||||
// can see the final battle results before the models are removed.
|
||||
var endedGames = new List<ShardokGameId>();
|
||||
|
||||
foreach (var oneResponse in specResponse) {
|
||||
if (!_currentModel.ShardokGameModels.TryGetValue(
|
||||
oneResponse.ShardokGameId,
|
||||
@@ -388,14 +392,32 @@ namespace eagle {
|
||||
_currentModel.ShardokGameModels[oneResponse.ShardokGameId] =
|
||||
shardokGameModel;
|
||||
} else {
|
||||
// Game ended - remove from active models so UI knows battle is over
|
||||
_currentModel.ShardokGameModels.TryRemove(
|
||||
oneResponse.ShardokGameId,
|
||||
out _);
|
||||
_shardokResultCounts.TryRemove(oneResponse.ShardokGameId, out _);
|
||||
// Game ended - mark for removal after UI callback
|
||||
_currentModel.ShardokGameModels[oneResponse.ShardokGameId] =
|
||||
shardokGameModel;
|
||||
endedGames.Add(oneResponse.ShardokGameId);
|
||||
}
|
||||
}
|
||||
|
||||
// Invoke UI callback BEFORE removing ended games, so the UI can
|
||||
// see the final battle results (with GameStatus = Victory/Defeat)
|
||||
if (UpdateAction != null) UpdateAction.Invoke(_currentModel);
|
||||
|
||||
// Now remove ended games from active models
|
||||
foreach (var endedGameId in endedGames) {
|
||||
_currentModel.ShardokGameModels.TryRemove(endedGameId, out _);
|
||||
_shardokResultCounts.TryRemove(endedGameId, out _);
|
||||
|
||||
// Also remove from ShardokBattles. We defer this cleanup to here
|
||||
// (rather than in RemovedBattleIds processing) to ensure Shardok
|
||||
// results with final battle turns are processed before cleanup.
|
||||
for (int i = 0; i < _currentModel.ShardokBattles.Count; i++) {
|
||||
if (_currentModel.ShardokBattles[i].ShardokGameId == endedGameId) {
|
||||
_currentModel.ShardokBattles.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GameUpdate.GameUpdateDetailsOneofCase.StreamingTextResponse:
|
||||
@@ -837,12 +859,12 @@ namespace eagle {
|
||||
}
|
||||
_shardokResultCounts.TryRemove(rb, out _);
|
||||
|
||||
for (int i = 0; i < _currentModel.ShardokBattles.Count; i++) {
|
||||
if (_currentModel.ShardokBattles[i].ShardokGameId == rb) {
|
||||
_currentModel.ShardokBattles.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// NOTE: We intentionally do NOT remove from ShardokBattles here.
|
||||
// Shardok results (with the final battle turns) may arrive AFTER this
|
||||
// Eagle update. If we remove from ShardokBattles now, MakeGameModel()
|
||||
// would return null and the final Shardok results would be dropped.
|
||||
// The cleanup from ShardokBattles happens when processing the Shardok
|
||||
// update with "game over" status (see ShardokActionResultResponse handler).
|
||||
}
|
||||
|
||||
foreach (BattalionType bt in entry.NewBattalionTypes) {
|
||||
|
||||
+12
-13
@@ -188,20 +188,19 @@ case class HumanPlayerClientConnectionState(
|
||||
if knownShardokResults.isEmpty then this
|
||||
else this.enqueueShardokResults(knownShardokResults)
|
||||
|
||||
val newHistoryClient = afterShardok.withNewCount(
|
||||
unfilteredCountAfter = unfilteredCountAfter
|
||||
// Always send the count update to the client, even when filteredResults is empty.
|
||||
// Previously, we returned early when filteredResults.isEmpty, which advanced the
|
||||
// server's tracking without notifying the client. This caused sync mismatches:
|
||||
// the server thought the client was up-to-date, but the client never received
|
||||
// the new count. This was particularly problematic after battles ended, when
|
||||
// AI turns might be filtered out (not visible to the human player).
|
||||
afterShardok.afterSendingResults(
|
||||
availableCommands = availableCommands,
|
||||
startingState = None,
|
||||
filteredResults = filteredResults,
|
||||
unfilteredCountAfter = unfilteredCountAfter,
|
||||
serverGameStatus = serverGameStatus
|
||||
)
|
||||
|
||||
if filteredResults.isEmpty then newHistoryClient
|
||||
else
|
||||
newHistoryClient
|
||||
.afterSendingResults(
|
||||
availableCommands = availableCommands,
|
||||
startingState = None,
|
||||
filteredResults = filteredResults,
|
||||
unfilteredCountAfter = unfilteredCountAfter,
|
||||
serverGameStatus = serverGameStatus
|
||||
)
|
||||
}
|
||||
|
||||
private def withNewCount(
|
||||
|
||||
Reference in New Issue
Block a user