Calendar and results-page Stärken work during a running career

Found with the debug log and savegames of a real session:

- Calendar: it read the memory copies of the season origin and day,
  which hold only the day the game was loaded or saved, and refused
  from the first kickoff on ("saved native season cursor disagrees").
  It now uses the live values, as the reschedule code does. This also
  fixes "Spiel verlegen".
- Stärken: the guard of dispatch_strengths required a desk stage, but
  the turn driver marks the running turn as Failed (replay guard) for
  its whole duration, so Stärken could never open from the live
  overview or the end-of-phase results page; the failed handover then
  left the other pages with stale owners and the match stuck. The
  guard now accepts the running turn while a live overview is open.
- Tests: calendar after a kickoff; live overview handovers on the
  phase results page.

Refs #71, #73.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-11-05 08:28:45 +01:00
1 parent f12857414e
commit 7cfc8267b6
4 files changed
+61 -8

No files matched your search

+5 -1
View File
@@ -2352,13 +2352,17 @@ std::optional<CareerSession::StrengthsDispatch> CareerSession::dispatch_strength
const ui::StrengthsRequest& request,uint64_t& revision,std::string& error,
const TransferOfferTeamInfoPresenter& team_info,bool family_transition) {
error.clear();const auto& id=request.identity;const bool opening=request.kind==ui::StrengthsAction::open;
// The turn driver marks the claimed turn as Failed until it completes (a guard against replaying
// a half-played turn), so inside the running matchday the stage is not a desk. The Stärken page
// of the live overview (G key, results page after a phase) belongs to that running turn.
const bool running_turn=live_overview_owner_.has_value()&&turn_driver_.stage==TurnDriver::Stage::Failed;
if(league_family_teaminfo_active_||strengths_dispatch_active_||revision==UINT64_MAX||id.revision!=revision||id.sequence==UINT64_MAX||
id.manager<0||id.manager>3||!g_.memory.has(::bmh::layout::ActiveManager)||g_.memory.u8(::bmh::layout::ActiveManager)!=id.manager||
size_t(id.manager)>=g_.manager_teams.size()||id.runtime_club!=g_.manager_teams[size_t(id.manager)]||
id.runtime_club<0||size_t(id.runtime_club)>=g_.club_ids.size()||
id.club_identity!=int(g_.club_ids[size_t(id.runtime_club)])||id.day_counter!=g_.date||
id.league<0||id.league>8||career_complete()||
(turn_driver_.stage!=TurnDriver::Stage::MatchdayDesks&&turn_driver_.stage!=TurnDriver::Stage::SeasonEndDesk)||
(turn_driver_.stage!=TurnDriver::Stage::MatchdayDesks&&turn_driver_.stage!=TurnDriver::Stage::SeasonEndDesk&&!running_turn)||
pending_offer_dispatch_active_||market_dispatch_active_||calendar_advance_active_||league_pairings_draft_||
league_pairings_dispatch_active_||transfer_offer_editor_||manager_join_||contract_quote_||
stadium_.investment||stadium_.tip||stadium_.periphery_quote||top_scorers_owner_||top_scorers_dispatch_active_ || stadium_.block_expansion||other_games_owner_||other_games_dispatch_active_) {
+7 -6
View File
@@ -24,12 +24,13 @@ void require_memory(const GameState& game, uint32_t address) {
CalendarState calendar_from_game(const GameState& game, const LeImage& executable) {
if (!executable.contains(::bmh::layout::CalendarState_CalendarFromGame_ExecutableField) || !executable.contains(::bmh::layout::CalendarState_CalendarFromGame_ExecutableField2))
throw FormatError("calendar: missing executable month lengths");
require_memory(game, ::bmh::layout::CalendarState_FormatError_RuntimeField3);
require_memory(game, ::bmh::layout::DaysIntoSeason);
const uint32_t native_start = game.memory.u16(::bmh::layout::CalendarState_FormatError_RuntimeField3);
const int native_current = game.memory.u16(::bmh::layout::DaysIntoSeason);
if (game.date < native_start || game.date - native_start != uint32_t(native_current))
throw FormatError("calendar: saved native season cursor disagrees with current date");
// The season origin and the day of the season are the live values of the game. Their copies in
// the memory image hold only the day the game was loaded or saved; they are not kept up to date
// while the career runs, so reading them failed from the first kickoff on.
const uint32_t native_start = game.season_start;
const int native_current = game.season_day();
if (game.date < native_start || native_current < 0)
throw FormatError("calendar: the season origin lies after the current date");
const DeskDate first_native_date = desk_date(native_start, executable);
if (first_native_date.month != 7 || first_native_date.day < 1 || first_native_date.day > 7)
throw FormatError("calendar: native season start is outside the first July week");
+7 -1
View File
@@ -315,8 +315,14 @@ void calendar_projection_tests(const LeImage& exe) {
"saved calendar mask 0xa2594 clears effective bit 0x10");
auto malformed = calendar_fixture(exe,0,0);
malformed.memory.set16(::bmh::layout::CalendarState_FormatError_RuntimeField3,1);
malformed.season_start = 5; // the origin of the season lies after the current date
rejected([&]{ calendar_from_game(malformed,exe); });
// the memory copies of origin and day hold only the day the game was loaded: after a kickoff the
// live values rule (this failed the calendar from the first kickoff on)
auto advanced = calendar_fixture(exe,0,0);
advanced.date = 24;
check(calendar_from_game(advanced,exe).current_day == 24,
"the calendar follows the live day of the season, not the load-day copy in memory");
auto outside = calendar_fixture(exe,0,0);
outside.date = 365;
rejected([&]{ calendar_from_game(outside,exe); });