Restore full environment controls and original match pacing for 0.1.2 (by Codex)
Build without game data / build (windows-x64, windows-2022) (push) Canceled after 0s
Build without game data / build (macos-arm64, macos-14) (push) Canceled after 0s
Build without game data / build (linux-x64, ubuntu-24.04) (push) Canceled after 0s
Prepare release packages / build (push) Canceled after 0s
Prepare release packages / draft (push) Canceled after 0s

This commit is contained in:
Codex committed 2026-10-17 21:09:38 +02:00
1 parent 4fb8b2f551
commit 310e3e2464
30 files changed
+422 -383

No files matched your search

+7 -17
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "game/balance_plan.hpp"
#include <algorithm>
@@ -160,13 +161,6 @@ uint32_t catering_per_game(const GameState& g, int m, int32_t gate) {
return sum;
}
// OpenBMH deviates from the original: omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
// TeamLeague3 (supported rule profile patch): the youth academy limit of the league
int32_t youth_limit(const GameState& g, int m) {
const int league = team_league(g.manager_teams.at(size_t(m)));
return league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
}
// The redraw of BalanceFromGame2 (with its continuation Redraw and the patch at
// Redraw2): recomputes the items if `refresh` asks for it, then the spectator income
// and the totals.
@@ -228,12 +222,12 @@ void redraw(const GameState& source, BalancePlanDraft& d) {
r[4] = wrap(int64_t(r[4]) + int64_t(facility_income(g, m)) * months);
const uint32_t catering = catering_per_game(g, m, r[kBalanceAverageGate]);
r[4] = wrap(int64_t(r[4]) + int64_t((catering * uint32_t(home)) / 12) * months);
// running costs Spending: the patch counts only the youth academy (index 1),
// with the whole league limit while +0x880 is below it
const uint32_t costs = ::bmh::layout::Spending + uint32_t(m) * 0x24;
if (mem32(g, costs + 4) != 0 && int64_t(months) * mem32(g, costs + 4) != 0) {
const int32_t limit = youth_limit(g, m);
if (uint32_t(rec32(g, m, 0x880)) < uint32_t(limit)) r[9] = wrap(int64_t(r[9]) + limit);
for (int k = 0; k < 3; ++k) {
const auto value = environment_monthly_cost(g, m, k);
const auto raw = mem32(g, costs + uint32_t(k) * 4);
const int count = k == kYouthAcademy && raw > kEnvironmentStep[k] * 6 ? 1 : months;
r[9] = wrap(int64_t(r[9]) + int64_t(count) * value);
}
for (int k = 0; k < 3; k++) r[size_t(10 + k)] = wrap(int64_t(r[size_t(10 + k)]) + int64_t(months) * mem32(g, costs + 0xc + uint32_t(k) * 4));
for (int k = 0; k < 2; k++) r[size_t(14 + k)] = wrap(int64_t(r[size_t(14 + k)]) + int64_t(months) * rec32(g, m, 0x854 + size_t(k) * 4));
@@ -276,11 +270,7 @@ int32_t stadium_required_attendance(const GameState& source, int manager) {
int32_t costs = wrap(int64_t(facility_costs(g, m)) + rec32(g, m, 0x854) + rec32(g, m, 0x858));
costs = wrap(int64_t(costs) + monthly_pay(g, m, 0xa));
for (int k = 0; k < 6; ++k) {
int32_t value = mem32(g, ::bmh::layout::Spending + uint32_t(m) * 0x24 + uint32_t(k) * 4);
if (k == 0 || k == 2) value = 0; // OpenBMH deviates from the original: omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
// supported rule profile MonthlyExpenses
if (k == 1 && value != 0)
value = uint32_t(rec32(g, m, 0x880)) < uint32_t(youth_limit(g, m)) ? youth_limit(g, m) : 0;
const int32_t value = environment_monthly_cost(g, m, k);
costs = wrap(int64_t(costs) + value);
}
costs = wrap(int64_t(costs) - shares_and_loans(g, m, 2, 0) + int(rec8(g, m, 0x179)) * 1000);
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// OpenBMH deviates from the original: uses the supported staff and youth-academy cost categories.
// All three youth budgets and staff costs share the monthly environment model.
// The balance plan ("Bilanz", desk menu 28, mode III; H2 p. 26-27; BMH.exe V2.24 + supported rule profile
// patch): the screen BalanceFromGame2 projects the club's income and expenses for the business
// year and lets the manager change every item. When he leaves the screen the resulting
+97 -87
View File
@@ -1,103 +1,113 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include <algorithm>
#include "game/messages.hpp"
#include "game/schedule.hpp"
#include "game/week.hpp"
#include <cstdlib>
namespace bmh {
namespace {
constexpr uint32_t kSpending = ::bmh::layout::Spending; // + manager * 0x24 + item * 4
constexpr size_t kRecordSize = 0xb0c;
constexpr size_t kYouthPaid = 0x880; // youth expenses booked this season
// EnvironmentRuntimeField: the step of each item in thousands (items 3..5: 5 000 per level)
constexpr int kUnit[kEnvironmentItems] = {2, 4, 5, 5, 5, 5};
uint32_t spending_at(int manager, int item) { return kSpending + uint32_t(manager) * 0x24 + uint32_t(item) * 4; }
// TeamLeague3: the academy's season price by the club's league
int32_t youth_price(const GameState& g, int manager) {
const int league = team_league(g.manager_teams.at(size_t(manager)));
return league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
uint32_t youth_at(int manager) { return layout::EnvironmentYouthTeams + uint32_t(manager) * 0x24; }
uint32_t spending_at(int manager, int item) {
return layout::Spending + uint32_t(manager) * 0x24 + uint32_t(item) * 4;
}
// YouthOpen: July (unless the Bundesliga is past its 17th round) or August
bool youth_open(const GameState& g) {
const int month = month_code(g.date);
if (month == 7) return !(g.league_rounds.at(0) > 0x11);
return month == 8;
void validate_manager(const GameState& g, int manager) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() ||
!g.memory.has(youth_at(manager) + 8) || !g.memory.has(spending_at(manager, 5) + 3))
throw FormatError("environment: invalid manager or truncated budgets");
}
bool youth_paid(const GameState& g, int manager) {
const size_t at = size_t(manager) * kRecordSize + kYouthPaid;
const uint32_t paid = uint32_t(g.manager_records.at(at)) | uint32_t(g.manager_records.at(at + 1)) << 8 |
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
return paid >= uint32_t(youth_price(g, manager));
int direction(int value) { return (value > 0) - (value < 0); }
int signed_clamp(int value, int low, int high) {
return std::clamp(int(int8_t(uint8_t(value))), low, high);
}
bool legacy_academy(const GameState& g, int manager) {
const auto value = g.memory.u32(spending_at(manager, kYouthAcademy));
return value == 1500000 || value == 1000000 || value == 580000 || value == 280000;
}
uint32_t academy_paid(const GameState& g, int manager) {
const auto at = size_t(manager) * 0xb0c + 0x880;
return uint32_t(g.manager_records.at(at)) | uint32_t(g.manager_records.at(at + 1)) << 8 |
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
}
}
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
const auto value = g.memory.u32(spending_at(manager, item));
if (item == kYouthAcademy && legacy_academy(g, manager) && academy_paid(g, manager) >= value) return 0;
return int32_t(value);
}
bool environment_academy_active(const GameState& g, int manager) {
const auto value = g.memory.u32(spending_at(manager, kYouthAcademy));
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
}
} // namespace
EnvironmentState environment_state(const GameState& g, int manager) {
EnvironmentState s;
for (int i = 0; i < kEnvironmentItems; i++) {
s.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
// the stars (SizeT7): staff value / step, the academy 6 when on, 0/2 none
if (i >= 3) s.level[size_t(i)] = std::clamp(s.monthly[size_t(i)] / (kUnit[i] * 1000), 0, 6);
else if (i == kYouthAcademy) s.level[size_t(i)] = s.monthly[size_t(i)] != 0 ? 6 : 0;
validate_manager(g, manager);
EnvironmentState result;
for (int i = 0; i < kEnvironmentItems; ++i) {
result.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
result.level[size_t(i)] = std::clamp(result.monthly[size_t(i)] / kEnvironmentStep[size_t(i)], 0, 6);
}
s.youth_price = youth_price(g, manager);
s.youth_paid = youth_paid(g, manager);
s.youth_open = youth_open(g);
return s;
}
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems || level < 0 ||
level > 6 || !g.memory.has(spending_at(manager, item) + 3))
return EnvironmentResult::invalid;
const uint32_t at = spending_at(manager, item);
const int32_t before = int32_t(g.memory.u32(at));
int32_t value = 0;
EnvironmentResult result = EnvironmentResult::changed;
if (item >= 3) {
value = level * kUnit[item] * 1000;
} else if (item == kYouthAcademy) {
// YouthPrice: a click on an active academy means "off"
int wanted = level;
if (before != 0 && wanted != 0) wanted = 0;
const int32_t price = youth_price(g, manager);
if (!youth_paid(g, manager)) {
if (wanted == 0) {
value = 0;
} else if (!youth_open(g)) {
value = 0;
result = EnvironmentResult::too_late;
if (message) *message = message_text(g, ::bmh::layout::Environment_SetEnvironment_ExecutableField); // "Zu spät für diese Saison..."
} else {
value = price;
}
} else {
// paid this season: stays on; a click meant as "off" brings the second string of
// the same text block (*Environment_SetEnvironment_ExecutableField + 0x42)
value = price;
if (wanted == 0) {
result = EnvironmentResult::contract_runs;
if (message) {
*message = message_text_following(g, ::bmh::layout::Environment_SetEnvironment_ExecutableField);
// OpenBMH-authored notice when an edition has no academy tail text.
if (message->empty()) *message = "This academy contract stays active until the season ends.";
}
}
}
for (uint32_t i = 0; i < 3; ++i) {
result.youth_strength[i] = g.memory.u8(youth_at(manager) + i);
result.youth_position[i] = g.memory.u8(youth_at(manager) + 3 + i);
result.youth_league[i] = g.memory.u8(youth_at(manager) + 6 + i);
if (result.youth_position[i] > 11 || result.youth_league[i] > 2)
throw FormatError("environment: invalid youth table");
}
g.memory.set32(at, uint32_t(value));
if (result == EnvironmentResult::changed && value == before) result = EnvironmentResult::unchanged;
return result;
}
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
if (message) message->clear();
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems ||
level < 0 || level > 6 || !g.memory.has(spending_at(manager, item) + 3))
return EnvironmentResult::invalid;
const auto at = spending_at(manager, item);
const auto value = uint32_t(level * kEnvironmentStep[size_t(item)]);
if (g.memory.u32(at) == value) return EnvironmentResult::unchanged;
g.memory.set32(at, value);
return EnvironmentResult::changed;
}
void advance_youth_teams(GameState& g, int manager, WatcomRandom& rand) {
const auto observed = environment_state(g, manager);
std::array<uint8_t, 44> movement{};
uint8_t step = 4;
for (auto& value : movement) {
value = step;
if (step != 0 && rand.range(0, 8) == 0) --step;
}
const auto round = g.league_rounds.at(0);
if (round >= movement.size()) throw FormatError("environment: youth round outside season");
constexpr int division_strength[] = {85, 70, 57};
for (size_t i = 0; i < 3; ++i) {
int strength = observed.youth_strength[i];
int position = observed.youth_position[i];
const int opponent = uint8_t(division_strength[observed.youth_league[i]] - position);
const int ratio = strength == 0 ? 100 :
int((((int64_t(observed.monthly[i]) * 100 / ((1 << i) * 10000)) >> 1) + 40) * 100 / strength);
int change = direction(ratio - 100);
if (rand.range(0, 4) == 0) change = rand.range(0, 2) - 1;
if (std::abs(ratio - 100) <= rand.range(0, 30)) change = 0;
if (rand.range(0, 2) == 0) strength = uint8_t(strength + change);
strength = signed_clamp(strength, 10, 85);
g.memory.set8(youth_at(manager) + uint32_t(i), uint8_t(strength));
const int difference = strength - opponent;
change = direction(difference);
if (rand.range(0, 4) == 0) change = rand.range(0, 2) - 1;
if (rand.range(0, 3) != 0 && std::abs(difference) * 2 < rand.range(1, 18)) change = 0;
position = signed_clamp(uint8_t(position - change * rand.range(1, movement[round])), 0, 11);
g.memory.set8(youth_at(manager) + 3 + uint32_t(i), uint8_t(position));
}
}
void finish_youth_season(GameState& g, int manager) {
const auto observed = environment_state(g, manager);
for (int i = 2; i >= 0; --i) {
auto division = observed.youth_league[size_t(i)];
const int position = observed.youth_position[size_t(i)];
int next_position = 5;
if (position < 2 && division != 0) { --division; next_position = position + 10; }
if (position > 10 && division < 2) { ++division; next_position = position - 10; }
if (i != 0) g.memory.set8(youth_at(manager) + uint32_t(i),
uint8_t((int(observed.youth_strength[size_t(i - 1)]) + observed.youth_strength[size_t(i)] * 2) / 3));
g.memory.set8(youth_at(manager) + 3 + uint32_t(i), uint8_t(next_position));
g.memory.set8(youth_at(manager) + 6 + uint32_t(i), division);
}
}
} // namespace bmh
+17 -33
View File
@@ -1,47 +1,31 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// OpenBMH deviates from the original: enables the supported youth academy and represents staff levels in monthly increments of five thousand.
// The club environment ("Umfeld", desk menu 24, H2 p. 93; supported rule profile manual p. 107, 111):
// the screen Image with the supported rule profile patch (SizeT7 / EnvironmentOperation /
// YouthPrice / YouthOpen). Six monthly running costs per manager live at
// Spending + manager * 0x24 (u32 each); the month change books them
// (month.cpp monthly_expenses) and the staff values steer training, injuries and healing.
//
// item 0, 2 the original's two other youth age groups: the patch always sets 0
// item 1 the youth academy (supported rule profile): on or off. On it is the league's season price
// (TeamLeague3: 1.5 M, 1 M, 580 000, 280 000), paid in full at the next month
// change while record +0x880 (youth expenses this season) is below it. It can
// be switched on in July and August only ("Zu spät für diese Saison...") and
// not switched off once paid ("Der Vertrag läuft bis zum Saisonende.").
// item 3..5 co-trainer, doctor, physio: level 0..6 times 5 000 a month (EnvironmentRuntimeField)
//
// A click on a tile sets the level from the mouse position (supported rule profile: one click per value).
#include <array>
#include <cstdint>
#include <string>
#include "game/random.hpp"
#include "game/state.hpp"
namespace bmh {
constexpr int kEnvironmentItems = 6;
enum EnvironmentItem : int { kYouthAcademy = 1, kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
// OpenBMH deviates from the original: uses six monthly environment budgets across data editions while retaining the shared staff prices and academy player-generation strength bands.
inline constexpr std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
struct EnvironmentState {
std::array<int32_t, kEnvironmentItems> monthly{}; // Spending values
std::array<int, kEnvironmentItems> level{}; // the stars the screen draws (0..6)
int32_t youth_price = 0; // the season price of the academy for the club's league
bool youth_paid = false; // record +0x880 reached the price: cannot be switched off
bool youth_open = false; // July/August: the academy can still be switched on
std::array<int32_t, kEnvironmentItems> monthly{};
std::array<int, kEnvironmentItems> level{};
std::array<uint8_t, 3> youth_strength{}, youth_position{}, youth_league{};
};
EnvironmentState environment_state(const GameState& g, int manager);
enum class EnvironmentResult : uint8_t { changed, unchanged, too_late, contract_runs, invalid };
// A click on `item` at `level` (0..6; for the academy any level > 0 means "on" and a click on
// an active academy switches it off). `message` gets the original's message box text, if any.
// Preserve already saved lump-sum academy contracts until the user edits them.
int32_t environment_monthly_cost(const GameState& g, int manager, int item);
bool environment_academy_active(const GameState& g, int manager);
enum class EnvironmentResult : uint8_t { changed, unchanged, invalid };
// Set a monthly budget to level 0..6, without an immediate debit or random draw.
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message = nullptr);
// Youth results advance with first-division matchdays. Promotion/relegation and
// the handover to the next age group happen before annual accounts.
void advance_youth_teams(GameState& g, int manager, WatcomRandom& rand);
void finish_youth_season(GameState& g, int manager);
} // namespace bmh
+2 -25
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "game/matchday.hpp"
#include <algorithm>
@@ -676,30 +677,6 @@ void manager_match_record(GameState& g, const MatchGroup& grp, int m, int home_g
}
// TicketPriceDraws: per human manager on a first league matchday. It once let the three
// ticket prices drift; in this version its stores were turned into comparisons (CMP
// instead of MOV), so only the random numbers remain.
void ticket_price_draws(const GameState& g, int manager, WatcomRandom& rand) {
uint8_t step[0x2c];
int b = 4;
for (int i = 0; i < 0x2c; i++) {
step[i] = uint8_t(b);
if (b != 0 && rand.range(0, 8) == 0) b--;
}
(void)g;
(void)manager;
const int round = g.league_rounds.empty() ? 0 : g.league_rounds[0];
for (int i = 0; i < 3; i++) {
// the direction terms depend on the prices, but only as values, not as draw counts
if (rand.range(0, 4) == 0) rand.range(0, 2);
rand.range(0, 30);
rand.range(0, 2);
if (rand.range(0, 4) == 0) rand.range(0, 2);
if (rand.range(0, 3) != 0) rand.range(1, 18);
rand.range(1, step[round < 0x2c ? round : 0x2b]);
}
}
// ManagerOf(manager, 0, value): the manager's position of this season.
static void store_season_position(GameState& g, int manager, int value) {
int season = std::min(g.season, 0x31);
@@ -742,7 +719,7 @@ void advance_league_rounds(GameState& g, uint32_t competitions, WatcomRandom& ra
for (int league = kFirst[c]; league < kFirst[c] + kCount[c]; league++) {
if (league == 0) {
for (size_t m = 0; m < g.manager_teams.size(); m++) {
ticket_price_draws(g, int(m), rand);
advance_youth_teams(g, int(m), rand);
const size_t rec = m * kManagerRecord;
if (g.league_rounds.at(0) == 0x10) wr32(g.manager_records, rec + 0x320, rd32(g.manager_records, rec + 0x308));
uint8_t& d = g.manager_records.at(rec + 0x220); // point deduction countdown
+3 -15
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "game/month.hpp"
#include "game/trace.hpp"
@@ -482,11 +483,9 @@ void return_loans(GameState& g, WatcomRandom& rand, GameRandom* game, MinuteRepo
}
}
// OpenBMH deviates from the original: omits the two discontinued youth-group cost categories from monthly accounts.
// OriginalFinancePreview(1): the month's expenses of a human manager: facility maintenance
// (BMHExeXa), record +0x854/+0x858, the wages of the squad (MonthlyPay with flags
// 14), the six running costs of Spending (the youth work capped per league by the
// supported rule profile patch MonthlyExpenses, which also drops the youth groups 0 and 2) and the debt
// 14), all six monthly environment budgets and the debt
// service (+0x179 x 1000); each booked in the statistics.
int32_t monthly_expenses(GameState& g, int m) {
std::vector<uint8_t>& r = g.manager_records;
@@ -514,18 +513,7 @@ int32_t monthly_expenses(GameState& g, int m) {
}
sum += wages;
for (int k = 0; k < 6; k++) {
int32_t v = int32_t(g.memory.u32(::bmh::layout::Spending + uint32_t(m) * 0x24 + uint32_t(k) * 4));
// OpenBMH deviates from the original: omits the two discontinued youth-group cost categories from monthly accounts.
// MonthlyExpenses (supported rule profile patch): the two other youth groups (items 0 and 2) cost
// nothing any more, whatever the saved value
if (k == 0 || k == 2) v = 0;
if (k == 1 && v != 0) {
// TeamLeague3: the limit of the league (1.5 M, 1 M, 580000, 280000); the full
// limit is paid while +0x880 is below it, nothing after
const int league = team_league(g.manager_teams.at(size_t(m)));
const uint32_t limit = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
v = rd32(r, rec + 0x880) < limit ? int32_t(limit) : 0;
}
const int32_t v = environment_monthly_cost(g, m, k);
if (k >= 3 && k <= 5) add32(r, rec + 0x878 + size_t(k) * 4, v);
else add32(r, rec + 0x880, v);
sum += v;
+15 -17
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "game/season.hpp"
#include <algorithm>
@@ -641,25 +642,21 @@ namespace {
} // namespace
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
// YouthAcademyPlayer(manager) with the supported rule profile patch (SeasonOperation2, SeasonOperation3, SeasonOperation4,
// SeasonOperation5): the youth academy's player at the season accounts. Only when the academy
// was paid in full this season (record +0x880 reached the league's price, TeamLeague3) and
// the squad has at most 22 players (SquadCount(team, 3)). A computer club's young player
// moves to the club: the slots 0x86f..0 of the big clubs are searched downwards (squads of
// human managers skipped) for a player not on loan whose age (years after 16) is at most
// G(t, t + 3), t starting at 15 and lowered by one for every pass that finds none. He leaves
// his club (ReleasePlayer), gets new values around a level of the club's league
// (GeneratePlayer with 0x3000: G(79, 95) first division, G(69, 85) second, G(49, 68) third,
// G(29, 48) below), a place in the squad with a fresh board entry (PendingOfferAnswer with the
// player id | 0xf000), mood 0x69 and an age of W(0, 4) (16..20). Returns whether a player
// came. The original's G(0, 0) before the search is kept.
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
// The middle youth budget enables the existing enhanced academy recruitment.
// Old lump-sum contracts remain eligible after their saved season payment.
// Player search, strength bands, age and board setup retain the shared rules.
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report) {
const int team = g.manager_teams.at(size_t(m));
const int league = club_league(team);
const uint32_t price = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
if (uint32_t(rec32(g, m, 0x880)) < price) return false;
if (!environment_academy_active(g, m)) return false;
if (squad_count(g, team, 3) > 0x16) return false;
const auto budget = g.memory.u32(::bmh::layout::Spending + uint32_t(m) * 0x24 + kYouthAcademy * 4);
if (budget <= uint32_t(kEnvironmentStep[kYouthAcademy] * 6) &&
g.memory.u8(::bmh::layout::CareerDuration) != 1 &&
int(g.memory.u8(::bmh::layout::EnvironmentYouthTeams + uint32_t(m) * 0x24 + 2)) <
team_average(g, team, 0xf3).value - 25)
return false;
const SquadRange own = squad_range(team);
if (game.range(0, 0) != 0) return false;
for (int t = 0xf;; --t) {
@@ -708,6 +705,7 @@ namespace {
void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report,
const SeasonTaxHooks& tax_hooks, SeasonTaxState& tax_state) {
for (size_t i = 0; i < 0xc; i++) rec8(g, m, 0x754 + i) = 0;
finish_youth_season(g, m);
if (!g.memory.has(::bmh::layout::Season_SeasonAccounts_RuntimeField)) g.memory.add_block(::bmh::layout::Season_SeasonAccounts_RuntimeField, 4); // (runtime only, not saved)
g.memory.set8(::bmh::layout::Season_SeasonAccounts_RuntimeField + uint32_t(m), 0);
season_event(g, m, game, rand, report);
@@ -720,8 +718,8 @@ void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand,
const SquadRange range = squad_range(team);
for (size_t s = 0; s < 24; s++)
if (g.squad_slots.at(range.first + s) != 0x0FFF) season_bonus(g, m, int(s), uint8_t(pos), true);
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
// YouthAcademyPlayer: the youth academy's player (supported rule profile), posted as Season_SeasonAccounts_TextPointer
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
// Academy recruitment is posted after the youth season has settled.
if (youth_academy_player(g, m, game, rand, report)) post_text(g, m, text_id(::bmh::layout::Season_SeasonAccounts_TextPointer));
if (report.unsupported) return;
if (league == 0 && pos < 100) rec8(g, m, 0x21c) = 1; // the best human club of the first division
+5 -5
View File
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#pragma once
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
// From one season to the next (BMH.exe V2.24 + supported rule profile patch).
//
// On 1 July the "Weiter" loop (DailyInterest) ends the season: CareerSession_RuntimeError_RuntimeField4 = 1, the season
@@ -94,10 +94,10 @@ void answer_offers(GameState& g, int manager, bool accept, WatcomRandom& rand, M
// offer slots (transfer list entries 0x28..0x2b, OfferSlots) are freed.
void free_offer_slots(GameState& g);
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
// YouthAcademyPlayer (supported rule profile youth academy, season accounts): when manager `m` paid the academy in
// full this season (+0x880) and has room, a young player of a computer club joins his squad
// with values by the league (see season.cpp). Returns whether one came.
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
// Annual recruitment with an active middle youth budget (or a paid legacy
// academy contract), provided the squad has room. Shared player strength bands
// remain in effect; see season.cpp.
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report);
// ClubBalance(0): every club's mood (TeamMorale, W(20, 30)) and flags (*TeamFlags): a random