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:
1 parent
f12857414e
commit
7cfc8267b6
4 files changed
+61
-8
No files matched your search
@@ -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_) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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); });
|
||||
|
||||
@@ -1269,6 +1269,18 @@ void check_calendar_readonly_controller(const std::filesystem::path& data) {
|
||||
check(flow.click(0, 0, true).request == FlowRequest::none, "menu 7 close release is consumed");
|
||||
check(!flow.calendar() && flow.screen_name() == "desktop",
|
||||
"right event8 closes menu 7 and returns to the refreshed desk");
|
||||
// After a kickoff the memory copy of the season day is only the day the game was loaded: the
|
||||
// calendar follows the live day (it was refused from the first kickoff on).
|
||||
ui::DeskRequest kickoff;
|
||||
kickoff.kind = ui::DeskRequestKind::advance_turn;
|
||||
kickoff.manager_slot = int(game.memory.u8(::bmh::layout::ActiveManager));
|
||||
kickoff.revision = revision;
|
||||
std::string kickoff_error;
|
||||
const auto advanced = session->dispatch_kickoff(kickoff, revision, kickoff_error);
|
||||
check(advanced.kind != TurnDeskKind::Failed, "the fixture's first kickoff is played");
|
||||
const auto after_kickoff = ui::calendar_from_game(game, load_le(asset_path(data, "BMH.exe")));
|
||||
check(after_kickoff.current_day == game.season_day() + after_kickoff.leading_days,
|
||||
"the calendar after a kickoff shows the live day of the season");
|
||||
}
|
||||
|
||||
void check_readonly_views(const std::filesystem::path& data) {
|
||||
@@ -4306,6 +4318,36 @@ void check_loaded_lineup(const std::filesystem::path& data, const std::filesyste
|
||||
(state.squad_slots.at(squad.first + 11) & 0x0fff) == (first & 0x0fff);
|
||||
}
|
||||
});
|
||||
// The end-of-phase results page (key slot 1 at the Source phase boundary) is the viewer the
|
||||
// players meet after every match: Spiele -> Stärken -> Spiele -> Tabelle -> close must not strand it.
|
||||
int phase_pages = 0;
|
||||
session.set_phase_results([&](const PhaseResultRequest&, const std::vector<MatchGroup>&, const GameState&) {
|
||||
if (phase_pages >= 2) return;
|
||||
std::string phase_error;
|
||||
auto opened = session.open_phase_results(revision, Image{}, phase_error);
|
||||
if (!opened) return; // a phase of another group or competition: nothing to view here
|
||||
++phase_pages;
|
||||
const auto hop = [&](ui::StrengthsIdentity from, int from_child, int target_child, const char* what) {
|
||||
ui::LeagueFamilyRequest nav;
|
||||
nav.identity = from; nav.kind = ui::LeagueFamilyRequestKind::navigate;
|
||||
nav.from_child = from_child; nav.target_child = target_child;
|
||||
auto page = session.dispatch_phase_results(app::CareerSession::LiveOverviewAction{nav}, revision, phase_error);
|
||||
if (!page) throw std::runtime_error(std::string("phase results ") + what + " failed: " + phase_error);
|
||||
return *page;
|
||||
};
|
||||
ui::StrengthsIdentity at = opened->family_identity;
|
||||
int child = opened->kind == app::CareerSession::LiveOverviewKind::league_table ? 1 : 2;
|
||||
const int path[] = {3, 2, 1, 3, 1, 2};
|
||||
for (const int next : path) {
|
||||
auto page = hop(at, child, next, "handover");
|
||||
at = page.family_identity; child = next;
|
||||
}
|
||||
ui::LeagueFamilyRequest close;
|
||||
close.identity = at; close.kind = ui::LeagueFamilyRequestKind::close;
|
||||
close.from_child = child; close.target_child = 0;
|
||||
auto closed = session.dispatch_phase_results(app::CareerSession::LiveOverviewAction{close}, revision, phase_error);
|
||||
if (!closed || !closed->closed) throw std::runtime_error("phase results page did not close: " + phase_error);
|
||||
});
|
||||
int turns = 0;
|
||||
for (; turns < 8 && (!saw_fixture || turns < 2); ++turns) {
|
||||
ui::DeskRequest request;
|
||||
|
||||
Reference in new issue
Block a user