Fork the Classic season core into src/modern and add the world layout (M1)

- src/modern/game: the season modules as bmh::modern, working on ModernState
  (a GameState). Data types stay shared with Classic; Modern code calls its
  season functions qualified (modern::...), so a missing Modern function is a
  compile error instead of a silent call into Classic.
- src/modern/app/modern_session: the session on the Modern core. It still uses
  the Classic UI projections until the Modern projections exist.
- SeasonHooks: the shared match core reaches player statistics and the table
  prediction of the season core that owns the game (Classic: unchanged).
- WorldLayout: team ranges, squad slots and pools of the running world. Shared
  code and the Modern fork read them; Classic keeps the original numbers.
- Transfer list views moved to game/transfer_offer_view.hpp (shared).
- tools/modern/check_fork_calls.sh, modern_season_sim and world_layout_tests.

Verified: Classic tests and replay regression unchanged; season_sim and
modern_season_sim produce identical output with Classic data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-23 18:08:54 +02:00
1 parent badd08f05e
commit f2fcb28f65
81 files changed
+29351 -91

No files matched your search

+6 -5
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/world_layout.hpp"
#include "game/lineup.hpp"
#include <cstdlib>
@@ -33,7 +34,7 @@ uint8_t formation_byte(const GameState& g, size_t index) {
}
bool pitch_context_valid(const GameState& g, int manager, int team) {
if (manager < 0 || manager > 3 || team < 0 || team >= 138 || g.lineups_frozen ||
if (manager < 0 || manager > 3 || team < 0 || team >= world_layout().league_teams || g.lineups_frozen ||
!g.memory.has(::bmh::layout::ActiveManager) || !g.memory.has(::bmh::layout::GameMode) ||
g.memory.u8(::bmh::layout::ActiveManager) != manager || g.memory.u8(::bmh::layout::GameMode) < 1 || g.memory.u8(::bmh::layout::GameMode) > 3 ||
size_t(manager) >= g.manager_teams.size() || g.manager_teams[size_t(manager)] != team ||
@@ -318,7 +319,7 @@ bool save_pitch_formation_source(GameState& g, int manager_slot, int runtime_clu
}
static void auto_lineup_impl(GameState& g, int team, int mode, int manager) {
if (team >= 138 && team != kNoTeam) return; // teams without squads
if (team >= world_layout().league_teams && team != no_team()) return; // teams without squads
if (g.lineups_frozen) return; // LineupRuntimeField (the season change)
const bool improve_from_reserves = (mode & 0x80) != 0;
mode &= 0x7F;
@@ -594,12 +595,12 @@ void auto_lineup(GameState& g, int team, int mode) {
void auto_lineup_parked_club_source(GameState& g, int team, int mode) {
constexpr size_t record = 4*0xb0c+0x290;
if (team<0 || team>=138 || g.manager_teams.size()!=1 || g.manager_teams[0]!=kNoTeam ||
if (team<0 || team>=world_layout().league_teams || g.manager_teams.size()!=1 || g.manager_teams[0]!=no_team() ||
!g.memory.has(::bmh::layout::CoachActive) || g.memory.u8(::bmh::layout::CoachActive)==0 ||
!g.memory.has(::bmh::layout::ManagerCount) || g.memory.u8(::bmh::layout::ManagerCount)!=1 ||
!g.memory.has(::bmh::layout::OriginalManagerCount) || g.memory.u8(::bmh::layout::OriginalManagerCount)<1 || g.memory.u8(::bmh::layout::OriginalManagerCount)>4 ||
record+2>g.manager_records.size() ||
(int(g.manager_records[0x290]) | int(g.manager_records[0x291])<<8)!=kNoTeam ||
(int(g.manager_records[0x290]) | int(g.manager_records[0x291])<<8)!=no_team() ||
(int(g.manager_records[record]) | int(g.manager_records[record+1])<<8)!=team ||
g.tactics.size()<5*0x840)
throw std::invalid_argument("auto_lineup: invalid FindManagerForClub parked club context");
@@ -630,7 +631,7 @@ void quicksort_by_key(int16_t* items, uint32_t* keys, int count, bool ascending)
}
bool substitute(GameState& g, int team, int off, int mode, WatcomRandom& rand) {
if (!(team < 138 || team == kNoTeam)) return false;
if (!(team < world_layout().league_teams || team == no_team())) return false;
const int manager = g.manager_of(team);
int used = g.team_flags.at(team) >> 5 & 7; // substitutions so far
if (mode == 10) {
+2 -1
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "game/match.hpp"
#include "game/world_layout.hpp"
#include <cstdlib>
#include <stdexcept>
@@ -73,7 +74,7 @@ int region_temperature(int region) { return region >= 0 && region < 48 ? kRegion
int month_temperature(int month) { return kMonthTemperature[month >= 0 && month <= 12 ? month : 0]; }
int team_region(int team) {
if (team == kNoTeam) return 0;
if (team == no_team()) return 0;
int t = team;
for (int league = 0; league < kLeagueCount; league++) {
t -= kLeagueSizes[league];
+18 -9
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/world_layout.hpp"
#include "game/match_engine.hpp"
#include <algorithm>
@@ -19,6 +20,14 @@ namespace bmh {
namespace {
// PlayerStatistic of the season core that owns the game (SeasonHooks; Classic by default).
void player_statistic_hook(GameState& g, int type, int player, int manager, int slot, int kind, int minute) {
if (g.season_hooks && g.season_hooks->player_statistic)
g.season_hooks->player_statistic(g, type, player, manager, slot, kind, minute);
else
player_statistic(g, type, player, manager, slot, kind, minute);
}
// Goal threshold by chance quality index 5..24 (table at layout field).
constexpr uint8_t kChanceTable[25] = {11, 12, 13, 14, 16, 18, 20, 21, 22, 22, 23, 25, 26,
27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33};
@@ -78,7 +87,7 @@ MinuteReport MatchEngine::minute(int minute, int last_minute, int stoppage) {
// Human teams use the places on their tactics board, also for the player's value.
int MatchEngine::pick_player(int team, int mode, int exclude, MinuteReport& report, int preset) {
mode &= 0x7F; // 0x80 = reuse the squad of the previous call, same team here
if (team >= 138 && team != kNoTeam) return 0xFFF; // clubs without squad: nobody, no draws
if (team >= world_layout().league_teams && team != no_team()) return 0xFFF; // clubs without squad: nobody, no draws
SquadRange range = squad_range(team);
if (range.count == 0) return 0xFFF;
RatingContext ctx{state.chance_rain, state.chance_temperature};
@@ -523,8 +532,8 @@ ForcedMatchEvent MatchEngine::event_impl(MatchGroup& g, int m, int s, int minute
// national team (0x165, squad nominated on the national team days) only while manager
// slot 0 holds it (CupDraw_FormatError_RuntimeField2 == 0x165: a Bundestrainer's match).
if (!(team < 90 || rand.range(0, 1) == 0)) return result;
if (!(team < 138 || team == kNoTeam)) return result;
if (team == kNoTeam && (state.manager_teams.empty() || state.manager_teams[0] != kNoTeam)) return result;
if (!(team < world_layout().league_teams || team == no_team())) return result;
if (team == no_team() && (state.manager_teams.empty() || state.manager_teams[0] != no_team())) return result;
const int manager = state.manager_of(team); // FindManagerForClub, local_6c
const bool human = manager >= 0;
SquadRange range = squad_range(team); // SquadRange4
@@ -944,7 +953,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
}
// Goalkeeper of the opponent: the player in squad slot 0 if the formation puts it in goal.
if (!reality_played && (opp_team < 168 || opp_team == kNoTeam)) {
if (!reality_played && (opp_team < world_layout().first_foreign_cup() || opp_team == no_team())) {
int x = 0, y = 0;
state.formation_position(opp_team, 0, x, y);
if (x == 0 && y == 4) keeper = state.squad_slots.at(squad_range(opp_team).first) & 0x0FFF;
@@ -979,7 +988,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
deflected = game.range(0, 5) == 0;
}
if (kind == 0) {
if (team >= 168 && team != kNoTeam) {
if (team >= world_layout().first_foreign_cup() && team != no_team()) {
// clubs without squad: the attack rating (TeamRating, profile 3), drawn
RatingContext drawn;
drawn.rand = &rand;
@@ -989,7 +998,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
}
}
if (keeper == 0xFFF) {
if (opp_team >= 168 && opp_team != kNoTeam) {
if (opp_team >= world_layout().first_foreign_cup() && opp_team != no_team()) {
// clubs without squad: the goalkeeping rating (profile 0), drawn
RatingContext drawn;
drawn.rand = &rand;
@@ -1111,9 +1120,9 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
}
// PlayerStatistic: goal for the shooter, assist (open play and set pieces of kind 3).
const int manager = state.manager_of(team); // MatchEngineRuntimeField16
if (shooter != 0xFFF) player_statistic(state, g.desc.at(0), shooter, manager, last_shooter_slot, 1, minute);
if (shooter != 0xFFF) player_statistic_hook(state, g.desc.at(0), shooter, manager, last_shooter_slot, 1, minute);
if ((kind == 0 || kind == 3) && assistant != 0xFFF)
player_statistic(state, g.desc.at(0), assistant, manager, last_assist_slot, 2, 0x5a);
player_statistic_hook(state, g.desc.at(0), assistant, manager, last_assist_slot, 2, 0x5a);
} else if (live == 2 && button(::bmh::layout::MatchEngine_Side_ExecutableField5)) {
live = 0; // ticker mode shows misses only if this button is off
}
@@ -1196,7 +1205,7 @@ void MatchEngine::penalty_shootout(MatchGroup& g, int m, MinuteReport& report) {
const int side = order[k];
const int team = pair[side];
int player = 0xFFF;
if (team < 138 || team == kNoTeam) {
if (team < world_layout().league_teams || team == no_team()) {
// a player who has not taken a penalty yet (after 100 tries the list restarts)
int tries = 0;
bool fresh;
+8 -4
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "game/rating.hpp"
#include "game/world_layout.hpp"
#include <array>
#include <cstdlib>
@@ -121,7 +122,7 @@ int human_correction(GameState& g, RatingContext& ctx, int manager, int rank, in
} // namespace
int team_rating(GameState& g, int team, const RatingProfile& profile, RatingContext& ctx, int* keeper) {
if (team >= 168 && team != kNoTeam) {
if (team >= world_layout().first_foreign_cup() && team != no_team()) {
// Clubs without squad: per group a random value around the level of the club
// (ForeignClubStrength bits 5-7 -> RatingRuntimeField2), +2 if the group's strength bit is set
// (bit 3, 3, 2, 1 for goal, defence, midfield, attack: RatingRuntimeField3) and a style
@@ -130,7 +131,7 @@ int team_rating(GameState& g, int team, const RatingProfile& profile, RatingCont
static const uint8_t kStrongBit[4] = {3, 3, 2, 1};
static const int8_t kStyle[8] = {0, 6, 0, -6, 0, -6, 0, 6};
if (!ctx.rand) throw std::invalid_argument("team_rating: a team without squad needs the Watcom generator");
const uint8_t s = g.foreign_strength.at(size_t(team - 168));
const uint8_t s = g.foreign_strength.at(size_t(team - world_layout().first_foreign_cup()));
int16_t total = 0;
for (int i = 0; i < 4; i++) {
const int level = kLevel[s >> 5];
@@ -143,7 +144,7 @@ int team_rating(GameState& g, int team, const RatingProfile& profile, RatingCont
// Human managers: the predicted final rank (Void5 in mode 1 before the tenth
// round of the manager's league, mode 2 after it) for the expected bonus. Mode 1 may
// post the season goal messages.
const int manager = team == kNoTeam ? -1 : g.manager_of(team); // local_5a
const int manager = team == no_team() ? -1 : g.manager_of(team); // local_5a
int rank = 0; // local_5e
if (manager >= 0) {
const size_t rec = size_t(manager) * 0xB0C;
@@ -151,7 +152,10 @@ int team_rating(GameState& g, int team, const RatingProfile& profile, RatingCont
const int mode = (league < int(g.league_rounds.size()) && g.league_rounds[size_t(league)] > 9) + 1;
std::array<uint8_t, 24> buf;
int size_word = -1;
const int r = table_prediction(g, g.manager_teams.at(size_t(manager)), mode, buf, &size_word);
// TablePrediction of the season core that owns the game (SeasonHooks; Classic by default).
const int r = g.season_hooks && g.season_hooks->table_prediction
? g.season_hooks->table_prediction(g, g.manager_teams.at(size_t(manager)), mode, buf, &size_word)
: table_prediction(g, g.manager_teams.at(size_t(manager)), mode, buf, &size_word);
rank = r == 0 ? 0xB : r + 1;
// Void5 (3 arguments) is called from the same frame as the player values
// (PlayerValue, 6 arguments): its league size word (local_2c, [ESP+0xfc]) lands in
+2 -1
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/world_layout.hpp"
#include "game/reality_setup.hpp"
#include <algorithm>
@@ -11,7 +12,7 @@ int manager(const GameState& state, int team) {
const int found = state.manager_of(team);
if (found >= 0) return found;
// FindManagerForClub's separate national-manager record is not in manager_teams.
if (!state.manager_teams.empty() && state.manager_teams[0] == kNoTeam &&
if (!state.manager_teams.empty() && state.manager_teams[0] == no_team() &&
state.manager_records.size() >= 4*0xb0c+0x292 &&
le16(state.manager_records,4*0xb0c+0x290) == team) return 4;
return -1;
+2 -1
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "game/schedule.hpp"
#include "game/world_layout.hpp"
#include "formats/executable_layout.hpp"
#include "formats/le.hpp"
@@ -129,7 +130,7 @@ void set_league_sizes(const uint8_t (&sizes)[kLeagueCount]) {
int total = 0;
for (int l = 0; l < kLeagueCount; l++) total += sizes[l];
const auto has_table = [](int teams) { return teams == 20 || teams == 18 || teams == 16 || teams == 12; };
if (total != 138 || !has_table(sizes[0]) || !has_table(sizes[5]))
if (total != world_layout().league_teams || !has_table(sizes[0]) || !has_table(sizes[5]))
throw std::invalid_argument("league sizes do not describe 138 league teams with fixture tables");
for (int l = 0; l < kLeagueCount; l++)
if (sizes[l] < 2 || sizes[l] > (l < 5 ? sizes[0] : sizes[5]))
+3 -2
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/world_layout.hpp"
#include "game/sportschau_presentation.hpp"
#include <algorithm>
#include "game/matchday.hpp"
@@ -25,7 +26,7 @@ std::optional<MatchdayIntroView> matchday_intro_view(const GameState& state,
if (league >= 9) throw FormatError("matchday intro: invalid Source league");
// LeagueName with TeamStatistics_SourceLeagueName_RuntimeField=1 includes the secondary-league prefix.
name = league < 5 ? league_name(state, int(league)) :
message_text(state, ::bmh::layout::SportschauAwards_MatchdayIntroView_TextPointer) + state.club_name(0x165 + int(league) - 4);
message_text(state, ::bmh::layout::SportschauAwards_MatchdayIntroView_TextPointer) + state.club_name(no_team() + int(league) - 4);
} else {
if (type > 14) throw FormatError("matchday intro: invalid Source competition type");
name = message_text(state, ::bmh::layout::DeskState_FormatError_ExecutableField3 + uint32_t(type) * 4);
@@ -43,7 +44,7 @@ std::string sportschau_competition_title(const GameState& state, const MatchGrou
if (id > 20) index = state.memory.u8(id + 0x18) + 9;
else if (index >= 9) index = std::min(index + 12, 19);
if (index < 5) return league_name(state, index);
if (index < 9) return state.club_name(0x165 + index - 4);
if (index < 9) return state.club_name(no_team() + index - 4);
return message_text(state, ::bmh::layout::CupDraw_FormatError_ExecutableField6 + uint32_t(index - 9) * 4);
}
+7 -9
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/world_layout.hpp"
#include "game/state.hpp"
#include <stdexcept>
@@ -10,11 +11,6 @@ namespace bmh {
namespace {
// Squad table layout constants of V2.24 (TeamsWithSquads, LargeSquadClubCount, NoTeamSquadStart).
constexpr int kBigSquadTeams = 90;
constexpr size_t kNoTeamSquadStart = 3072;
constexpr int kTeamsWithSquads = 168;
// C-style signed division by 8 as compiled by Watcom (rounds toward zero).
int div8(int x) { return x / 8; }
@@ -156,14 +152,16 @@ void GameState::formation_position(int team, int slot, int& x, int& y) const {
}
SquadRange squad_range(int team) {
if (team == kNoTeam) return {kNoTeamSquadStart, 24};
if (team < kBigSquadTeams) return {size_t(team) * 24, 24};
if (team < 138) return {size_t(team) * 16 + kBigSquadTeams * 8, 16};
// WorldLayout: Classic gives the original table (24 slots for the 90 German clubs, 16 for
// the 48 international ones from slot 2160, 24 for kNoTeam at 3072).
const WorldLayout& w = world_layout();
if (team == w.no_team()) return {w.pool_end, w.no_team_slots};
if (team >= 0 && team < w.league_teams) return {w.squad_start[size_t(team)], w.squad_size[size_t(team)]};
return {0, 0};
}
TeamAverage team_average(const GameState& g, int team, uint16_t flags, WatcomRandom* rand) {
if (team >= kTeamsWithSquads && team != kNoTeam) {
if (team >= world_layout().first_foreign_cup() && team != no_team()) {
// TeamRating(team, profile 2 at layout field): a random value around the club's level
if (!rand) throw std::invalid_argument("team_average: a team without squad needs the Watcom generator");
RatingContext ctx;
+13
View File
@@ -24,6 +24,7 @@ namespace bmh {
struct TransferOfferListView;
struct TransferDecisionEvent;
struct HumanBuyerSaleHooks;
struct GameState;
// Special team id used by the original for "no club" / the player pool (0x165).
constexpr int kNoTeam = 0x165;
@@ -35,7 +36,19 @@ constexpr int kNoTeam = 0x165;
constexpr uint16_t kEmptySlot = 0x0FFF;
constexpr uint16_t kSlotInLineup = 0x8000;
// Season functions the shared match core calls back into. Classic leaves the pointer in
// GameState empty and the core calls its own season functions; the Modern season core
// (src/modern) installs its versions, so one match core serves both season cores.
struct SeasonHooks {
void (*player_statistic)(GameState& g, int competition_type, int player, int manager, int slot, int kind,
int minute) = nullptr;
int (*table_prediction)(GameState& g, int team, int mode, std::array<uint8_t, 24>& buf,
int* size_word) = nullptr;
};
struct GameState {
// Season core callbacks for the shared match core; nullptr = Classic (see SeasonHooks).
const SeasonHooks* season_hooks = nullptr;
std::vector<uint16_t> squad_slots; // *SquadSlots, all squads back to back (see squad_range)
std::vector<Player> players; // *PlayerConditionTechniqueForm / *PlayerSkillWords / *PlayerIdentityWords, names not filled
std::vector<uint8_t> team_morale; // *TeamMorale, per team: bits 0-5 morale / 2, bits 6-7 flags
+68
View File
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// Read-only views of the weekly transfer list decision. GameState callbacks refer to them,
// so they are shared by the Classic and the Modern season cores.
#include <array>
#include <cstdint>
namespace bmh {
// Projection passed to the optional original-style seller decision callback
// (TransferListCountdown -> IncomingTransferScreen). Rows retain raw bid slots 0..3; ranking,
// quote RNG, and transaction remain in the synchronous weekly call site.
struct TransferOfferCandidateView {
int bid_index = -1;
bool present = false;
int buyer = -1;
int buyer_manager = -1;
uint32_t fee = 0;
uint32_t monthly_salary = 0;
uint32_t fee_reference = 0; // RateTransferBidSource for this offer's term
uint32_t salary_reference = 0;
uint8_t contract_months = 0; // raw term low 7 bits; high bit is loan
bool loan = false;
std::array<uint8_t, 7> bonuses{};
bool affordable = false;
bool has_squad_room = false;
bool passes_foreign_limit = false;
bool loan_permitted = true;
bool transaction_supported = true; // false for human-involved loans until return lifecycle is ported
bool eligible = false;
};
struct TransferOfferListView {
bool valid = false;
int list_entry = -1;
int player = -1;
int seller = -1;
int seller_manager = -1;
int seller_loan_count = -1; // DeskActions_Unsupported_RuntimeField[seller_manager], -1 when unavailable
int preferred_bid_index = -1;
bool preferred_bid_passed_random_check = false; // TransferListCountdown uVar6 < ranking score
int rejected_bid_index = -1;
uint32_t notice_text_address = 0;
uint32_t quoted_fee = 0;
uint32_t quoted_monthly_salary = 0;
uint8_t quoted_years = 0;
uint32_t asking_fee = 0;
uint32_t asking_monthly_salary = 0;
int offer_count = 0;
std::array<TransferOfferCandidateView, 4> offers{};
};
// Source-backed read-only events around transfer settlement and countdown
// notices. `offers` owns a snapshot of all four raw bid slots; selected_bid_index
// is the ranked raw row, not a compact row. last_week is the system modal at
// countdown 2 -> 1 and carries result_text_address PendingOffer_TransferLastWeekDialog_ExecutableField.
enum class TransferDecisionEventKind { evaluation, confirmation, last_week };
struct TransferDecisionEvent {
TransferDecisionEventKind kind = TransferDecisionEventKind::evaluation;
TransferOfferListView offers;
int selected_bid_index = -1;
bool accepted = false; // evaluation: the one W(90,110) result; confirmation: accepted/declined
int viewer_manager = -1; // ActiveManager at evaluation; human seller first, otherwise buyer
uint32_t result_text_address = 0; // evaluation: OK/NEIN; confirmation: PendingOffer_FormatError_ExecutableField2 / PendingOffer_PendingOfferNoticeDialog_ExecutableField
};
} // namespace bmh
+1 -57
View File
@@ -23,6 +23,7 @@
#include "game/random.hpp"
#include "game/state.hpp"
#include "game/transfer_allocator.hpp"
#include "game/transfer_offer_view.hpp"
#include <array>
#include <cstdint>
@@ -30,63 +31,6 @@
namespace bmh {
// Projection passed to the optional original-style seller decision callback
// (TransferListCountdown -> IncomingTransferScreen). Rows retain raw bid slots 0..3; ranking,
// quote RNG, and transaction remain in the synchronous weekly call site.
struct TransferOfferCandidateView {
int bid_index = -1;
bool present = false;
int buyer = -1;
int buyer_manager = -1;
uint32_t fee = 0;
uint32_t monthly_salary = 0;
uint32_t fee_reference = 0; // RateTransferBidSource for this offer's term
uint32_t salary_reference = 0;
uint8_t contract_months = 0; // raw term low 7 bits; high bit is loan
bool loan = false;
std::array<uint8_t, 7> bonuses{};
bool affordable = false;
bool has_squad_room = false;
bool passes_foreign_limit = false;
bool loan_permitted = true;
bool transaction_supported = true; // false for human-involved loans until return lifecycle is ported
bool eligible = false;
};
struct TransferOfferListView {
bool valid = false;
int list_entry = -1;
int player = -1;
int seller = -1;
int seller_manager = -1;
int seller_loan_count = -1; // DeskActions_Unsupported_RuntimeField[seller_manager], -1 when unavailable
int preferred_bid_index = -1;
bool preferred_bid_passed_random_check = false; // TransferListCountdown uVar6 < ranking score
int rejected_bid_index = -1;
uint32_t notice_text_address = 0;
uint32_t quoted_fee = 0;
uint32_t quoted_monthly_salary = 0;
uint8_t quoted_years = 0;
uint32_t asking_fee = 0;
uint32_t asking_monthly_salary = 0;
int offer_count = 0;
std::array<TransferOfferCandidateView, 4> offers{};
};
// Source-backed read-only events around transfer settlement and countdown
// notices. `offers` owns a snapshot of all four raw bid slots; selected_bid_index
// is the ranked raw row, not a compact row. last_week is the system modal at
// countdown 2 -> 1 and carries result_text_address PendingOffer_TransferLastWeekDialog_ExecutableField.
enum class TransferDecisionEventKind { evaluation, confirmation, last_week };
struct TransferDecisionEvent {
TransferDecisionEventKind kind = TransferDecisionEventKind::evaluation;
TransferOfferListView offers;
int selected_bid_index = -1;
bool accepted = false; // evaluation: the one W(90,110) result; confirmation: accepted/declined
int viewer_manager = -1; // ActiveManager at evaluation; human seller first, otherwise buyer
uint32_t result_text_address = 0; // evaluation: OK/NEIN; confirmation: PendingOffer_FormatError_ExecutableField2 / PendingOffer_PendingOfferNoticeDialog_ExecutableField
};
// Projects the current live rows without mutation or RNG. The selector caller
// performs the Source-ranked selection and ProjectTransferOfferList post-selection check.
TransferOfferListView project_transfer_offer_list(const GameState& g, int list_entry);
+57
View File
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "game/world_layout.hpp"
#include <stdexcept>
#include <utility>
namespace bmh {
namespace {
WorldLayout& current() {
static WorldLayout layout = classic_world_layout();
return layout;
}
} // namespace
WorldLayout classic_world_layout() {
// Squad table of V2.24 (TeamsWithSquads, LargeSquadClubCount, NoTeamSquadStart): the
// 90 German clubs have 24 slots, the 48 international clubs 16 from slot 90 * 24.
WorldLayout w;
w.squad_start.resize(size_t(w.league_teams));
w.squad_size.resize(size_t(w.league_teams));
for (int team = 0; team < w.league_teams; ++team) {
const bool german = team < w.german_teams;
w.squad_start[size_t(team)] = german ? uint32_t(team) * 24 : uint32_t(team) * 16 + uint32_t(w.german_teams) * 8;
w.squad_size[size_t(team)] = german ? 24 : 16;
}
return w;
}
const WorldLayout& world_layout() { return current(); }
void set_world_layout(WorldLayout layout) {
const size_t teams = size_t(layout.league_teams);
if (layout.league_teams <= 0 || layout.german_teams < 0 || layout.german_teams > layout.league_teams ||
layout.amateur_teams < 0 || layout.foreign_cup_teams < 0 || layout.national_teams < 0 ||
layout.squad_start.size() != teams || layout.squad_size.size() != teams)
throw std::invalid_argument("world layout: inconsistent team ranges");
// Squads lie back to back in id order before the pools; the pools and the no-club
// squad follow in their fixed order.
uint32_t next = 0;
for (size_t team = 0; team < teams; ++team) {
if (layout.squad_start[team] != next || layout.squad_size[team] == 0)
throw std::invalid_argument("world layout: squads must be consecutive");
next += layout.squad_size[team];
}
if (layout.transfer_list != next || layout.free_agents != layout.transfer_list + 44 ||
layout.foreign_offers != layout.free_agents + 80 || layout.pool_end != layout.foreign_offers + 20 ||
layout.total_slots < layout.pool_end + layout.no_team_slots)
throw std::invalid_argument("world layout: pools must follow the squads");
// Squad slot values hold 12-bit player ids; loans store 10-bit club ids.
if (layout.total_teams() > 1023) throw std::invalid_argument("world layout: too many teams");
current() = std::move(layout);
}
} // namespace bmh
+59
View File
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// The dimensions of a game world: team id ranges and the squad slot table.
//
// The original game (Classic) fixes them: 138 league clubs (90 German with 24 squad
// slots, 48 international with 16), 30 amateur clubs, 189 squadless foreign cup clubs,
// the pseudo team kNoTeam (0x165) for the national team / player pool, and the
// player pools behind the squads. Classic never changes the layout, so every shared
// function below returns exactly the original numbers there.
//
// The Modern season core (docs/new_engine) installs a layout derived from its world
// data, for example 168 league clubs with 24 slots each. One game per process, like
// the league tables of schedule.hpp.
#include <cstddef>
#include <cstdint>
#include <vector>
namespace bmh {
struct SquadRange;
struct WorldLayout {
// Team id ranges, in this order: league clubs, amateur clubs (cup newcomers),
// squadless foreign cup clubs, the pseudo team "no club", national teams.
int league_teams = 138; // ids 0 .. league_teams-1 have squads
int german_teams = 90; // the first league clubs (German leagues)
int amateur_teams = 30; // ids league_teams .. +amateur_teams-1, no squads
int foreign_cup_teams = 189; // squadless foreign clubs (27 nations x 7)
int national_teams = 62; // after no_team
// Squad slot table: first slot and slot count per league club, then the pools.
std::vector<uint32_t> squad_start; // per league club
std::vector<uint8_t> squad_size; // per league club
uint32_t transfer_list = 0xB70; // 44 slots: players on the transfer list
uint32_t free_agents = 0xB9C; // 80 slots: players without a club
uint32_t foreign_offers = 0xBEC; // 20 slots: players offered from abroad
uint32_t pool_end = 0xC00; // end of the pools = first slot of no_team
uint32_t no_team_slots = 24; // the national team / no-club squad
uint32_t total_slots = 3150; // including the reserve behind no_team
int first_amateur() const { return league_teams; }
int first_foreign_cup() const { return league_teams + amateur_teams; }
int no_team() const { return first_foreign_cup() + foreign_cup_teams; }
int total_teams() const { return no_team() + national_teams; }
bool has_squad(int team) const { return (team >= 0 && team < league_teams) || team == no_team(); }
};
// The original dimensions (V2.24 and the supported German and English editions).
WorldLayout classic_world_layout();
// The layout of the running game (Classic unless a Modern session installed another).
const WorldLayout& world_layout();
void set_world_layout(WorldLayout layout);
// Shortcut for the pseudo team "no club" of the running game (Classic: kNoTeam, 0x165).
inline int no_team() { return world_layout().no_team(); }
} // namespace bmh