diff --git a/src/app/controller.cpp b/src/app/controller.cpp index 1028e9f..65c4546 100644 --- a/src/app/controller.cpp +++ b/src/app/controller.cpp @@ -579,7 +579,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu opened.identity.runtime_team!=desk.runtime_club|| opened.identity.day_counter!=desk.day_counter||desk.manager_slot<0|| size_t(desk.manager_slot)>=desk.managers.size()|| - opened.identity.club_identity!=desk.managers[size_t(desk.manager_slot)].club_identity_key) + opened.identity.club_identity!=desk.session_identity_key(size_t(desk.manager_slot))) throw FormatError("other games: stale desktop identity"); flow.show_other_games(std::move(opened),session->preparation_projection(revision),result.desk_action); }); @@ -822,14 +822,14 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu const bool national_source_case=flow.national_friendly_family_active(); const int stable_identity=national_source_case&&flow.desktop()&& owner.manager_slot>=0&&size_t(owner.manager_slot)state().managers.size()? - flow.desktop()->state().managers[size_t(owner.manager_slot)].club_identity_key:-1; + flow.desktop()->state().session_identity_key(size_t(owner.manager_slot)):-1; auto page=OpportunitiesActions(*session).open(owner,revision,underlay,error, national_source_case,stable_identity,[&](ui::OpportunitiesState& opened) { const auto& desk=flow.desktop()->state(); if(opened.identity.manager_slot!=desk.manager_slot||opened.identity.runtime_team!=desk.runtime_club|| opened.identity.day_counter!=desk.day_counter||desk.manager_slot<0|| size_t(desk.manager_slot)>=desk.managers.size()|| - opened.identity.stable_club_identity!=int(desk.managers[size_t(desk.manager_slot)].club_identity_key)) + opened.identity.stable_club_identity!=int(desk.session_identity_key(size_t(desk.manager_slot)))) throw FormatError("opportunities: stale desktop identity"); flow.show_opportunities(std::move(opened),session->preparation_projection(revision),owner); }); @@ -939,7 +939,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu opened.identity.day_counter!=desk.day_counter|| desk.manager_slot<0|| size_t(desk.manager_slot)>=desk.managers.size()|| - opened.identity.club_identity!=desk.managers[size_t(desk.manager_slot)].club_identity_key) + opened.identity.club_identity!=desk.session_identity_key(size_t(desk.manager_slot))) throw FormatError("top scorers: stale desktop identity"); flow.show_top_scorers(std::move(opened),session->preparation_projection(revision),result.desk_action); }); @@ -1321,7 +1321,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu const auto& desk=flow.desktop()->state(); if(!semantic||semantic->identity.manager!=desk.manager_slot||semantic->identity.runtime_club!=desk.runtime_club|| semantic->identity.day_counter!=desk.day_counter||desk.manager_slot<0||size_t(desk.manager_slot)>=desk.managers.size()|| - semantic->identity.club_identity!=desk.managers[size_t(desk.manager_slot)].club_identity_key) + semantic->identity.club_identity!=desk.session_identity_key(size_t(desk.manager_slot))) throw FormatError("strengths: stale desktop identity"); const auto applied=session->dispatch_strengths(*semantic,revision,error); if(!applied)throw FormatError(error.empty()?"league family Strengths entry rejected":error); diff --git a/src/ui/desk_state.cpp b/src/ui/desk_state.cpp index 01b8775..6caaae1 100644 --- a/src/ui/desk_state.cpp +++ b/src/ui/desk_state.cpp @@ -234,6 +234,7 @@ DeskState project(const StaticMemory& memory, const Tables& t, const LeImage& ex d.managers.at(0).club_identity_key = coach->club_identity_key; } if (d.runtime_club < 0 || d.runtime_club >= int(t.name_offsets.size())) throw FormatError("desk: invalid runtime club"); + d.runtime_club_identity = int(t.name_offsets.at(size_t(d.runtime_club))); if (d.national_team && ((!d.options.world && !d.national_coach_takeover) || d.manager_slot != 0 || d.options.managers != 1)) throw FormatError("desk: national team requires one manager and world-mode or source takeover evidence"); diff --git a/src/ui/desk_state.hpp b/src/ui/desk_state.hpp index c818637..8e1e121 100644 --- a/src/ui/desk_state.hpp +++ b/src/ui/desk_state.hpp @@ -63,6 +63,15 @@ struct DeskState { // In a multiplayer career the visible national desk has only the coach in slot 0. std::vector national_return_roster; bool national_team = false; + // Stable name-pool identity of the runtime club (GameState::club_ids): at the national desk that of + // the national team, whereas managers[slot].club_identity_key keeps the home club for the hand-back. + int runtime_club_identity = -1; + // The identity the session's pages carry for this desk's manager (Table, Stärken, ...): the runtime + // club's own identity, so at the national desk that of the national team. + int session_identity_key(size_t slot) const { + return national_team && int(slot) == manager_slot && runtime_club_identity >= 0 + ? runtime_club_identity : managers.at(slot).club_identity_key; + } // SwapManagerSlots2 temporary coach assignment (CoachActive). This can make // a league-only, single-manager career temporarily project team 0x165. bool national_coach_takeover = false; diff --git a/src/ui/desktop.cpp b/src/ui/desktop.cpp index e5f3278..a263a20 100644 --- a/src/ui/desktop.cpp +++ b/src/ui/desktop.cpp @@ -739,8 +739,17 @@ void DesktopScreen::acknowledge(DeskState updated) { Image next_badge = badge_; if ((updated.badge >> 3) != (state_.badge >> 3)) next_badge = load_vga(asset_path(data_ / "W", std::to_string(updated.badge >> 3) + ".VGA")); + // The opponent changes from day to day: its badge sheet (one W file holds eight badges) is + // reloaded with the state, not kept from the day the screen was built. + std::optional next_opponent_badge; + if (updated.next_opponent && *updated.next_opponent >= 0 && updated.next_opponent_badge && + !updated.next_opponent_badge_fallback) { + const int selector = *updated.next_opponent_badge & 0x1ff; + next_opponent_badge = load_vga(asset_path(data_ / "W", std::to_string(selector >> 3) + ".VGA")); + } shortcut_bar_visible_ = updated.shortcut_bar_always || shortcut_bar_edge_toggle_; state_ = std::move(updated); badge_ = std::move(next_badge); + next_opponent_badge_ = std::move(next_opponent_badge); pending_.reset(); last_rejection_.clear(); } void DesktopScreen::acknowledge_mailbox_parent(DeskState updated) { diff --git a/src/ui/preparation_flow.cpp b/src/ui/preparation_flow.cpp index 8c8a78d..8aef4fc 100644 --- a/src/ui/preparation_flow.cpp +++ b/src/ui/preparation_flow.cpp @@ -98,7 +98,7 @@ void validate_strengths_preparation(const StrengthsIdentity& id,const DeskState& if(next.desktop.revision!=before.revision+1||next.desktop.revision!=id.revision|| id.manager!=before.manager_slot||id.runtime_club!=before.runtime_club||id.day_counter!=before.day_counter|| id.manager<0||size_t(id.manager)>=before.managers.size()|| - id.club_identity!=before.managers[size_t(id.manager)].club_identity_key) + id.club_identity!=before.session_identity_key(size_t(id.manager))) throw FormatError("strengths: mismatched desk acknowledgement"); auto expected=before;expected.revision=id.revision; if(desk_json(expected)!=desk_json(next.desktop))throw FormatError("strengths: unrelated desk state changed"); @@ -110,7 +110,7 @@ void validate_other_games_preparation(const OtherGamesIdentity& id, const DeskSt id.manager_slot != before.manager_slot || id.runtime_team != before.runtime_club || id.day_counter != before.day_counter || id.manager_slot < 0 || size_t(id.manager_slot) >= before.managers.size() || - id.club_identity != int(before.managers[size_t(id.manager_slot)].club_identity_key)) + id.club_identity != int(before.session_identity_key(size_t(id.manager_slot)))) throw FormatError("other games: mismatched desk acknowledgement"); auto expected = before; expected.revision = id.revision; @@ -175,7 +175,7 @@ void StartupFlow::show_top_scorers(TopScorersState page,PreparationState prepara page.identity.runtime_team!=desktop_->state().runtime_club|| page.identity.day_counter!=desktop_->state().day_counter|| page.identity.revision!=desktop_->state().revision+1||page.identity.sequence!=0||!page.identity.scope|| - page.identity.club_identity!=int(desktop_->state().managers.at(size_t(owner.manager_slot)).club_identity_key)) + page.identity.club_identity!=int(desktop_->state().session_identity_key(size_t(owner.manager_slot)))) throw FormatError("top scorers: mismatched opening acknowledgement"); if(preparation.desktop.revision!=page.identity.revision||preparation.desktop.manager_slot!=owner.manager_slot|| preparation.desktop.runtime_club!=desktop_->state().runtime_club|| @@ -246,7 +246,7 @@ void StartupFlow::show_opportunities(OpportunitiesState page,PreparationState pr owner.manager_slot!=desktop_->state().manager_slot||owner.revision!=desktop_->state().revision|| page.identity.manager_slot!=owner.manager_slot||page.identity.runtime_team!=desktop_->state().runtime_club|| page.identity.day_counter!=desktop_->state().day_counter||page.identity.revision!=desktop_->state().revision+1|| - page.identity.sequence!=0||page.identity.stable_club_identity!=int(desktop_->state().managers.at(size_t(owner.manager_slot)).club_identity_key)) + page.identity.sequence!=0||page.identity.stable_club_identity!=int(desktop_->state().session_identity_key(size_t(owner.manager_slot)))) throw FormatError("opportunities: mismatched opening acknowledgement"); if(preparation.desktop.revision!=page.identity.revision||preparation.desktop.manager_slot!=owner.manager_slot|| preparation.desktop.runtime_club!=desktop_->state().runtime_club||preparation.desktop.day_counter!=desktop_->state().day_counter) @@ -1167,7 +1167,7 @@ void StartupFlow::show_balance(BalanceState page,const DeskRequest& owner) { owner.manager_slot!=desktop_->state().manager_slot||owner.revision!=desktop_->state().revision|| page.identity.manager_slot!=owner.manager_slot||page.identity.runtime_club!=desktop_->state().runtime_club|| page.identity.day_counter!=desktop_->state().day_counter||page.identity.revision!=owner.revision|| - page.identity.sequence!=0||!page.identity.scope||page.identity.club_identity!=int(desktop_->state().managers.at(size_t(owner.manager_slot)).club_identity_key)) + page.identity.sequence!=0||!page.identity.scope||page.identity.club_identity!=int(desktop_->state().session_identity_key(size_t(owner.manager_slot)))) throw FormatError("balance: mismatched opening acknowledgement"); auto screen=std::make_unique(data_,std::move(page)); desktop_->resolve_local_menu();balance_=std::move(screen); @@ -1180,7 +1180,7 @@ void StartupFlow::acknowledge_balance(BalanceState page) { page.identity.revision!=pending->identity.revision||page.identity.scope!=pending->identity.scope|| page.identity.revision!=desktop_->state().revision||page.identity.manager_slot!=desktop_->state().manager_slot|| page.identity.runtime_club!=desktop_->state().runtime_club||page.identity.day_counter!=desktop_->state().day_counter|| - page.identity.club_identity!=int(desktop_->state().managers.at(size_t(page.identity.manager_slot)).club_identity_key)|| + page.identity.club_identity!=int(desktop_->state().session_identity_key(size_t(page.identity.manager_slot)))|| page.identity.sequence!=pending->identity.sequence+1|| (pending->kind==BalanceAction::close)!=page.pending_close) throw FormatError("balance: mismatched preview acknowledgement"); @@ -1198,7 +1198,7 @@ void StartupFlow::close_balance(BalanceState page,PreparationState preparation) if(page.identity!=expected||pending->identity.manager_slot!=desktop_->state().manager_slot|| pending->identity.revision!=desktop_->state().revision||pending->identity.runtime_club!=desktop_->state().runtime_club|| pending->identity.day_counter!=desktop_->state().day_counter|| - pending->identity.club_identity!=int(desktop_->state().managers.at(size_t(pending->identity.manager_slot)).club_identity_key)|| + pending->identity.club_identity!=int(desktop_->state().session_identity_key(size_t(pending->identity.manager_slot)))|| preparation.desktop.revision!=expected.revision|| preparation.desktop.manager_slot!=expected.manager_slot|| preparation.desktop.manager_teams!=desktop_->state().manager_teams|| @@ -1826,7 +1826,7 @@ void StartupFlow::show_family_table_dispatch(std::array tab throw FormatError("league family: mismatched Table dispatch identity"); if(identity.manager<0||size_t(identity.manager)>=desktop_->state().managers.size()|| identity.manager!=desktop_->state().manager_slot||identity.runtime_club!=desktop_->state().runtime_club|| - identity.club_identity!=int(desktop_->state().managers[size_t(identity.manager)].club_identity_key)) + identity.club_identity!=int(desktop_->state().session_identity_key(size_t(identity.manager)))) throw FormatError("league family: invalid Table dispatch manager identity"); if(!league_family_identity_&&(!desktop_->pending()|| desktop_->pending()->kind!=DeskRequestKind::open_menu||desktop_->pending()->menu_kind!=(friendly_entry?6:0)|| @@ -2081,7 +2081,7 @@ void StartupFlow::begin_league_family(StrengthsIdentity identity) { identity.family_id==0) throw FormatError("league family: invalid desktop entry identity"); if(identity.manager<0||size_t(identity.manager)>=desktop_->state().managers.size()|| - identity.club_identity!=int(desktop_->state().managers[size_t(identity.manager)].club_identity_key)) + identity.club_identity!=int(desktop_->state().session_identity_key(size_t(identity.manager)))) throw FormatError("league family: invalid manager identity"); league_family_identity_=identity;league_family_child_=0; }