mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 21:35:42 +00:00
fix-swap-model-stale-state
Two related bugs in EagleGameController could leave the UI pointing at provinces that the model no longer considers actionable: 1. SwapModel's early return at the "still have commands" check skipped the swap unconditionally whenever both the old and new model had any commands. When a refresh arrived after a phase advance, the controllers (mapController.SelectedProvinceId, _commandPanelController, mapController.ProvincesWithCommands, etc.) kept pointing at the old provinces, but _currentModel.CommandToken in the model layer had already advanced. A subsequent commit then posted a stale province with the freshly-advanced token, producing "Attempted to select province N out of TreeSet(...)" on the server. Tighten the early return to only skip when the available province set is identical between the two models. If the set has changed, we must swap so stale UI references get cleared. 2. NextActiveProvinceKeyPair used .First(predicate) to look up the suggested province, which throws InvalidOperationException when no element matches. This can happen when SuggestedProvinceId lags AvailableCommandsByProvince by a refresh, and the throw aborts SwapModel partway through — leaving a half-updated UI behind. Switch to TryGetValue with a fallback to the first available province. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The file is empty.
Languages
Scala
44.5%
C++
19.9%
C#
16.6%
Starlark
10.1%
Go
3.5%
Other
5.3%