Load Modern worlds and add Modern training camps (M3, M4)
M3 - Modern world loader: - modern/content/world: typed view of the world tables (leagues, clubs, players, nations, league dates, training camp catalogue). - modern/content/world_package: opens a Modern world (runtime:modern-v1, or editor:world-v1 until data revision 1.4), reads only the engine entries and decodes the Classic payload (import: load_classic_payload). - modern/content/world_expand: turns the Classic start into the world: club ids in the order of the world's leagues, per-club tables remapped (added clubs copy an original club of their league), added players from their attributes, 24 squad slots per league club, pools kept, layout, league sizes and league dates installed; UTF-8 names and OBW ids in ModernState. - Fixes found by playing the Modern data set: referee pool exhausted on days with German and larger international leagues (Modern deviation), card table per league club grown, slot-to-team lookup via WorldLayout, form history stride from the layout, remaining slot literals. - Classic UI projections used by the session read the layout instead of executable constants (Classic values unchanged). - modern_season_sim opens .obw worlds; MODERN_DEBUG / MODERN_WATCH tracing. M4 - training camps: - Catalogue in ModernState (built-in 18 fictional camps on three maps, or the world's extended catalogue); price, booking and effect use it. - Six-star grades: step index capped, limit +1 from pitch 5 and +1 with pitch and fitness 6, catering 6 one more point of condition, lodging 6 one week less injury. Classic data behaves as before. modern_camp_tests. Verified: 190 tests pass; Classic replay regression identical to the M0 baseline; season_sim and modern_season_sim identical with Classic data; the Modern data set plays full seasons (leagues 34/38/34 rounds). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13bdc56f04
commit
6f55622307
53 files changed
+1392
-87
No files matched your search
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/achievements.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -184,7 +185,7 @@ Image AchievementsScreen::render()const{
|
||||
for(int season=0;season<state_.season_count;++season){
|
||||
const auto& row=state_.seasons[size_t(season)];const int x=0x41+season*4;
|
||||
if(row.league_result<0xfe){
|
||||
int remaining=(int(exe_.u16(::bmh::layout::TeamsWithSquads))-0x12)-row.league_result;
|
||||
int remaining=(world_layout().german_teams-0x12)-row.league_result;
|
||||
int y=baselines[0]-1, color_index=0, step_index=4;
|
||||
while(remaining>=0){
|
||||
const int step=exe_.u8(::bmh::layout::LeagueSizes+uint32_t(step_index));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/club_info.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -46,7 +47,7 @@ int source_manager_of(const GameState& game, int team) {
|
||||
const int manager = game.manager_of(team);
|
||||
if (manager >= 0) return manager;
|
||||
constexpr size_t fifth_team_offset = size_t(4) * 0xb0c + 0x290;
|
||||
if (!game.manager_teams.empty() && game.manager_teams.front() == kNoTeam &&
|
||||
if (!game.manager_teams.empty() && game.manager_teams.front() == no_team() &&
|
||||
game.manager_records.size() >= fifth_team_offset + 2) {
|
||||
const uint16_t fifth_team = uint16_t(game.manager_records[fifth_team_offset] |
|
||||
uint16_t(game.manager_records[fifth_team_offset + 1]) << 8);
|
||||
@@ -59,14 +60,14 @@ int source_manager_of(const GameState& game, int team) {
|
||||
ClubInfoProjection club_info_from_game(const GameState& g, int team,
|
||||
const ClubInfoEntry& entry, const LeImage& exe,
|
||||
const TextDb&) {
|
||||
if (team < 0 || team > kNoTeam) throw FormatError("club info: runtime team outside Original range");
|
||||
if (team < 0 || team > no_team()) throw FormatError("club info: runtime team outside Original range");
|
||||
ClubInfoProjection out;
|
||||
out.runtime_team = team;
|
||||
out.original_club_name = g.club_name(team);
|
||||
out.gradient_text = g.memory.u8(::bmh::layout::TextGradientDisabled) == 0 && exe.u8(::bmh::layout::TextGradientMode) == 2;
|
||||
out.decorated_background = g.memory.u8(::bmh::layout::PlainBackground) == 0;
|
||||
out.has_squad = team == kNoTeam || team < exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField);
|
||||
if (team != kNoTeam && team >= exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField)) {
|
||||
out.has_squad = team == no_team() || team < world_layout().league_teams;
|
||||
if (team != no_team() && team >= world_layout().league_teams) {
|
||||
out.has_squad = false;
|
||||
out.category = team >= 0 && size_t(team) < g.team_morale.size()
|
||||
? uint8_t((g.team_morale[size_t(team)] >> 6) & 3) : 0;
|
||||
@@ -80,7 +81,7 @@ ClubInfoProjection club_info_from_game(const GameState& g, int team,
|
||||
? uint8_t((g.team_morale[size_t(team)] >> 6) & 3) : 0;
|
||||
const int manager = source_manager_of(g, team);
|
||||
std::vector<int> loan_records;
|
||||
if (manager >= 0 && team != kNoTeam &&
|
||||
if (manager >= 0 && team != no_team() &&
|
||||
g.memory.has(::bmh::layout::Career_CareerManagersEnd_RuntimeField + 0x17) && g.memory.has(::bmh::layout::ClubInfo_FormatError_RuntimeField2 + 0x0b) && g.memory.has(::bmh::layout::ClubInfo_FormatError_RuntimeField + 0x41f)) {
|
||||
for (int loan = 0; loan < 12; ++loan)
|
||||
if (g.memory.u16(::bmh::layout::Career_CareerManagersEnd_RuntimeField + uint32_t(loan) * 2) != 0x0fff &&
|
||||
@@ -120,7 +121,7 @@ ClubInfoProjection club_info_from_game(const GameState& g, int team,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player.player_id >= 0 && manager >= 0 && team != kNoTeam) {
|
||||
if (player.player_id >= 0 && manager >= 0 && team != no_team()) {
|
||||
for (int offer = 0; offer < 4; ++offer) {
|
||||
const uint32_t address = ::bmh::layout::OfferSlots + uint32_t(offer) * 4;
|
||||
if (g.memory.has(address + 3)) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/contracts.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
|
||||
@@ -88,7 +89,7 @@ ContractsState contracts_from_game(const GameState& game, int manager_slot, uint
|
||||
size_t(manager_slot) * kManagerRecord + kManagerRecord > game.manager_records.size())
|
||||
throw FormatError("contracts: invalid manager slot");
|
||||
const int team = game.manager_teams[size_t(manager_slot)];
|
||||
if (team == kNoTeam) throw FormatError("contracts: Vereinsverträge sind für Nationalteams nicht verfügbar");
|
||||
if (team == no_team()) throw FormatError("contracts: Vereinsverträge sind für Nationalteams nicht verfügbar");
|
||||
const SquadRange range = squad_range(team);
|
||||
const size_t board = size_t(manager_slot) * kBoard;
|
||||
if (range.count > 24 || range.first + range.count > game.squad_slots.size() || board + range.count * kBoardSlot > game.tactics.size())
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/cup_draw.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -51,7 +52,7 @@ void source_frame(Image& out,int x,int y) {
|
||||
for(int yy=y-1;yy<=y+38;++yy)if(yy>=0&&yy<out.height&&x+38>=0&&x+38<out.width)out.at(x+38,yy)=0x40;
|
||||
}
|
||||
int region_for_team(int id) {
|
||||
if(id==kNoTeam)return 0;
|
||||
if(id==no_team())return 0;
|
||||
int t=id;
|
||||
for(int league=0;league<kLeagueCount;++league){t-=kLeagueSizes[league];if(t<0)return league>=5?league-5+1:0;}
|
||||
if(t-kCupOnlyTeams>=0)return (t-kCupOnlyTeams)/7-5+10;
|
||||
@@ -152,7 +153,7 @@ CupDrawProjection cup_draw_from_game(const GameState& game,const SeasonCupDrawEv
|
||||
context+=original_to_utf8(exe.cstring(::bmh::layout::CupDraw_FormatError_ExecutableField));
|
||||
} else {
|
||||
std::array<int,5> values{};
|
||||
if(id>=168&&id!=kNoTeam) {
|
||||
if(id>=168&&id!=no_team()) {
|
||||
const auto snapshot=std::find_if(event.group_average_snapshots.begin(),event.group_average_snapshots.end(),
|
||||
[&](const auto& v){return v.runtime_id==id;});
|
||||
if(snapshot==event.group_average_snapshots.end())
|
||||
|
||||
+14
-12
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -82,7 +83,7 @@ void project_drawer_rows(DeskState& d, const LeImage& exe, const Bytes& managers
|
||||
// TablePosition returns rank 2 for this special national row;
|
||||
// QuoteNationalFriendlyMatch uses its native no-team squad (no random rating).
|
||||
curve.current_position = 2;
|
||||
if (game) curve.strength = team_average(*game, kNoTeam, 0x1ff).value;
|
||||
if (game) curve.strength = team_average(*game, no_team(), 0x1ff).value;
|
||||
return;
|
||||
}
|
||||
const int league = executable_league(exe, team);
|
||||
@@ -186,7 +187,7 @@ DeskState project(const StaticMemory& memory, const Tables& t, const LeImage& ex
|
||||
identity.league = t.managers.at(manager_base + 0x210);
|
||||
identity.portrait = t.managers.at(manager_base + 0x221);
|
||||
identity.badge = word(t.badges, size_t(team) * 2) & 0x1ff;
|
||||
if ((team != kNoTeam && identity.league > 8) || identity.portrait > 11)
|
||||
if ((team != no_team() && identity.league > 8) || identity.portrait > 11)
|
||||
throw FormatError("desk: invalid manager identity");
|
||||
d.managers.push_back(std::move(identity));
|
||||
}
|
||||
@@ -194,7 +195,7 @@ DeskState project(const StaticMemory& memory, const Tables& t, const LeImage& ex
|
||||
if (t.managers.size() < base + 0xb0c || t.options.size() < size_t(d.manager_slot + 1) * 5)
|
||||
throw FormatError("desk: truncated manager records/options");
|
||||
d.runtime_club = t.teams.at(d.manager_slot);
|
||||
d.national_team = d.runtime_club == kNoTeam;
|
||||
d.national_team = d.runtime_club == no_team();
|
||||
d.national_coach_takeover = memory.has(::bmh::layout::CoachActive) && memory.u8(::bmh::layout::CoachActive) != 0;
|
||||
if (d.national_team && d.national_coach_takeover) {
|
||||
const int saved_manager_count = memory.has(::bmh::layout::OriginalManagerCount) ? memory.u8(::bmh::layout::OriginalManagerCount) : 0;
|
||||
@@ -209,7 +210,7 @@ DeskState project(const StaticMemory& memory, const Tables& t, const LeImage& ex
|
||||
if (t.managers.size() < manager_base + 0x292)
|
||||
throw FormatError("desk: truncated saved manager roster during national takeover");
|
||||
const int team = word(t.managers, manager_base + 0x290);
|
||||
if (team < 0 || team >= int(t.name_offsets.size()) || team == kNoTeam ||
|
||||
if (team < 0 || team >= int(t.name_offsets.size()) || team == no_team() ||
|
||||
t.badges.size() < size_t(team + 1) * 2)
|
||||
throw FormatError("desk: invalid home club in national return roster");
|
||||
DeskManagerIdentity original;
|
||||
@@ -303,10 +304,11 @@ DeskState project(const StaticMemory& memory, const Tables& t, const LeImage& ex
|
||||
uint8_t remaining = 18;
|
||||
for (size_t kind = 6; kind < 13; ++kind) remaining = uint8_t(remaining - t.managers.at(base + 0xc5 + kind));
|
||||
d.warnings[3] = remaining < 4;
|
||||
const int max24 = exe.u16(::bmh::layout::TeamsWithSquads), league_teams = exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField);
|
||||
if (!d.national_team && d.runtime_club >= league_teams) throw FormatError("desk: cup-only squad projection not supported");
|
||||
const size_t first = d.national_team ? 3072 : size_t(d.runtime_club < max24 ? d.runtime_club * 24 : d.runtime_club * 16 + max24 * 8);
|
||||
const size_t count = d.national_team ? 24 : (d.runtime_club < max24 ? 24 : 16);
|
||||
const int league_teams = world_layout().league_teams; // WorldLayout: Classic = executable TeamsWithSquads/DispatchLineup values
|
||||
if (!d.national_team && d.runtime_club >= league_teams) throw FormatError("desk: cup-only squad projection not supported (club " + std::to_string(d.runtime_club) + ")");
|
||||
const SquadRange squad_slots = squad_range(d.national_team ? no_team() : d.runtime_club);
|
||||
const size_t first = squad_slots.first;
|
||||
const size_t count = squad_slots.count;
|
||||
if (t.squads.size() < first + count || t.tactics.size() < size_t(d.manager_slot) * 0x840 + count * 0x58)
|
||||
throw FormatError("desk: truncated squad/tactics");
|
||||
int lineup = 0, reserve = 0, condition = 0, technique = 0, form = 0, morale = 0;
|
||||
@@ -425,10 +427,10 @@ void validate_desk_state(const DeskState& d) {
|
||||
if (team < 0 || !unique.insert(team).second || manager.runtime_club != team ||
|
||||
manager.club_identity_key < 0 || !unique_identities.insert(manager.club_identity_key).second ||
|
||||
manager.portrait < 0 || manager.portrait > 11 ||
|
||||
(team != kNoTeam && (manager.league < 0 || manager.league > 8)))
|
||||
(team != no_team() && (manager.league < 0 || manager.league > 8)))
|
||||
throw FormatError("desk: invalid or duplicate manager runtime club");
|
||||
}
|
||||
const bool national = d.runtime_club == kNoTeam;
|
||||
const bool national = d.runtime_club == no_team();
|
||||
if (d.table_position && (*d.table_position < 0 || *d.table_position > 31))
|
||||
throw FormatError("desk: invalid Source table position");
|
||||
if (d.national_team != national ||
|
||||
@@ -440,7 +442,7 @@ void validate_desk_state(const DeskState& d) {
|
||||
throw FormatError("desk: missing national return roster");
|
||||
std::set<int> return_keys;
|
||||
for (const auto& manager : d.national_return_roster)
|
||||
if (manager.runtime_club < 0 || manager.runtime_club >= kNoTeam ||
|
||||
if (manager.runtime_club < 0 || manager.runtime_club >= no_team() ||
|
||||
manager.club_identity_key < 0 || !return_keys.insert(manager.club_identity_key).second ||
|
||||
manager.portrait < 0 || manager.portrait > 11 || manager.league < 0 || manager.league > 8)
|
||||
throw FormatError("desk: invalid national return roster identity");
|
||||
@@ -516,7 +518,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
exe, g.level, g.date, g.season_day(), g.season, revision);
|
||||
// DeskDate only auto-opens for an ordinary club manager; the national
|
||||
// runtime (0x165) suppresses this consumer while manual mailbox access remains valid.
|
||||
if (d.runtime_club != kNoTeam && d.manager_slot >= 0 && d.manager_slot < 32 && g.memory.has(::bmh::layout::MailboxRecipientMask))
|
||||
if (d.runtime_club != no_team() && d.manager_slot >= 0 && d.manager_slot < 32 && g.memory.has(::bmh::layout::MailboxRecipientMask))
|
||||
d.mailbox_notification_pending = (g.memory.u32(::bmh::layout::MailboxRecipientMask) & (uint32_t(1) << d.manager_slot)) != 0;
|
||||
d.date.year += g.display_start_year - exe.display_start_year();
|
||||
project_table_position(d, g);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/environment.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -59,7 +60,7 @@ EnvironmentView environment_from_game(const bmh::GameState& game, uint64_t revis
|
||||
if (manager < 0 || size_t(manager) >= game.manager_teams.size())
|
||||
throw FormatError("environment: active manager is outside the source roster");
|
||||
const int team = game.manager_teams[size_t(manager)];
|
||||
if (team < 0 || team == kNoTeam) throw FormatError("environment: no club environment for this manager");
|
||||
if (team < 0 || team == no_team()) throw FormatError("environment: no club environment for this manager");
|
||||
EnvironmentView view;
|
||||
view.manager_slot = manager;
|
||||
view.runtime_club = team;
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/flow.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/source_hold.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -93,7 +94,7 @@ void validate_confirmed_desk(const std::vector<ManagerChoice>& choices,
|
||||
const std::vector<DeskManagerIdentity>& previous_national_roster,
|
||||
bool allow_turn_handoff, const DeskState& desk) {
|
||||
validate_desk_state(desk);
|
||||
const bool previous_national = previous.size() == 1 && previous[0].runtime_club == kNoTeam &&
|
||||
const bool previous_national = previous.size() == 1 && previous[0].runtime_club == no_team() &&
|
||||
(desk.options.world || previous_national_coach_takeover);
|
||||
const bool incoming_national = desk.national_team &&
|
||||
(desk.options.world || desk.national_coach_takeover);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/friendly_match.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -78,7 +79,7 @@ FriendlyMatchScreen::FriendlyMatchScreen(const std::filesystem::path& data, Frie
|
||||
font_(load_font(asset_path(data / "F", "BMH2.FNT"))),
|
||||
exe_(load_le(asset_path(data, "BMH.exe"))),
|
||||
data_(data), next_request_id_(state_.first_request_id) {
|
||||
const bool valid_national_slot = state_.national_team && state_.runtime_team == bmh::kNoTeam;
|
||||
const bool valid_national_slot = state_.national_team && state_.runtime_team == bmh::no_team();
|
||||
if (state_.manager_slot < 0 || state_.manager_slot > 3 || state_.runtime_team < 0 ||
|
||||
(state_.runtime_team >= 168 && !valid_national_slot) ||
|
||||
state_.revision == UINT64_MAX || !state_.first_request_id || state_.planner_count < 0 ||
|
||||
@@ -87,7 +88,7 @@ FriendlyMatchScreen::FriendlyMatchScreen(const std::filesystem::path& data, Frie
|
||||
if (!state_.mode_three) {
|
||||
stage_ = FriendlyStage::unavailable;
|
||||
feedback_ = "Freundschaftsspiele sind nur in Modus III verfuegbar.";
|
||||
} else if (state_.national_team || state_.runtime_team == bmh::kNoTeam) {
|
||||
} else if (state_.national_team || state_.runtime_team == bmh::no_team()) {
|
||||
stage_ = FriendlyStage::unavailable;
|
||||
feedback_ = "Freundschaftsspiele fuer die Nationalmannschaft sind hier nicht verfuegbar.";
|
||||
} else if (desk_menu_kind_ != 6) {
|
||||
@@ -108,14 +109,14 @@ FriendlyMatchScreen::FriendlyMatchScreen(const std::filesystem::path& data, Frie
|
||||
FriendlyQuoteProjection national_quote, NationalFriendlyBookingRequest national_booking,
|
||||
int desk_menu_kind)
|
||||
: FriendlyMatchScreen(data, std::move(state), desk_menu_kind) {
|
||||
const bool source_owner = desk_menu_kind == 6 && national_quote.runtime_team == bmh::kNoTeam &&
|
||||
const bool source_owner = desk_menu_kind == 6 && national_quote.runtime_team == bmh::no_team() &&
|
||||
national_booking.owner.menu_kind == 6 && national_booking.owner.manager == national_quote.manager_slot &&
|
||||
national_booking.owner.runtime_team == bmh::kNoTeam &&
|
||||
national_booking.owner.runtime_team == bmh::no_team() &&
|
||||
national_booking.owner.revision == national_quote.revision &&
|
||||
national_booking.quote.terms.opponent == national_quote.opponent &&
|
||||
national_booking.quote.terms.manager_home == national_quote.manager_home &&
|
||||
national_booking.quote.terms.planner_count == national_quote.planner_count;
|
||||
if (!source_owner || !state_.national_team || state_.runtime_team != bmh::kNoTeam ||
|
||||
if (!source_owner || !state_.national_team || state_.runtime_team != bmh::no_team() ||
|
||||
state_.manager_slot != national_quote.manager_slot || state_.revision != national_quote.revision ||
|
||||
national_quote.dates.size() != 366 || national_quote.cost < 0 ||
|
||||
national_booking.quote.terms.status != bmh::FriendlyQuoteStatus::quoted ||
|
||||
@@ -124,8 +125,8 @@ FriendlyMatchScreen::FriendlyMatchScreen(const std::filesystem::path& data, Frie
|
||||
feedback_ = "Diese Freundschaftsspielanfrage ist nicht mehr aktuell.";
|
||||
return;
|
||||
}
|
||||
const int expected_home = national_quote.manager_home ? bmh::kNoTeam : national_quote.opponent;
|
||||
const int expected_away = national_quote.manager_home ? national_quote.opponent : bmh::kNoTeam;
|
||||
const int expected_home = national_quote.manager_home ? bmh::no_team() : national_quote.opponent;
|
||||
const int expected_away = national_quote.manager_home ? national_quote.opponent : bmh::no_team();
|
||||
if (national_quote.home_team != expected_home || national_quote.away_team != expected_away ||
|
||||
national_quote.payer_manager != national_booking.quote.terms.payer_manager ||
|
||||
national_quote.opponent_manager != national_booking.quote.terms.opponent_manager ||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/incoming_transfer.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
|
||||
@@ -95,7 +96,7 @@ IncomingTransferDecisionState incoming_transfer_decision_from_game_impl(
|
||||
: view.list_entry >= 0 && view.list_entry < (view.source_outgoing_editor_context ? 44 : 40);
|
||||
if (!view.valid || !entry_valid ||
|
||||
view.player < 0 || size_t(view.player) >= game.players.size() ||
|
||||
(view.seller != 0x0fff && view.seller != kNoTeam && (view.seller < 0 || size_t(view.seller) >= game.club_ids.size())) ||
|
||||
(view.seller != 0x0fff && view.seller != no_team() && (view.seller < 0 || size_t(view.seller) >= game.club_ids.size())) ||
|
||||
view.seller_manager < -1 || view.viewer_manager < -1 ||
|
||||
view.preferred_bid_index < -1 || view.preferred_bid_index >= 4)
|
||||
throw FormatError("incoming transfer: invalid decision context");
|
||||
@@ -113,10 +114,10 @@ IncomingTransferDecisionState incoming_transfer_decision_from_game_impl(
|
||||
out.has_preferred_bid = view.has_preferred_bid;
|
||||
out.preferred_bid_passed_random_check = view.preferred_bid_passed_random_check;
|
||||
out.player_name = game.player_name(view.player);
|
||||
out.seller_name = (view.seller == 0x0fff || view.seller == kNoTeam) ? std::string() : game.club_name(view.seller);
|
||||
out.seller_name = (view.seller == 0x0fff || view.seller == no_team()) ? std::string() : game.club_name(view.seller);
|
||||
// ClubName2 derives this label from the seller team token. A club is
|
||||
// named directly; the player-pool token resolves to the original adviser.
|
||||
out.negotiator_name = (view.seller == 0x0fff || view.seller == kNoTeam)
|
||||
out.negotiator_name = (view.seller == 0x0fff || view.seller == no_team())
|
||||
? (game.texts ? (*game.texts)[925] : "SPIELERBERATER")
|
||||
: out.seller_name;
|
||||
out.age = game.players[size_t(view.player)].age();
|
||||
|
||||
+6
-4
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/lineup.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -37,14 +38,15 @@ LineupState project(const StaticMemory& memory, const LeImage& exe, const std::v
|
||||
if (out.manager_slot < 0 || out.manager_slot > 3 || size_t(out.manager_slot) >= teams.size())
|
||||
throw FormatError("lineup: unsupported active manager");
|
||||
out.runtime_club = teams.at(out.manager_slot);
|
||||
const int split = exe.u16(::bmh::layout::TeamsWithSquads), limit = exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField);
|
||||
const bool national = out.runtime_club == kNoTeam && out.manager_slot == 0 && teams.size() == 1 &&
|
||||
const int limit = world_layout().league_teams; // WorldLayout: Classic = executable DispatchLineup value
|
||||
const bool national = out.runtime_club == no_team() && out.manager_slot == 0 && teams.size() == 1 &&
|
||||
((memory.u32(::bmh::layout::CompetitionSelection) & 2) != 0 ||
|
||||
(memory.has(::bmh::layout::CoachActive) && memory.u8(::bmh::layout::CoachActive) != 0));
|
||||
if (out.runtime_club < 0 || (out.runtime_club >= limit && !national))
|
||||
throw FormatError("lineup: only domestic league squads are supported");
|
||||
const size_t count = national || out.runtime_club < split ? 24 : 16;
|
||||
const size_t first = national ? 3072 : out.runtime_club < split ? size_t(out.runtime_club) * 24 : size_t(out.runtime_club) * 16 + split * 8;
|
||||
const SquadRange squad_slots = squad_range(national ? no_team() : out.runtime_club);
|
||||
const size_t count = squad_slots.count;
|
||||
const size_t first = squad_slots.first;
|
||||
const size_t board_base = size_t(out.manager_slot) * 0x840;
|
||||
if (first + count > squad.size() || board_base + count * 0x58 > tactics.size() || size_t(out.manager_slot) * 5 >= options.size())
|
||||
throw FormatError("lineup: truncated squad/tactics/options");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/live_matchday.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -51,7 +52,7 @@ std::string original(std::string_view utf8) {
|
||||
int placed_players(const GameState& state, int team) {
|
||||
// SquadRange3 returns 11 for every non-league field team, except the special no-team squad.
|
||||
const SquadRange range = squad_range(team);
|
||||
if (range.count == 0 && team != kNoTeam) return 11;
|
||||
if (range.count == 0 && team != no_team()) return 11;
|
||||
uint8_t count = 0;
|
||||
const size_t end = std::min(state.squad_slots.size(), range.first + range.count);
|
||||
for (size_t slot = range.first; slot < end; ++slot) {
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -150,7 +151,7 @@ ManagerScreen::ManagerScreen(const std::filesystem::path& data, int slot, const
|
||||
if (exe_.u8(::bmh::layout::Manager_FormatError_RuntimeField + i * 2) < 'B') ++text_id;
|
||||
if (last_[i] - first_[i] >= 20) throw FormatError("manager: league exceeds picker grid");
|
||||
}
|
||||
first_[5] = exe_.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField); last_[5] = first_[5] + 19;
|
||||
first_[5] = world_layout().league_teams; last_[5] = first_[5] + 19;
|
||||
first_[6] = first_[5] + 20; last_[6] = first_[5] + exe_.u16(::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6) - 1;
|
||||
leagues_[5] = texts_[(::bmh::layout::Manager_FormatError_TextPointer - ::bmh::layout::TextPointerTable) / 4]; leagues_[6] = leagues_[5];
|
||||
if (leagues_[6].empty()) throw FormatError("manager: missing extra-team label");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/other_games_state.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -164,7 +165,7 @@ int source_league(const LeImage& exe, int team) {
|
||||
}
|
||||
|
||||
uint8_t source_country(const LeImage& exe, int team) {
|
||||
if (team == kNoTeam) return 0;
|
||||
if (team == no_team()) return 0;
|
||||
if (team < 0) invalid("negative team for Source country lookup");
|
||||
int remaining = team;
|
||||
const int domestic_cutoff = exe.u8(::bmh::layout::LeaguePairings_LeaguePairingsConstants_RuntimeField);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/pending_offer.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -20,7 +21,7 @@ int pending_offer_owner_team(const GameState& game, int manager) {
|
||||
// AdvanceTurn restores NextDeskManager[0] after the temporary one-manager national
|
||||
// desk. Records1..3 still exist even though they have no runtime desk.
|
||||
const bool retained = manager > 0 && manager < 4 &&
|
||||
game.manager_teams.size() == 1 && game.manager_teams[0] == kNoTeam &&
|
||||
game.manager_teams.size() == 1 && game.manager_teams[0] == no_team() &&
|
||||
game.memory.has(::bmh::layout::CoachActive) && game.memory.u8(::bmh::layout::CoachActive) != 0 &&
|
||||
game.memory.has(::bmh::layout::ManagerCount) && game.memory.u8(::bmh::layout::ManagerCount) == 1 &&
|
||||
game.memory.has(::bmh::layout::OriginalManagerCount) && game.memory.u8(::bmh::layout::OriginalManagerCount) <= 4 &&
|
||||
@@ -40,7 +41,7 @@ int pending_offer_owner_team(const GameState& game, int manager) {
|
||||
|
||||
bool pending_offer_spare_buyer(const GameState& game, int raw_offer_slot, int expected_team) {
|
||||
if (raw_offer_slot < 0 || raw_offer_slot >= 4 ||
|
||||
game.manager_teams.size() != 1 || game.manager_teams[0] != kNoTeam ||
|
||||
game.manager_teams.size() != 1 || game.manager_teams[0] != no_team() ||
|
||||
!game.memory.has(::bmh::layout::CoachActive) || game.memory.u8(::bmh::layout::CoachActive) == 0 ||
|
||||
!game.memory.has(::bmh::layout::ManagerCount) || game.memory.u8(::bmh::layout::ManagerCount) != 1 ||
|
||||
!game.memory.has(::bmh::layout::OriginalManagerCount) || game.memory.u8(::bmh::layout::OriginalManagerCount) < 1 || game.memory.u8(::bmh::layout::OriginalManagerCount) > 4 ||
|
||||
@@ -59,7 +60,7 @@ bool pending_offer_spare_buyer(const GameState& game, int raw_offer_slot, int ex
|
||||
const uint32_t offer = ::bmh::layout::OfferSlots + uint32_t(raw_offer_slot) * 4;
|
||||
const uint32_t list = ::bmh::layout::EditorList + uint32_t(raw_offer_slot + 40) * 0x58;
|
||||
const size_t pool = 0xb70 + size_t(raw_offer_slot + 40);
|
||||
if (team_at(0) != kNoTeam || buyer >= 138 || buyer != expected_team || !game.memory.has(offer + 3) ||
|
||||
if (team_at(0) != no_team() || buyer >= 138 || buyer != expected_team || !game.memory.has(offer + 3) ||
|
||||
!game.memory.has(list + 0x57) || pool >= game.squad_slots.size())
|
||||
return false;
|
||||
const uint32_t word = game.memory.u32(offer);
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/pitch.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -58,7 +59,7 @@ PitchExtras extras(const StaticMemory& memory,const Bytes& managers,const Bytes&
|
||||
const int count=memory.u8(::bmh::layout::ManagerCount);
|
||||
if(count<1||count>4||e.manager_slot>=count||teams.size()!=size_t(count))throw FormatError("pitch: invalid active manager");
|
||||
e.runtime_club=teams.at(e.manager_slot);
|
||||
if(e.runtime_club<0||e.runtime_club>=exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField))throw FormatError("pitch: unsupported club");
|
||||
if(e.runtime_club<0||e.runtime_club>=world_layout().league_teams)throw FormatError("pitch: unsupported club");
|
||||
const size_t m=size_t(e.manager_slot)*0xb0c,f=size_t(e.manager_slot)*0x160;
|
||||
if(managers.size()<m+0xb0c||formations.size()<f+0x160||badges.size()<size_t(e.runtime_club+1)*2)
|
||||
throw FormatError("pitch: truncated manager/formations/badges");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/player_card.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -45,7 +46,7 @@ PlayerCardState project(LineupState lineup,const LeImage& exe,int row,const Byte
|
||||
const int nation=p.attributes.nationality()+((p.bonus&0x80)?32:0);
|
||||
const size_t nation_club=exe.u16(::bmh::layout::ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField3)+exe.u16(::bmh::layout::NoTeamSquadStart)+nation;
|
||||
out.nationality_name=pool_name(names,offsets.at(nation_club));
|
||||
if (out.lineup.runtime_club == kNoTeam) {
|
||||
if (out.lineup.runtime_club == no_team()) {
|
||||
// The national runtime slot is absent from the ordinary short-name
|
||||
// table; its projected club name is already the full country label.
|
||||
out.club_short_name=out.lineup.club_name;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/flow.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -319,9 +320,9 @@ void StartupFlow::show_national_friendly_picker(WorldCupStatisticsProjection pro
|
||||
if (!desktop_ || !engine_attached_ || in_preparation_menu() || in_readonly_view() || matchday_results_ ||
|
||||
!desktop_->pending() || *desktop_->pending() != owner || owner.kind != DeskRequestKind::open_menu ||
|
||||
owner.menu_kind != 6 || owner.revision != desktop_->state().revision ||
|
||||
owner.manager_slot != desktop_->state().manager_slot || runtime_team != bmh::kNoTeam ||
|
||||
owner.manager_slot != desktop_->state().manager_slot || runtime_team != bmh::no_team() ||
|
||||
size_t(owner.manager_slot) >= desktop_->state().manager_teams.size() ||
|
||||
desktop_->state().manager_teams[size_t(owner.manager_slot)] != bmh::kNoTeam ||
|
||||
desktop_->state().manager_teams[size_t(owner.manager_slot)] != bmh::no_team() ||
|
||||
!projection.can_select_opponent || next_friendly_request_id_ == UINT64_MAX)
|
||||
throw FormatError("national friendly: expected the active menu-6 national caller");
|
||||
NationalFriendlyUiOwner ui_owner{6, owner.manager_slot, runtime_team,
|
||||
@@ -361,7 +362,7 @@ void StartupFlow::show_national_friendly_calendar(FriendlyMatchState state,
|
||||
booking.quote.terms.status!=FriendlyQuoteStatus::quoted||
|
||||
national_friendly_desk_owner_.revision!=desktop_->state().revision||
|
||||
national_friendly_desk_owner_.manager_slot!=state.manager_slot||
|
||||
state.runtime_team!=bmh::kNoTeam||!state.national_team||state.revision!=desktop_->state().revision||
|
||||
state.runtime_team!=bmh::no_team()||!state.national_team||state.revision!=desktop_->state().revision||
|
||||
state.manager_slot!=desktop_->state().manager_slot||quote.request_id!=booking.owner.request_id||
|
||||
quote.revision!=booking.owner.revision||quote.opponent!=booking.quote.terms.opponent||
|
||||
quote.manager_slot!=booking.owner.manager||state.manager_name!=original_to_utf8(desktop_->state().manager_name)||
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/tactics.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -34,11 +35,11 @@ TacticsState project(const StaticMemory& memory, const Bytes& managers, const By
|
||||
throw FormatError("tactics: truncated manager/board/options");
|
||||
TacticsState s;
|
||||
s.manager_slot = slot; s.runtime_club = teams.at(slot); s.revision = revision;
|
||||
const bool national = s.runtime_club == kNoTeam && slot == 0 && count == 1 &&
|
||||
const bool national = s.runtime_club == no_team() && slot == 0 && count == 1 &&
|
||||
((memory.u32(::bmh::layout::CompetitionSelection) & 2) != 0 ||
|
||||
(memory.has(::bmh::layout::CoachActive) && memory.u8(::bmh::layout::CoachActive) != 0));
|
||||
if (s.runtime_club < 0 || s.runtime_club >= int(offsets.size()) ||
|
||||
(s.runtime_club == kNoTeam && !national))
|
||||
(s.runtime_club == no_team() && !national))
|
||||
throw FormatError("tactics: unsupported runtime club");
|
||||
s.manager_name = bounded_string(managers, manager + 0xa8, 26);
|
||||
s.club_name = bounded_string(names, offsets.at(s.runtime_club), names.size());
|
||||
|
||||
+5
-3
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/world_layout.hpp"
|
||||
#include "ui/training.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -56,10 +57,11 @@ TrainingState project(const StaticMemory& memory, const Bytes& records, const By
|
||||
if (manager_count < 1 || manager_count > 4 || s.manager_slot >= manager_count || teams.size() != size_t(manager_count))
|
||||
throw FormatError("training: inconsistent active manager");
|
||||
s.runtime_club = teams.at(s.manager_slot);
|
||||
const int max24 = exe.u16(::bmh::layout::TeamsWithSquads), max16 = exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField);
|
||||
const int max16 = world_layout().league_teams; // WorldLayout: Classic = executable DispatchLineup value
|
||||
if (s.runtime_club < 0 || s.runtime_club >= max16) throw FormatError("training: national/cup-only squad unsupported");
|
||||
s.squad_capacity = s.runtime_club < max24 ? 24 : 16;
|
||||
const size_t first = size_t(s.runtime_club < max24 ? s.runtime_club * 24 : s.runtime_club * 16 + max24 * 8);
|
||||
const SquadRange squad_slots = squad_range(s.runtime_club);
|
||||
s.squad_capacity = int(squad_slots.count);
|
||||
const size_t first = squad_slots.first;
|
||||
const size_t manager = size_t(s.manager_slot) * 0xb0c, board = size_t(s.manager_slot) * 0x840;
|
||||
if (records.size() < manager + 0xb0c || tactics.size() < board + size_t(s.squad_capacity) * 0x58 ||
|
||||
options.size() < size_t(s.manager_slot + 1) * 5 || squads.size() < first + size_t(s.squad_capacity))
|
||||
|
||||
Reference in new issue
Block a user