Separate runtime roster and domestic boundaries for the 1.1 profile (by Codex)

This commit is contained in:
Codex committed 2026-10-31 09:59:10 +01:00
1 parent ff05d4f28a
commit aae6556708
9 files changed
+84 -20

No files matched your search

+1
View File
@@ -220,6 +220,7 @@ add_library(bmhcore STATIC
src/game/league_pairings.cpp
src/game/source_tip.cpp
src/game/table_forecast.cpp
src/game/profile_runtime.cpp
src/game/state.cpp
src/game/rating.cpp
src/game/match.cpp
+6 -6
View File
@@ -12,12 +12,12 @@ namespace bmh {
namespace {
constexpr size_t kPoolSlots = 2928; // CareerRuntimeField: the clubs' squads end here
constexpr size_t kTailFrom = 2928 + 40;
constexpr size_t kTailTo = 2972; // CareerRuntimeField2
constexpr size_t kExtraSlots = 3096; // CareerSession_DataDirectory_RuntimeField4: 54 extra players from here
constexpr size_t kSquadSlots = 3096 + 54;
constexpr int kLeagueTeams = 138; // CareerSession_DispatchLineup_RuntimeField
const int& kPoolSlots = runtime_dimensions.pool_first; // CareerRuntimeField: the clubs' squads end here
const int& kTailFrom = runtime_dimensions.market_special_first;
const int& kTailTo = runtime_dimensions.free_first; // CareerRuntimeField2
const int& kExtraSlots = runtime_dimensions.extra_slots_first; // CareerSession_DataDirectory_RuntimeField4: 54 extra players from here
const int& kSquadSlots = runtime_dimensions.total_slots;
const int& kLeagueTeams = runtime_dimensions.league_teams; // CareerSession_DispatchLineup_RuntimeField
// LeagueSizes: clubs per league; LeagueStrengthRanges: (minimum, maximum) strength per league.
// (the clubs per league are kLeagueSizes, schedule.hpp)
+23
View File
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "game/profile_runtime.hpp"
#include "formats/data_profile.hpp"
namespace bmh {
void install_runtime_profile(const DataProfile& profile) {
profile.validate();
RuntimeDimensions next;
next.league_teams=int(profile.counts.league_teams);
next.cup_teams=int(profile.counts.cup_teams);
next.big_squad_teams=int(profile.big_squad_teams);
next.record_teams=int(profile.counts.n42);
next.national_first=int(profile.national_first);
next.pool_first=int(profile.pool_first());
next.market_special_first=next.pool_first+40;
next.free_first=next.pool_first+44;
next.foreign_free_first=next.pool_first+124;
next.national_slots_first=int(profile.national_slots_first());
next.extra_slots_first=int(profile.extra_slots_first());
next.total_slots=int(profile.total_slots());
next.expanded=profile.extended();
runtime_dimensions=next;
}
}
+17
View File
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
namespace bmh {
struct DataProfile;
// Explicitly distinct concepts: German clubs, league clubs and large rosters.
// One installation is active per process, like the existing fixture/rule tables.
struct RuntimeDimensions {
int domestic_teams=90, league_teams=138, cup_teams=30, big_squad_teams=90;
int record_teams=168;
int national_first=357, pool_first=2928, market_special_first=2968;
int free_first=2972, foreign_free_first=3052, national_slots_first=3072;
int extra_slots_first=3096, total_slots=3150;
bool expanded=false;
};
inline RuntimeDimensions runtime_dimensions{};
void install_runtime_profile(const DataProfile& profile);
}
+5 -4
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "game/schedule.hpp"
#include "game/profile_runtime.hpp"
#include "formats/executable_layout.hpp"
#include "formats/le.hpp"
@@ -123,16 +124,16 @@ std::vector<Fixture> generate_fixtures(int teams, int matchday, int rounds, int
return out;
}
int league_table_teams(int league) { return league < 5 ? kLeagueSizes[0] : kLeagueSizes[5]; }
int league_table_teams(int league) { return runtime_dimensions.expanded ? kLeagueSizes[league] : (league < 5 ? kLeagueSizes[0] : kLeagueSizes[5]); }
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]))
throw std::invalid_argument("league sizes do not describe 138 league teams with fixture tables");
if (total != runtime_dimensions.league_teams || !has_table(sizes[0]) || !has_table(sizes[5]))
throw std::invalid_argument("league sizes do not match the installed profile and fixture tables");
for (int l = 0; l < kLeagueCount; l++)
if (sizes[l] < 2 || sizes[l] > (l < 5 ? sizes[0] : sizes[5]))
if (sizes[l] < 2 || (!runtime_dimensions.expanded && sizes[l] > (l < 5 ? sizes[0] : sizes[5])) || (runtime_dimensions.expanded && !has_table(sizes[l])))
throw std::invalid_argument("a league is larger than its fixture table");
for (int l = 0; l < kLeagueCount; l++) kLeagueSizes[l] = sizes[l];
}
+4 -4
View File
@@ -11,9 +11,9 @@ 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;
const int& kBigSquadTeams = runtime_dimensions.big_squad_teams;
const int& kNoTeamSquadStart = runtime_dimensions.national_slots_first;
const int& kTeamsWithSquads = runtime_dimensions.record_teams;
// C-style signed division by 8 as compiled by Watcom (rounds toward zero).
int div8(int x) { return x / 8; }
@@ -158,7 +158,7 @@ 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};
if (team < runtime_dimensions.league_teams) return {size_t(team) * 16 + kBigSquadTeams * 8, 16};
return {0, 0};
}
+2 -1
View File
@@ -16,6 +16,7 @@
#include "formats/savestate.hpp"
#include "formats/textd.hpp"
#include "game/memory.hpp"
#include "game/profile_runtime.hpp"
#include "game/random.hpp"
#include "game/reality_motion.hpp"
@@ -26,7 +27,7 @@ struct TransferDecisionEvent;
struct HumanBuyerSaleHooks;
// Special team id used by the original for "no club" / the player pool (0x165).
constexpr int kNoTeam = 0x165;
inline const int& kNoTeam = runtime_dimensions.national_first;
// Squad slot values (u16 in table *SquadSlots):
// bits 0-11 player id, 0xFFF = empty slot
+6 -5
View File
@@ -32,8 +32,8 @@ constexpr size_t kBoard = 0x840; // tactics board of a manager
constexpr size_t kBoardSlot = 0x58;
constexpr uint32_t kTransferList = ::bmh::layout::EditorList; // 44 entries of 0x58 bytes, one per pool slot
constexpr uint32_t kListEntry = 0x58;
constexpr size_t kPoolSlots = 0xb70; // CareerRuntimeField: first squad slot of the transfer pool
constexpr int kLeagueClubs = 0x8a; // CareerSession_DispatchLineup_RuntimeField
const int& kPoolSlots = runtime_dimensions.pool_first; // CareerRuntimeField: first squad slot of the transfer pool
const int& kLeagueClubs = runtime_dimensions.league_teams; // CareerSession_DispatchLineup_RuntimeField
constexpr int kBigSquadClubs = 90; // TeamsWithSquads
// Offers and incidents (Bool): 1 in WeeklyRuntimeField[kind] is only possible while the
@@ -154,8 +154,9 @@ int squad_count(const GameState& g, int team, int flags) {
// SlotTeam: club of an absolute squad slot (-1 for the pool).
int slot_team(int slot) {
if (slot < kBigSquadClubs * 24) return slot / 24;
if (slot < int(kPoolSlots)) return (slot - kBigSquadClubs * 24) / 16 + kBigSquadClubs;
const int large=runtime_dimensions.big_squad_teams;
if (slot < large * 24) return slot / 24;
if (slot < int(kPoolSlots)) return (slot - large * 24) / 16 + large;
return -1;
}
@@ -605,7 +606,7 @@ void transfer_bid(GameState& g, int slot, uint32_t list, bool high, int months,
const int r = rand.range(int16_t(need) + 3, int16_t(need) + 0xd);
if (int16_t(diff) < r) score += int(int16_t(need + 0xe - diff)) * 16 + 100;
else score -= int16_t(diff) * 8;
const int8_t* wanted = team < kBigSquadClubs ? kWantedBig : kWantedSmall;
const int8_t* wanted = team < runtime_dimensions.big_squad_teams ? kWantedBig : kWantedSmall;
int16_t d = int16_t(wanted[position] - int8_t(count[position]));
if (d < 0) {
score += int(d) << 8;
+20
View File
@@ -1,8 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/data_profile.hpp"
#include "formats/savestate.hpp"
#include "game/profile_runtime.hpp"
#include "game/state.hpp"
#include "game/weekly.hpp"
#include "game/schedule.hpp"
#include "formats/executable_layout.hpp"
#include <filesystem>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <stdexcept>
@@ -26,6 +31,21 @@ int main()try {
check(decoded.block(bmh::layout::PlayerConditionTechniqueForm).size == profile.counts.players * 4,
"player block ignored configured profile counts");
}
bmh::install_runtime_profile(expanded);
check(bmh::squad_range(163).first==3912 && bmh::squad_range(163).count==24,
"last international club does not have a full-size squad");
check(bmh::squad_range(bmh::kNoTeam).first==4080 && bmh::kNoTeam==383,
"national squad overlaps the expanded clubs/pool");
check(bmh::slot_team(3935)==163 && bmh::slot_team(3936)==-1,
"absolute slot ownership was truncated or misclassified");
uint8_t sizes[9];std::copy(expanded.leagues.begin(),expanded.leagues.end(),sizes);
bmh::set_league_sizes(sizes);
check(bmh::league_table_teams(6)==20 && bmh::league_table_teams(5)==18,
"England incorrectly shares the smaller foreign fixture table");
bmh::install_runtime_profile(classic);std::copy(classic.leagues.begin(),classic.leagues.end(),sizes);bmh::set_league_sizes(sizes);
check(bmh::runtime_dimensions.record_teams==168,"Classic cup-only rating boundary changed");
check(bmh::squad_range(90).first==2160 && bmh::squad_range(90).count==16 && bmh::kNoTeam==357,
"switching back did not restore original squad conventions");
auto invalid=expanded;invalid.counts.players=4095;bool rejected=false;
try{invalid.validate();}catch(const bmh::FormatError&){rejected=true;}
check(rejected,"Player-ID sentinel collision accepted");