Prepare Classic 1.0 edition rules and Diamond 3.7 foreign crests (by Codex)

This commit is contained in:
Codex committed 2026-10-30 15:39:56 +01:00
1 parent c293a35f56
commit 8ee062ea46
46 files changed
+296 -147

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ name: Build without game data
on:
push:
branches: [main]
branches: [main, release/1.0]
pull_request:
workflow_dispatch:
workflow_call:
+1 -1
View File
@@ -37,4 +37,4 @@ jobs:
*) echo "Release tag and package version differ" >&2; exit 1 ;;
esac
done
gh release create "$RELEASE_TAG" dist/*.zip --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/0.1/RELEASE_NOTES.md
gh release create "$RELEASE_TAG" dist/*.zip --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/1.0/RELEASE_NOTES.md
+13 -4
View File
@@ -1,8 +1,14 @@
# SPDX-License-Identifier: GPL-3.0-only
cmake_minimum_required(VERSION 3.24)
project(OpenBMH VERSION 0.1.2 LANGUAGES CXX C)
project(OpenBMH VERSION 1.0.0 LANGUAGES CXX C)
set(OPENBMH_PRERELEASE "rc.1" CACHE STRING "Prerelease identifier; empty for final release")
set(OPENBMH_PRODUCT_VERSION "${PROJECT_VERSION}")
if(OPENBMH_PRERELEASE)
string(APPEND OPENBMH_PRODUCT_VERSION "-${OPENBMH_PRERELEASE}")
endif()
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/product-version.txt" CONTENT "${OPENBMH_PRODUCT_VERSION}\n")
# the one place of the version: --version of both programs and the window title (src/version.hpp)
add_compile_definitions(OPENBMH_VERSION="${PROJECT_VERSION}")
add_compile_definitions(OPENBMH_VERSION="${OPENBMH_PRODUCT_VERSION}")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -202,7 +208,6 @@ add_library(bmhcore STATIC
src/formats/textd.cpp
src/formats/fbm.cpp
src/formats/le.cpp
src/formats/rule_base.cpp
src/formats/m3d.cpp
src/formats/savestate.cpp
src/game/schedule.cpp
@@ -441,7 +446,7 @@ add_executable(openbmh_play
target_link_libraries(openbmh_play PRIVATE bmhui bmhlaunch_dialog openbmh_audio ${BMH_SDL_TARGET})
# a game without a console window on double-click (SDL2main provides WinMain); started from a
# console it attaches to that one for --version, --help and start errors (src/app/main.cpp)
set_target_properties(openbmh_play PROPERTIES WIN32_EXECUTABLE TRUE)
set_target_properties(openbmh_play PROPERTIES WIN32_EXECUTABLE TRUE OUTPUT_NAME OpenBMH)
if(MSVC)
target_compile_options(openbmh_play PRIVATE /utf-8)
# App sources also compile in headless tests/helpers without target /utf-8.
@@ -1106,3 +1111,7 @@ foreach(dependency IN ITEMS SDL2 miniz lzma_sdk nfd)
string(JSON package_dependencies SET "${package_dependencies}" "${dependency}" "\"${dependency_path}\"")
endforeach()
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/package-dependencies.json" CONTENT "${package_dependencies}\n")
add_executable(classic_rules_unit_tests tests/classic_rules_unit_tests.cpp)
target_link_libraries(classic_rules_unit_tests PRIVATE bmhcore)
add_test(NAME classic_rules_unit_tests COMMAND classic_rules_unit_tests)
+10 -10
View File
@@ -1,10 +1,10 @@
# OpenBMH
A modern and faithful open source rebuild of the *Bundesliga Manager Hattrick* engine.
A faithful, standalone community reconstruction of *Bundesliga Manager Hattrick*, using the player's original installation and SDL2 interface.
OpenBMH is a standalone C++20 engine with an SDL2 interface for *Bundesliga Manager Hattrick* (1994/95) and its English edition, *Football Limited*. The project develops a playable reconstruction alongside a platform for new rules, content and interfaces. Keeping the familiar game enjoyable and making it easier to extend are equally important goals.
OpenBMH 1.0 is the Classic line, based on v0.1.2 with reviewed bug fixes. It starts directly with original data: no mod launcher, converter or OBW package is required. Original game files, graphics, audio and manuals are not distributed. German CD-compatible BMH and verified Diamond editions are the primary release targets. Football Limited remains experimental; the older floppy executable is not supported.
The engine reads a game installation supplied by the player. Game data, artwork, music, manuals and the original executable are not distributed with OpenBMH. Its aim is recognisable behaviour and plausible results; documented compatibility decisions and safety fixes take precedence over reproducing every original fault.
The former 0.3 / NextGen development continues separately as [Dreierpack Manager](https://github.com/Weyoune/Dreierpack-Manager). OpenBMH remains available for community maintenance and extensions of the original game.
This is an independent community project, with no affiliation with or endorsement by the original rights holders, the DFL or the Bundesliga. It is an engine implementation, not an official source release or a remaster.
@@ -14,12 +14,12 @@ Check the [releases page](https://github.com/Weyoune/openbmh/releases) for avail
1. Have your own supported game installation available.
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
3. Start `openbmh_play` (`openbmh_play.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
3. Start `OpenBMH` (`OpenBMH.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
From a terminal:
```sh
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
OpenBMH --data "path/to/game" --save-directory "path/to/saves"
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
```
@@ -29,11 +29,11 @@ Use a writable save directory and keep backups of existing games. German edition
The graphical client and console share career management, matches, transfers, contracts, finances, training, stadium management and save handling. The console supports command batches, structured views and multiple manager clients. Audio is decoded from the user's installation where supported.
Version 0.1 establishes the playable engine and development interfaces. Later milestones introduce an open data format and typed model, configurable rules, a scalable interface and independently distributable content. These are goals rather than delivery dates; the [roadmap](docs/ROADMAP.md) describes their dependencies.
OpenBMH focuses on Classic compatibility, stability and community contributions. Next-generation interfaces, open-world formats and configurable competition structures belong to Dreierpack Manager.
## Build from source
The following recipes target v0.1.2. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
The following recipes target OpenBMH 1.0 release candidates. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
Clone the public repository, then run the commands for your system:
@@ -50,7 +50,7 @@ Install Visual Studio 2022 or its Build Tools with **Desktop development with C+
cmake -S . -B build-windows -G "Visual Studio 17 2022" -A x64
cmake --build build-windows --config Release
ctest --test-dir build-windows -C Release --output-on-failure
.\build-windows\Release\openbmh_play.exe --data "path/to/game" --save-directory "path/to/saves"
.\build-windows\Release\OpenBMH.exe --data "path/to/game" --save-directory "path/to/saves"
```
### Linux
@@ -62,7 +62,7 @@ sudo apt install build-essential git cmake ninja-build pkg-config libgtk-3-dev l
cmake -S . -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-linux
ctest --test-dir build-linux --output-on-failure
./build-linux/openbmh_play --data "path/to/game" --save-directory "path/to/saves"
./build-linux/OpenBMH --data "path/to/game" --save-directory "path/to/saves"
```
Use a newer CMake if your distribution ships a version older than 3.24. A Linux binary can still require system libraries such as GTK3; a ZIP is not a guarantee of portability across distributions.
@@ -77,7 +77,7 @@ brew install cmake ninja
cmake -S . -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64
cmake --build build-macos
ctest --test-dir build-macos --output-on-failure
./build-macos/openbmh_play --data "path/to/game" --save-directory "path/to/saves"
./build-macos/OpenBMH --data "path/to/game" --save-directory "path/to/saves"
```
On Intel Macs omit the arm64 setting or select `x86_64`. These commands build terminal executables; they do not create a signed application bundle.
+12 -21
View File
@@ -2,7 +2,7 @@
OpenBMH aims to preserve the familiar game while handling malformed input and unsafe edge cases explicitly. A reconstruction can remain faithful without reproducing a crash or pretending to implement an unknown path.
- Content such as names, text, graphics and edition-specific tables is loaded from the user's installation. OpenBMH's shared rule base supplies simulation values; selecting another data edition does not select a separate engine.
- Content such as names, text, graphics and edition-specific tables is loaded from the user's installation. The loaded program retains its own rule-table values; loading no longer applies the former shared replacement profile.
- Safety checks reject transactions that would exhaust required return capacity, use stale identities or lose a valid state. Unsupported operations report their limitation rather than inventing an outcome.
- Calendar progression handles boundary days and seasonal transitions without relying on unsafe fixed-day assumptions.
- Saves are written from the committed session state. Saving does not deliberately replay unrelated game actions.
@@ -23,26 +23,17 @@ An unavailable native message box also cancels the request. This applies to
voluntary application exits, including quit events received during animations;
normal completed-career handling remains separate.
## Environment and presentation in 0.1.2
## Original edition rules in 1.0
The desktop environment provides three youth teams and three staff
budgets, each set to zero through six stars. Youth budgets are monthly, can be
changed throughout the season, and contribute to the finance preview, balance
plan and booked expenses. Youth tables develop on first-division matchdays;
promotion, relegation and age-group handover occur at the season change.
The two previously hidden youth groups are available across data editions.
Staff prices and the shared academy player-generation strength bands stay in
effect. Recruitment needs an active middle youth budget and an oldest youth team
within 25 strength points of the senior squad (the full-build mode bypasses the
strength gate). This deliberately
combines the six-budget environment with OpenBMH's existing player-generation rules.
Loaded executable images are not rewritten to the former shared rule profile. Career strength ranges are read from all nine pairs of the original table. Normalized simulation values from 0.2/NextGen are not backported.
Old saved academy lump sums remain payable once and retain their paid status.
They are not multiplied into twelve monthly payments. Editing that tile replaces
the old amount with the selected monthly budget. There is no new save field.
The six-budget monthly environment implementation has been checked against the provided CD and Diamond 3.6/3.7 program code. Its budget increments are read from that program's own table. Capability recognition uses verified code fingerprints, never directory names. Unrecognized environment implementations cannot be edited or simulated through a guessed model; they require separate compatibility verification. Older Diamond academy patches are not silently treated as the monthly model. The old floppy executable remains unsupported, and Football Limited remains experimental.
Live match minutes use the loaded original delay setting (A9), including zero,
instead of an added fixed pause. A9 and the existing scene delays can be adjusted
in Settings; loaded saves and EIN files retain their chosen speeds. VGA retrace
animations use a 70-Hz reference instead of the host monitor's refresh rate.
`--live-frame-ms` and `BMH_LIVE_FRAME_MS` remain explicit diagnostic overrides.
Release acceptance of individual editions is recorded separately from their recognition. Source compatibility and automated tests do not establish full original-game or platform validation.
## Diamond 3.7 foreign crests
The supplied edition controls whether foreign league clubs use individual
original crests or the original neutral crest. OpenBMH recognizes the verified
Diamond 3.7 drawing gate and uses its database/save selectors and W atlases.
Older drawing gates retain their own behaviour; no external crest pack is needed.
-4
View File
@@ -7,14 +7,10 @@ describe deliberate changes; they are not a list of every known compatibility li
- [src/app/career_session.cpp](../src/app/career_session.cpp): supports designated set-piece record initialization and validation.
- [src/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
- [src/formats/le.hpp](../src/formats/le.hpp): applies a shared supported rule profile when loading editions with different rule-table values.
- [src/formats/rule_base.cpp](../src/formats/rule_base.cpp): normalizes live-scene defaults, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit across supported editions.
- [src/formats/rule_base.hpp](../src/formats/rule_base.hpp): normalizes live-scene options, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit.
- [src/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
- [src/game/career.hpp](../src/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
- [src/game/desk_actions.cpp](../src/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): supports designated set-piece records and the supported transfer-editor rules.
- [src/game/environment.hpp](../src/game/environment.hpp): uses six monthly environment budgets across data editions while retaining the shared staff prices and academy player-generation strength bands.
- [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image.
- [src/game/lineup.cpp](../src/game/lineup.cpp): disables the foreign-player limit in the supported rule profile.
- [src/game/lineup.hpp](../src/game/lineup.hpp): disables the foreign-player limit and supports owner-bound designated set-piece selection.
+1 -1
View File
@@ -19,7 +19,7 @@ OpenBMH reconstructs the Bundesliga Manager Hattrick engine in C++20. The graphi
- Setup ignores mouse releases without a matching press on that screen, so
window activation cannot toggle the initial league/national-team selection
through that input path ([#10](https://github.com/Weyoune/openbmh/issues/10)).
- Source builds include the standalone [OBW installation converter](../../formats/obw/import.md).
- Source builds include the standalone [OBW installation converter](https://github.com/Weyoune/openbmh/blob/v0.2.1/docs/formats/obw/import.md).
It produces intermediate database conversions; game integration remains
planned for 0.2.
+46
View File
@@ -0,0 +1,46 @@
# Classic 1.0 backport audit
Baseline: v0.1.2. The release branch keeps the existing public history; the baseline restoration is an ordinary commit, not a force reset of main.
| Later change | Decision |
|---|---|
| 8326a23: host filenames/path display, setup input guards | Included; direct-installation code, no launcher/converter dependency |
| e1d17d8: explicit quit confirmation | Included; cancellation preserves current owner/state |
| c8f04d0: reschedule undo replay bit | Included; restores original target-day availability |
| b879d5b: standalone original message texts | Included as a focused adaptation; no native-content dependency |
| 978a014: edition-specific restored match-group expansion | Pending compatibility verification; no OBW save changes will be taken |
| 0b2354c: native file flows and English media | OBW paths excluded; applicable legacy filename correction reviewed separately |
| 856d38c / 500354c: RmlUI/WARP startup | Not applicable to the restored SDL Classic application; do not bring back RmlUI |
| 0.3 Modern manager placement correction | Excluded; belongs to Dreierpack Manager, not faithful Classic behaviour |
Version 1.0 no longer rewrites loaded rule tables to a shared profile. Original strength ranges and environment price steps are installed from the supplied edition. Environment implementations outside verified program fingerprints remain unverified, never silently enabled by a directory name.
This is an implementation audit, not a completed release acceptance report. Original-data, GUI, save compatibility and platform results must be recorded before the final tag.
## Diamond 3.7 foreign crests
The drawing policy is installed from the verified gate in the supplied executable.
Diamond 3.7 uses individual original W-sheet cells for the 48 foreign league clubs.
Earlier verified editions retain their neutral foreign-club crest. Database and
savegame selectors remain authoritative, including after club movement; no
high-resolution replacement pack or changed competition structure is required.
Unknown drawing gates retain the conservative legacy policy. National teams,
non-rostered clubs and missing-club tokens retain their existing treatment.
Private data verification decoded all 48 Diamond 3.7 selections and checked their
38-pixel cells against atlas bounds. This is an asset-path/contact-sheet check,
not a claim of completed interactive GUI acceptance.
## Author-supplied defect reference
The Diamond author supplied a private reference catalogue covering 33 original
bug corrections. The supplied original executable hash and all 1,084 documented
byte changes were independently checked against local original/Diamond files.
The archive and disassembly remain outside this public repository. Binary patch
caves are evidence of the old defect, not an implementation requirement.
Initial source review finds corrected camp field packing and separated card
save-back contexts already present. Their dedicated regression acceptance is
still pending. Retirement handling still excludes transfer-market slots and
requires correction. The complete 33-item review is tracked privately; none of
the unreviewed entries is claimed complete.
+9
View File
@@ -0,0 +1,9 @@
# OpenBMH 1.0 release candidate
Classic direct-installation runtime restored from v0.1.2. No launcher, converter, OBW runtime or Modern UI. The game executable is OpenBMH / OpenBMH.exe; openbmh_cli remains available.
Reviewed backports include host filename/path handling, explicit quit confirmation, original message text installation in standalone tools, and clearing the calendar replay flag after undoing a reschedule. German CD-compatible BMH and verified Diamond editions are the release targets. Football Limited remains experimental; the old floppy executable is unsupported.
This candidate is under compatibility validation, especially edition-dependent rules and environment behaviour. No complete platform or original-game acceptance is claimed before its recorded tests pass. Existing 0.2/editor releases remain historical; NextGen development moves to Dreierpack Manager.
Diamond 3.7 foreign league crests use the supplied edition's original drawing gate, database selectors and W sheets. Older editions retain their original neutral foreign-club crest.
+13
View File
@@ -0,0 +1,13 @@
# Classic 1.0 candidate validation
Status: implementation candidate, not final-release acceptance.
- Linux x64 Release build: all targets compiled.
- CTest: 32 passed, 157 skipped, zero failures (189 registered tests). Skips require separately configured original-data or save fixtures; they are not acceptance passes.
- Synthetic tests cover unchanged executable image loading, nine original strength ranges, atomic rejection of malformed ranges, unsupported environment guards, and legacy/extended/truncated crest gates.
- Public source scan: zero findings; generated differences catalogue matches source markers.
- Version output: both GUI and console identify 1.0.0-rc.1.
- Private crest probe: all 48 foreign league clubs in Diamond 3.7 resolve to original 38 × 38 W cells within atlas bounds. A native-size contact sheet was inspected; older Diamond data retain the neutral-crest gate.
- Author defect reference: original hash and all 1,084 listed original/changed bytes checked. All 33 defects are tracked privately; source inspection is not regression acceptance.
Still required: dedicated original-game/GUI/save roundtrips, completing the original-defect audit, per-edition gameplay review, Windows/macOS native checks and release-package acceptance. No final 1.0 tag is justified by these checks alone.
+5 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "app/career_session.hpp"
@@ -540,6 +541,9 @@ static void install_league_sizes(const LeImage& exe) {
kNewcomerCount = exe.u16(::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6);
// EXE strings the engine posts (messages.hpp)
install_message_texts(exe);
install_career_rules(exe);
install_environment_rules(exe);
install_original_badge_policy(exe);
}
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed)
@@ -3331,7 +3335,7 @@ std::optional<CareerSession::BalanceDispatch> CareerSession::dispatch_balance_pl
notice.manager_name.assign(reinterpret_cast<const char*>(next.state.manager_records.data()+name_at),name_end-name_at);
notice.portrait=next.state.manager_records[record+0x221];
const int club=next.state.manager_teams[size_t(manager)];
notice.badge_fallback=club==0x0fff||(club>89&&club<138)||(club>167&&club<357);
notice.badge_fallback=original_badge_fallback(club,&exe_);
if(!notice.badge_fallback&&club>=0&&size_t(club)*2+2<=next.state.club_heap_78.size())
notice.badge_sprite=(int(next.state.club_heap_78[size_t(club)*2])|
int(next.state.club_heap_78[size_t(club)*2+1])<<8)&0x1ff;
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "app/controller.hpp"
#include "app/window_actions.hpp"
@@ -56,7 +57,7 @@ ui::NationalFriendlyIdentity national_friendly_identity(const GameState& game,in
out.manager_name.push_back(char(game.manager_records[record+0xa8+i]));
out.portrait=game.manager_records[record+0x221];
out.manager_slot=manager;
out.badge_fallback=team==0x0fff||(team>89&&team<138)||(team>167&&team<357);
out.badge_fallback=original_badge_fallback(team);
if(!out.badge_fallback&&team>=0&&size_t(team)*2+1<game.club_heap_78.size())
out.badge_sprite=int(game.club_heap_78[size_t(team)*2]|
uint16_t(game.club_heap_78[size_t(team)*2+1])<<8)&0x1ff;
+2 -2
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/live_timing.hpp"
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
@@ -684,8 +685,7 @@ int main(int argc, char** argv) {
view.manager_name += char(state.manager_records[base + 0xa8 + i]);
view.body = event.text;
view.portrait = state.manager_records[base + 0x221];
view.badge_fallback = event.team == 0x0fff || (event.team > 89 && event.team < 138) ||
(event.team > 167 && event.team < 357);
view.badge_fallback = original_badge_fallback(event.team);
view.badge_sprite = view.badge_fallback ? 0 : le16(state.club_heap_78, size_t(event.team) * 2) & 0x1ff;
ui::GameEndTaxDialog screen(data, std::move(view), game_end_options(state),
event.kind == SeasonTaxEventKind::outcome ? season_backdrop : std::optional<Image>{});
+36
View File
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "formats/executable_layout.hpp"
#include "formats/le.hpp"
namespace bmh {
// Installed alongside the loaded edition's other runtime tables. Club selectors
// remain database/savegame data; this only reproduces the original drawing gate.
inline int original_foreign_badge_end = 138;
inline int original_badge_gate(const LeImage& exe) {
constexpr auto instruction = layout::ForeignBadgeGateInstruction;
if (exe.contains(instruction) && exe.contains(instruction + 6) &&
exe.u8(instruction) == 0x66 && exe.u8(instruction + 1) == 0x81 &&
exe.u8(instruction + 2) == 0xfb && exe.u8(instruction + 5) == 0x7c &&
exe.u8(instruction + 6) == 7) {
const int end = exe.u16(instruction + 3);
if (end == 90 || end == 138) return end;
}
// Never invent individual foreign crests for an unverified drawing routine.
return 138;
}
inline void install_original_badge_policy(const LeImage& exe) {
original_foreign_badge_end = original_badge_gate(exe);
}
inline bool original_badge_fallback(int token, const LeImage* exe = nullptr) {
const int team = token & 0xfff;
const int end = exe ? original_badge_gate(*exe) : original_foreign_badge_end;
return team == 0xfff || (team >= 90 && team < end) || (team >= 168 && team < 357);
}
} // namespace bmh
+10
View File
@@ -1976,3 +1976,13 @@ inline constexpr auto EnglishDesktopBinSourceX = 0x6e180;
inline constexpr auto EnglishDesktopBinSourceY = 0x6e182;
inline constexpr auto EnglishDesktopSocketSourceX = 0x6e184;
} // namespace bmh::layout
namespace bmh::layout {
inline constexpr auto EnvironmentBudgetSteps = 0xa50ff;
inline constexpr auto EnvironmentVerifiedCodeBegin = 0x6c000;
inline constexpr auto EnvironmentVerifiedCodeEnd = 0x6cb40;
inline constexpr auto EnvironmentVerifiedHookBegin = 0x7af65;
inline constexpr auto EnvironmentVerifiedHookEnd = 0x7b020;
}
namespace bmh::layout { inline constexpr auto ForeignBadgeGateInstruction = 0x10070; }
-3
View File
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/le.hpp"
#include "formats/rule_base.hpp"
#include <algorithm>
#include <fstream>
@@ -43,7 +42,6 @@ LeImage load_le(const std::filesystem::path& path) {
const uint32_t base = word(sizeof kImageMagic), size = word(sizeof kImageMagic + 4);
if (raw.size() != sizeof kImageMagic + 8 + size_t(size)) throw FormatError("OpenBMH image: wrong size");
LeImage img = LeImage::from_bytes(base, Bytes(raw.begin() + sizeof kImageMagic + 8, raw.end()));
apply_rule_base(img);
return img;
}
auto u8 = [&](size_t o) -> uint32_t {
@@ -133,7 +131,6 @@ LeImage load_le(const std::filesystem::path& path) {
}
}
}
apply_rule_base(img);
return img;
}
+2 -4
View File
@@ -29,7 +29,7 @@ public:
// The string a pointer variable at `address` points to (e.g. Weekly_AdvertisingOffers_TextPointer).
std::string string_at_pointer(uint32_t address) const { return cstring(u32(address)); }
const uint8_t* data(uint32_t address) const { return bytes_.data() + (address - base_); }
// Overwrites bytes inside the image (the rule base, formats/rule_base.hpp).
// Overwrites bytes inside a prepared image for verified address translation.
void patch(uint32_t address, const uint8_t* bytes, size_t count) {
for (size_t i = 0; i < count; ++i) bytes_.at(address - base_ + i) = bytes[i];
}
@@ -51,10 +51,8 @@ private:
Bytes bytes_;
};
// OpenBMH deviates from the original: applies a shared supported rule profile when loading editions with different rule-table values.
// Loads the original executable image without changing edition-specific rule tables.
// Throws FormatError for files that are not LE executables or use external fixups.
// A German BMH.EXE is loaded with the OpenBMH rule base applied (formats/rule_base.hpp):
// every edition plays by the supported rule profile rule values.
LeImage load_le(const std::filesystem::path& path);
// The OpenBMH image format: "OPENBMH-IMAGE" NUL, u32 base, u32 size, the bytes. load_le()
-44
View File
@@ -1,44 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "formats/rule_base.hpp"
#include <cstdint>
#include <vector>
namespace bmh {
namespace {
struct RuleBytes {
uint32_t address;
std::vector<uint8_t> bytes;
};
// OpenBMH deviates from the original: normalizes live-scene defaults, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit across supported editions.
// Every byte here differs in at least one German edition from supported rule profile 2026-27 and is read by
// the engine as a rule (runtime verification exe_diff over the ten editions, minus texts, calendar,
// season values and screen positions).
const std::vector<RuleBytes> kRuleBase = {
{::bmh::layout::LiveSceneOptions, {0x01, 0x01, 0x01, 0x01, 0x01, 0x01}}, // live scene options (CareerSession_DispatchLiveTactic_RuntimeField2, RerateTeam)
// (The training camp resorts DeskActions_ConfigureTrainingCampData_RuntimeField.. - qualities and prices - are content, not rules:
// every edition, the English one too, keeps its own resorts;
{::bmh::layout::LeagueStrengthRanges, {0x47, 0x5d, 0x31, 0x47, 0x1c, 0x31, 0x1c, 0x31, 0x0a, 0x1c}}, // league strength ranges (LeagueStrengthRanges)
{::bmh::layout::AdditionalLeagueStrengthRanges, {0x5f, 0x5a, 0x5f, 0x4b, 0x5f}}, // league strength ranges
{::bmh::layout::FinalLeagueStrengthMaximum, {0x5f}}, // league strength ranges
{::bmh::layout::RuleOptionDefaults, {0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x04, 0x02, 0x03, 0x02, 0x03, 0x06, 0x08, 0x06, 0x08, 0x0a, 0x0c, 0x10, 0x14, 0x18, 0x1c, 0x1e}}, // option defaults (ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField4...)
{::bmh::layout::StadiumPriceTable, {0xa0, 0x25, 0x26, 0x00, 0xa0, 0xf0, 0x19, 0x00, 0xc0, 0x91, 0x21, 0x00, 0x40, 0x42, 0x0f, 0x00, 0xe0, 0xc8, 0x10, 0x00, 0x60, 0xe3, 0x16, 0x00, 0xc0, 0x45, 0x04, 0x00, 0xc0, 0x45, 0x04, 0x00, 0xc0, 0x45, 0x04, 0x00, 0xc0, 0x45, 0x04, 0x00, 0x30, 0x57, 0x05, 0x00, 0x30, 0x57, 0x05, 0x00, 0x30, 0x57, 0x05, 0x00, 0x30, 0x57, 0x05, 0x00, 0xa0, 0xbb, 0x0d, 0x00, 0xb0, 0x71, 0x0b, 0x00, 0x40, 0x77, 0x1b, 0x00, 0xc0, 0x91, 0x21, 0x00, 0x30, 0x57, 0x05, 0x00, 0xc0, 0x27, 0x09, 0x00, 0x70, 0x64, 0x08, 0x00, 0x40, 0x42, 0x0f, 0x00, 0xe0, 0x93, 0x04, 0x00, 0xd8, 0xb8, 0x05, 0x00, 0xe0, 0x93, 0x04, 0x00, 0x30, 0x57, 0x05, 0x00, 0xe0, 0x93, 0x04, 0x00, 0xd8, 0xb8, 0x05, 0x00, 0xe0, 0x93, 0x04, 0x00, 0x30, 0x57, 0x05, 0x00, 0xd0, 0x07, 0xb8, 0x0b, 0xb8, 0x0b, 0x40, 0x1f, 0xa0, 0x0f, 0xb8, 0x0b}}, // stadium prices (CareerSession_DispatchStadium_RuntimeField)
{::bmh::layout::AdditionalStadiumPrices, {0x88, 0x13, 0xc0, 0x12, 0x60, 0x09, 0x40, 0x1f}}, // stadium prices (CareerSession_DispatchStadium_RuntimeField)
{::bmh::layout::StadiumBlockCapacities, {0x12, 0x08, 0x0e, 0x08, 0x12, 0x08, 0x0e}}, // stadium block places (CareerSession_Invalid_RuntimeField)
{::bmh::layout::ComputerBettingLimits, {0x33, 0x20, 0x50, 0x74}}, // computer tip gaps (CareerSession_DispatchLeagueTableControl_RuntimeField)
{::bmh::layout::ForeignPlayerLimitEnabled, {0x00}}, // substitution rule switch (ForeignPlayerLimitEnabled)
};
} // namespace
void apply_rule_base(LeImage& exe) {
// only the German data object has these addresses
if (exe.base() != 0x10000 || !exe.contains(::bmh::layout::GermanDataSegmentBegin) || !exe.contains(::bmh::layout::GermanDataCompatibilityEnd)) return;
for (const RuleBytes& r : kRuleBase) exe.patch(r.address, r.bytes.data(), r.bytes.size());
}
} // namespace bmh
-17
View File
@@ -1,17 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// One engine uses a shared rule profile across supported editions.
// OpenBMH deviates from the original: normalizes live-scene options, league
// strength ranges, option defaults, stadium prices and capacities, betting limits,
// and the foreign-player limit. Texts, currency, calendar, league structure, screen
// positions, season values, and edition-specific resort content stay loaded from data.
#include "formats/le.hpp"
namespace bmh {
// Applies the shared rule profile to compatible German executable images.
// Images without the matching data segment are left unchanged.
void apply_rule_base(LeImage& exe);
} // namespace bmh
+18 -1
View File
@@ -20,11 +20,28 @@ constexpr int kLeagueTeams = 138; // CareerSession_DispatchLineup_RuntimeFie
// LeagueSizes: clubs per league; LeagueStrengthRanges: (minimum, maximum) strength per league.
// (the clubs per league are kLeagueSizes, schedule.hpp)
constexpr int kLeagueStrength[9][2] = {{71, 93}, {49, 71}, {28, 49}, {28, 49}, {10, 28},
int kLeagueStrength[9][2] = {{71, 93}, {49, 71}, {28, 49}, {28, 49}, {10, 28},
{85, 95}, {90, 95}, {75, 95}, {80, 95}};
} // namespace
std::pair<int,int> career_strength_range(int league) {
if (league<0 || league>=9) throw FormatError("career: invalid league range");
return {kLeagueStrength[league][0],kLeagueStrength[league][1]};
}
void install_career_rules(const LeImage& exe) {
int next[9][2]{};
for (int league = 0; league < 9; ++league) {
for (int bound = 0; bound < 2; ++bound)
next[league][bound] = exe.u8(layout::LeagueStrengthRanges + uint32_t(league * 2 + bound));
if (next[league][0] > next[league][1] || next[league][1] > 99)
throw FormatError("career: unsupported original league strength range");
}
for (int league = 0; league < 9; ++league)
for (int bound = 0; bound < 2; ++bound) kLeagueStrength[league][bound] = next[league][bound];
}
void generate_player(GameState& g, int id, int level_flags, GameRandom& game, WatcomRandom& rand) {
Player& p = g.players.at(size_t(id));
const bool keep_age = (level_flags & 0x1000) != 0, exact = (level_flags & 0x2000) != 0;
+4
View File
@@ -24,6 +24,10 @@
namespace bmh {
// Install the nine strength ranges from the loaded edition, never a shared replacement.
void install_career_rules(const LeImage&);
std::pair<int,int> career_strength_range(int league);
// OpenBMH deviates from the original: uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
// GeneratePlayer with the supported rule profile patch GeneratePlayer2: new values for player `id` around
// `level` (low 12 bits of `level_flags`; 0x1000 = leave the age at 0, 0x2000 = exactly
+20
View File
@@ -3,9 +3,12 @@
#include "game/environment.hpp"
#include <algorithm>
#include <cstdlib>
#include <utility>
namespace bmh {
namespace {
bool supported_environment = true; // Synthetic state tests explicitly use the verified monthly model.
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;
@@ -29,6 +32,21 @@ uint32_t academy_paid(const GameState& g, int manager) {
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
}
}
void install_environment_rules(const LeImage& exe) {
for (size_t i=0;i<kEnvironmentStep.size();++i) {
const uint32_t at=layout::EnvironmentBudgetSteps+uint32_t(i);
if (!exe.contains(at) || exe.u8(at)==0) { supported_environment=false; return; }
kEnvironmentStep[i]=int32_t(exe.u8(at))*1000;
}
uint64_t fingerprint = 14695981039346656037ull;
for (const auto [first,last] : {std::pair{layout::EnvironmentVerifiedCodeBegin,layout::EnvironmentVerifiedCodeEnd},std::pair{layout::EnvironmentVerifiedHookBegin,layout::EnvironmentVerifiedHookEnd}}) {
if (!exe.contains(first) || !exe.contains(last-1)) { supported_environment=false; return; }
for (uint32_t at=first;at<last;++at) fingerprint=(fingerprint ^ exe.u8(at))*1099511628211ull;
}
// Fingerprints identify verified behaviour, not filenames, dates or artwork.
supported_environment = fingerprint==0xc2488a656f340e99ull || fingerprint==0x19adba7ef3eda507ull;
}
bool environment_rules_supported() { return supported_environment; }
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;
@@ -39,6 +57,7 @@ bool environment_academy_active(const GameState& g, int manager) {
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
}
EnvironmentState environment_state(const GameState& g, int manager) {
if (!supported_environment) throw FormatError("environment: this original program variant is not verified");
validate_manager(g, manager);
EnvironmentState result;
for (int i = 0; i < kEnvironmentItems; ++i) {
@@ -56,6 +75,7 @@ EnvironmentState environment_state(const GameState& g, int manager) {
}
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
if (message) message->clear();
if (!supported_environment) return EnvironmentResult::invalid;
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;
+6 -2
View File
@@ -4,14 +4,18 @@
#include <cstdint>
#include <string>
#include "game/random.hpp"
#include "formats/le.hpp"
#include "game/state.hpp"
namespace bmh {
// Verified original-program capability; unknown environment variants are not guessed.
void install_environment_rules(const LeImage&);
bool environment_rules_supported();
constexpr int kEnvironmentItems = 6;
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};
// Monthly environment model verified in the supported CD and Diamond 3.6/3.7 programs.
inline std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
struct EnvironmentState {
std::array<int32_t, kEnvironmentItems> monthly{};
std::array<int, kEnvironmentItems> level{};
-2
View File
@@ -11,7 +11,6 @@
#include <vector>
#include "formats/binary.hpp"
#include "formats/rule_base.hpp"
#include "launch/archive.hpp"
#include "launch/game_data.hpp"
@@ -120,7 +119,6 @@ LeImage translate_fltd(const fs::path& fltd_exe) {
}
}
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
apply_rule_base(out);
return out;
}
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/balance_plan.hpp"
@@ -52,7 +53,7 @@ BalanceState balance_from_game(const GameState& g,const BalancePlanDraft& d,cons
const int portrait=rec+0x221<g.manager_records.size()?g.manager_records[rec+0x221]:0;
if(portrait>14)throw FormatError("balance: invalid Source manager portrait");
const int team=g.manager_teams[size_t(d.manager)];
const bool fallback=team==0x0fff||(team>89&&team<138)||(team>167&&team<357);
const bool fallback=original_badge_fallback(team);
int badge=0;if(!fallback){if(team<0||size_t(team)*2+2>g.club_heap_78.size())throw FormatError("balance: missing Source badge selector");badge=(int(g.club_heap_78[size_t(team)*2])|int(g.club_heap_78[size_t(team)*2+1])<<8)&0x1ff;}
const uint8_t compact_dialog_frame=g.memory.has(::bmh::layout::CompactDialogFrame)?g.memory.u8(::bmh::layout::CompactDialogFrame):exe.u8(::bmh::layout::CompactDialogFrame);
for(auto* projection:{&s.read_only_notice,&s.close_notice}){projection->portrait=portrait;projection->badge_fallback=fallback;projection->badge_sprite=badge;projection->compact_dialog_frame=compact_dialog_frame!=0;}
+3 -2
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/club_player_detail.hpp"
@@ -50,7 +51,7 @@ ClubPlayerDetailProjection club_player_detail_from_game(const GameState& g,
club.original_short_name=club.original_short_name.substr(raw>>4,(raw&15)+1);
}
// SourceBadgeFallback consults the selector only for real atlas clubs.
if(id<=89||(id>=138&&id<=167)||id>=357){
if(!original_badge_fallback(id,&exe)){
if(size_t(id)*2+1>=g.club_heap_78.size())throw FormatError("club player detail: truncated badge table");
club.badge_selector=le16(g.club_heap_78,size_t(id)*2)&0x1ff;
}
@@ -92,7 +93,7 @@ ClubPlayerDetailScreen::ClubPlayerDetailScreen(const std::filesystem::path& data
if(atlas_.width==314){Image padded(320,atlas_.height);padded.blit(atlas_,0,0);atlas_=std::move(padded);}
for(size_t i=0;i<2;++i)if(projection_.clubs[i]){
auto& club=*projection_.clubs[i];const int id=club.runtime_team;
if(id<=89||(id>=138&&id<=167)||id>=357){
if(!original_badge_fallback(id,&exe_)){
badges_[i]=load_vga(asset_path(data/"W",std::to_string(club.badge_selector>>3)+".VGA"));
}
// TextWidth national/foreign names: longest word, then remove two
+3 -2
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/cup_draw.hpp"
@@ -229,7 +230,7 @@ struct CupDrawScreen::Impl {
copy(screen,panel,0,0,29,22,261,203);bottom=screen;drawing=screen;present=true;flush=true;}
else {draw_overview();drawing=screen;}
for(size_t i=0;i<p.count;++i){const int id=p.clubs[i].runtime_id,sel=p.clubs[i].badge_selector&0x1ff;
if(!((id>=0x5a&&id<=0x89)||(id>=0xa8&&id<=0x164)||id==0xfff)){
if(!original_badge_fallback(id,&exe)){
const int atlas=sel>>3;if(!badges.contains(atlas))badges.emplace(atlas,load_vga(asset_path(data/"W",std::to_string(atlas)+".VGA")));
}
}
@@ -255,7 +256,7 @@ struct CupDrawScreen::Impl {
void source_badge(Image& out,const CupDrawClub& c,int x,int y) const {
source_frame(out,x,y);
const int id=c.runtime_id,selector=c.badge_selector&0x1ff;
if((id>=0x5a&&id<=0x89)||(id>=0xa8&&id<=0x164)||id==0xfff)
if(original_badge_fallback(id,&exe))
copy(out,widgets,8,0,x,y,38,38);
else {
const int atlas=selector>>3;copy(out,badges.at(atlas),(selector&7)*38,0,x,y,38,38);
+2 -2
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/desk_state.hpp"
@@ -600,8 +601,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
*d.next_opponent < int(g.club_ids.size())) {
const int opponent = *d.next_opponent;
d.next_opponent_name = g.club_name(opponent);
const bool fallback = opponent == 0x0fff ||
(opponent > 0x59 && (opponent < 0x8a || opponent > 0xa7) && opponent < 0x165);
const bool fallback = original_badge_fallback(opponent,&exe);
d.next_opponent_badge_fallback = fallback;
if (!fallback) {
const size_t badge_at = size_t(opponent) * 2;
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/environment.hpp"
@@ -50,7 +51,7 @@ const char* result_name(EnvironmentRequestKind kind) {
bool generic_badge(int club) {
// SourceBadgeFallback gates on the runtime club ID, before looking up its W sprite.
const unsigned team = unsigned(club) & 0xfff;
return team == 0xfff || (team >= 90 && team <= 137) || (team >= 168 && team <= 356);
return original_badge_fallback(int(team));
}
} // namespace
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/game_end.hpp"
@@ -288,7 +289,7 @@ Image GameEndTaxDialog::render(std::optional<Button> pressed) const {
}
bool source_badge_fallback(int token) {
const int club=token&0x0fff;
return club==0x0fff || (club>89&&(club<138||club>167)&&club<357);
return original_badge_fallback(club);
}
void draw_source_dialog(Image& out,const SourceDialogAssets& assets,const TaxDialogProjection& p,
bool gradient,std::optional<GameEndTaxDialog::Button> pressed) {
+2 -2
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/incoming_transfer.hpp"
#include "ui/game_end.hpp"
@@ -80,8 +81,7 @@ int source_seller_team_token(const IncomingTransferDecisionState& state) {
}
bool source_neutral_seller_token(int token) {
return (token >= 90 && token <= 137) || token == 0x0fff ||
(token >= 168 && token <= 356);
return original_badge_fallback(token);
}
} // namespace
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/manager.hpp"
@@ -262,7 +263,7 @@ void ManagerScreen::portrait(Image& out, int x, int y, int id) const {
}
void ManagerScreen::badge(Image& out, int x, int y, int id) const {
border(out, x, y);
if (id > 89 && id < 138) { copy(out, widgets_, 8, 0, x, y, 38, 38); return; }
if (id>=90 && id<original_badge_gate(exe_)) { copy(out, widgets_, 8, 0, x, y, 38, 38); return; }
int sprite = le16(db_.raw_club_badge_selectors, size_t(id) * 2) & 0x1ff;
auto atlas = load_vga(asset_path(data_ / "W", std::to_string(sprite >> 3) + ".VGA"));
copy(out, atlas, (sprite & 7) * 38, 0, x, y, 38, 38);
+2 -2
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/pending_offer.hpp"
@@ -93,8 +94,7 @@ void manager_identity(const GameState& game, int manager, TaxDialogProjection& o
// reserves 14 for the manager-placeholder tile drawn from KB0.VGA.
if (out.portrait > 14) throw FormatError("pending offer UI: invalid Source manager portrait");
out.badge_fallback = team == 0x0fff || (team > 89 && team < 138) ||
(team > 167 && team < 357);
out.badge_fallback = original_badge_fallback(team);
if (out.badge_fallback) {
out.badge_sprite = 0;
} else {
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/player_card.hpp"
@@ -194,7 +195,7 @@ PlayerCardScreen::PlayerCardScreen(const std::filesystem::path& data,PlayerCardS
badge_=load_vga(asset_path(data/"W",std::to_string(state_.badge>>3)+".VGA"));
if(state_.loan)for(size_t i=0;i<2;++i){
const int club=i?state_.loan->borrower:state_.loan->owner;
if(club<=89||(club>=138&&club<=167)||club>=357)
if(!original_badge_fallback(club,&exe_))
loan_badges_[i]=load_vga(asset_path(data/"W",std::to_string(state_.loan->badges[i]>>3)+".VGA"));
}
if(atlas_.width==314){Image padded(320,atlas_.height);padded.blit(atlas_,0,0);atlas_=std::move(padded);}
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/season_promotion.hpp"
@@ -181,7 +182,7 @@ SeasonPromotionProjection season_promotion_from_game(
rows.reserve(event.count);
for(size_t i=0;i<event.count;++i) {
const uint16_t id=ids[i]&0x0fff;
const bool fallback=id==0x0fff||(id>0x59&&((id<0x8a||id>0xa7)&&id<0x165));
const bool fallback=original_badge_fallback(id);
uint16_t badge=0;
if(!fallback) {
const size_t at=size_t(id)*2;
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/sportschau.hpp"
@@ -375,7 +376,7 @@ SportschauMatchReport::SportschauMatchReport(const std::filesystem::path& data_d
for (size_t side = 0; side < badge_words.size(); ++side) {
const int team = side == 0 ? fixture_.home_team : fixture_.away_team;
if (team == 0x0fff) continue; // SourceBadgeFallback uses its generic missing-club icon.
const bool has_source_badge = team <= 89 || (team >= 138 && team <= 167) || team >= 357;
const bool has_source_badge = !original_badge_fallback(team);
if (!has_source_badge) continue; // Source FormatError draws a distinct generic icon; see notes.
if (badge_words[side] == 0xffff) throw FormatError("sportschau: missing live Source badge word");
const unsigned atlas = (badge_words[side] & 0x01ff) >> 3;
+2
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/sprite_font.hpp"
@@ -20,6 +21,7 @@ std::string original_bytes(std::string_view utf8) {
SpriteFont::SpriteFont(const std::filesystem::path& data_directory)
: atlas_(load_vga(asset_path(data_directory / "KB", "54.VGA"))),
exe_(load_le(asset_path(data_directory, "BMH.exe"))) {
install_original_badge_policy(exe_);
if (atlas_.height < 21 || atlas_.width <= 0)
throw FormatError("sprite font: unsupported KB/54 atlas");
}
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/team_statistics.hpp"
@@ -93,7 +94,7 @@ TeamStatisticsProjection team_statistics_from_game(const GameState& game, int te
TeamStatisticsProjection out;
out.runtime_team = team;
out.mode = mode;
out.source_badge_fallback = team == 0x0fff || (team >= 90 && team <= 137) || (team >= 168 && team < 0x165);
out.source_badge_fallback = original_badge_fallback(team,&exe);
out.badge_heap = game.club_heap_78;
if (team != 0x165) {
int region_team = team;
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/transfer_market.hpp"
@@ -267,7 +268,7 @@ TaxDialogProjection poach_notice_from_game(const GameState& game,const PoachStar
out.portrait=game.manager_records[base+0x221];
if(out.portrait>14)throw FormatError("poach notice: invalid Original portrait");
const int team=game.manager_teams[size_t(manager)];
out.badge_fallback=team==0x0fff || (team>89&&team<138) || (team>167&&team<357);
out.badge_fallback=original_badge_fallback(team);
if(!out.badge_fallback) {
if(team<0 || size_t(team)*2+2>game.club_heap_78.size())throw FormatError("poach notice: missing badge selector");
out.badge_sprite=(int(game.club_heap_78[size_t(team)*2])|int(game.club_heap_78[size_t(team)*2+1])<<8)&0x1ff;
+41
View File
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/le.hpp"
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "game/career.hpp"
#include "game/environment.hpp"
#include <filesystem>
#include <iostream>
#include <stdexcept>
void check(bool v,const char* m){if(!v)throw std::runtime_error(m);}
int main()try {
using namespace bmh;
constexpr uint32_t image_base=0x10000;
constexpr size_t image_size=0xb0000;
auto image=LeImage::from_bytes(image_base,Bytes(image_size,0));
uint8_t original=7;image.patch(layout::LiveSceneOptions,&original,1);
const auto file=std::filesystem::temp_directory_path()/"openbmh-classic-original-rules.image";
save_image(image,file);const auto loaded=load_le(file);std::filesystem::remove(file);
check(loaded.bytes()==image.bytes(),"Loading silently replaced original rules");
Bytes ranges;for(int i=0;i<9;++i){ranges.push_back(uint8_t(30+i));ranges.push_back(uint8_t(40+i));}
image.patch(layout::LeagueStrengthRanges,ranges.data(),ranges.size());install_career_rules(image);
check(career_strength_range(0)==std::pair{30,40} && career_strength_range(8)==std::pair{38,48},"Original league ranges not installed");
uint8_t invalid[]={90,20};image.patch(layout::LeagueStrengthRanges+16,invalid,2);bool rejected=false;
try{install_career_rules(image);}catch(const FormatError&){rejected=true;}
check(rejected,"Invalid original ranges accepted");
check(career_strength_range(0)==std::pair{30,40} && career_strength_range(8)==std::pair{38,48},"Failed range installation partially changed rules");
install_environment_rules(image);check(!environment_rules_supported(),"Unknown program code guessed an environment model");
auto badges=LeImage::from_bytes(image_base,Bytes(256,0));
const uint8_t legacy_gate[]={0x66,0x81,0xfb,138,0,0x7c,7};
badges.patch(layout::ForeignBadgeGateInstruction,legacy_gate,sizeof legacy_gate);
install_original_badge_policy(badges);check(original_badge_fallback(90)&&original_badge_fallback(137),"Older edition no longer uses its original neutral badge");
const uint8_t extended=90;badges.patch(layout::ForeignBadgeGateInstruction+3,&extended,1);
install_original_badge_policy(badges);check(!original_badge_fallback(90)&&!original_badge_fallback(137)&&original_badge_fallback(168)&&original_badge_fallback(0xfff),"Extended foreign badge gate is incorrect");
check(!original_badge_fallback(0xf05a) && !original_badge_fallback(138) &&
!original_badge_fallback(357) && original_badge_fallback(356),
"Tagged club IDs and national/amateur badge ranges changed");
auto truncated=LeImage::from_bytes(layout::ForeignBadgeGateInstruction+1,Bytes(6,0));
check(original_badge_gate(truncated)==138,"Truncated badge routine was not rejected");
const uint8_t unknown=1;badges.patch(layout::ForeignBadgeGateInstruction+3,&unknown,1);install_original_badge_policy(badges);check(original_badge_fallback(90),"Unknown badge routine guessed a crest capability");
std::cout<<"Classic original rules retained; strength ranges and unknown-variant guard passed\n";return 0;
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
+2 -2
View File
@@ -22,10 +22,10 @@ class PackageAllowlistTests(unittest.TestCase):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
# Empty authored placeholders test names/structure, not executable behavior.
for name in ['openbmh_play', 'openbmh_cli', 'README.md', 'LICENSE',
for name in ['OpenBMH', 'openbmh_cli', 'README.md', 'LICENSE',
'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md']:
(root / name).write_text('synthetic')
notes = root / 'docs/release/0.1/RELEASE_NOTES.md'
notes = root / 'docs/release/1.0/RELEASE_NOTES.md'
notes.parent.mkdir(parents=True)
notes.write_text('synthetic release notes')
licenses = Path(__file__).resolve().parents[1] / 'docs' / 'licenses'
+4
View File
@@ -2,6 +2,8 @@
#pragma once
#include "formats/le.hpp"
#include "game/messages.hpp"
#include "game/career.hpp"
#include "game/environment.hpp"
#include "game/schedule.hpp"
namespace bmh::test {
@@ -12,6 +14,8 @@ inline LeImage load_executable(const std::filesystem::path& path) {
auto executable = bmh::load_le(path);
install_fixture_tables(executable);
install_message_texts(executable);
install_career_rules(executable);
install_environment_rules(executable);
return executable;
}
}
-1
View File
@@ -10,7 +10,6 @@
#include "formats/binary.hpp"
#include "formats/font.hpp"
#include "formats/le.hpp"
#include "formats/rule_base.hpp"
using namespace bmh;
using namespace bmh::ui;
+2 -2
View File
@@ -10,7 +10,7 @@ import zipfile
def validate(directory, windows):
products = {'openbmh_play.exe', 'openbmh_cli.exe'} if windows else {'openbmh_play', 'openbmh_cli'}
products = {'OpenBMH.exe', 'openbmh_cli.exe'} if windows else {'OpenBMH', 'openbmh_cli'}
documents = {'README.md', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md'}
licenses = {'README.md', 'LGPL-2.1.txt', 'Nuked-OPL3-notices.txt', 'LZMA-SDK.txt', 'SDL2-HIDAPI-BSD.txt',
'SDL2-HIDAPI-options.txt', 'SDL2-HIDAPI-original.txt', 'SDL2-yuv2rgb.txt',
@@ -33,7 +33,7 @@ def validate(directory, windows):
if not allowed:
raise RuntimeError('Unexpected package entry: ' + relative.as_posix())
required = products | documents | {'docs/licenses/' + name for name in licenses}
required.add('docs/release/0.1/RELEASE_NOTES.md')
required.add('docs/release/1.0/RELEASE_NOTES.md')
if required - present:
raise RuntimeError('Missing package entries: ' + ', '.join(sorted(required - present)))
if windows and not {'vcruntime140.dll', 'msvcp140.dll'} <= present:
+2 -2
View File
@@ -145,8 +145,8 @@ def main():
'--root', str(source)], check=True)
cache = (args.build / 'CMakeCache.txt').read_text()
import re
version = re.search(r'^CMAKE_PROJECT_VERSION:STATIC=([^\n]+)$', cache, re.M).group(1)
if not re.fullmatch(r'\d+\.\d+\.\d+', version):
version = (args.build / 'product-version.txt').read_text().strip()
if not re.fullmatch(r'\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?', version):
raise RuntimeError('Unexpected source version')
dependencies = json.loads((args.build / 'package-dependencies.json').read_text())
args.out.mkdir(parents=True, exist_ok=True)
+2 -2
View File
@@ -50,8 +50,8 @@ LEGACY_SYMBOLS = re.compile(
PRIVATE_TEXT = re.compile(
r"(?:(?<![\w}./\\])/" + r"tools/|[A-Z]:[/\\]Users[/\\]|[A-Z]:[/\\]OpenBMH[/\\]|"
r"docs/(?:analyses|agents)/|src/ui/(?:validation|reference)/|"
+ "bmh" + r"-work|matter" + r"most|\bMich" + r"ael\b|\bDIA" +
r"MOND\b|(?<![\w}./\\])/" + r"root/[^\s]+|https?://(?:10\.|192\.168\.|172\.(?:1[6-9]|2[0-9]|3[01])\.)|"
+ "bmh" + r"-work|matter" + r"most|\bMich" + r"ael\b|"
r"(?<![\w}./\\])/" + r"root/[^\s]+|https?://(?:10\.|192\.168\.|172\.(?:1[6-9]|2[0-9]|3[01])\.)|"
r"github\.com/[^/\s]+/openbmh[_-]dc\b)",
re.IGNORECASE,
)