Compare commits

..
113 Commits
Author SHA1 Message Date
Codex 249bdca1a8 Prepare Classic 1.0.4 patch release (by Codex)
Prepare verified release / draft (push) Waiting to run
2026-11-02 21:03:19 +01:00
Codex b8904db92d Document original mouse behavior and verified layout mapping (by Codex) 2026-11-02 18:08:06 +01:00
Codex 9ec136a09f Check effective English translation neighbors (by Codex) 2026-11-02 18:08:02 +01:00
Codex a275ffa1a9 Preserve English overwrite question in translation (by Codex) 2026-11-02 18:03:04 +01:00
Codex fcb6ac14bb Refuse malformed widget formation before desktop projection (by Codex) 2026-11-02 17:47:49 +01:00
Codex acdc7d5c14 Isolate desktop pointer regressions from edition-specific mocks (by Codex) 2026-11-02 17:42:09 +01:00
Codex 0faad16148 Verify incoming transfer crests against installed edition profile (by Codex) 2026-11-02 17:37:26 +01:00
Codex f44de65e22 Handle unframed desktop admission and automation controls (by Codex) 2026-11-02 17:37:26 +01:00
Codex bea5478433 Run focused mouse input regressions in configured test suites (by Codex) 2026-11-02 17:37:26 +01:00
Codex 2d744e380c Align stadium UI fixtures with retained capacity policy (by Codex) 2026-11-02 17:30:07 +01:00
Codex 9140fb4b03 Run synthetic desktop input checks without private inventories (by Codex) 2026-11-02 16:59:52 +01:00
Codex 02f47f7972 Add mouse-operated overwrite confirmation (by Codex) 2026-11-02 16:26:29 +01:00
Codex 564af00d8d Add focused advertising input controller test route (by Codex) 2026-11-02 16:26:29 +01:00
Codex e8ba78e135 Verify folder corner removal and expose desktop input checks (by Codex) 2026-11-02 16:26:29 +01:00
Codex fcbe1ebc13 Refresh advertising hover when modal input returns (by Codex) 2026-11-02 16:23:10 +01:00
Codex 8b1dc16233 Fix unframed desktop date and folder input (by Codex) 2026-11-02 16:14:11 +01:00
Codex 9c10a2bfeb Restore original advertising hover outlines and help (by Codex) 2026-11-02 16:13:01 +01:00
Codex 6f33f9c155 Fix safe save overwrite activation by double-click (by Codex) 2026-11-02 16:13:01 +01:00
Codex 9c82cb16b5 Embed supplied high-resolution Classic start artwork (by Codex) 2026-11-02 02:24:56 +01:00
Codex 0bfa705ec5 Document verified Diamond 3.7 save import for Classic 1.0.3 (by Codex)
Prepare verified release / draft (push) Waiting to run
2026-11-01 19:39:44 +01:00
Codex c6341aa4f9 (by Codex) Import verified Diamond 3.7 native save containers 2026-11-01 19:39:08 +01:00
Codex 8862bd4f89 Require an owned mouse release in transfer modals (by Codex)
Late or repeated releases from a post-match table cannot decline the immediately following transfer or acknowledge its confirmation. Track presses within each release-driven modal; keep semantic Source DOWN actions and fresh left/right gestures. Reproduced and verified through the real post-match table-to-transfer GUI flow.

Refs: #44
2026-11-01 19:19:21 +01:00
Codex a5aa4c6a08 Document Classic maintenance release and saved compatibility extensions (by Codex) 2026-11-01 19:07:27 +01:00
Codex 2a2fd17d07 Cover all named stadium table addresses in the synthetic fixture (by Codex) 2026-11-01 18:45:20 +01:00
Codex 0e8cfe5cd9 Finalize Classic 1.0.3 release notes and integrated stadium QA expectations (by Codex) 2026-11-01 18:33:08 +01:00
Codex feb6ca2717 Avoid overflowing dividend products before division (by Codex)
Use 64-bit products in actual monthly fund/property settlement, monthly and annual previews, and weekly dividend offers. Retain per-unit rounding, recipient policy and final native fields. Test representable high-value settlements against their forecasts. Full 32-bit money storage overflow remains unresolved.

Refs: #46
2026-11-01 18:20:05 +01:00
Codex 5caf23c452 (by Codex) Persist a per-manager monthly bank robbery limit 2026-11-01 18:17:14 +01:00
Codex 30843fc9f3 (by Codex) Preserve long-career player counts and title history 2026-11-01 18:15:55 +01:00
Codex 8e2f491d5e Prepare the Classic 1.0.3 bugfix version (by Codex) 2026-11-01 18:10:27 +01:00
Codex 4a93d9fd88 (by Codex) Initialize runtime currency fields in the bank display fixture 2026-11-01 18:03:53 +01:00
Codex 540178b264 Synchronize match reveals and restore pitch input feedback (by Codex)
Hold scoreboard digits through chance animations, retain overview gesture ownership through moved releases, and restore original affinity swatches and colored pointer from each edition. Preserve simulation and RNG boundaries; cover source observer and UI projections.

Refs: #43, #44, #45
2026-11-01 18:03:53 +01:00
Codex 86e2bfd32a (by Codex) Keep bank overview totals and currency display in 64 bits 2026-11-01 18:01:00 +01:00
Codex 8baf80564a (by Codex) Fix seller transfer review and fresh-arrival contract flags 2026-11-01 17:57:55 +01:00
Codex d57b6b5a96 (by Codex) Widen daily interest calculations before rate division 2026-11-01 17:55:56 +01:00
Codex 70082ef825 (by Codex) Keep static title responsive to window redraw and Escape 2026-11-01 17:55:16 +01:00
Codex f87d927c8d (by Codex) Resolve original CD executable casing in opening presenters 2026-11-01 17:55:16 +01:00
Codex 777039832d (by Codex) Wait for a complete mouse click on the static title 2026-11-01 17:55:16 +01:00
Codex fc07e45bbc (by Codex) Render opening artwork with its supplied embedded palette 2026-11-01 17:55:16 +01:00
Codex 7482697248 (by Codex) Preserve exit confirmation during original opening screens 2026-11-01 17:55:16 +01:00
Codex 7b5cd6988e Extend edition-aware stadium blocks to 144k with scaled build periods (by Codex) 2026-11-01 17:55:16 +01:00
Codex c8ae7a31d2 (by Codex) Restore original startup screens and edition runtime defaults 2026-11-01 17:37:48 +01:00
Codex db56c323aa Point extended development to the separate OpenBMH-Extended project (by Codex) 2026-11-01 17:22:19 +01:00
Codex b2a6300aad Separate widget close clicks from right-button desktop dragging (by Codex)
Prepare verified release / draft (push) Waiting to run
2026-10-31 09:06:12 +01:00
Codex 12e3e52537 Use the SDL entry-point signature in the video lifetime test (by Codex)
Prepare verified release / draft (push) Waiting to run
2026-10-30 23:33:15 +01:00
Codex 6d97b60ebc Initialize native Mac compiler rules before dependency configuration (by Codex) 2026-10-30 23:21:04 +01:00
Codex e3e2262e37 Keep native Mac keyboard regression on a supported ARM runner (by Codex) 2026-10-30 23:18:07 +01:00
Codex 184a421512 Fix automation preview, desktop drag highlight and macOS keyboard startup (by Codex) 2026-10-30 23:13:44 +01:00
Codex 998b037d3d Clarify stable release build and launch instructions [skip ci] (by Codex) 2026-10-30 18:31:57 +01:00
Codex d43d09a378 Read the original edition calendar for gameplay, desktop and saves (by Codex)
Prepare verified release / draft (push) Waiting to run
2026-10-30 18:02:52 +01:00
Codex f0ef79a119 Complete original edition rules, season safety and verified 1.0 releases (by Codex) 2026-10-30 17:14:28 +01:00
Codex e432f20ae7 Focus the community repository and documentation on the original game (by Codex) 2026-10-30 16:18:00 +01:00
Codex 6b942a2293 Retire ageing market players without age wrap or duplicate entries (by Codex) 2026-10-30 15:56:46 +01:00
Codex 3cce6465d0 Validate the Classic source export separately from retained Modern history (by Codex) 2026-10-30 15:50:36 +01:00
Codex 8ee062ea46 Prepare Classic 1.0 edition rules and Diamond 3.7 foreign crests (by Codex) 2026-10-30 15:39:56 +01:00
Codex c293a35f56 Backport original message installation for Classic standalone tools (by Codex) 2026-10-30 14:22:18 +01:00
Codex 81fc772a15 Preserve Classic reschedule targets after undo (by Codex) 2026-10-30 14:21:55 +01:00
Codex dcfb724ebe Confirm application exits in German and English (by Codex)
Route window-close events, animation polls, Escape and desktop exit through a native confirmation with Cancel selected by default. Preserve the current owner when cancelled. Refs #11.
2026-10-30 14:20:55 +01:00
Codex 17ac426039 Fix English desktop mapping and host file input issues (by Codex)
Correct setup sprites, balance colour and shortcut controls; restore native filename focus, normalize displayed directory separators and guard setup mouse releases. Refs #7, #8, #9, #10.
2026-10-30 14:20:55 +01:00
Codex c3704878d6 Restore direct-installation Classic baseline for OpenBMH 1.0 (by Codex) 2026-10-30 14:19:25 +01:00
ClaudeandClaude Opus 5.5 c8f04d0099 Reschedule undo clears the calendar replay bit (#16)
UndoReschedule of the original clears bit 0x4000 of the calendar day
(high byte & 0xbf) when no replay of another club stays on it; the
engine kept the bit, so the day and its neighbour were no longer offered
as targets after a move was taken back. The test checks the same target
days after the undo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 15:17:10 +01:00
ClaudeandClaude Opus 5.5 b879d5be00 Install the engine's message texts in standalone tools (fixes #14)
The six texts the engine posts from the game image (contract warning,
Masters, indoor entry bonus, league title bonus, friendly share) were
set only by the career sessions. week_check and the other standalone
tools left them empty, so the indoor entry bonus mail held only the
venue and the replays failed from the first public commit on.
install_message_texts(exe) now sets them for both sessions and in the
test executable loader.

Classic regression: the ten turns of #14 (game 1: 18, 21, 65, 88, 109,
201, 247; 2P: 24, 29, 34) pass again; no other turn changed against the
0.3 M0 baseline. The divergence the issue saw in the youth teams block
(bd4bc, since 310e3e2) is among the tolerated block differences.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 12:20:28 +02:00
Codex 6a3e51038c Correct large-window dropdown QA capture bounds (by Codex)
OBW Editor / editor (linux-x64, ubuntu-24.04) (push) Waiting to run
OBW Editor / editor (macos-arm64, macos-14) (push) Waiting to run
OBW Editor / editor (windows-x64, windows-2022) (push) Waiting to run
2026-10-23 14:51:41 +02:00
Codex 354baf2e6f Center editor dropdown chevrons and release 0.5.5 (by Codex) 2026-10-23 14:49:13 +02:00
Codex fe307dea41 Add editor browser navigation, idle rendering and Modern pickers (by Codex)
OBW Editor / editor (linux-x64, ubuntu-24.04) (push) Waiting to run
OBW Editor / editor (macos-arm64, macos-14) (push) Waiting to run
OBW Editor / editor (windows-x64, windows-2022) (push) Waiting to run
2026-10-23 13:48:32 +02:00
Codex 245e213cca Integrate current main with editor and Windows fixes (by Codex)
OBW Editor / editor (linux-x64, ubuntu-24.04) (push) Waiting to run
OBW Editor / editor (macos-arm64, macos-14) (push) Waiting to run
OBW Editor / editor (windows-x64, windows-2022) (push) Waiting to run
Prepare release packages / build (push) Blocked by required conditions
Build without game data / build (linux-x64, ubuntu-24.04) (push) Blocked by required conditions
Build without game data / build (macos-arm64, macos-14) (push) Blocked by required conditions
Build without game data / build (windows-x64, windows-2022) (push) Blocked by required conditions
2026-10-23 11:03:38 +02:00
Codex f21247a244 Add read-only image previews and linked asset navigation (by Codex) 2026-10-23 11:03:32 +02:00
ClaudeandClaude Opus 5.5 59be8b0b21 List --export-midi in the openbmh_sound usage
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 10:43:44 +02:00
ClaudeandClaude Opus 5.5 814583e482 Export the Original music as MIDI for remastering
openbmh_sound --original DATA --export-midi 0..2 OUT.mid [--loops N] [--map FILE]
runs the sequencer offline and records every started note through a new note
observer. One MIDI track per song track (track 9 = samples on the GM drum
channel), sixteenth-note steps, tempo from the IRQ0 divisor, pitches from the
note table of the user's executable, loop markers. Programs and drum notes are
guessed from pitch range, chords and the samples' sound, and written to an
editable OUT.map.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 10:43:21 +02:00
Codex e306c2c4a2 Add league-to-squad navigation and preserve Windows CPU dispatch (by Codex) 2026-10-23 10:10:23 +02:00
Codex 06e846416a Keep stadium pixels intact with the Direct3D TGA loader (by Codex) 2026-10-23 10:01:44 +02:00
Codex 678fce47f6 Decode Windows WebP images without an AVX requirement (by Codex) 2026-10-23 09:55:01 +02:00
Codex a7aa1d3713 Show readable editor startup errors in native dialogs (by Codex) 2026-10-23 09:08:26 +02:00
Codex 500354cc39 Keep startup reporting independent of renderer headers (by Codex) 2026-10-23 08:52:10 +02:00
Codex 856d38cc0c Support Windows Server GUI startup with Direct3D and WARP (by Codex) 2026-10-23 08:52:10 +02:00
ClaudeandClaude Opus 5.5 d9d05f83b4 Engine split: OBW-only saves for all variants; backporting is a working idea
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 08:49:14 +02:00
ClaudeandClaude Opus 5.5 c1121da116 Engine split: Classic Extended backports Modern features into Classic
Classic Extended is the Classic season engine plus Modern features ported
back one at a time where the bitmap interface can present them. Modern
features are written against small ports in a shared feature library so
they can be backported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 08:39:30 +02:00
Codex 9f1928bd9e Add read-only game and league regulations to editor 0.5.2 (by Codex)
OBW Editor / editor (linux-x64, ubuntu-24.04) (push) Waiting to run
OBW Editor / editor (macos-arm64, macos-14) (push) Waiting to run
OBW Editor / editor (windows-x64, windows-2022) (push) Waiting to run
2026-10-23 06:28:12 +02:00
Codex 221478b629 Add sortable editor ratings and payroll comparisons (by Codex)
OBW Editor / editor (linux-x64, ubuntu-24.04) (push) Waiting to run
OBW Editor / editor (macos-arm64, macos-14) (push) Waiting to run
OBW Editor / editor (windows-x64, windows-2022) (push) Waiting to run
2026-10-23 05:26:10 +02:00
Codex a447d9282a Prepare game 0.2.0 and standalone editor 0.5.0 releases (by Codex)
OBW Editor / editor (linux-x64, ubuntu-24.04) (push) Waiting to run
OBW Editor / editor (macos-arm64, macos-14) (push) Waiting to run
OBW Editor / editor (windows-x64, windows-2022) (push) Waiting to run
Prepare release packages / build (push) Blocked by required conditions
Build without game data / build (linux-x64, ubuntu-24.04) (push) Waiting to run
Build without game data / build (macos-arm64, macos-14) (push) Waiting to run
Build without game data / build (windows-x64, windows-2022) (push) Waiting to run
2026-10-22 23:32:54 +02:00
Codex 6636308cad Integrate native OBW editor and three submenu themes (by Codex)
# Conflicts:
#	tools/public_release/check_public_tree.py
2026-10-22 23:06:59 +02:00
Codex b8183e4165 Integrate Classic 0.2 launcher and native runtime (by Codex)
# Conflicts:
#	tools/public_release/check_public_tree.py
#	tools/public_release/test_public_tree.py
2026-10-22 23:05:57 +02:00
Codex a475c1ba80 Match all editor themes to modern submenu palettes (by Codex) 2026-10-22 22:53:44 +02:00
Codex fcf6092063 Isolate entity image edits and retain shared fallbacks (by Codex) 2026-10-22 22:17:07 +02:00
Codex f128a46104 Keep editor QA out of game packages and retain dependency notices (by Codex) 2026-10-22 22:07:17 +02:00
Codex 056ac8ebea Bundle Windows CRT with standalone editor packages (by Codex) 2026-10-22 22:03:52 +02:00
Codex ef111342f9 Handle Unicode Windows profile paths in editor settings (by Codex) 2026-10-22 21:51:34 +02:00
Codex b199f67eec Scope editor CI audit to its branch and use UTF-8 tests on MSVC (by Codex) 2026-10-22 21:43:28 +02:00
Codex bde8b10762 Add native OBW editor POC with shared MCP session (by Codex) 2026-10-22 21:41:10 +02:00
Michael 56b91ddca0 Add OBW competition trophy references (by Codex)
Add optional OBW competition trophy references
2026-10-22 12:54:17 +02:00
Codex 4f8e296f86 Merge verified public source export guard (by Codex) 2026-10-22 12:12:42 +02:00
Michael b868a236ea Fix source export history checks (by Codex)
Fix public-source checks across launcher history
2026-10-22 12:12:03 +02:00
Codex 7ea00c7046 Fix source history checks for reviewed launcher artwork and edition names (by Codex) 2026-10-22 11:20:15 +02:00
Codex faaecf2eb2 Define competition trophy references and generic fallback (by Codex) 2026-10-22 09:02:10 +02:00
ClaudeandClaude Opus 5.5 906cce902d Add the engine split concept: shared match engine, three season engines
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 19:17:45 +02:00
Codex 6e5fa72ed5 Finish Classic 0.2 portability and release preparation (by Codex) 2026-10-18 20:51:39 +02:00
Codex 74ca973111 Correct launcher stadium skyline and football pitch details (by Codex) 2026-10-18 13:44:34 +02:00
Codex 8aa849e9fa Add RmlUI night-stadium launcher and shared theme (by Codex) 2026-10-18 13:30:24 +02:00
Codex 00f522c1f3 Resolve native replay and resume paths before mounting content (by Codex) 2026-10-18 12:21:35 +02:00
Codex 0b2354c979 Complete native GUI file flows and Football Limited audio data (by Codex) 2026-10-18 12:13:10 +02:00
Codex 978a014b87 Preserve prepared match groups and English save continuation (by Codex) 2026-10-18 11:40:04 +02:00
Codex 481b525582 Fix native launcher platform setup and executable discovery (by Codex) 2026-10-18 11:32:15 +02:00
Codex 2552528176 Build 0.2 native launcher and portable Classic runtime (by Codex) 2026-10-18 11:28:51 +02:00
Codex 3a021fc160 Complete Classic BMH and FLTD installation imports (by Codex) 2026-10-18 10:07:38 +02:00
ClaudeandClaude Opus 5.5 65b087c1d0 OBW: store composed player portraits as a frozen part recipe
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 09:24:54 +02:00
Codex e1d17d8f81 Confirm application exits in German and English (by Codex)
Route window-close events, animation polls, Escape and desktop exit through a native confirmation with Cancel selected by default. Preserve the current owner when cancelled. Refs #11.
2026-10-17 22:52:11 +02:00
Codex 7eff8a34f8 Package versioned OBW schema documentation (by Codex) 2026-10-17 22:52:11 +02:00
Codex 8326a23274 Fix English desktop mapping and host file input issues (by Codex)
Correct setup sprites, balance colour and shortcut controls; restore native filename focus, normalize displayed directory separators and guard setup mouse releases. Refs #7, #8, #9, #10.
2026-10-17 22:36:58 +02:00
Codex 9bff07828a Add standalone BMH and FLTD to OBW converter (by Codex) 2026-10-17 22:21:17 +02:00
Codex 310e3e2464 Restore full environment controls and original match pacing for 0.1.2 (by Codex)
Prepare release packages / build (push) Blocked by required conditions
Build without game data / build (linux-x64, ubuntu-24.04) (push) Waiting to run
Build without game data / build (macos-arm64, macos-14) (push) Waiting to run
Build without game data / build (windows-x64, windows-2022) (push) Waiting to run
2026-10-17 21:09:38 +02:00
ClaudeandClaude Opus 5.5 4fb8b2f551 Point repository links to the renamed account
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 12:35:16 +02:00
ClaudeandClaude Opus 5.5 f1a31c9940 Add the OBW data format concept for roadmap 0.2-0.4
Versioned ZIP+JSON container for worlds, saves, content packs and RmlUi
themes: typed entities, generic competition stages (league phase, groups,
knockout, nations-league tiers), 32-league engine limit, BMH/FLTD import,
asset keys for high-resolution crests and photos, gettext languages and
TrueType/OpenType fonts. Match engine out of scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 12:34:54 +02:00
Codex aa53c6e2e2 Prepare 0.1.1 release with the UI corrections (by Codex)
Prepare release packages / build (push) Blocked by required conditions
Build without game data / build (linux-x64, ubuntu-24.04) (push) Waiting to run
Build without game data / build (macos-arm64, macos-14) (push) Waiting to run
Build without game data / build (windows-x64, windows-2022) (push) Waiting to run
2026-10-17 09:45:40 +02:00
Codex a3d1948fcd Fix live lineup navigation, instructions and desktop file dialogs (by Codex)
Address UI reports #1–#4: preserve the native live pitch page, acknowledge page controls on press, restore original instruction sprites and coverage, and allow file dialog cancellation and filename replacement. Keep graphical comparisons and save evidence in the private reference repository.
2026-10-16 23:26:09 +02:00
190 changed files with 14152 additions and 1578 deletions

No files matched your search

+20 -5
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:
@@ -21,7 +21,7 @@ jobs:
platform: linux-x64
- runner: windows-2022
platform: windows-x64
- runner: macos-14
- runner: macos-15
platform: macos-arm64
runs-on: ${{ matrix.runner }}
timeout-minutes: 90
@@ -36,8 +36,13 @@ jobs:
- name: Install Linux build dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y build-essential git cmake ninja-build pkg-config libgtk-3-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxfixes-dev libxss-dev libasound2-dev libpulse-dev libgl1-mesa-dev libudev-dev
# Audit the selected tree shipped in source archives. Full repository
# history auditing is available separately with --history.
- name: Verify source export
run: python3 tools/public_release/check_public_tree.py --root . --history
run: |
python3 tools/public_release/check_public_tree.py --root .
python3 tools/ci/test_build_runnable_tests.py
python3 tools/package/test_verify_ci_release.py
- name: Set up MSVC x64
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@a102174a2b586eec2ea151a69e6fd14404a8ce7c # v1.13.0
@@ -62,10 +67,20 @@ jobs:
run: |
test "$(uname -m)" = arm64
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DBMH_DATA= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Build every target
run: cmake --build build --config Release --parallel 2
- name: Build products and every runnable test
run: python3 tools/ci/build_runnable_tests.py --build build --config Release --parallel 2
- name: Run synthetic tests and report data tests as skipped
run: ctest --test-dir build -C Release --output-on-failure --output-junit test-results.xml
- name: Verify product versions
shell: python
run: |
import pathlib, subprocess, sys
build = pathlib.Path('build').resolve()
version = (build / 'product-version.txt').read_text().strip()
suffix = '.exe' if sys.platform == 'win32' else ''
cli = subprocess.run([str(build / ('openbmh_cli' + suffix)), '--version'], check=True, capture_output=True, text=True)
assert cli.stdout.strip() == 'OpenBMH console ' + version
subprocess.run([str(build / ('OpenBMH' + suffix)), '--version'], check=True)
- name: Package products and licenses
run: python3 tools/package/make_package.py --build build --out dist --platform ${{ matrix.platform }}
- name: Package corresponding source and pinned dependencies
+36 -11
View File
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-only
name: Prepare release packages
name: Prepare verified release
on:
push:
@@ -7,34 +7,59 @@ on:
permissions:
contents: read
actions: read
jobs:
build:
uses: ./.github/workflows/ci.yml
draft:
needs: build
runs-on: ubuntu-24.04
permissions:
contents: write
actions: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
fetch-depth: 0
- name: Locate successful CI for this exact revision
id: ci
env:
GH_TOKEN: ${{ github.token }}
EXPECTED_SHA: ${{ github.sha }}
run: |
gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?status=success&event=push&per_page=100" > ci-runs.json
python3 - <<'PY'
import json, os
runs = json.load(open('ci-runs.json'))['workflow_runs']
matches = [r for r in runs if r['head_sha'] == os.environ['EXPECTED_SHA'] and
r['conclusion'] == 'success' and r['event'] == 'push' and
r['head_repository']['full_name'].lower() == os.environ['GITHUB_REPOSITORY'].lower()]
if not matches:
raise SystemExit('Run the full CI successfully for this revision before tagging a release')
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
output.write('run_id=' + str(matches[0]['id']) + '\n')
PY
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
github-token: ${{ github.token }}
run-id: ${{ steps.ci.outputs.run_id }}
pattern: OpenBMH-*
path: dist
merge-multiple: true
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
github-token: ${{ github.token }}
run-id: ${{ steps.ci.outputs.run_id }}
pattern: tests-*
path: test-reports
- name: Verify archives, corresponding source and platform reports
env:
RELEASE_TAG: ${{ github.ref_name }}
CI_RUN: ${{ steps.ci.outputs.run_id }}
run: |
python3 tools/package/verify_ci_release.py --dist dist --reports test-reports --tag "$RELEASE_TAG" --source-sha "$GITHUB_SHA" --ci-run "$CI_RUN" --repository "$GITHUB_REPOSITORY"
- name: Create draft for review
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
for package in dist/*.zip; do
case "$(basename "$package")" in
OpenBMH-${RELEASE_TAG#v}-*.zip) ;;
*) 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 dist/SHA256SUMS dist/QA-REPORT.json --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/1.0.4/RELEASE_NOTES.md
+138 -9
View File
@@ -1,8 +1,19 @@
# SPDX-License-Identifier: GPL-3.0-only
cmake_minimum_required(VERSION 3.24)
project(OpenBMH VERSION 0.1.0 LANGUAGES CXX C)
project(OpenBMH VERSION 1.0.4 LANGUAGES CXX C)
if(APPLE)
# Enable native languages before dependencies/subdirectories inherit rules.
enable_language(OBJC OBJCXX)
endif()
set(OPENBMH_PRERELEASE "" 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}")
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/generated/openbmh_build_version.hpp"
CONTENT "// SPDX-License-Identifier: GPL-3.0-only\n#pragma once\n#define OPENBMH_VERSION \"${OPENBMH_PRODUCT_VERSION}\"\n")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -39,7 +50,7 @@ function(bmh_add_data_test)
set(T_DATA_DIR "${BMH_DATA}")
endif()
set(reason "")
set(external_text_tests season_transition_tests environment_tests cli_console_tests
set(external_text_tests season_transition_tests cli_console_tests
ui_desktop_tests ui_lineup_tests format_tests app_controller_tests bank_app_tests
cli_soak ui_cup_draw_tests league_pairings_tests ui_pending_offer_tests
reality_reporter_layout_tests season_cup_draw_app_tests
@@ -62,7 +73,7 @@ function(bmh_add_data_test)
message(FATAL_ERROR "Invalid game data directory for ${T_NAME}: ${T_DATA_DIR}")
endif()
foreach(option IN LISTS T_REQUIRED_OPTIONS)
if(NOT "${${option}}" OR NOT EXISTS "${${option}}")
if("${${option}}" STREQUAL "" OR NOT EXISTS "${${option}}")
set(reason "External test input not supplied: ${option}")
endif()
endforeach()
@@ -202,7 +213,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
@@ -222,6 +232,7 @@ add_library(bmhcore STATIC
src/game/reality_ball.cpp
src/game/reality_duel.cpp
src/game/reality_reporter.cpp
src/game/long_career.cpp
src/game/matchday.cpp
src/game/sportschau_replay.cpp
src/game/sportschau_rating.cpp
@@ -239,6 +250,7 @@ add_library(bmhcore STATIC
src/game/weekly.cpp
src/game/messages.cpp
src/game/table.cpp
src/game/calendar.cpp
src/game/week.cpp
src/game/lineup.cpp
src/game/national.cpp
@@ -329,6 +341,10 @@ bmh_add_data_test(NAME format_tests REQUIRED_OPTIONS BMH_TEST_INPUTS
REQUIRED_FILES expected-text.tsv format-players.tsv format-start.fbm
COMMAND format_tests "${BMH_DATA}" "${BMH_REFERENCE}")
add_executable(stadium_extended_limits_tests tests/stadium_extended_limits_tests.cpp)
target_link_libraries(stadium_extended_limits_tests PRIVATE bmhcore)
add_test(NAME stadium_extended_limits_tests COMMAND stadium_extended_limits_tests)
add_executable(stand_block_actions_tests tests/stand_block_actions_tests.cpp)
target_link_libraries(stand_block_actions_tests PRIVATE bmhcore)
add_test(NAME stand_block_actions_tests COMMAND stand_block_actions_tests)
@@ -365,9 +381,7 @@ bmh_add_data_test(NAME reschedule_tests REQUIRED_OPTIONS BMH_TEST_RESCHEDULE_TES
add_executable(environment_tests tests/environment_tests.cpp)
target_link_libraries(environment_tests PRIVATE bmhcore)
set(BMH_TEST_ENVIRONMENT_TESTS_INPUT_1 "" CACHE PATH "External input 1 for environment_tests; not distributed")
bmh_add_data_test(NAME environment_tests REQUIRED_OPTIONS BMH_TEST_ENVIRONMENT_TESTS_INPUT_1 COMMAND environment_tests "${BMH_DATA}"
"${BMH_TEST_ENVIRONMENT_TESTS_INPUT_1}")
add_test(NAME environment_tests COMMAND environment_tests)
add_executable(youth_academy_tests tests/youth_academy_tests.cpp)
target_link_libraries(youth_academy_tests PRIVATE bmhcore)
@@ -435,15 +449,33 @@ target_link_libraries(desk_check PRIVATE bmhcore)
add_executable(init_check tests/init_check.cpp)
target_link_libraries(init_check PRIVATE bmhcore)
# The approved compressed title is embedded: no install-time sidecar dependency.
set(BMH_START_SCREEN_DATA "${CMAKE_BINARY_DIR}/generated/start_screen_data.cpp")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/generated")
add_custom_command(OUTPUT "${BMH_START_SCREEN_DATA}"
COMMAND "${CMAKE_COMMAND}" "-DINPUT=${CMAKE_SOURCE_DIR}/assets/start-screen.jpg"
"-DOUTPUT=${BMH_START_SCREEN_DATA}" -P "${CMAKE_SOURCE_DIR}/cmake/EmbedStartScreen.cmake"
DEPENDS assets/start-screen.jpg cmake/EmbedStartScreen.cmake
VERBATIM)
add_library(openbmh_start_screen STATIC src/app/start_screen.cpp "${BMH_START_SCREEN_DATA}")
target_include_directories(openbmh_start_screen PRIVATE "${CMAKE_SOURCE_DIR}/src")
target_link_libraries(openbmh_start_screen PUBLIC ${BMH_SDL_TARGET})
add_executable(start_screen_tests tests/start_screen_tests.cpp)
target_include_directories(start_screen_tests PRIVATE "${CMAKE_SOURCE_DIR}/src")
target_link_libraries(start_screen_tests PRIVATE openbmh_start_screen)
add_test(NAME start_screen_tests COMMAND start_screen_tests)
# The playable program: the shared UI library connected to the engine by src/app.
add_executable(openbmh_play
src/app/main.cpp
${BMH_APP_CONTROLLER_SOURCE}
${BMH_APP_SESSION_SDL_SOURCE})
target_link_libraries(openbmh_play PRIVATE bmhui bmhlaunch_dialog openbmh_audio ${BMH_SDL_TARGET})
target_link_libraries(openbmh_play PRIVATE openbmh_start_screen)
# 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)
target_include_directories(openbmh_play PRIVATE "${CMAKE_BINARY_DIR}/generated")
if(MSVC)
target_compile_options(openbmh_play PRIVATE /utf-8)
# App sources also compile in headless tests/helpers without target /utf-8.
@@ -482,6 +514,9 @@ if(MSVC)
endif()
bmh_add_data_test(NAME app_controller_tests COMMAND app_controller_tests "${BMH_DATA}")
set(BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 "" CACHE PATH "External input 1 for app_delay_settings_tests; not distributed")
bmh_add_data_test(NAME app_desktop_input_tests COMMAND app_controller_tests "${BMH_DATA}" --desktop-input-only)
bmh_add_data_test(NAME app_advertising_input_tests COMMAND app_controller_tests "${BMH_DATA}" --advertising-input-only)
bmh_add_data_test(NAME app_environment_tests COMMAND app_controller_tests "${BMH_DATA}" --environment-only)
bmh_add_data_test(NAME app_delay_settings_tests REQUIRED_OPTIONS BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 COMMAND app_controller_tests "${BMH_DATA}"
--delay-settings-only "${BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1}")
@@ -501,6 +536,10 @@ add_executable(national_friendly_actions_tests tests/national_friendly_actions_t
target_link_libraries(national_friendly_actions_tests PRIVATE bmhcore)
add_test(NAME national_friendly_actions_tests COMMAND national_friendly_actions_tests)
add_executable(edition_startup_app_tests tests/edition_startup_app_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
target_link_libraries(edition_startup_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
bmh_add_data_test(NAME edition_startup_app_tests COMMAND edition_startup_app_tests "${BMH_DATA}")
add_executable(manager_join_app_tests tests/manager_join_app_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
target_link_libraries(manager_join_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
if(MSVC)
@@ -622,6 +661,7 @@ add_executable(openbmh_cli
src/cli/seat_hub.cpp
src/cli/json.cpp
${BMH_APP_SESSION_SOURCE})
target_include_directories(openbmh_cli PRIVATE "${CMAKE_BINARY_DIR}/generated")
target_link_libraries(openbmh_cli PRIVATE bmhui bmhlaunch)
if(WIN32)
target_link_libraries(openbmh_cli PRIVATE ws2_32) # --listen (Winsock)
@@ -924,6 +964,7 @@ bmh_add_data_test(NAME league_views_data_tests COMMAND league_views_data_tests "
# FLTD is translated by launch_check/the launcher first. Do not point these
# tests at the raw DOS directory: the shared UI consumes the prepared image.
set(BMH_ENGLISH_DATA "" CACHE PATH "Prepared Football Limited game-data directory")
bmh_add_data_test(NAME english_edition_startup_app_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND edition_startup_app_tests "${BMH_ENGLISH_DATA}")
bmh_add_data_test(NAME english_pairings_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_pairings_data_tests "${BMH_ENGLISH_DATA}")
bmh_add_data_test(NAME english_desktop_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND desktop_data_tests "${BMH_ENGLISH_DATA}" --english)
bmh_add_data_test(NAME english_league_views_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_views_data_tests "${BMH_ENGLISH_DATA}")
@@ -1070,6 +1111,25 @@ if(MSVC)
endif()
add_test(NAME launch_unit_tests COMMAND launch_unit_tests)
add_executable(fltd_translation_unit_tests tests/fltd_translation_unit_tests.cpp)
target_link_libraries(fltd_translation_unit_tests PRIVATE bmhlaunch)
add_test(NAME fltd_translation_unit_tests COMMAND fltd_translation_unit_tests)
add_executable(host_path_display_unit_tests tests/host_path_display_unit_tests.cpp)
target_include_directories(host_path_display_unit_tests PRIVATE src)
if(MSVC)
target_compile_options(host_path_display_unit_tests PRIVATE /utf-8)
endif()
add_test(NAME host_path_display_unit_tests COMMAND host_path_display_unit_tests)
add_executable(quit_confirmation_unit_tests tests/quit_confirmation_unit_tests.cpp)
target_include_directories(quit_confirmation_unit_tests PRIVATE src)
target_link_libraries(quit_confirmation_unit_tests PRIVATE ${BMH_SDL_TARGET})
if(MSVC)
target_compile_options(quit_confirmation_unit_tests PRIVATE /utf-8)
endif()
add_test(NAME quit_confirmation_unit_tests COMMAND quit_confirmation_unit_tests)
add_executable(fixture_table_tests tests/fixture_table_tests.cpp)
target_link_libraries(fixture_table_tests PRIVATE bmhcore)
add_test(NAME fixture_table_unit_tests COMMAND fixture_table_tests)
@@ -1088,3 +1148,72 @@ 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)
add_executable(season_player_reset_tests tests/season_player_reset_tests.cpp)
target_link_libraries(season_player_reset_tests PRIVATE bmhcore)
add_test(NAME season_player_reset_tests COMMAND season_player_reset_tests)
set_tests_properties(season_player_reset_tests PROPERTIES TIMEOUT 10)
add_executable(lineup_foreign_limit_tests tests/lineup_foreign_limit_tests.cpp)
target_link_libraries(lineup_foreign_limit_tests PRIVATE bmhcore)
add_test(NAME lineup_foreign_limit_tests COMMAND lineup_foreign_limit_tests)
add_executable(calendar_epoch_tests tests/calendar_epoch_tests.cpp)
target_link_libraries(calendar_epoch_tests PRIVATE bmhui)
add_test(NAME calendar_epoch_tests COMMAND calendar_epoch_tests)
add_executable(video_session_tests tests/video_session_tests.cpp)
target_include_directories(video_session_tests PRIVATE src)
target_link_libraries(video_session_tests PRIVATE ${BMH_SDL_TARGET})
add_test(NAME video_session_tests COMMAND video_session_tests)
if(APPLE)
add_executable(mac_video_picker_tests tests/mac_video_picker_tests.mm)
set_target_properties(mac_video_picker_tests PROPERTIES OBJCXX_STANDARD 20 OBJCXX_STANDARD_REQUIRED YES)
target_include_directories(mac_video_picker_tests PRIVATE src)
target_link_libraries(mac_video_picker_tests PRIVATE ${BMH_SDL_TARGET} nfd::nfd "-framework Cocoa")
add_test(NAME mac_video_picker_tests COMMAND mac_video_picker_tests)
endif()
add_executable(desktop_feedback_tests tests/desktop_feedback_tests.cpp)
target_link_libraries(desktop_feedback_tests PRIVATE bmhui)
bmh_add_data_test(NAME desktop_feedback_tests COMMAND desktop_feedback_tests "${BMH_DATA}")
add_executable(daily_interest_unit_tests tests/daily_interest_unit_tests.cpp)
target_link_libraries(daily_interest_unit_tests PRIVATE bmhcore)
add_test(NAME daily_interest_unit_tests COMMAND daily_interest_unit_tests)
add_executable(transfer_seller_actions_tests tests/transfer_seller_actions_tests.cpp)
target_link_libraries(transfer_seller_actions_tests PRIVATE bmhcore)
add_test(NAME transfer_seller_actions_tests COMMAND transfer_seller_actions_tests)
add_executable(transfer_seller_app_tests tests/transfer_seller_app_tests.cpp ${BMH_APP_SESSION_SDL_SOURCE})
target_link_libraries(transfer_seller_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
set(BMH_TEST_TRANSFER_SELLER_APP_SAVE "" CACHE FILEPATH "External career for seller-offer integration; not distributed")
bmh_add_data_test(NAME transfer_seller_app_tests REQUIRED_OPTIONS BMH_TEST_TRANSFER_SELLER_APP_SAVE
COMMAND transfer_seller_app_tests "${BMH_DATA}" "${BMH_TEST_TRANSFER_SELLER_APP_SAVE}")
add_executable(wide_number_unit_tests tests/wide_number_unit_tests.cpp)
target_link_libraries(wide_number_unit_tests PRIVATE bmhcore)
add_test(NAME wide_number_unit_tests COMMAND wide_number_unit_tests)
add_executable(long_career_tests tests/long_career_tests.cpp)
target_link_libraries(long_career_tests PRIVATE bmhcore)
add_test(NAME long_career_tests COMMAND long_career_tests)
add_executable(bank_robbery_month_tests tests/bank_robbery_month_tests.cpp)
target_link_libraries(bank_robbery_month_tests PRIVATE bmhcore)
add_test(NAME bank_robbery_month_tests COMMAND bank_robbery_month_tests)
add_executable(monthly_dividend_tests tests/monthly_dividend_tests.cpp)
target_link_libraries(monthly_dividend_tests PRIVATE bmhui)
add_test(NAME monthly_dividend_tests COMMAND monthly_dividend_tests)
add_executable(native_save_version_tests tests/native_save_version_tests.cpp)
target_link_libraries(native_save_version_tests PRIVATE bmhcore)
add_test(NAME native_save_version_tests COMMAND native_save_version_tests)
add_executable(native_save_import_tests tests/native_save_import_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
target_link_libraries(native_save_import_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
set(BMH_TEST_NATIVE_SAVE_IMPORT_INPUT "" CACHE FILEPATH "External native save for import compatibility; not distributed")
bmh_add_data_test(NAME native_save_import_tests REQUIRED_OPTIONS BMH_TEST_NATIVE_SAVE_IMPORT_INPUT
COMMAND native_save_import_tests "${BMH_DATA}" "${BMH_TEST_NATIVE_SAVE_IMPORT_INPUT}")
+1 -1
View File
@@ -1,6 +1,6 @@
# Contributing to OpenBMH
Use [issues](https://github.com/rezmer/openbmh/issues) for reproducible bugs and proposals. For a bug, include the OpenBMH version, platform, game edition, expected behaviour and the smallest sequence of actions that shows the problem. Remove personal paths and account information from diagnostic text.
Use [issues](https://github.com/Weyoune/openbmh/issues) for reproducible bugs and proposals. For a bug, include the OpenBMH version, platform, game edition, expected behaviour and the smallest sequence of actions that shows the problem. Remove personal paths and account information from diagnostic text.
Keep proprietary game files out of public submissions: no executables, databases, manuals, extracted text, artwork, recordings or saved games. Prefer synthetic inputs and a short description. If an investigation requires privately owned data, coordinate an appropriate process with the maintainers instead of attaching it publicly.
+23 -16
View File
@@ -1,44 +1,49 @@
# OpenBMH
A modern and faithful open source rebuild of the *Bundesliga Manager Hattrick* engine.
**Classic-Version: 1.0.4.** Die originalgetreue Linie bleibt in diesem Repository.
Erweiterte Ligen, die gemeinsame deutsche/englische Karriere und der Dateneditor
werden separat als **[OpenBMH-Extended 1.0 Beta](https://github.com/Weyoune/OpenBMH-extended)** entwickelt.
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.
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.
A faithful, standalone community reconstruction of *Bundesliga Manager Hattrick*, using the player's original installation and SDL2 interface.
OpenBMH 1.0 builds on v0.1.2 with reviewed bug fixes and starts directly with the original game data. 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.
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.
## Get started
Check the [releases page](https://github.com/rezmer/openbmh/releases) for available packages and their platform notes. A Windows package uses the name `OpenBMH-<version>-windows-x64.zip`. Availability and native validation are stated for each release; source build instructions do not establish platform support on their own.
Check the [releases page](https://github.com/Weyoune/openbmh/releases) for available packages and their platform notes. A Windows package uses the name `OpenBMH-<version>-windows-x64.zip`. Availability and native validation are stated for each release; source build instructions do not establish platform support on their own.
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:
From a terminal in the extracted package on Linux or macOS:
```sh
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
./OpenBMH --data "path/to/game" --save-directory "path/to/saves"
./openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
```
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [0.1 release notes](docs/release/0.1/RELEASE_NOTES.md).
In Windows PowerShell, use `.\OpenBMH.exe` and `.\openbmh_cli.exe` instead.
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0.4/RELEASE_NOTES.md).
## Features and direction
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 original-game compatibility, stability and community contributions. See the [contribution guide](CONTRIBUTING.md) and [maintenance roadmap](docs/ROADMAP.md).
## Build from source
The following recipes target v0.1.0. 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 build OpenBMH 1.0. 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:
```sh
git clone https://github.com/rezmer/openbmh.git
git clone https://github.com/Weyoune/openbmh.git
cd openbmh
```
@@ -50,7 +55,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 +67,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 +82,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.
@@ -103,6 +108,8 @@ The implementation grew from study of file formats and behaviour of a legally ob
OpenBMH's own code and documentation are licensed under **GNU GPL version 3 only**, SPDX **GPL-3.0-only**. [LICENSE](LICENSE) contains the unchanged GPLv3 text; the example wording in its appendix does not change this project's version choice. Game content has separate ownership and is not covered by this license.
Release source is identified by the matching version tag: [v0.1.0](https://github.com/rezmer/openbmh/tree/v0.1.0) for this version. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
Every published binary release identifies its matching source tag and provides a corresponding source archive. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
Bundled components retain their own licenses, including Nuked OPL3 under LGPL-2.1-or-later. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and [ACKNOWLEDGEMENTS.md](ACKNOWLEDGEMENTS.md).
The supplied project start artwork is embedded at native resolution; see [start-screen artwork](docs/START_SCREEN.md). It replaces the original title image while the game continues to use your own original data and assets.
+1
View File
@@ -4,6 +4,7 @@ OpenBMH's own code and documentation use GPL-3.0-only. This does not replace the
| Component | Version used by the build | License | Included notice |
|---|---|---|---|
| [stb_image](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h) | 2.30, vendored header; JPEG decoder only | MIT or public-domain alternative | [stb_image.txt](docs/licenses/stb_image.txt) |
| [SDL2](https://github.com/libsdl-org/SDL/tree/release-2.32.10) | 2.32.10, or an explicitly selected system SDL2 | zlib license | [SDL2.txt](docs/licenses/SDL2.txt) |
| SDL2 HIDAPI code | Included with SDL2 | BSD-3-Clause option; upstream also offers GPL-3.0 and its original license | [license options](docs/licenses/SDL2-HIDAPI-options.txt), [BSD text](docs/licenses/SDL2-HIDAPI-BSD.txt), [original text](docs/licenses/SDL2-HIDAPI-original.txt) |
| SDL2 yuv2rgb code | Included with SDL2 | BSD-3-Clause | [SDL2-yuv2rgb.txt](docs/licenses/SDL2-yuv2rgb.txt) |
+18
View File
@@ -0,0 +1,18 @@
# OpenBMH Classic start artwork
The project maintainer supplied this new start-screen artwork for use and
repository distribution with this application. It is not extracted game content.
The repository license applies to project artwork; original game assets remain
external. The unmodified upstream decoder has its separate documented license.
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
without EXIF or other input metadata. It occupies 587,410 bytes.
The application embeds it at build time and decodes it once at startup, so
installed applications need no image sidecar or original title-screen VGA.
The SDL renderer uses the actual image dimensions while showing the title,
including high-DPI output and aspect-preserving side bars, then restores the
320 × 240 game/input canvas. A complete left or right mouse click continues;
there is no loading-ball animation. Changing the artwork also requires an
explicit review/update of its SHA256 in the public-source guard.
Binary file not shown.

After

Width:  |  Height:  |  Size: 574 KiB

+4
View File
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-3.0-only
file(READ "${INPUT}" artwork HEX)
string(REGEX REPLACE "(..)" "0x\\1," artwork "${artwork}")
file(WRITE "${OUTPUT}" "// Generated from the repository-owned compressed start screen.\n#include \"app/start_screen_data.hpp\"\nnamespace bmh::app {\nconst unsigned char start_screen_jpeg[] = {${artwork}};\nconst std::size_t start_screen_jpeg_size=sizeof(start_screen_jpeg);\n}\n")
+13 -2
View File
@@ -10,7 +10,7 @@ ctest --test-dir build --output-on-failure
The public checkout does not include game data. Tests that require a game installation are conditional; configure with `-DBMH_DATA="path/to/game"` to make locally available data eligible. Private saved-game fixtures are not supplied by the project. Read the test output to distinguish executed and skipped checks.
Main programs are `openbmh_play` (graphical game) and `openbmh_cli` (console and protocol). Single-configuration generators put them in the build directory; multi-configuration generators normally add a configuration directory. On Windows they have the `.exe` suffix.
Main programs are `OpenBMH` (graphical game) and `openbmh_cli` (console and protocol). Single-configuration generators put them in the build directory; multi-configuration generators normally add a configuration directory. On Windows they have the `.exe` suffix.
## Windows
@@ -45,8 +45,19 @@ Use native toolchain/dependency architectures consistently. A terminal executabl
## Run with your data
```sh
build/openbmh_play --data "path/to/game" --save-directory "path/to/saves"
build/OpenBMH --data "path/to/game" --save-directory "path/to/saves"
build/openbmh_cli --console --data "path/to/game" --saves "path/to/saves" --seed 1
```
For redistribution, include [LICENSE](../LICENSE), [THIRD_PARTY_NOTICES.md](../THIRD_PARTY_NOTICES.md), the full texts in [licenses/](licenses/README.md), and the corresponding source and build information required by the applicable licenses. Inspect the actual libraries in each platform package; static SDL2 alone does not establish that every dependency is static.
## Build the data-free CI subset
`cmake --build build` compiles every development helper and test. With no private integration data configured, CI builds both products and every executable actually referenced by CTest instead:
```sh
python3 tools/ci/build_runnable_tests.py --build build --config Release --parallel 2
ctest --test-dir build -C Release --output-on-failure
```
Tests whose inputs are unavailable still report a skip through the normal optional-data helper; they are not counted as passes. Supplying integration data during configuration causes their real programs to enter this build subset automatically. Source-export and build-discovery checks run separately in CI.
+5 -2
View File
@@ -139,6 +139,8 @@ This index includes registered and reserved names. `ListOptions` and `Help` from
| `SetSquadSheet` | sheet:enum(A,B) | Set Squad Sheet. See current Help for behaviour and bounds. |
| `SetMarketVisible` | on:bool | Set Market Visible. See current Help for behaviour and bounds. |
| `ShowPlayer` | player:Player | Show Player. See current Help for behaviour and bounds. |
| `ShowOffers` | player:Player | existing bids for an owned listing; raw bid slots 0..3 |
| `AcceptOffer` | player:Player, bid:int(0..3) | accept an existing bid before weekly expiry |
| `SellPlayer` | player:Player | VER-KAUFEN: put an own player on the list |
| `LoanOutPlayer` | player:Player, months:int(12\|24) | VER-LEIHEN: offer an own player for loan |
| `BuyPlayer` | player:Player | VER-KAUFEN on a market player: the offer editor |
@@ -308,9 +310,10 @@ This index includes registered and reserved names. `ListOptions` and `Help` from
| Command | Parameters | Purpose |
|---|---|---|
| `ShowEnvironment` | – | staff levels and the youth academy |
| `ShowEnvironment` | – | six monthly budgets and three youth tables |
| `SetStaffLevel` | role:enum(AssistantCoach,Doctor,Physio), level:int(0..6) | click a staff tile: level 0..6, 5 000 a month each |
| `SetYouthAcademy` | state:enum(On,Off) | start (July/August) or stop the youth academy |
| `SetYouthLevel` | team:enum(Youngest,Academy,Oldest), level:int(0..6) | set a youth team’s monthly budget |
| `SetYouthAcademy` | state:enum(On,Off) | compatibility alias: middle youth budget at level 6 or 0 |
### `Balance`
+1 -1
View File
@@ -1,6 +1,6 @@
# Text, encoding and editions
The installation supplies game text and names. The command vocabulary stays stable across editions; it is not translated into the selected game's display language. German and English installation data can have different text, league contents, executable layouts and currency presentation. English support remains experimental as described in the [release notes](../release/0.1/RELEASE_NOTES.md).
The installation supplies game text and names. The command vocabulary stays stable across editions; it is not translated into the selected game's display language. German and English installation data can have different text, league contents, executable layouts and currency presentation. English support remains experimental as described in the [release notes](../release/1.0/RELEASE_NOTES.md).
Legacy bytes are decoded at the display boundary. Client-facing text is intended to be UTF-8, while save and database offsets refer to legacy byte pools. Avoid using a displayed name as a persistent identifier: names may be edited, ambiguous or rendered differently. Prefer the ID domain required by the current command.
+157 -1
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.
@@ -11,3 +11,159 @@ OpenBMH aims to preserve the familiar game while handling malformed input and un
Intentional changes in code should use the marker `OpenBMH deviates from the original:` and explain their purpose. Adding a new behaviour or balance change requires a concrete description and relevant tests; this page is not permission to substitute guessed rules.
The [generated differences catalogue](DIFFERENCES.md) lists these markers with links to their source files.
## Application exit confirmation
Closing the window, exiting with Escape or confirming the desktop's exit control
opens a native confirmation dialog. BMH data uses German text and Football
Limited data uses English. Enter, Escape and closing the confirmation cancel the
exit; only the explicit Quit/Beenden button permits normal shutdown. Cancelling
keeps the current dialog or match owner alive without a turn or implicit save.
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.
## Original edition rules in 1.0
Loaded executable images retain their own rule tables. Career strength ranges are read from all nine pairs of the supplied original table.
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.
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.
OpenBMH deviates from the original: graphical startup shows the supplied static
137.VGA title with its embedded palette, without the DOS loading animation.
It waits for a complete left or right mouse click before the game options.
The title does not advance on a timer; its confirming press and release are
consumed so they cannot also change a setup option.
Setup restores ordinary scene-backed manager dialogs before a career is created
or loaded. The executable's boot-only black dialog mode is process state and is
not restored from native save files. Football Limited's translated data includes
its own verified calendar year and weekday operands; German epochs are not used
as a substitute for the English edition.
## 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.
The automatic lineup installs the supplied foreign-player rule switch alongside the career tables. Where enabled, it restores the original three/two-player limit, reserve swaps with board-coordinate preservation and the short-lineup outcome when domestic reserves are unavailable. This does not consume additional random draws.
New careers correct the original all-zero EM qualification placeholders to the original national-team placeholders. Supplied nonzero seeds and restored savegame state are not rewritten by this initialization.
## Stadium extension in1.0.3
The user-requested stadium extension raises standard A–H maxima to14/24/14/20/
14/24/14/20thousand places (144,000total), keeping larger supplied custom limits
where the saved byte fields can represent them. Original unit prices remain
edition-owned. Each stand's base build period is at least two weeks per1,000
places of its expanded maximum and never shorter than the edition's original
period. Contractor shortening remains unchanged.
The original Diamond3.6/3.7 table's14k stands really used25weeks versus30weeks
for8k and37weeks for18k. That was original data, not a mistaken timer. Expanded
limits/time policy is an intentional improvement. The UI now validates quotes
against the actual edition and this shared policy rather than hardcoded Diamond
prices and sizes. Existing eight capacity/construction bytes and saves are retained.
## Daily interest at large native balances
OpenBMH deviates from the original: daily debt and deposit interest uses 64-bit
intermediate arithmetic before the original integer divisions. The balance-plan
preview uses the same calculation. Original rates, division order and random
consumption remain unchanged. Account balances and accumulated statistics retain
the native 32-bit save representation; this change does not add unlimited account
balances or change the original high-cash deduction policy.
OpenBMH deviates from the original: the legacy transfer market allows an owned
listing to open incoming offers before its weekly expiry. Select the player and
use the sale action (or Enter). Cancel keeps the listing and offers unchanged;
acceptance uses the existing buyer eligibility, player salary qualification and
transaction rules. Human-buyer loans still require their separate consent and
allocator context and are unavailable in this early review. Viewing/canceling
consumes no RNG. The weekly auction remains unchanged.
The transfer overview processes one selected player per action and renders action
feedback in its footer. A cleared unsuccessful listing can be listed again
immediately; there is no additional cooldown. The manager listing action refuses a full ordinary market
without allocating a reserved special-offer row. These are explicit
application outcomes instead of the Original's destructive overflow/dialog paths.
OpenBMH deviates from the original: a newly initialized squad board entry clears
retirement, refused-negotiation and month-processing flags left by its previous
occupant. The Original leaves that byte intact when reusing the row, so purchases
and academy arrivals can inherit a refusal to renew. Existing players' genuine
retirement/refusal flags remain effective. The initial academy contract remains
two years; a young arrival can immediately negotiate any supported renewal term.
This corrects the reused-row mechanism; it does not establish a fixed 200–300
season threshold or repair ambiguous refusal flags in existing saved careers.
Bank finance-overview totals and gains use 64-bit read-only projections and
currency formatting, including values beyond a signed native account word.
Saved cash, deposits, loan fields and holdings retain their original widths.
This prevents a positive combined portfolio from appearing negative; it does
not recover amounts that have already overflowed inside a native saved field.
Live ball, set-piece and shot animations retain
visible scoreboard digits at the chance-preview value until the result view.
The simulation still commits goals, statistics and random draws at their existing
boundaries. Post-match overview dismissal owns its full mouse gesture, including
release after pointer movement, before the following calendar decision can open.
The pitch uses each edition's original position-distance tables, atlas swatches
and pointer bitmap for placement feedback; this display state is not serialized.
OpenBMH deviates from the original: cumulative human-club appearances, goals and
assists have optional 64-bit counters. Original byte/word fields keep their
modulo representation for gameplay/layout compatibility; roster projections use
the wider values. Tracking begins with the surviving legacy values, so high bits
already lost in an imported save cannot be recovered. A new arrival clears the
previous squad occupant's totals. Club promotion remaps counter ownership.
Title-holder and cup-winner lists retain all observed seasons in the same optional
OpenBMH save extension. The Original nine-by-fifty table remains a rolling window.
The archive captures that window before it shifts, and the title list can page
through the archived rows. Late legacy imports start with their surviving fifty
seasons; earlier winners are unknown and are not fabricated. Stored winner names
are historical snapshots, so later renaming and promotion cannot change them.
The separate manager-achievements graph retains its Original fifty-season view.
These records use a versioned `OBMHEXT1` extension after the Original name pools;
see [save format](formats/LONG_CAREER.md). Original programs and older OpenBMH
writers do not preserve this archive. Keep an OpenBMH backup when exchanging
careers with those writers. The native calendar still has its existing signed
16-bit season limit; this patch does not claim an unlimited calendar.
## Monthly high-cash loss limit
OpenBMH deviates from the original: the high-cash bank robbery can occur at most
once per manager and calendar month. The original threshold above 100 million
and random loss of 10–20 million remain. A blocked repeat consumes no random
draw. Month boundaries follow the same source calendar used by daily processing,
and the guard is stored in the optional BRM1 section of OBMHEXT1 saves.
An older save has no record of past robberies. Its first qualifying high-cash month
receives a grace period without a loss or random draw; subsequent saves retain
that guard. The next calendar month can trigger the ordinary loss. Import cannot
infer whether an event already occurred before this feature. Fresh histories
receive the same initial grace month.
OpenBMH deviates from the original: monthly fund/property dividends multiply
unit price by the dividend factor in 64 bits before the existing integer division.
The monthly and annual previews and weekly offers use the same widened product.
Per-unit rounding and the selected legacy/typed recipient policy are unchanged.
This corrects intermediate overflow for representable dividends; account,
deposit, property book value and monthly totals still use their native 32-bit
storage and can overflow. It is not a complete large-balance finance fix.
Release-driven incoming-transfer presenters require a matching press observed
inside that modal. An orphan or repeated release from the preceding result table
cannot decline an offer or dismiss its confirmation. Repeated presses while a
button is held still form one gesture; fresh left/right clicks keep their actions.
## Host file overwrite confirmation
The file picker reuses the Original overwrite question and Ja/Nein button
layout. A separate Yes click or Enter confirms; repeated double-clicks do not.
OpenBMH deviates from the original: host file operations use the shared dialog's
system identity because the picker does not own a live manager portrait projection.
+18 -14
View File
@@ -6,32 +6,36 @@ See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These en
describe deliberate changes; they are not a list of every known compatibility limit.
- [src/app/career_session.cpp](../src/app/career_session.cpp): supports designated set-piece record initialization and validation.
- [src/cli/console/windows_environment.cpp](../src/cli/console/windows_environment.cpp): uses monthly staff levels in increments of five thousand and the supported youth-academy controls.
- [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/balance_plan.cpp](../src/game/balance_plan.cpp): omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
- [src/game/balance_plan.hpp](../src/game/balance_plan.hpp): uses the supported staff and youth-academy cost categories.
- [src/app/main.cpp](../src/app/main.cpp): display the repository-owned title at its native resolution until a complete left/right click, without loading balls.
- [src/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
- [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): enables the supported youth academy and represents staff levels in monthly increments of five thousand.
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): a seller may accept an existing bid before expiry.
- [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.
- [src/game/lineup.hpp](../src/game/lineup.hpp): supports owner-bound designated set-piece selection.
- [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules.
- [src/game/match_engine.cpp](../src/game/match_engine.cpp): supports designated set-piece takers, the enhanced injury tables, and the extended suspension fields.
- [src/game/month.cpp](../src/game/month.cpp): omits the two discontinued youth-group cost categories from monthly accounts.
- [src/game/season.cpp](../src/game/season.cpp): uses the enhanced youth-academy season settlement and player-generation rules.
- [src/game/season.hpp](../src/game/season.hpp): uses the enhanced youth-academy season settlement and player-generation rules.
- [src/game/month.cpp](../src/game/month.cpp): keep the price product in 64 bits until division, retaining per-unit truncation and recipient policy.
- [src/game/national.cpp](../src/game/national.cpp): a new arrival must not inherit the previous occupant's retirement/refusal/month-processing flags.
- [src/game/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
- [src/game/season.cpp](../src/game/season.cpp): age/retire each player once, even when a temporary offer row references his club slot or regeneration moves him to a later free-agent slot.
- [src/game/season.cpp](../src/game/season.cpp): includes transfer-market players in retirement so the five-bit age cannot wrap to 16.
- [src/game/season.cpp](../src/game/season.cpp): initializes the empty EM qualifier seeds with national teams, preventing club zero from entering the EM.
- [src/game/season.hpp](../src/game/season.hpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
- [src/game/stadium_blocks.cpp](../src/game/stadium_blocks.cpp): allow 144,000 standard places and size-aware construction times while retaining edition-owned unit prices.
- [src/game/state.hpp](../src/game/state.hpp): retains designated set-piece selections in the supported manager-record extension.
- [src/game/week.cpp](../src/game/week.cpp): widen products before annual-rate division so valid native account amounts do not overflow intermediate sums.
- [src/game/week.cpp](../src/game/week.cpp): an unknown history receives a grace month; later losses occur at most once per source month.
- [src/game/week.cpp](../src/game/week.cpp): uses the enhanced training rules: focus strength is at least five below its target, and completed skills rotate to another focus.
- [src/game/week.hpp](../src/game/week.hpp): uses the enhanced assistant-training rules, retaining the selected skill until it reaches its maximum.
- [src/game/weekly.cpp](../src/game/weekly.cpp): uses the supported weekly-event configuration, with its rule switch disabled.
- [src/game/weekly.hpp](../src/game/weekly.hpp): uses the supported weekly processing and transfer rule profile.
- [src/ui/advertising.cpp](../src/ui/advertising.cpp): uses the supported youth-academy cap and its saved cost fields.
- [src/ui/environment.cpp](../src/ui/environment.cpp): omits the two discontinued youth groups from the environment screen.
- [src/ui/bank.cpp](../src/ui/bank.cpp): read-only totals use wide arithmetic; individual saved account, price, holding and paid fields are unchanged.
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): omits DOS drive and delete buttons in the directory-confined save/load view.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): the host file picker uses the shared dialog's system identity without a live manager portrait projection.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): permits cancelling host file dialogs with the right mouse button.
+12 -21
View File
@@ -1,29 +1,20 @@
# Roadmap
# Community maintenance roadmap
OpenBMH combines a playable reconstruction with a foundation for extension. These milestones describe direction and dependencies, not promised dates.
OpenBMH reconstructs the original Bundesliga Manager Hattrick experience using the player's own game data. Development priorities are compatibility, reliability and accessible community maintenance.
## 0.1: a usable engine
## 1.0 acceptance
Career management, matches, finances, transfers, original-style SDL2 screens, audio and a console share the same session logic. German game data is the primary target; Football Limited support is experimental. Compatibility and remaining limitations are documented in the [release notes](release/0.1/RELEASE_NOTES.md).
- Validate German CD-compatible BMH and supported Diamond installations, including career setup, management, matches and season transitions.
- Preserve original data and save layouts; document intentional bug corrections.
- Check Windows x64, macOS ARM64 and Linux x64 builds and publish matching source archives, licenses and checksums.
- Keep release limitations and reproducible defects visible in the issue tracker.
## 0.15: broader English compatibility
## Continued maintenance
Complete edition-specific loading, presentation, competitions and sound support. Imported content determines names, text, clubs and league organisation; a shared engine rule base defines the simulation.
Prioritize reproducible gameplay, save, rendering, input and platform bugs. Keep improvements focused and cover unsafe state transitions with regression tests. Contributions should preserve the familiar interface and the supplied edition's content and competition structure.
## 0.2: open data and typed state
Football Limited remains experimental. Improvements require independent checks of its original loading, presentation, competitions, audio and save compatibility; German acceptance does not establish English acceptance.
Introduce a documented import format and a native save format, retaining supported legacy import where practical. Replace fixed-layout state gradually with typed clubs, players, contracts and competitions. Keep each intermediate stage usable and cover transitions with tests.
The SDL2 graphical client and console share the game/session layer. Community clients and automation should use the documented [console interface](CONSOLE_CLIENTS.md) and retain its ownership and revision checks.
## 0.3: configurable rules
Expose rule values and balance choices as configuration, with reproducible simulations to assess changes. Improve tactical automation, transfer decisions and scoring distributions through documented changes rather than hidden edition-specific branches.
## 0.4: adaptable interfaces and competitions
Add a scalable interface through the shared application/protocol boundary. Make league sizes and competition structures data-driven. Define content-pack formats for independently licensed artwork, names and other resources; do not distribute third-party material without permission.
## 0.5: independently distributable content
Provide original or freely licensed graphics, sound and generated football worlds so that OpenBMH can be played without proprietary game data. Support editors, new competitions and multiplayer clients built on the same engine interfaces.
The typed model and open format are prerequisites for flexible competitions, configurable rules and new content. See [architecture](architecture.md) for the current boundaries and [compatibility decisions](COMPATIBILITY.md) for intentional departures.
See [architecture](architecture.md), [compatibility decisions](COMPATIBILITY.md) and [contributing](../CONTRIBUTING.md) before changing shared behaviour. No proprietary game content belongs in public code, tests or releases.
+18
View File
@@ -0,0 +1,18 @@
# OpenBMH Classic start artwork
The project maintainer supplied this new start-screen artwork for use and
repository distribution with this application. It is not extracted game content.
The repository license applies to project artwork; original game assets remain
external. The unmodified upstream decoder has its separate documented license.
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
without EXIF or other input metadata. It occupies 587,410 bytes.
The application embeds it at build time and decodes it once at startup, so
installed applications need no image sidecar or original title-screen VGA.
The SDL renderer uses the actual image dimensions while showing the title,
including high-DPI output and aspect-preserving side bars, then restores the
320 × 240 game/input canvas. A complete left or right mouse click continues;
there is no loading-ball animation. Changing the artwork also requires an
explicit review/update of its SHA256 in the public-source guard.
+51
View File
@@ -0,0 +1,51 @@
# Desktop and advertising mouse input fixes
The optional desktop frame bit controls decoration, not whether the visible
widget contents accept input. The corrections reuse the Original renderer,
coordinates, layout records and action dispatchers.
- The date widget activates the same owned advance action as Anstoß, with or
without a frame. In a multiplayer turn this first hands control to the next
manager. The separate calendar/rescheduling menu keeps its own behavior.
- Stored icons remain clickable and draggable from unframed folders. Extraction
restores the actual icon record to the visible chain; the folder stays put.
Hidden or unlinked owners remain invalid. Removal corners keep their separate
transaction and mouse-release barrier. The same frame-origin correction also
covers the existing admission scale and five automation controls.
- A true double-click on an existing save opens the shared Original-style
overwrite question. A separate single click on Ja confirms, Nein returns to
the picker, and repeated double-click releases cannot write. Enter and cancel
paths remain. FBM, EIN and MEN use the same confirmation boundary.
- Advertising follows all nineteen original hit rectangles with palette0x27
outlines and the installed edition's detail/help text. Motion alone does not
change the career, revision or either random stream. Offers/calculators retain
their input owner; returning from them reevaluates the actual pointer, avoiding
a stale highlight without requiring another mouse movement.
## Validation
The focused configured-data tests are `app_desktop_input_tests`,
`app_advertising_input_tests`, `ui_desktop_input_tests`, `ui_save_load_tests` and
`ui_advertising_tests`. They cover frame variants, exact field boundaries,
canonical actions, stale/hidden-owner refusal, cancellation, input release,
overwrite confirmation and unchanged game/random state for presentation-only
input. The desktop input test isolates these checks from unrelated private
text/badge inventories; the existing full test retains its additional checks.
Private Linux SDL before/after captures and actual saved games are maintained in
`bmh_4k_ui/docs/qa/classic-extended-ui-input`. The fixtures use actual club/player
data with a controlled desktop layout. No results are fabricated. A successful
compile or CI run alone is not native Windows/macOS UI verification.
Tracked reports: [#51](https://github.com/Weyoune/openbmh/issues/51), [#52](https://github.com/Weyoune/openbmh/issues/52), [#53](https://github.com/Weyoune/openbmh/issues/53), [#54](https://github.com/Weyoune/openbmh/issues/54).
The primary regression run uses the supplied Diamond 3.7 installation. Unrelated
historical rendering fixtures retain their declared reference requirements.
Two existing Classic test fixtures were aligned with the already implemented
stadium-capacity policy and verified edition-specific crest gate; product
validation was not relaxed to satisfy those tests.
The overwrite prompt also maps the actual Football Limited English pointer.
The translation copies exactly that four-byte pointer and preserves adjacent
empty slots. The launcher translation-cache revision is advanced, so an existing
cached English installation receives the newly supported prompt as well.
+27 -2
View File
@@ -783,7 +783,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
| `EnglishLayoutTranslation157` | `0x6e094` | English image adapter |
| `EnglishLayoutTranslation158` | `0x6e0b8` | English image adapter |
| `EnglishLayoutTranslation159` | `0x6e0bb` | English image adapter |
| `EnglishLayoutTranslation16` | `0x6be4f` | English image adapter |
| `EnglishLayoutTranslation16` | `0x6be50` | English image adapter |
| `EnglishLayoutTranslation160` | `0x6e0d8` | English image adapter |
| `EnglishLayoutTranslation161` | `0x6e110` | English image adapter |
| `EnglishLayoutTranslation162` | `0x6e11c` | English image adapter |
@@ -1005,7 +1005,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
| `EnglishLayoutTranslation70` | `0x6d270` | English image adapter |
| `EnglishLayoutTranslation71` | `0x6d272` | English image adapter |
| `EnglishLayoutTranslation72` | `0x6d274` | English image adapter |
| `EnglishLayoutTranslation73` | `0x6d29c` | English image adapter |
| `EnglishLayoutTranslation73` | `0x6d29d` | English image adapter |
| `EnglishLayoutTranslation74` | `0x6d3b4` | English image adapter |
| `EnglishLayoutTranslation75` | `0x6d404` | English image adapter |
| `EnglishLayoutTranslation76` | `0x6d408` | English image adapter |
@@ -1045,6 +1045,11 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
| `Environment_FormatError_RuntimeField` | `0xa50f0` | German-compatible image / runtime field |
| `Environment_FormatError_RuntimeField2` | `0xa50f6` | German-compatible image / runtime field |
| `Environment_Render_TextPointer` | `0xaeb74` | German-compatible image / runtime field |
| `EnvironmentYouthTeams` | `0xbd4bc` | German-compatible image / runtime field |
| `EnvironmentYouthPositionSuffix` | `0xa1698` | German-compatible image / runtime field |
| `EnvironmentCostSuffix` | `0xa169d` | German-compatible image / runtime field |
| `EnvironmentYouthLeagueTextPointer` | `0xaeb78` | German-compatible image / runtime field |
| `EnvironmentYouthColors` | `0xa50fc` | German-compatible image / runtime field |
| `Environment_SetEnvironment_ExecutableField` | `0xaf394` | German-compatible image / runtime field |
| `EuropeNameTable` | `0xae710` | German-compatible image / runtime field |
| `EventPasses` | `0xa2ba1` | German-compatible image / runtime field |
@@ -1490,6 +1495,17 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
| `Pitch_Render_TextPointer3` | `0xae0f0` | German-compatible image / runtime field |
| `Pitch_Render_TextPointer4` | `0xae0f4` | German-compatible image / runtime field |
| `Pitch_Render_TextPointer5` | `0xae0f8` | German-compatible image / runtime field |
| `PitchPreferenceDepthBases` | `0xa3cc3` | German-compatible image / runtime field |
| `PitchPreferenceRed` | `0xa3cc7` | German-compatible image / runtime field |
| `PitchPreferenceGreen` | `0xa3cd1` | German-compatible image / runtime field |
| `OriginalPointerPixels` | `0xa45b4` | German-compatible image / runtime field |
| `EnglishPitchPreferenceDepthBases` | `0x6e230` | English image adapter |
| `EnglishPitchPreferenceRed` | `0x6e234` | English image adapter |
| `EnglishPitchPreferenceGreen` | `0x6e240` | English image adapter |
| `EnglishOriginalPointerPixels` | `0x70554` | English image adapter |
| `PitchOrderPositionPointers` | `0xa2a37` | German-compatible image / runtime field |
| `PitchOrderZoneMasks` | `0xa2a4b` | German-compatible image / runtime field |
| `PitchOrderZoneTextPointers` | `0xae818` | German-compatible image / runtime field |
| `Placements` | `0xbd38c` | German-compatible image / runtime field |
| `PlainBackground` | `0xa2569` | German-compatible image / runtime field |
| `PlanTicketPrice` | `0xa4856` | German-compatible image / runtime field |
@@ -1562,6 +1578,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
| `SaveLoad_Render_RuntimeField` | `0xa2334` | German-compatible image / runtime field |
| `SaveLoad_Render_RuntimeField2` | `0xa233f` | German-compatible image / runtime field |
| `SaveLoad_Render_RuntimeField3` | `0xa234a` | German-compatible image / runtime field |
| `SaveLoad_OverwriteQuestionPointer` | `0xa21c4` | German-compatible image / runtime field |
| `SaveLoad_Render_TextPointer` | `0xa1512` | German-compatible image / runtime field |
| `SaveLoad_Render_TextPointer2` | `0xae5f0` | German-compatible image / runtime field |
| `SaveLoad_Render_TextPointer3` | `0xae620` | German-compatible image / runtime field |
@@ -1983,3 +2000,11 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
| `EnglishSixTeamFixtureTable` | `0x6eed4` | English image adapter |
| `EnglishTwelveTeamFixtureTable` | `0x6f0bc` | English image adapter |
| `EnglishTwentyTeamFixtureTable` | `0x6ee40` | English image adapter |
| `EnglishDesktopBinSourceX` | `0x6e180` | English image adapter |
| `EnglishDesktopBinSourceY` | `0x6e182` | English image adapter |
| `EnglishDesktopSocketSourceX` | `0x6e184` | English image adapter |
| `EnvironmentBudgetSteps` | `0xa50ff` | German-compatible image / runtime field |
| `EnvironmentVerifiedCodeBegin` | `0x6c000` | English image adapter |
| `EnvironmentVerifiedCodeEnd` | `0x6cb40` | English image adapter |
| `EnvironmentVerifiedHookBegin` | `0x7af65` | English image adapter |
| `EnvironmentVerifiedHookEnd` | `0x7b020` | English image adapter |
+37 -1
View File
@@ -9,7 +9,7 @@
| Plain header | Variable | Manager/date information for the load list |
| Signature area | 10 bytes | Eight-byte `KRON_FBM` signature and two following bytes |
| First ID | u32 | Container identifier |
| Version | 6 bytes | NUL-terminated version field, normally `V2.24` for the supported state layout |
| Version | 6 bytes | NUL-terminated version field, `V2.24` or the verified Diamond `V3.7` marker for this state layout |
| Second ID | u32 | Save identifier |
| Random byte | u8 | Header value |
| Initial key | u8 | Rolling-cipher seed |
@@ -26,8 +26,44 @@ The supported layout contains a fixed ordered block table, followed by four name
Each name pool has a u16 byte length followed by that many bytes, in club, player, referee and stadium order. These pools preserve renamed entities. The splitter rejects missing/truncated blocks or pools and requires exact stream consumption. See [STATE](STATE.md) for interpreted records and [M3D](M3D.md) for pool references.
## Optional OpenBMH state
After the four name pools, OpenBMH can append `OBMHEXT1`, a u16 block count,
then each block as a u32 identifier, u32 byte length and payload. There is at
most one such container and the decoder requires exact consumption of it.
Original saves have no container. The entire extension is included in the outer
rolling cipher and checksum.
Known OpenBMH-owned sections include:
| Identifier | Payload | Purpose |
|---|---|---|
| `OBLC` (`0x4f424c43`) | Versioned variable-length archive | [Long-career player counters and title winners](LONG_CAREER.md) |
| `BRM1` (`0x314d5242`) | Four little-endian u32 month-start keys (16 bytes) | Per-manager monthly high-cash robbery guard |
A robbery key is the absolute first day of the last blocked source-calendar
month. `UINT32_MAX` means unknown. An unknown high-cash history receives a
first qualifying grace month; later deductions can occur at most once per
calendar month. Managers have independent keys. A truncated or duplicate BRM1
section is rejected before game state is published.
These identifiers describe OpenBMH-owned payloads, not original executable
addresses. The container can also hold explicitly supported compatibility blocks,
such as edition-specific cup state. Unrecognized payloads are not a general
persistence API. Original programs and older OpenBMH writers may reject or
discard optional information: keep a backup before opening a new save with them.
## Edition compatibility
Diamond 3.7 uses the `V3.7` container label with the verified German V2.24 state
layout. Career loading, saved-desktop/preparation import and browser information
accept that exact label as well as `V2.24`. The checksum, full block/pool structure
and installed edition's database dimensions are still required. An accepted
version label cannot make a malformed or mismatched state valid. Ordinary
OpenBMH native saves continue to use the canonical `V2.24` output marker.
Unknown labels are rejected separately from checksum failures.
Original Football Limited V2.20 saves use a different state block list despite sharing the signature and rolling cipher. They are not interchangeable with the V2.24 layout. Reading an English installation and importing its original saves are separate features; do not edit a version string to bypass the distinction. OpenBMH's own English careers use the session's supported save representation.
Keep a backup before using a save with another engine version. Unknown bytes retained for compatibility are not safe targets for direct client manipulation.
+34
View File
@@ -0,0 +1,34 @@
# Optional long-career statistics and title archive
The existing `OBMHEXT1` container can contain block `0x4f424c43` (OpenBMH-owned,
not a guest memory address). Original state blocks and all four name pools retain
their sizes and ordering. No extension is emitted until an archive is needed.
Payload integers use little-endian encoding:
| Field | Encoding |
|---|---|
| Payload version | u32, currently 1 |
| Player/club record count | u32 |
| Known season record count | u32 |
| Each player/club record | u32 key, then six u64 counters |
| Each season record | u32 absolute zero-based season, then nine names |
| Each name | u16 byte length followed by Original-encoding bytes |
The player key is `(runtime_club << 12) | player_id`. The six counters are league,
national-cup and European-cup appearances, total appearances, goals and assists.
Club swaps remap keys; fresh squad entry initialization resets the new player's
club record. The Original byte/word fields continue to update normally.
Season names follow the nine Original title categories. An empty name is a known
season with no holder for that category. Missing season records are unknown,
not an assertion that no competition was held. Names are owned snapshots at the
award/capture time, independent of future club-number and name-pool changes.
A legacy import contributes only its surviving window; no earlier information
is inferred. The title list uses the earliest known absolute season when paging
and compensates for the native rolling-window year offset.
The decoder rejects unknown versions, truncated payloads, invalid/duplicate
identities and seasons, duplicate blocks and trailing bytes before publishing
archive state. Season records remain within the native signed 16-bit calendar
range. The surrounding FBM checksum covers the extension. Older writers may
discard extensions; Original-game roundtrip preservation is not promised.
+2
View File
@@ -12,3 +12,5 @@ These files preserve upstream license and attribution wording. They are not a gr
- [LGPL version 2.1](LGPL-2.1.txt): full license supplied with Nuked OPL3. Its source notices permit version 2.1 or any later version.
[THIRD_PARTY_NOTICES.md](../../THIRD_PARTY_NOTICES.md) identifies the upstream versions and distribution requirements. Include this directory, that notice file and the root LICENSE with release packages. Preserve upstream attribution within these verbatim texts.
- [stb_image](stb_image.txt): complete upstream dual-license text from the vendored 2.30 header. JPEG-only decoding is used for the supplied project start screen.
+38
View File
@@ -0,0 +1,38 @@
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
-44
View File
@@ -1,44 +0,0 @@
OpenBMH v0.1.0
===============
OpenBMH ist eine eigenstaendige Neuumsetzung der Engine von Bundesliga Manager
Hattrick und der englischen Fassung Football Limited. Die englische Unterstuetzung
ist experimentell. Originale Spielinhalte sind nicht enthalten; du benoetigst eine
eigene unterstuetzte Installation. Originale V2.20-Spielstaende der englischen
Fassung sind nicht mit dem unterstuetzten Speicherlayout austauschbar.
Start
-----
Paket in einen eigenen Ordner oder neben die Installation entpacken.
openbmh_play starten (unter Windows openbmh_play.exe). Der Dateidialog nimmt einen
Spielordner, die Programmdatei oder ZIP/7z mit einer einzelnen Installation an.
Aus einem Terminal:
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
Unter Windows den Programmnamen um .exe ergaenzen. Ein beschreibbarer separater
Spielstandordner wird empfohlen. Vorhandene Spielstaende vorher sichern.
Tonoptionen: --mute, --no-music, --volume 0.5. --version zeigt die Programmversion.
In der Konsole zeigt ListOptions die aktuellen Befehle; eine eigene Zeile go.
fuehrt den eingegebenen Block aus. Help beschreibt die Parameter.
Dokumentation und Rueckmeldungen
-------------------------------
README.md enthaelt die Bauanleitungen fuer Windows, Linux und macOS.
Die Releasehinweise beschreiben den Umfang und die bekannten Grenzen.
Linux benoetigt je nach Paket Systembibliotheken, insbesondere GTK3 fuer den
Standard-Dateidialog. Plattform-Bauhinweise sind kein Nachweis eines nativen Tests.
Fehler mit Programmversion, Spielfassung und kurzen eigenen Schritten melden.
Keine Originaldateien, Spielbilder, Aufnahmen, Textlisten oder Spielstaende in
oeffentliche Issues hochladen.
Lizenz
------
Eigener OpenBMH-Code und Dokumentation: GNU GPL Version 3 ausschliesslich
(GPL-3.0-only). LICENSE enthaelt den vollstaendigen Text. Drittanbieter behalten
ihre Lizenzen; siehe THIRD_PARTY_NOTICES.md und docs/licenses/.
Diese Lizenzen gelten nicht fuer die separat benoetigten Originalinhalte.
OpenBMH ist ein unabhaengiges Projekt ohne Verbindung oder Billigung durch die
urspruenglichen Rechteinhaber, DFL oder Bundesliga.
-32
View File
@@ -1,32 +0,0 @@
# OpenBMH v0.1.0
OpenBMH reconstructs the Bundesliga Manager Hattrick engine in C++20. The graphical client uses SDL2; the console provides command batches and local manager-client transports over the same career session. This release needs a supported game installation supplied by the player. No original executable, artwork, music, text database, manual or saved game is included.
## Scope
The engine includes career management, leagues and cups, transfers and contracts, finances, training and camps, stadium management, live match interventions, audio playback and normal saves. Supported actions remain subject to mode, manager and phase restrictions; an unimplemented path reports an explicit error rather than an invented result. The project aims for recognisable behaviour and plausible results, not a promise that every original version produces identical events.
German game editions are the primary compatibility target. **Football Limited support is experimental.** English installation loading and edition-specific text/layout data are supported paths, while original V2.20 save import, English audio and remaining competition/interface differences have limitations. Check current issues before relying on a particular English workflow.
## Compatibility decisions
OpenBMH uses shared rule values across supported German editions, with installation-specific content read from the selected data. It includes safety handling around invalid input, calendar boundaries, capacity checks and suspended operations. See [compatibility decisions](../../COMPATIBILITY.md) and [architecture](../../architecture.md). This is an independent reconstruction, not an official update to the original game.
## Running
Extract the package to a separate directory or alongside your installation. `openbmh_play` can select a game directory, executable or a ZIP/7z containing one supported installation. Use an explicit writable save directory when the original directory is read-only, and keep backups.
```sh
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
```
Version 0.1 ships binary packages for Windows x64, macOS on Apple silicon (arm64, macOS 11 or later) and Linux x64. The Linux package passes the automated build and tests but has not yet been played natively; reports are welcome. The macOS package is not signed or notarized, so Gatekeeper asks for confirmation on first start: open it once via right-click → Open, or allow it under System Settings → Privacy & Security. Packages and their native platform results are listed with the release assets. The [build instructions](../../BUILDING.md) cover Windows, Linux and macOS source builds; an instruction is not a claim of native acceptance. Linux's default file dialog backend requires GTK3 system libraries. A macOS terminal executable is distinct from a signed application bundle.
## License
The matching application source tag is [v0.1.0](https://github.com/rezmer/openbmh/tree/v0.1.0). Source/build and relinking materials for linked components must also accompany or be offered with binary releases under their licenses.
OpenBMH-owned code and documentation use GPL-3.0-only. Third-party components retain their licenses; the full texts accompany the package. Read [LICENSE](../../../LICENSE) and [THIRD_PARTY_NOTICES](../../../THIRD_PARTY_NOTICES.md). These licenses do not grant rights to original game content.
For reports, include the OpenBMH version, data edition, independently written steps and the observed result. Do not upload original files, game screenshots, recordings, text collections or saved games to public issues.
+71
View File
@@ -0,0 +1,71 @@
# OpenBMH 1.0.3
This Classic maintenance release fixes startup, dialog and match presentation,
transfer handling and several long-career limits. It uses the player's own
supported game installation. Extended development lives separately in
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
## Changes
- Football Limited startup reads its own calendar epoch and prepared-image
tables. Original CD assets are located without assuming filename case.
- Original Diamond 3.7 saves with the verified `V3.7` container marker load in
the career, browser information and preparation paths. Unknown versions and
checksum failures are reported separately; layout checks remain strict.
- The original title remains visible until a complete left or right mouse click,
without loading balls or automatic advancement.
- Career dialogs retain their scene background instead of inheriting the
executable's black boot-dialog mode.
- Goal scenes retain the previous visible score until the result is revealed.
- Closing a table or pairings overview owns the complete right-button gesture.
- Pitch placement again uses the edition's preferred-position colors and
original colored cursor.
- Select an owned transfer listing and use the sale action or Enter to inspect
existing offers before expiry. Cancel preserves the listing. Cleared listings
can be offered again; refusals receive visible feedback.
- A fresh squad arrival clears negotiation flags left by the previous occupant
of its row. This prevents inherited refusal of contract renewal.
- Optional saved archives preserve cumulative player counters and observed
title winners beyond the original byte/word and fifty-season windows.
- Daily interest and property/fund dividend products use wider intermediate
arithmetic; Bank portfolio totals use wide display values.
- The high-cash bank robbery remains, at most once per manager and calendar
month. Saving and loading preserves the limit. An older save with unknown
history receives a first qualifying month of grace.
- Standard stadium blocks now allow 144,000 places in total. Unit prices come
from the loaded edition; build periods increase with expanded block size.
## Validation
The release workflow requires successful builds, configured synthetic tests and
package checks for Windows x64, macOS ARM64 and Linux x64 at the tagged revision.
Reports and checksums accompany the downloads. Missing external-data tests are
reported as skipped, rather than counted as successful game tests.
Additional private Linux checks use Original CD, Diamond and Football Limited
assets for startup and setup, scene-backed dialogs, calendar/rescheduling,
transfer decisions, preferred-position feedback and score reveal. A 144,000-place
stadium was rendered after encrypted native save/load. These checks do not
constitute manual gameplay validation on Windows or macOS, or a full
200–300-season simulation.
## Known limits
- Individual native cash, deposit and financial-history fields remain 32-bit and
can still overflow. Wider calculations and aggregate display do not solve
multi-billion single-account storage; that issue remains open.
- Calendar and rescheduling opened in the checked Classic datasets; the reported
failure remains open because it could not be reproduced.
- Football Limited remains experimental. Its original V2.20 save layout is
different and is not enabled by the Diamond 3.7 import correction.
- Already lost counters and earlier title winners cannot be reconstructed. The
separate manager-achievements graph retains its original fifty-season window.
Original programs and older OpenBMH writers can discard optional archive and
monthly-robbery extensions; keep backups before exchanging saves.
- The row-initialization correction does not clear genuine retirement/refusal
flags in an existing career or establish a fixed 200–300-season threshold.
- Early acceptance of a human-buyer loan still needs its separate consent flow
and is unavailable from the early offer preview.
The public downloads contain implementation, corresponding source and notices;
original game content is not included.
+57
View File
@@ -0,0 +1,57 @@
# OpenBMH Classic 1.0.4
This Classic patch release includes the desktop, save and advertising fixes
added after 1.0.3. It requires the player's own supported game installation.
Extended development remains separate in
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
## Changes since 1.0.3
- The supplied Classic start artwork is embedded at its native resolution and
displayed with correct proportions, including high-DPI output. A complete
left or right mouse click continues into the game.
- An unframed desktop calendar/date control now starts the next turn correctly.
Unframed admission-price and automation controls use their correct origins;
hidden controls and national-team restrictions remain enforced.
- Dragging an icon out of a stored desktop folder moves the selected icon while
keeping the folder in place. Folder-corner removal uses the original input
geometry.
- Double-clicking an occupied save slot opens the original overwrite question.
Its Yes/No buttons work entirely with the mouse. No preserves the existing
file; Yes writes the selected slot.
- Advertising choices use the original hover outlines and help areas. Returning
from a dialog refreshes the pointer state and removes stale highlighting.
- Malformed saved formation automation is rejected before desktop projection,
without changing the career state or random streams.
- Football Limited retains its original overwrite question during English-data
translation. The launcher rebuilds older translated caches automatically.
## Validation
The release workflow requires successful builds, configured tests, version and
package checks for Windows x64, macOS ARM64 and Linux x64 at the exact tagged
revision. Downloads include checksums, a platform test report and corresponding
source with pinned open-source dependencies.
Additional private Linux validation of the fixes used Diamond 3.7 data and real
mouse input. The 211-test configured suite executed 116 passing tests, skipped
95 checks needing other private fixtures, and reported no failures. Focused
save, desktop and advertising input checks executed. Native before/after checks
verified mouse-only overwrite refusal/acceptance, folder extraction and a real
two-manager calendar handoff, with saved-state verification. An original
Football Limited data probe verified the translated overwrite question.
These checks do not establish manual gameplay acceptance on Windows or macOS.
Issues [#51](https://github.com/Weyoune/openbmh/issues/51),
[#52](https://github.com/Weyoune/openbmh/issues/52),
[#53](https://github.com/Weyoune/openbmh/issues/53) and
[#54](https://github.com/Weyoune/openbmh/issues/54) remain open for human QA.
## Known limits
The compatibility and long-career limits documented for
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
its original V2.20 save layout remains unsupported. Keep backups of saves.
macOS packages are unsigned terminal executables, not notarised app bundles.
No original executables, databases, saves, graphics or audio are included.
+43
View File
@@ -0,0 +1,43 @@
# 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, uses direct original-installation data |
| 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; reads the original message table |
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. Transfer-market retirement is now corrected and covered by a
synthetic season-boundary regression test, including relocation uniqueness and
unchanged club-player random draws. The complete 33-item review is tracked privately; none of
the unreviewed entries is claimed complete.
+22
View File
@@ -0,0 +1,22 @@
OpenBMH 1.0
Eigenstaendige Community-Umsetzung von Bundesliga Manager Hattrick mit der
Original-Oberflaeche. Originaldateien werden nicht mitgeliefert.
Das Paket vollstaendig entpacken und OpenBMH starten (Windows: OpenBMH.exe).
Die eigene Spielinstallation oder deren ausfuehrbare Datei auswaehlen.
Ein gesondertes, beschreibbares Verzeichnis fuer Spielstaende wird empfohlen.
Beispiel:
OpenBMH --data "path/to/game" --save-directory "path/to/saves"
Deutsche CD-kompatible Versionen und gepruefte Diamond-Ausgaben sind die
primaeren Ziele. Football Limited ist experimentell; die alte Disketten-EXE
wird nicht unterstuetzt. Bestehende Spielstaende vorher sichern.
Quellen, Plattformhinweise und bekannte Einschraenkungen stehen in README.md
und docs/release/1.0/RELEASE_NOTES.md. Reproduzierbare Fehler bitte ueber den
Issue-Tracker des Repositorys melden; keine Originaldateien hochladen.
Eigener Programmcode: GPL-3.0-only. Lizenzen und Hinweise fuer eingebundene
Komponenten stehen in LICENSE und THIRD_PARTY_NOTICES.md.
+37
View File
@@ -0,0 +1,37 @@
# OpenBMH 1.0.2
A left click on an open desktop widget's upper-left close button now hides that widget through the normal validated layout transaction. The close button no longer starts a drag or shows the moving outline. Moving an element with the right mouse button remains available.
The close action consumes its matching mouse release even if the engine has already removed the widget, preventing an accidental click on an icon underneath. The automation and macOS keyboard fixes from 1.0.1 remain unchanged.
---
# OpenBMH 1.0.1
The automatic-lineup monitor now draws the selected formation from the actual manager formation table. Outdoor, indoor and custom formation slots retain their original coordinates and palette. Dragging a desktop element shows the original yellow outline, which disappears when the drag ends.
SDL video initialization now precedes the initial native file picker. On macOS this lets SDL establish the Cocoa application and keyboard activation policy before the picker creates or modifies NSApp. It addresses keyboard input missing throughout the game, including entering the manager name. A native macOS regression checks the activation policy after the picker initialization/shutdown lifecycle.
Native interactive Mac keyboard acceptance remains human QA; automated checks do not represent physical typing on a user's Mac.
---
# OpenBMH 1.0.0
Classic direct-installation runtime restored from v0.1.2. 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 community release focuses on the original game. See VALIDATION.md for the scope and limits of its checks. Build/test reports do not establish complete bit-for-bit parity with every original edition.
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.
Transfer-market players now enter the season-boundary retirement process, preventing the five-bit age from wrapping from 47 to 16. Relocated free agents no longer leave a duplicate in their old market slot. Young club players retain their existing random-draw count.
The automatic lineup reads the original foreign-player limit switch: enabled editions enforce three foreign starters in domestic clubs and two in the foreign leagues, with original reserve replacement and partial-lineup handling. Editions that disable this rule retain unrestricted selection. New careers also initialize the original empty EM qualification placeholders with national-team IDs; existing nonzero seeds and loaded savegames are preserved.
Known limits: Football Limited remains experimental, the floppy executable is unsupported, and intentional implementation differences remain listed in docs/DIFFERENCES.md. The supplied original-defect catalogue is an ongoing compatibility reference, not a claim that all its entries have received independent runtime acceptance.
The season reset processes each player only once, including temporary offer references to an active club player. This prevents double ageing and regeneration of a still-owned player into a second club. The correction is covered by a synthetic cached-offer regression and long runs through eleven to twelve season-end desks.
The start year and weekday are read from the supplied edition for the desktop, engine and save-list headers. Original CD therefore starts in 1995 on Saturday; checked Diamond editions retain 2026 on Wednesday. The original date arithmetic remains intact.
+45
View File
@@ -0,0 +1,45 @@
# OpenBMH 1.0 validation
Scope: recorded automated/original-data checks. Exact final source revision and native platform build records accompany the published release.
- Linux x64 Release build: all targets compiled.
- Local Linux CTest: 35 passed, 157 skipped, zero failures (192 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.
Source archives contain the audited current tree. The optional full-history audit is a separate check; published Git history has not been rewritten.
## Follow-up original-data checks
Twenty-six additional private-data checks passed across BMH CD and Diamond 3.6/3.7: exact loaded fixture tables, manager selection, standard dialogs, training camps, tactics, banking, settings and player cards. The Diamond 3.6 two-manager fixture also passed the human-buyer transfer and rescheduling suites. A currency-format fixture had assumed the Diamond resort price for all German editions; its fixed-price check now uses an explicit synthetic price, and the CD test passes without changing game data or product prices. These are automated render/interaction and engine checks, not a claim of complete interactive playthroughs.
The market-player retirement regression failed before the correction with an age wrap from 47 to 16 and passed afterward. It checks market boundaries, unique relocation, unaffected extra slots, new-career setup and unchanged random draw counts for a young club player.
## Additional edition rules
Targeted synthetic tests pass for the enabled/disabled foreign-player switch, domestic and foreign clubs, human assistant board and card-row movement, reserve shortages and switching back to an unrestricted edition. Separate season-boundary tests pass for zero EM placeholders becoming national teams and existing nonzero seeds remaining unchanged. Final full-build/platform acceptance for these additions is recorded with the release artifacts.
Long-run diagnostics with seed 4711 and the existing explicit contract-renewal policy reached 120 turns and two season-end desks in each of the three German data editions. Diamond 3.6/3.7 returned success. Original CD exceeded the simulator's statistical high-score threshold (two ordinary results above twelve goals); it is recorded as a QA finding, not hidden or counted as a successful simulation. The earlier no-presenter runs stopped at a contract expiry; enabling the existing opt-in presenter resolved that harness limitation without changing gameplay code.
## Extended season regression
After the final lineup, qualification and once-per-player season-reset corrections, each German edition completed 600 turns using seed 4711. Original CD reached twelve season-end desks; Diamond 3.6 and 3.7 reached eleven each. With the existing explicit contract-renewal and advertising policies enabled, all three simulator runs returned success, with no duplicate club players or other invariant failures. With contract renewals alone, all three still completed 600 turns without duplicate club players; only the test policy's excessive-debt warning remained. The latter is not presented as a successful financial strategy.
The duplicate-player defect was reproduced and captured before correction: a temporary offer referenced a player already owned by a club, then the extended market-retirement pass regenerated that player a second time. Frozen private before/after saves and a cached-reference regression support the correction. Save-envelope diagnostics use a separate RNG and do not consume either gameplay stream.
Calendar epoch regression covers the original CD and Diamond parameters, engine weekdays, desktop dates, save-header dates, year rollover and atomic rejection of invalid/unknown setup instructions. The original and checked Diamond date routines differ only in their weekday/year operands. After installing the original CD calendar parameters, the 600-turn run with contract and advertising policies completed eleven season-end desks without invariant failures.
## 1.0.1 desktop and macOS regressions
The desktop feedback test checks selected saved formations against their original table, compares changed miniature pixels, and checks the original yellow outline during a drag and its removal afterward. Private CD and Diamond render captures use the original assets. The SDL lifetime test checks initialization before the picker scope, normal destruction and failed initialization cleanup.
A macOS-only native Cocoa test initializes SDL before the native picker lifecycle, checks regular activation, creates a keyboard-focused window and verifies that a Cocoa key event produces both SDL key and text events. This automated native event test supplements human keyboard QA; it is not a claim of physical typing on the user's machine.
## 1.0.2 close-button regression
The desktop feedback test checks that the left corner requests removal instead of entering drag mode, that the remaining layout chain is intact, and that the release after acknowledgement does not activate an underlying icon. A subsequent independent click remains usable. Right-button movement and its temporary yellow outline remain covered. The user confirmed the 1.0.1 automation and Mac keyboard corrections.
+70 -37
View File
@@ -1,4 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/native_save_version.hpp"
#include "formats/badge_policy.hpp"
#include "game/calendar.hpp"
#include "formats/executable_layout.hpp"
#include "app/career_session.hpp"
@@ -539,18 +542,17 @@ static void install_league_sizes(const LeImage& exe) {
kNewcomerFirst = exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField);
kNewcomerCount = exe.u16(::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6);
// EXE strings the engine posts (messages.hpp)
kContractEndsSoonText = exe.cstring(kEnglishCompetitions ? ::bmh::layout::EnglishContractExpiryWarningText : ::bmh::layout::ContractExpiryWarningText);
kMastersQualificationText = kEnglishCompetitions ? "Masters entry confirmed. Your participation bonus has been credited." : exe.cstring(::bmh::layout::MastersQualificationText);
kMastersWinnerText = kEnglishCompetitions ? "Masters title won. Your prize money has been credited." : exe.cstring(::bmh::layout::MastersWinnerText);
kIndoorInvitationText = kEnglishCompetitions ? "Indoor event entry bonus credited for " : exe.cstring(::bmh::layout::IndoorInvitationText);
kChampionshipBonusText = kEnglishCompetitions ? "League title bonus credited." : exe.cstring(::bmh::layout::ChampionshipBonusText);
kFriendlyPayerPrefixText = kEnglishCompetitions ? "Your share: " : exe.cstring(::bmh::layout::NationalFriendlyPayerPrefixText);
install_message_texts(exe);
install_career_rules(exe);
install_environment_rules(exe);
install_original_badge_policy(exe);
install_calendar_rules(exe);
}
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed)
: data_directory_(data), exe_(load_le(data / "BMH.exe")),
db_(load_database(data / "M3D.MAN")),
texts_(load_textd(data / "TEXTD.BLK")),
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))),
db_(load_database(ui::asset_path(data, "M3D.MAN"))),
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))),
rand_(watcom_seed) {
install_league_sizes(exe_);
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
@@ -559,7 +561,7 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
? TransferAllocatorContext::zero : TransferAllocatorContext::blocked;
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
initialize_club_modal_runtime();
g_ = startup_state(exe_, db_, read_file(data / "M3.MEN"), read_file(data / "M3.DAT"));
g_ = startup_state(exe_, db_, read_file(ui::asset_path(data, "M3.MEN")), read_file(ui::asset_path(data, "M3.DAT")));
g_.texts = &texts_;
g_.currency_suffix = exe_.cstring(::bmh::layout::CurrencySuffixText); // CurrencySuffixText
configure_training_camp_data(g_, exe_);
@@ -575,8 +577,8 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed,
const std::filesystem::path& save_path)
: data_directory_(data), exe_(load_le(data / "BMH.exe")), db_(load_database(data / "M3D.MAN")),
texts_(load_textd(data / "TEXTD.BLK")), rand_(watcom_seed) {
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))), db_(load_database(ui::asset_path(data, "M3D.MAN"))),
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))), rand_(watcom_seed) {
install_league_sizes(exe_);
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
turn_driver_.disable_match_events = exe_.u8(::bmh::layout::MatchEventsDisabled) != 0;
@@ -585,7 +587,7 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
initialize_club_modal_runtime();
const Savegame file = load_savegame(save_path);
if (!file.checksum_ok || file.version != "V2.24") throw std::runtime_error("savegame: unsupported or damaged FBM");
require_native_savegame(file);
const DbCounts counts{exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
const SaveState save(file.stream, counts);
g_ = GameState::from_save(save, counts);
@@ -925,6 +927,9 @@ std::optional<PendingOfferResult> CareerSession::dispatch_club_player_pending_of
}
void CareerSession::initialize_club_modal_runtime() {
// Setup clears the boot-only dialog mode before either creating or loading
// a career. This process flag is deliberately absent from native saves.
club_modal_runtime_.emplace(layout::CompactDialogFrame, 0);
// LE object4 has bb cdd/de/e1 in its zero-initialized virtual tail;
// CareerSession_InitializeClubModalRuntime_ExecutableField is file-backed zero. These are explicit process-start values,
// carried by this runtime owner across modal entry/return, not FBM bytes.
@@ -3336,7 +3341,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;
@@ -3981,7 +3986,8 @@ std::optional<CareerSession::TransferMarketPreviewDispatch> CareerSession::previ
std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& presenters,
uint64_t& revision, std::string& error) {
uint64_t& revision, std::string& error,
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
error.clear();
@@ -3994,7 +4000,18 @@ std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
error = "transfer market: stale or nested request";
return std::nullopt;
}
if (request.kind == ui::TransferMarketRequestKind::submit_bid) {
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
if (!review || request.bid.manager != request.manager_slot || request.bid.list_entry < 0 ||
request.bid.list_entry >= 40 || request.bid.source_slot != 0xb70 + request.bid.list_entry ||
request.squad_row != -1 || !request.selected_players.empty()) {
error = "transfer market: invalid offer review"; return std::nullopt;
}
const auto view = project_transfer_offer_list(g_, request.bid.list_entry);
if (!view.valid || view.player != request.bid.player || view.seller != request.runtime_club ||
view.seller_manager != request.manager_slot) {
error = "transfer market: stale seller listing"; return std::nullopt;
}
} else if (request.kind == ui::TransferMarketRequestKind::submit_bid) {
if (request.bid.manager != request.manager_slot || request.squad_row != -1 ||
request.expected_player != -1 ||
std::any_of(request.bid.bonuses.begin(), request.bid.bonuses.end(),
@@ -4060,7 +4077,21 @@ std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
try {
const auto before = save_stream(g_);
TransferActionResult result;
if (request.kind == ui::TransferMarketRequestKind::list_player)
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
const auto view = project_transfer_offer_list(next_state, request.bid.list_entry);
const int selected = view.offer_count ? review(next_state, view) : -1;
result.player = view.player; result.list_entry = view.list_entry;
result.status = TransferActionStatus::pending;
if (selected != -1) {
auto allocator = TransferAllocatorContext::unsupported;
if (turn_driver_.transfer_allocator_context == PendingOfferAllocatorGate::zero)
allocator = TransferAllocatorContext::zero;
else if (turn_driver_.transfer_allocator_context == PendingOfferAllocatorGate::blocked)
allocator = TransferAllocatorContext::blocked;
result = accept_manager_transfer_offer(next_state, request.manager_slot,
view.list_entry, view.player, selected, next_rand, report, allocator);
}
} else if (request.kind == ui::TransferMarketRequestKind::list_player)
result = list_manager_player(next_state, request.manager_slot, request.squad_row, next_rand, report);
else
result = submit_transfer_bid_source_human_buyer(next_state, request.bid, next_rand, hooks, report);
@@ -4558,9 +4589,9 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
const bool consumed = (request.column == 7 &&
((request.row <= 6) || request.row == 7 || request.row == 9 || request.row == 10 ||
(scoped_settings && request.row == 8))) ||
// B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
// A9 match minutes; B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
// I9 cup draw; K9 Reality report; M9 preview/shootout; P9 shot.
(request.column == 8 && ((request.row >= 1 && request.row <= 6) ||
(request.column == 8 && ((request.row >= 0 && request.row <= 6) ||
request.row == 7 || request.row == 8 || request.row == 10 || request.row == 12 || request.row == 15));
if (!consumed || old >= 200) {
error = "Diese Einstellung ist noch nicht verfügbar.";
@@ -5595,15 +5626,20 @@ bool CareerSession::dispatch_desk_widget(const ui::DeskRequest& request, uint64_
identity.stable_club_identity = int(g_.club_ids[size_t(identity.runtime_club)]);
}
if (!validate_desk_setting_owner(identity, revision, error, false)) return false;
// Refuse malformed saved formation state before projecting widget ownership.
// The desktop renderer cannot project indices outside the stored 0..8 range.
if (g_.manager_options[size_t(active) * 5] > 8) {
error = "invalid_saved_formation_automation"; return false;
}
const bool price = request.kind == ui::DeskRequestKind::change_ticket_price;
if (!price && request.kind != ui::DeskRequestKind::change_option) {
error = "unsupported_desk_widget"; return false;
}
// Keep SDL requests bound to a visible, open and enabled MEN drawer/item.
// Keep SDL requests bound to a visible and enabled MEN drawer/item; the frame bit is optional.
const auto desk = desktop_projection(revision);
const int expected_kind = price ? 55 : 64;
const auto item = std::find_if(desk.items.begin(), desk.items.end(), [&](const ui::DeskItem& item) {
return item.id == request.item_id && item.kind == expected_kind && item.open && !item.disabled;
return item.id == request.item_id && item.kind == expected_kind && !item.disabled;
});
if (request.menu_kind != expected_kind || item == desk.items.end()) {
error = "stale_or_closed_desk_widget"; return false;
@@ -5713,19 +5749,20 @@ bool CareerSession::dispatch_desktop_layout(const ui::DeskRequest& request, uint
(expected[at+13]&0x7f)!=folder||expected[at+12]>=50) {
error="invalid_desk_folder_child_return"; return false;
}
bool owner_open=false;
bool owner_visible=false;
for(size_t item=1;item<kItems;++item) {
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+13]&0x80)==0) continue;
// The frame bit does not hide folder contents; require a visible linked owner.
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+1]&0x10)!=0) continue;
int cursor=0;size_t visited=0;
while(++visited<kItems) {
const int next=expected[size_t(cursor)*kStride+5];
if(next==int(item)) { owner_open=true;break; }
if(next==int(item)) { owner_visible=true;break; }
if(next<=0||next>=int(kItems)) break;
cursor=next;
}
if(owner_open) break;
if(owner_visible) break;
}
if(!owner_open) { error="desk_folder_child_owner_closed"; return false; }
if(!owner_visible) { error="desk_folder_child_owner_hidden"; return false; }
const int max_x=std::max(1,319-int(expected[at+3])),max_y=std::max(1,239-int(expected[at+4]));
const int source_x=int(moved_x&0xefff);
const bool snap=g_.memory.has(::bmh::layout::CareerSession_DispatchDesktopLayout_RuntimeField2)&&g_.memory.u8(::bmh::layout::CareerSession_DispatchDesktopLayout_RuntimeField2)==0;
@@ -5766,19 +5803,20 @@ bool CareerSession::dispatch_desktop_layout(const ui::DeskRequest& request, uint
(expected[at+13]&0x7f)!=folder||expected[at+12]>=50) {
error="invalid_desk_bin_restore";return false;
}
bool owner_open=false;
bool owner_visible=false;
for(size_t item=1;item<kItems;++item) {
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+13]&0x80)==0) continue;
// The frame bit does not hide folder contents; require a visible linked owner.
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+1]&0x10)!=0) continue;
int cursor=0;size_t visited=0;
while(++visited<kItems) {
const int next=expected[size_t(cursor)*kStride+5];
if(next==int(item)) { owner_open=true;break; }
if(next==int(item)) { owner_visible=true;break; }
if(next<=0||next>=int(kItems)) break;
cursor=next;
}
if(owner_open)break;
if(owner_visible)break;
}
if(!owner_open) { error="desk_bin_restore_folder_closed";return false; }
if(!owner_visible) { error="desk_bin_restore_folder_hidden";return false; }
int tail=0;size_t guard=0;
while(expected[size_t(tail)*kStride+5]!=0) {
if(++guard>=kItems) { error="invalid_desk_layout_chain";return false; }
@@ -8101,12 +8139,7 @@ bool CareerSession::dispatch_stadium(const ui::StadiumRequest& supplied_request,
if (request.object != -1 || request.option != -1 || request.price != 0 ||
(request.kind != ui::StadiumRequestKind::expansion_answer_tip && request.accept_tip))
return invalid("invalid_block_expansion_envelope");
StadiumBlockExpansionConstants block_constants;
for (unsigned i = 0; i < 8; ++i) {
block_constants.price_per_1000[i] = exe_.u32(::bmh::layout::CareerSession_DispatchStadium_RuntimeField + (i + 8) * 4);
block_constants.weeks[i] = exe_.u8(::bmh::layout::CareerSession_DispatchStadium_RuntimeField2 + (i + 22) * 5);
block_constants.max_places[i] = uint32_t(exe_.u8(::bmh::layout::CareerSession_Invalid_RuntimeField + i)) * 1000;
}
const auto block_constants=stadium_block_expansion_constants(exe_);
const auto quote_block = [&](StadiumBlockSlot slot, uint32_t total, uint8_t features) {
return quote_stadium_block_expansion(g_, active, slot, total, features,
stadium_.price_percent, block_constants);
+2 -1
View File
@@ -175,7 +175,8 @@ public:
// result with valid dependent projections becomes the live state.
std::optional<TransferActionResult> dispatch_transfer_market(
const ui::TransferMarketRequest&, const HumanBuyerSaleHooks&,
uint64_t& revision, std::string& error);
uint64_t& revision, std::string& error,
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
struct TransferMarketPreviewDispatch {
ui::PreparationState preparation;
+21 -8
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;
@@ -369,9 +370,11 @@ std::string transfer_status_message(TransferActionStatus status, ui::TransferMar
case TransferActionStatus::accepted:
return kind == ui::TransferMarketRequestKind::list_player
? "Der Spieler steht jetzt auf der Transferliste." : "Der Spieler hat das Angebot angenommen.";
case TransferActionStatus::pending: return "Der Spieler entscheidet sich nächste Woche.";
case TransferActionStatus::pending: return kind == ui::TransferMarketRequestKind::list_player
? "Der Spieler steht bereits auf der Transferliste." : "Der Spieler entscheidet sich nächste Woche.";
case TransferActionStatus::offer_too_low: return "Das Angebot ist zu niedrig.";
case TransferActionStatus::blocked_by_board: return "Der Vorstand genehmigt diesen Transfer nicht.";
case TransferActionStatus::blocked_by_board: return kind == ui::TransferMarketRequestKind::list_player
? "Transferliste voll oder Spieler nicht verfügbar." : "Der Vorstand genehmigt diesen Transfer nicht.";
case TransferActionStatus::insufficient_funds: return "Das Geld reicht für diesen Transfer nicht aus.";
case TransferActionStatus::no_squad_room: return "Im Kader ist kein Platz für diesen Spieler.";
case TransferActionStatus::rejected: return "Der Spieler hat das Angebot abgelehnt.";
@@ -383,7 +386,8 @@ void serve_transfer_action(ui::StartupFlow& flow, CareerSession& session,
const ui::TransferMarketRequest& request, uint64_t& revision,
const HumanBuyerSaleHooks& presenters,
HumanBuyerMarketEntryPolicy entry_policy,
const CareerSession::PoachPlayerSelector& poach_selector, const PoachNoticePresenter& poach_notice) {
const CareerSession::PoachPlayerSelector& poach_selector, const PoachNoticePresenter& poach_notice,
const TransferOfferPresenter& review) {
const auto* pending = flow.pending_transfer_market();
// JSON covers every offer field except its redundant nested manager identity.
// Check that identity too, before an engine helper can consume a random draw.
@@ -472,13 +476,22 @@ void serve_transfer_action(ui::StartupFlow& flow, CareerSession& session,
const auto outcome = TransferActions(session).market(request, hooks, revision, error, entry_policy,
[&](const TransferActions::MarketDispatch& applied) {
// Preserve the Source caller's existing notice/ACK sequence.
const bool source_finished = entry_policy == HumanBuyerMarketEntryPolicy::normal_interactive &&
(source_notice_presented || applied.action.status == TransferActionStatus::pending);
const bool source_finished = request.kind != ui::TransferMarketRequestKind::review_offers &&
entry_policy == HumanBuyerMarketEntryPolicy::normal_interactive &&
(source_notice_presented || (request.kind == ui::TransferMarketRequestKind::submit_bid &&
applied.action.status == TransferActionStatus::pending));
auto notice = source_finished ? std::string{} : transfer_status_message(applied.action.status, request.kind);
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
notice = applied.action.status == TransferActionStatus::accepted
? "Das Angebot wurde angenommen."
: applied.action.status == TransferActionStatus::pending
? "Spieler bleibt auf der Transferliste."
: "Angebot abgelehnt; Transferliste unverändert.";
}
if (!applied.changed && source_finished) flow.acknowledge_unchanged_transfer_market();
else if (!applied.changed) flow.reject_preparation_action(std::move(notice));
else flow.acknowledge_preparation(session.preparation_projection(revision), std::move(notice));
});
}, review);
if (!outcome) throw FormatError(error);
} catch (const std::exception&) {
flow.reject_preparation_action("Diese Transferaktion konnte nicht übernommen werden.");
@@ -1532,7 +1545,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
} else if (result.request == ui::FlowRequest::submenu_action && session &&
std::holds_alternative<ui::TransferMarketRequest>(result.submenu_action)) {
serve_transfer_action(flow, *session, std::get<ui::TransferMarketRequest>(result.submenu_action), revision,
market_sale_presenter, market_entry_policy, poach_player_selector, poach_notice_presenter);
market_sale_presenter, market_entry_policy, poach_player_selector, poach_notice_presenter, transfer_presenter);
} else if (result.request == ui::FlowRequest::submenu_action && session &&
std::holds_alternative<ui::OutgoingTransferRequest>(result.submenu_action)) {
serve_transfer_offer(flow, *session, std::get<ui::OutgoingTransferRequest>(result.submenu_action), revision,
+270 -265
View File
File diff suppressed because it is too large. Load diff
+50
View File
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <SDL.h>
#include <algorithm>
#include <array>
#include <cstdint>
#include <optional>
#include <vector>
namespace bmh::app {
// SDL owns pointer position; the UI supplies only the original bitmap/colors.
class PitchPointer {
public:
~PitchPointer() { clear(); }
void clear() {
if (cursor_) {
SDL_SetCursor(SDL_GetDefaultCursor());
SDL_FreeCursor(cursor_);
cursor_ = nullptr;
}
pixels_.reset();
}
void show(const std::optional<std::array<uint32_t,121>>& pixels, SDL_Renderer* renderer) {
if (!pixels) { SDL_SetCursor(SDL_GetDefaultCursor()); return; }
int width = 320, height = 240;
SDL_GetRendererOutputSize(renderer, &width, &height);
const int scale = std::max(1, std::min(width / 320, height / 240));
if (!cursor_ || pixels != pixels_ || scale != scale_) {
std::vector<uint32_t> enlarged(size_t(11 * scale) * size_t(11 * scale));
for (int y = 0; y < 11 * scale; ++y) for (int x = 0; x < 11 * scale; ++x)
enlarged[size_t(y) * size_t(11 * scale) + size_t(x)] =
pixels->at(size_t(y / scale) * 11 + size_t(x / scale));
SDL_Surface* surface = SDL_CreateRGBSurfaceWithFormatFrom(enlarged.data(),
11 * scale, 11 * scale, 32, 11 * scale * 4, SDL_PIXELFORMAT_ARGB8888);
SDL_Cursor* next = surface ? SDL_CreateColorCursor(surface, 0, 0) : nullptr;
if (surface) SDL_FreeSurface(surface);
if (!next) return; // A headless SDL driver may not support host cursors.
clear(); cursor_ = next; pixels_ = pixels; scale_ = scale;
}
SDL_SetCursor(cursor_);
}
private:
SDL_Cursor* cursor_ = nullptr;
std::optional<std::array<uint32_t,121>> pixels_;
int scale_ = 1;
};
} // namespace bmh::app
+63
View File
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <SDL.h>
#include <functional>
#include <utility>
namespace bmh::app {
// OpenBMH deviates from the original: confirms application exit with a localized native dialog, with cancellation selected by default.
// All event retrieval remains on the UI thread. An event filter/watch could run
// on SDL's event thread and must not own a native modal dialog.
class QuitConfirmation {
public:
using Presenter = std::function<int(const SDL_MessageBoxData*, int*)>;
QuitConfirmation(SDL_Window* window, bool english, Presenter presenter = SDL_ShowMessageBox)
: window_(window), english_(english), presenter_(std::move(presenter)) {}
bool confirm() {
if (confirmed_) return true;
const SDL_MessageBoxButtonData buttons[] = {
{SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT | SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT,
0, english_ ? "Cancel" : "Abbrechen"},
{0, 1, english_ ? "Quit" : "Beenden"}
};
const SDL_MessageBoxData dialog{SDL_MESSAGEBOX_WARNING, window_,
english_ ? "Quit OpenBMH?" : "OpenBMH beenden?",
english_ ? "Do you really want to quit OpenBMH?\nUnsaved changes will be lost." :
"OpenBMH wirklich beenden?\nNicht gespeicherte Änderungen gehen verloren.",
2, buttons, nullptr};
int selected = 0;
if (presenter_(&dialog, &selected) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Cannot show quit confirmation: %s", SDL_GetError());
return false; // A failed dialog must not silently discard the session.
}
confirmed_ = selected == 1;
return confirmed_;
}
int poll(SDL_Event* event) {
if (!event) return SDL_PollEvent(nullptr);
while (SDL_PollEvent(event)) {
if (event->type != SDL_QUIT || confirm()) return 1;
}
return 0;
}
int peep(SDL_Event* events, int count, SDL_eventaction action, Uint32 first, Uint32 last) {
const int received = SDL_PeepEvents(events, count, action, first, last);
if (received <= 0 || !events || action != SDL_GETEVENT) return received;
int kept = 0;
for (int i = 0; i < received; ++i)
if (events[i].type != SDL_QUIT || confirm()) events[kept++] = events[i];
return kept;
}
private:
SDL_Window* window_;
bool english_, confirmed_ = false;
Presenter presenter_;
};
} // namespace bmh::app
+40
View File
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "app/start_screen.hpp"
#include "app/start_screen_data.hpp"
#include <SDL.h>
#include <memory>
#include <stdexcept>
#include <string>
#define STBI_ONLY_JPEG
#define STBI_NO_STDIO
#define STBI_NO_HDR
#define STBI_NO_LINEAR
#define STB_IMAGE_IMPLEMENTATION
#include "app/third_party/stb_image.h"
namespace bmh::app {
StartScreen::StartScreen(SDL_Renderer* renderer):renderer_(renderer) {
if(!renderer_)throw std::runtime_error("Start screen: missing renderer");
SDL_RenderGetLogicalSize(renderer_,&previous_width_,&previous_height_);
int channels=0;
const std::unique_ptr<unsigned char,decltype(&stbi_image_free)> pixels(
stbi_load_from_memory(start_screen_jpeg,int(start_screen_jpeg_size),&width_,&height_,&channels,3),stbi_image_free);
if(!pixels)throw std::runtime_error("Start screen: embedded artwork could not be decoded");
texture_=SDL_CreateTexture(renderer_,SDL_PIXELFORMAT_RGB24,SDL_TEXTUREACCESS_STATIC,width_,height_);
if(!texture_)throw std::runtime_error(SDL_GetError());
if(SDL_UpdateTexture(texture_,nullptr,pixels.get(),width_*3)!=0||SDL_SetTextureScaleMode(texture_,SDL_ScaleModeLinear)!=0) {
const std::string error=SDL_GetError();SDL_DestroyTexture(texture_);texture_=nullptr;throw std::runtime_error(error);
}
}
StartScreen::~StartScreen() {
SDL_DestroyTexture(texture_);
SDL_RenderSetLogicalSize(renderer_,previous_width_,previous_height_);
}
void StartScreen::present() {
if(SDL_RenderSetLogicalSize(renderer_,width_,height_)!=0)throw std::runtime_error(SDL_GetError());
Uint8 r=0,g=0,b=0,a=0;SDL_GetRenderDrawColor(renderer_,&r,&g,&b,&a);
SDL_SetRenderDrawColor(renderer_,0,0,0,255);
const int cleared=SDL_RenderClear(renderer_);SDL_SetRenderDrawColor(renderer_,r,g,b,a);
if(cleared!=0||SDL_RenderCopy(renderer_,texture_,nullptr,nullptr)!=0)throw std::runtime_error(SDL_GetError());
SDL_RenderPresent(renderer_);
}
}
+22
View File
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
struct SDL_Renderer;
struct SDL_Texture;
namespace bmh::app {
// Owned, embedded artwork, rendered independently of the indexed game canvas.
// Destruction restores the caller's logical size and therefore its input mapping.
class StartScreen {
public:
explicit StartScreen(SDL_Renderer*);
~StartScreen();
StartScreen(const StartScreen&)=delete;
StartScreen& operator=(const StartScreen&)=delete;
void present();
int width()const{return width_;}
int height()const{return height_;}
private:
SDL_Renderer* renderer_;
SDL_Texture* texture_=nullptr;
int width_=0,height_=0,previous_width_=0,previous_height_=0;
};
}
+7
View File
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <cstddef>
namespace bmh::app {
extern const unsigned char start_screen_jpeg[];
extern const std::size_t start_screen_jpeg_size;
}
+8
View File
@@ -0,0 +1,8 @@
# stb_image
Unmodified upstream stb_image 2.30 header, commit `013ac3beddff3dbffafd5177e7972067cd2b5083`.
Source: [013ac3beddff3dbffafd5177e7972067cd2b5083](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h).
SHA256: `594c2fe35d49488b4382dbfaec8f98366defca819d916ac95becf3e75f4200b3`.
Only JPEG decoding is compiled. The complete dual MIT/public-domain license
is retained in the header and in `docs/licenses/stb_image.txt`.
+7988
View File
File diff suppressed because it is too large. Load diff
+22
View File
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <SDL.h>
#include <stdexcept>
#include <string>
namespace bmh::app {
// Establish SDL's native application before any file picker can create NSApp.
// Cocoa otherwise retains the picker's non-keyboard activation policy.
class VideoSession {
public:
VideoSession() {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
const std::string error = SDL_GetError();
SDL_Quit();
throw std::runtime_error(error);
}
}
~VideoSession() { SDL_Quit(); }
VideoSession(const VideoSession&) = delete;
VideoSession& operator=(const VideoSession&) = delete;
};
}
+5 -3
View File
@@ -108,12 +108,13 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
std::optional<TransferActions::MarketDispatch> TransferActions::market(
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& hooks,
uint64_t& revision, std::string& error, HumanBuyerMarketEntryPolicy policy,
const MarketAccept& acknowledge) {
const MarketAccept& acknowledge,
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
std::optional<MarketDispatch> result;
apply(revision, [&] {
const auto old_revision = revision;
if (policy == HumanBuyerMarketEntryPolicy::normal_interactive) {
const auto action = session_.dispatch_transfer_market(request, hooks, revision, error);
const auto action = session_.dispatch_transfer_market(request, hooks, revision, error, review);
if (!action) return false;
result = MarketDispatch{*action, revision != old_revision};
} else {
@@ -174,7 +175,8 @@ std::string TransferActions::rejection(const ui::TransferMarketRequest& request,
return "Dieser Spieler gehört nicht mehr zur gewählten Kaderposition.";
} else if (request.kind != ui::TransferMarketRequestKind::open_offer &&
request.kind != ui::TransferMarketRequestKind::preview_quote &&
request.kind != ui::TransferMarketRequestKind::open_poach)
request.kind != ui::TransferMarketRequestKind::open_poach &&
request.kind != ui::TransferMarketRequestKind::review_offers)
return "Diese Transferaktion ist nicht verfügbar.";
return {};
}
+2 -1
View File
@@ -38,7 +38,8 @@ public:
std::optional<MarketDispatch> market(const ui::TransferMarketRequest&, const HumanBuyerSaleHooks&,
uint64_t& revision, std::string& error,
HumanBuyerMarketEntryPolicy = HumanBuyerMarketEntryPolicy::normal_interactive,
const MarketAccept& = {});
const MarketAccept& = {},
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
std::optional<CareerSession::TransferOfferEditorDispatch> open_offer(const ui::TransferMarketRequest&,
uint64_t& revision, std::string& error, const OfferAccept& = {});
std::optional<CareerSession::TransferMarketPreviewDispatch> preview(const ui::TransferMarketRequest&,
+16 -18
View File
@@ -1,11 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
// OpenBMH deviates from the original: uses monthly staff levels in increments of five thousand and the supported youth-academy controls.
// The club environment (menu 24, docs/CLI_CONCEPT/06-verein.md 10, H2 p. 93, supported rule profile p. 107,
// 111): co-trainer, doctor and physio in levels of 5 000 a month, and the supported rule profile youth
// academy that costs a season price of the league.
//
// The rules are the engine's (src/game/environment.hpp, a port of Image with the
// supported rule profile patch); a command is one click of the original screen.
// The console and desktop share all six monthly environment budgets.
#include "app/desktop_actions.hpp"
#include "cli/console/console.hpp"
@@ -19,20 +13,21 @@ using namespace detail;
void Console::register_environment_commands() {
auto show = [this] {
const EnvironmentState s = environment_state(session_->state(), active_slot());
std::vector<std::vector<std::string>> rows = {
{"AssistantCoach", std::to_string(s.level[kCoTrainer]), money(s.monthly[kCoTrainer])},
{"Doctor", std::to_string(s.level[kDoctor]), money(s.monthly[kDoctor])},
{"Physio", std::to_string(s.level[kPhysio]), money(s.monthly[kPhysio])},
{"YouthAcademy", s.monthly[kYouthAcademy] != 0 ? "on" : "off", money(s.youth_price) + " per season"}};
emit_table({"Item", "Level", "Costs"}, rows);
emit('i', std::string("youth academy: ") + (s.youth_paid ? "paid this season" : s.youth_open ? "can be started (July/August)"
: "too late for this season"));
std::vector<std::vector<std::string>> rows;
constexpr const char* names[] = {"YouthYoungest", "YouthAcademy", "YouthOldest", "AssistantCoach", "Doctor", "Physio"};
for (int i = 0; i < kEnvironmentItems; ++i)
rows.push_back({names[i], std::to_string(s.level[size_t(i)]), money(s.monthly[size_t(i)])});
emit_table({"Item", "Level", "MonthlyCosts"}, rows);
rows.clear();
for (size_t i = 0; i < 3; ++i)
rows.push_back({names[i], std::to_string(s.youth_position[i] + 1), std::to_string(s.youth_league[i] + 1)});
emit_table({"YouthTeam", "Position", "Division"}, rows);
};
openers_[24] = [this, show] {
open_window("Environment");
show();
};
add({"Environment", "ShowEnvironment", {}, "staff levels and the youth academy", false}, [show](const Values&) { show(); });
add({"Environment", "ShowEnvironment", {}, "all six monthly budgets and youth tables", false}, [show](const Values&) { show(); });
auto apply = [this, show](int item, int level) {
std::string error;
const auto r=app::EnvironmentActions(*session_).set_console(
@@ -44,11 +39,14 @@ void Console::register_environment_commands() {
add({"Environment", "SetStaffLevel", {choice("role", {"AssistantCoach", "Doctor", "Physio"}), integer("level", 0, 6)},
"click a staff tile: level 0..6, 5 000 a month each", true},
[apply](const Values& v) { apply(kCoTrainer + v.choice("role"), int(v.integer("level"))); });
add({"Environment", "SetYouthAcademy", {choice("state", {"On", "Off"})}, "start (July/August) or stop the youth academy", true},
add({"Environment", "SetYouthLevel", {choice("team", {"Youngest", "Academy", "Oldest"}), integer("level", 0, 6)},
"set one youth team's monthly budget, level 0..6", true},
[apply](const Values& v) { apply(v.choice("team"), int(v.integer("level"))); });
add({"Environment", "SetYouthAcademy", {choice("state", {"On", "Off"})}, "set the middle youth budget to level 6 or 0", true},
[this, apply](const Values& v) {
const bool on = environment_state(session_->state(), active_slot()).monthly[kYouthAcademy] != 0;
const bool want = v.choice("state") == 0;
// the original's click on an active academy switches it off: click only for a change
// Retain the old On/Off command as an alias for the middle youth budget.
if (on == want) emit('+', std::string("youth academy already ") + (on ? "on" : "off"));
else apply(kYouthAcademy, want ? 6 : 0);
});
+38
View File
@@ -160,6 +160,8 @@ void Console::register_transfer_commands() {
require_engine(false, "transfer", error);
}
flush_notices();
if (outcome->action.status != TransferActionStatus::accepted)
fail("E_RULE", "Der Spieler konnte nicht auf die Transferliste gesetzt werden.");
emit('+', utf8(item.name) + (loan
? " steht auf der Transferliste; der Entleiher wählt 12 oder 24 Monate im Angebot"
: " is on the transfer list"));
@@ -175,6 +177,42 @@ void Console::register_transfer_commands() {
list_player(v.text("player"), true);
});
add({"Transfer", "ShowOffers", {player}, "incoming offers for an own listed player", false},
[this, market_item](const Values& v) {
const auto item = market_item(v.text("player"));
if (!item.own_listing) fail("E_RULE", "the listing belongs to another club");
const auto offers = project_transfer_offer_list(session_->state(), item.list_entry);
std::vector<std::vector<std::string>> rows;
for (const auto& offer : offers.offers) {
if (!offer.present) continue;
rows.push_back({std::to_string(offer.bid_index), utf8(session_->state().club_name(offer.buyer)),
money(offer.fee), money(offer.monthly_salary), std::to_string(offer.contract_months),
offer.loan ? "loan" : "sale",
offer.eligible && offer.loan_permitted && offer.transaction_supported ? "yes" : "no"});
}
emit_table({"Bid", "Club", "Fee", "Monthly salary", "Months", "Type", "Available"}, rows);
if (rows.empty()) emit('i', "Noch keine Angebote für diesen Spieler.");
});
add({"Transfer", "AcceptOffer", {player, integer("bid", 0, 3)}, "accept an existing bid before weekly expiry", true},
[this, market, market_item, hooks, flush_notices](const Values& v) {
const auto observed = market();
const auto item = market_item(v.text("player"));
if (!item.own_listing) fail("E_RULE", "the listing belongs to another club");
auto request = app::TransferActions::opening(observed, item, false);
request.kind = ui::TransferMarketRequestKind::review_offers;
request.selected_players.clear();
const int bid = int(v.integer("bid"));
std::string error;
const auto outcome = app::TransferActions(*session_).market(request, hooks(), revision_, error,
app::HumanBuyerMarketEntryPolicy::normal_interactive, {},
[bid](const GameState&, const TransferOfferListView&) { return bid; });
if (!outcome) require_engine(false, "transfer", error);
flush_notices();
if (outcome->action.status != TransferActionStatus::accepted)
fail("E_RULE", "Dieses Angebot kann nicht angenommen werden; die Transferliste bleibt unverändert.");
emit('+', "Das Angebot wurde angenommen.");
});
// --- Transfer.Negotiate: the offer editor (06-verein 5.2) -----------------------------
auto show_offer = [this] {
if (!offer_editor_) fail("E_INTERNAL", "no offer editor");
+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
+34 -2
View File
@@ -764,7 +764,7 @@ inline constexpr auto EnglishLayoutTranslation156 = 0x6e08c;
inline constexpr auto EnglishLayoutTranslation157 = 0x6e094;
inline constexpr auto EnglishLayoutTranslation158 = 0x6e0b8;
inline constexpr auto EnglishLayoutTranslation159 = 0x6e0bb;
inline constexpr auto EnglishLayoutTranslation16 = 0x6be4f;
inline constexpr auto EnglishLayoutTranslation16 = 0x6be50;
inline constexpr auto EnglishLayoutTranslation160 = 0x6e0d8;
inline constexpr auto EnglishLayoutTranslation161 = 0x6e110;
inline constexpr auto EnglishLayoutTranslation162 = 0x6e11c;
@@ -986,7 +986,7 @@ inline constexpr auto EnglishLayoutTranslation7 = 0x6be0c;
inline constexpr auto EnglishLayoutTranslation70 = 0x6d270;
inline constexpr auto EnglishLayoutTranslation71 = 0x6d272;
inline constexpr auto EnglishLayoutTranslation72 = 0x6d274;
inline constexpr auto EnglishLayoutTranslation73 = 0x6d29c;
inline constexpr auto EnglishLayoutTranslation73 = 0x6d29d;
inline constexpr auto EnglishLayoutTranslation74 = 0x6d3b4;
inline constexpr auto EnglishLayoutTranslation75 = 0x6d404;
inline constexpr auto EnglishLayoutTranslation76 = 0x6d408;
@@ -1026,6 +1026,11 @@ inline constexpr auto EnglishLeagueCupSemiFinalResults = 0x7d002;
inline constexpr auto Environment_FormatError_RuntimeField = 0xa50f0;
inline constexpr auto Environment_FormatError_RuntimeField2 = 0xa50f6;
inline constexpr auto Environment_Render_TextPointer = 0xaeb74;
inline constexpr auto EnvironmentYouthTeams = 0xbd4bc;
inline constexpr auto EnvironmentYouthPositionSuffix = 0xa1698;
inline constexpr auto EnvironmentCostSuffix = 0xa169d;
inline constexpr auto EnvironmentYouthLeagueTextPointer = 0xaeb78;
inline constexpr auto EnvironmentYouthColors = 0xa50fc;
inline constexpr auto Environment_SetEnvironment_ExecutableField = 0xaf394;
inline constexpr auto EuropeNameTable = 0xae710;
inline constexpr auto EventPasses = 0xa2ba1;
@@ -1471,6 +1476,17 @@ inline constexpr auto Pitch_Render_TextPointer2 = 0xae0ec;
inline constexpr auto Pitch_Render_TextPointer3 = 0xae0f0;
inline constexpr auto Pitch_Render_TextPointer4 = 0xae0f4;
inline constexpr auto Pitch_Render_TextPointer5 = 0xae0f8;
inline constexpr auto PitchPreferenceDepthBases = 0xa3cc3;
inline constexpr auto PitchPreferenceRed = 0xa3cc7;
inline constexpr auto PitchPreferenceGreen = 0xa3cd1;
inline constexpr auto OriginalPointerPixels = 0xa45b4;
inline constexpr auto EnglishPitchPreferenceDepthBases = 0x6e230;
inline constexpr auto EnglishPitchPreferenceRed = 0x6e234;
inline constexpr auto EnglishPitchPreferenceGreen = 0x6e240;
inline constexpr auto EnglishOriginalPointerPixels = 0x70554;
inline constexpr auto PitchOrderPositionPointers = 0xa2a37;
inline constexpr auto PitchOrderZoneMasks = 0xa2a4b;
inline constexpr auto PitchOrderZoneTextPointers = 0xae818;
inline constexpr auto Placements = 0xbd38c;
inline constexpr auto PlainBackground = 0xa2569;
inline constexpr auto PlanTicketPrice = 0xa4856;
@@ -1543,6 +1559,7 @@ inline constexpr auto SaveLoad_Render_ExecutableField = 0xa148f;
inline constexpr auto SaveLoad_Render_RuntimeField = 0xa2334;
inline constexpr auto SaveLoad_Render_RuntimeField2 = 0xa233f;
inline constexpr auto SaveLoad_Render_RuntimeField3 = 0xa234a;
inline constexpr auto SaveLoad_OverwriteQuestionPointer = 0xa21c4;
inline constexpr auto SaveLoad_Render_TextPointer = 0xa1512;
inline constexpr auto SaveLoad_Render_TextPointer2 = 0xae5f0;
inline constexpr auto SaveLoad_Render_TextPointer3 = 0xae620;
@@ -1964,4 +1981,19 @@ inline constexpr auto EnglishFourTeamFixtureTable = 0x6eea0;
inline constexpr auto EnglishSixTeamFixtureTable = 0x6eed4;
inline constexpr auto EnglishTwelveTeamFixtureTable = 0x6f0bc;
inline constexpr auto EnglishTwentyTeamFixtureTable = 0x6ee40;
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; }
namespace bmh::layout { inline constexpr auto CalendarDateSetup = 0x21270; }
-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()
+20
View File
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "formats/fbm.hpp"
#include <string_view>
namespace bmh {
// Verified German V2.24 state layout: the supplied Diamond 3.7 changes its
// container label, while retaining the same block order and database counts.
// Expanded careers have their own layout and must not accept these markers.
inline bool supported_native_save_version(std::string_view version, bool expanded = false) {
return expanded ? version == "O1.1" : version == "V2.24" || version == "V3.7";
}
inline void require_native_savegame(const Savegame& save, bool expanded = false) {
if (!save.checksum_ok) throw FormatError("savegame: FBM checksum mismatch");
if (!supported_native_save_version(save.version, expanded))
throw FormatError("savegame: unsupported FBM version " + save.version);
// Callers still parse the complete state using the installed edition's
// exact DbCounts; a recognized marker never bypasses layout validation.
}
}
+18
View File
@@ -16,6 +16,24 @@ Palette load_palette(const std::filesystem::path& path) {
return p;
}
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path) {
const Bytes bytes = read_file(path);
if (bytes.size() < 8) throw FormatError("VGA palette source is truncated");
const size_t rle_end = 8 + size_t(le32(bytes, 4));
if (rle_end > bytes.size()) throw FormatError("VGA RLE length exceeds palette source");
const size_t trailing = bytes.size() - rle_end;
if (trailing == 0) return std::nullopt;
if (trailing < 768) throw FormatError("truncated embedded VGA palette");
Palette palette;
for (size_t i = 0; i < palette.argb.size(); ++i) {
const auto channel = [&](size_t component) {
return uint32_t(vga_dac_rgb8(bytes[rle_end + i * 3 + component]));
};
palette.argb[i] = 0xff000000u | channel(0) << 16 | channel(1) << 8 | channel(2);
}
return palette;
}
uint8_t Palette::nearest(uint8_t r, uint8_t g, uint8_t b) const {
int best = 0, best_dist = INT32_MAX;
for (int i = 0; i < 256; i++) {
+3
View File
@@ -4,6 +4,7 @@
#include <array>
#include <cstdint>
#include <filesystem>
#include <optional>
namespace bmh {
@@ -21,5 +22,7 @@ constexpr uint8_t vga_dac_rgb8(uint8_t channel) {
}
Palette load_palette(const std::filesystem::path& path);
// Some full-screen VGA pictures carry their own DAC palette after the RLE data.
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path);
} // namespace bmh
-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
+10 -30
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>
@@ -55,19 +56,9 @@ uint32_t facility_level(const GameState& g, int m, int k) {
// (balance 1 %, fixed deposit 2 % a year), positive an expense (overdraft 12 %, beyond the
// credit line 18 %). The divisor is -36500.
int32_t daily_interest_preview(const GameState& g, int m) {
constexpr int32_t kAnnual = -0x8e94;
const int32_t balance = rec32(g, m, 0x314), deposit = rec32(g, m, 0x318), credit = rec32(g, m, 0x31c);
int32_t result = 0;
if (balance < 0) {
const int32_t with_credit = wrap(int64_t(balance) + credit);
if (with_credit < 0) result = wrap(int64_t(with_credit) * 0x12) / kAnnual;
int32_t below = wrap(-int64_t(credit));
if (below < balance) below = balance;
result = wrap(int64_t(result) + wrap(int64_t(below) * 0xc) / kAnnual);
} else {
result = balance / kAnnual;
}
return wrap(int64_t(result) + wrap(int64_t(deposit / 10000) * 20000) / kAnnual);
const auto interest = daily_interest_amounts(balance, deposit, credit);
return interest.borrowing + interest.cash_and_deposit;
}
// SharesAndLoans(manager, flags, months): flags 1 the dividends of the manager's funds and
@@ -77,7 +68,7 @@ int32_t shares_and_loans(const GameState& g, int m, int flags, int months) {
int32_t sum = 0;
if (flags & 1) {
for (int k = 0; k < 6; k++) {
const uint32_t unit = g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c) * uint32_t(kShareUnits[k]) / 10000;
const uint32_t unit = uint32_t((uint64_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c)) * uint32_t(kShareUnits[k])) / 10000);
sum = wrap(int64_t(sum) + int64_t(unit * g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c)));
}
if (flags & 4) sum = wrap(int64_t(sum) * months);
@@ -160,13 +151,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 +212,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 +260,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
+35
View File
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "game/state.hpp"
#include <limits>
#include <optional>
namespace bmh {
// OpenBMH-owned OBMHEXT1 section BRM1: four little-endian blocked month-start keys.
// Unknown histories use UINT32_MAX; original save fields are not repurposed.
inline constexpr uint32_t kBankRobberyMonthExtension = 0x314d5242;
inline constexpr uint32_t kUnknownBankRobberyMonth = std::numeric_limits<uint32_t>::max();
inline constexpr uint32_t kBankRobberyMonthBytes = 16;
inline std::optional<uint32_t> bank_robbery_guard_month(const GameState& state, int manager) {
if (manager < 0 || manager > 3) throw FormatError("bank robbery: invalid manager");
if (!state.memory.has(kBankRobberyMonthExtension)) return {};
if (!state.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
throw FormatError("bank robbery: truncated monthly guard");
const auto key = state.memory.u32(kBankRobberyMonthExtension + uint32_t(manager) * 4);
return key == kUnknownBankRobberyMonth ? std::nullopt : std::optional<uint32_t>{key};
}
inline void set_bank_robbery_guard_month(GameState& state, int manager, std::optional<uint32_t> key) {
if (manager < 0 || manager > 3) throw FormatError("bank robbery: invalid manager");
if (!state.memory.has(kBankRobberyMonthExtension)) {
state.memory.add_block(kBankRobberyMonthExtension, kBankRobberyMonthBytes);
for (uint32_t slot = 0; slot < 4; ++slot)
state.memory.set32(kBankRobberyMonthExtension + slot * 4, kUnknownBankRobberyMonth);
}
if (!state.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
throw FormatError("bank robbery: truncated monthly guard");
state.memory.set32(kBankRobberyMonthExtension + uint32_t(manager) * 4, key.value_or(kUnknownBankRobberyMonth));
}
// The first absolute day of the source calendar month, distinct across years.
uint32_t bank_robbery_month_key(uint32_t date);
}
+35
View File
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "game/calendar.hpp"
#include "formats/executable_layout.hpp"
#include "formats/le.hpp"
namespace bmh {
namespace { CalendarEpoch installed_epoch{2026, 2}; }
CalendarEpoch calendar_epoch_from_executable(const LeImage& exe) {
constexpr auto setup = layout::CalendarDateSetup;
constexpr uint8_t weekday_prefix[] = {0xc6,0x44,0x24,0x04};
constexpr uint8_t month_and_year_prefix[] = {0xc6,0x44,0x24,0x0c,0x07,0xc7,0x04,0x24};
if (!exe.contains(setup) || !exe.contains(setup + 16))
throw FormatError("calendar: missing original date setup");
constexpr uint8_t english_prefix[] = {0xc6,0x45,0xf6};
constexpr uint8_t english_month_and_year[] = {0xc6,0x45,0xf7,0x07,0x66,0xc7,0x45,0xf8};
bool english = true;
for (uint32_t i=0;i<sizeof english_prefix;++i)
english = english && exe.u8(setup+i)==english_prefix[i];
for (uint32_t i=0;i<sizeof english_month_and_year;++i)
english = english && exe.u8(setup+4+i)==english_month_and_year[i];
if (english) {
const auto year=exe.u16(setup+12); const int weekday=exe.u8(setup+3);
if(year<1600||year>9999||weekday>6)throw FormatError("calendar: invalid original English epoch");
return {int(year),weekday};
}
for (uint32_t i=0;i<sizeof weekday_prefix;++i)
if(exe.u8(setup+i)!=weekday_prefix[i])throw FormatError("calendar: unverified weekday setup");
for (uint32_t i=0;i<sizeof month_and_year_prefix;++i)
if(exe.u8(setup+5+i)!=month_and_year_prefix[i])throw FormatError("calendar: unverified year setup");
const auto year=exe.u32(setup+13);const int weekday=exe.u8(setup+4);
if(year<1600||year>9999||weekday>6)throw FormatError("calendar: invalid original epoch");
return {int(year),weekday};
}
void install_calendar_rules(const LeImage& exe) { installed_epoch=calendar_epoch_from_executable(exe); }
CalendarEpoch calendar_epoch() { return installed_epoch; }
}
+11
View File
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
namespace bmh {
class LeImage;
struct CalendarEpoch { int year; int weekday; };
// Read verified original date-setup operands; unknown routines are rejected.
CalendarEpoch calendar_epoch_from_executable(const LeImage& exe);
void install_calendar_rules(const LeImage& exe);
// Isolated authored states default to the established synthetic calendar.
CalendarEpoch calendar_epoch();
}
+24 -1
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/career.hpp"
#include "game/lineup.hpp"
#include <algorithm>
@@ -20,11 +21,29 @@ 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");
}
install_lineup_rules(exe);
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;
@@ -152,6 +171,10 @@ GameState startup_state(const LeImage& exe, const Database& db, const Bytes& m3_
}
const SaveState save(stream, counts);
GameState g = GameState::from_save(save, counts);
// The original options entry restores ordinary dialogs before any manager
// confirmation. The executable's initial value belongs to its boot screens.
g.memory.add_block(layout::CompactDialogFrame, 1);
g.memory.set8(layout::CompactDialogFrame, 0);
competition_pointers(g.memory, exe); // CompetitionPointers
return g;
}
+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
+2 -2
View File
@@ -622,7 +622,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
g.manager_records.at(at) = uint8_t(n + 1), g.manager_records.at(at + 1) = uint8_t((n + 1) >> 8);
}
// ListTitleHoldersAf(winner, title): the list of title holders (Titles)
mem.set16(::bmh::layout::Titles + uint32_t(title) * 100 + uint32_t(std::min<int>(g.season, 0x31)) * 2, winners[0]);
record_title_holder(g, title, winners[0]);
}
if (type == 0 && !winners.empty()) {
// the national cup: winner (Cup_AdvanceCup_RuntimeField5) and the previous holder
@@ -654,7 +654,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
if (mem.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && winner_display)
winner_display(g, {7, winner});
if (mem.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && mem.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2)) mem.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2, 0);
mem.set16(::bmh::layout::Titles + 7 * 100 + uint32_t(std::min<int>(g.season, 0x31)) * 2, winner);
record_title_holder(g, 7, winner);
if (mem.has(::bmh::layout::Cup_AdvanceCup_RuntimeField7)) mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField7, winner);
const int manager = g.manager_of(winner);
if (manager >= 0) {
+7
View File
@@ -538,6 +538,13 @@ TransferActionResult list_manager_player(GameState& g, int manager, int squad_ro
out.status = TransferActionStatus::invalid_player;
return out;
}
bool free_entry = false;
for (size_t entry = 0; entry < 40; ++entry) {
const int listed = g.squad_slots.at(0xb70 + entry) & 0xfff;
if (listed == player) { out.status = TransferActionStatus::pending; out.player = player; out.list_entry = int(entry); return out; }
free_entry = free_entry || listed == 0xfff;
}
if (!free_entry) { out.status = TransferActionStatus::blocked_by_board; return out; }
if (!list_transfer_player(g, slot, rand, report)) {
out.status = report.unsupported ? TransferActionStatus::invalid_request : TransferActionStatus::blocked_by_board;
return out;
+7
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "game/transfer_allocator.hpp"
// OpenBMH deviates from the original: supports designated set-piece records and the supported transfer-editor rules.
// Actions a human manager can take at his desk that change the game state and draw random
// numbers (BMH.exe V2.24 + supported rule profile patch). The screens themselves belong to the UI; these
@@ -272,6 +273,12 @@ struct TransferOfferEditorSubmitResult {
TransferOfferEditorSubmitResult submit_transfer_offer_editor_source(GameState&,
const TransferOfferEditorState&,WatcomRandom&,const HumanBuyerSaleHooks&,MinuteReport&);
// OpenBMH deviates from the original: a seller may accept an existing bid before expiry.
// The caller stages state/RNG; cancellation is handled before invoking this action.
TransferActionResult accept_manager_transfer_offer(GameState&, int manager, int list_entry,
int expected_player, int bid_index, WatcomRandom&, MinuteReport&,
TransferAllocatorContext = TransferAllocatorContext::unsupported);
// Submit a manager bid on an existing list entry. A full-value fee and salary meeting
// the demand complete an immediate agreement; lower viable offers persist for weekly review.
TransferActionResult submit_transfer_bid(GameState& g, const TransferBidRequest& request, WatcomRandom& rand);
+116 -86
View File
@@ -1,103 +1,133 @@
// 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>
#include <utility>
namespace bmh {
namespace {
bool supported_environment = true; // Synthetic state tests explicitly use the verified monthly model.
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;
}
}
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;
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;
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) {
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 (!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;
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
+21 -33
View File
@@ -1,47 +1,35 @@
// 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 "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 { kYouthAcademy = 1, kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
// 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{}; // 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
+54 -2
View File
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/lineup.hpp"
#include "formats/le.hpp"
#include "game/match.hpp"
#include "game/weekly.hpp"
#include <cstdlib>
#include <stdexcept>
@@ -10,6 +13,7 @@
namespace bmh {
namespace {
bool original_foreign_limit_enabled = false;
// Position type by formation depth x (table at layout field).
constexpr int8_t kTypeByDepth[24] = {0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 0, 1, 2, 2};
@@ -317,6 +321,10 @@ bool save_pitch_formation_source(GameState& g, int manager_slot, int runtime_clu
}
}
void install_lineup_rules(const LeImage& exe) {
original_foreign_limit_enabled = exe.u8(layout::ForeignPlayerLimitEnabled) != 0;
}
static void auto_lineup_impl(GameState& g, int team, int mode, int manager) {
if (team >= 138 && team != kNoTeam) return; // teams without squads
if (g.lineups_frozen) return; // LineupRuntimeField (the season change)
@@ -574,8 +582,52 @@ static void auto_lineup_impl(GameState& g, int team, int mode, int manager) {
break;
}
}
// OpenBMH deviates from the original: disables the foreign-player limit in the supported rule profile.
// (foreign-player limit ForeignPlayerLimitEnabled is off in the supported rule profile)
if (original_foreign_limit_enabled) {
const int country = team_region(team) & 0xff;
const int allowed = 3 - int(country != 0);
std::vector<int> foreign_rows, foreign_roles;
for (int row = 0; row < 11; ++row) {
const int id = g.squad_slots.at(range.first + row) & 0x0fff;
if (id != 0x0fff && nationality(g, id) != country) {
foreign_rows.push_back(row);
foreign_roles.push_back(g.players.at(id).position());
}
}
int tolerance = 0;
for (int attempt = 0; foreign_rows.size() > size_t(allowed) && attempt < 200; ++attempt) {
++tolerance;
if (tolerance > 100) {
// No suitable domestic reserve: retain the original short-lineup
// outcome rather than fielding more foreign players than allowed.
g.squad_slots.at(range.first + foreign_rows.back()) &= 0x1fff;
foreign_rows.pop_back(); foreign_roles.pop_back();
continue;
}
for (int row = 11; row < players && value[row] != kUnavailable; ++row) {
const int id = g.squad_slots.at(range.first + row) & 0x0fff;
if (id == 0x0fff || nationality(g, id) != country) continue;
const int role = g.players.at(id).position();
const int replaced_role = foreign_roles.back();
if ((role == 0 && replaced_role != 0 && tolerance <= 7) ||
std::abs(role - replaced_role) >= tolerance) continue;
const int field = foreign_rows.back();
foreign_rows.pop_back(); foreign_roles.pop_back();
auto& incoming = g.squad_slots.at(range.first + row);
auto& outgoing = g.squad_slots.at(range.first + field);
incoming = uint16_t((incoming & 0x1fff) | 0x8000);
outgoing = uint16_t((outgoing & 0x1fff) | (row < 17 ? 0x4000 : 0));
std::swap(incoming, outgoing);
std::swap(value[row], value[field]);
if (manager >= 0) {
std::swap_ranges(board(row), board(row) + 0x58, board(field));
std::swap(board(row)[0x41], board(field)[0x41]);
std::swap(board(row)[0x42], board(field)[0x42]);
}
tolerance = 0;
if (foreign_rows.size() <= size_t(allowed)) break;
}
}
}
// After a full line-up every player in the eleven or on the bench notes his squad slot
// (relative to the squad start) in bits 0-4 of his card word (*PlayerCards).
if (!first_eleven_only && !g.player_cards.empty())
+7 -3
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// OpenBMH deviates from the original: disables the foreign-player limit and supports owner-bound designated set-piece selection.
// OpenBMH deviates from the original: supports owner-bound designated set-piece selection.
// Automatic line-up of computer teams, port of Int2.
//
// The squad of a team is a run of squad slots (squad_range). The first 11 slots are the
@@ -21,7 +21,7 @@
// The chosen player is swapped into slot p and flagged 0x8000 (slots 0-10) or 0x4000.
//
// Ported: assistant training-camp familiarity penalty and detailed position scoring at
// difficulty >= 6. The foreign-player limit (ForeignPlayerLimitEnabled) is off in supported rule profile.
// difficulty >= 6. The supplied edition controls the original foreign-player limit.
#include <cstdint>
#include <array>
@@ -30,6 +30,10 @@
#include "game/state.hpp"
namespace bmh {
class LeImage;
// Install the supplied edition's original automatic-lineup rule switch.
void install_lineup_rules(const LeImage& exe);
// Games: in-place quicksort (Hoare partition, middle element as pivot) of `keys`
// descending (ascending if `ascending`), comparing as unsigned 32-bit, moving `items`
@@ -93,7 +97,7 @@ bool save_pitch_formation_source(GameState& g, int manager_slot, int runtime_clu
int formation, uint8_t expected_weights,
const std::array<uint8_t, 22>& formation_positions);
// OpenBMH deviates from the original: disables the foreign-player limit and supports owner-bound designated set-piece selection.
// OpenBMH deviates from the original: supports owner-bound designated set-piece selection.
// supported rule profile NormalizePitchSetPieceSource/NormalizePitchSetPieceSource3/NormalizePitchSetPieceSource2/NormalizePitchSetPieceSource4: deterministic, owner-bound
// set-piece presentation state. Stored takers are player_id+1; zero is AUTO.
bool normalize_pitch_set_piece_source(GameState& g, int manager_slot, int runtime_club);
+149
View File
@@ -0,0 +1,149 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "game/long_career.hpp"
#include "game/state.hpp"
#include "formats/executable_layout.hpp"
#include <algorithm>
#include <limits>
#include <stdexcept>
namespace bmh {
namespace {
uint32_t key(int team, int player) {
if (team < 0 || team > 0xfff || player < 0 || player >= 0xfff)
throw FormatError("long career: invalid player/club identity");
return uint32_t(team) << 12 | uint32_t(player);
}
int manager_team(const GameState& g, int manager) {
if (manager >= 0 && size_t(manager) < g.manager_teams.size()) return g.manager_teams[size_t(manager)];
const size_t at = size_t(manager) * 0xb0c + 0x290;
if (manager < 0 || manager > 4 || at + 1 >= g.manager_records.size())
throw FormatError("long career: invalid manager");
return int(g.manager_records[at] | uint16_t(g.manager_records[at + 1]) << 8);
}
PlayerClubStatistics legacy(const std::array<uint8_t, 0x58>& b) {
auto word = [&](size_t at) { return uint64_t(b[at] | uint16_t(b[at + 1]) << 8); };
return {{b[7], b[8], b[9]}, word(0x48), word(0x4a), word(0x4c)};
}
void increment(uint64_t& n) {
if (n == std::numeric_limits<uint64_t>::max()) throw FormatError("long career: statistics counter exhausted");
++n;
}
void put(Bytes& b, uint64_t n, int width) { for (int i = 0; i < width; ++i) b.push_back(uint8_t(n >> (i * 8))); }
struct Reader {
const Bytes& bytes; size_t pos = 0;
uint64_t get(int width) {
if (size_t(width) > bytes.size() - pos) throw FormatError("long career: truncated extension");
uint64_t n = 0; for (int i = 0; i < width; ++i) n |= uint64_t(bytes[pos++]) << (i * 8); return n;
}
std::string string() {
const size_t size = size_t(get(2));
if (size > bytes.size() - pos) throw FormatError("long career: truncated title name");
std::string s(bytes.begin() + pos, bytes.begin() + pos + size); pos += size; return s;
}
};
}
PlayerClubStatistics player_club_statistics(const GameState& g, int team, int player,
const std::array<uint8_t, 0x58>& board) {
const auto found = g.player_statistics.find(key(team, player));
return found == g.player_statistics.end() ? legacy(board) : found->second;
}
void record_player_statistics(GameState& g, int manager, int row, int player, int cls, int kind) {
const size_t at = size_t(manager) * 0x840 + size_t(row) * 0x58;
if (manager < 0 || row < 0 || row >= 24 || at + 0x58 > g.tactics.size() || cls < 0 || cls > 3 || kind < 0 || kind > 2)
throw FormatError("long career: invalid statistics row/event");
std::array<uint8_t, 0x58> board; std::copy_n(g.tactics.begin() + at, board.size(), board.begin());
const auto identity = key(manager_team(g, manager), player);
auto [found, inserted] = g.player_statistics.try_emplace(identity, legacy(board));
auto next = found->second;
if (kind == 0) { if (cls < 3) increment(next.appearances[size_t(cls)]); increment(next.total); }
else if (kind == 1) increment(next.goals);
else increment(next.assists);
found->second = next;
}
void reset_player_statistics(GameState& g, int manager, int player) {
g.player_statistics.erase(key(manager_team(g, manager), player));
}
void swap_statistics_clubs(GameState& g, int first, int second) {
PlayerStatisticsArchive next;
for (const auto& [identity, value] : g.player_statistics) {
const int club = int(identity >> 12), player = int(identity & 0xfff);
next.emplace(key(club == first ? second : club == second ? first : club, player), value);
}
g.player_statistics = std::move(next);
}
TitleHistoryArchive title_history_rows(const GameState& g) {
if (g.season < 0) throw FormatError("long career: negative season index");
auto rows = g.title_history;
if (!g.memory.has(layout::Titles + 899)) return rows;
const int first = std::max(0, g.season - 49);
for (int slot = 0; slot < 50 && first + slot <= g.season; ++slot) {
const auto season = uint32_t(first + slot);
if (rows.contains(season)) continue;
std::array<std::string, 9> winners;
for (size_t category = 0; category < 9; ++category) {
const auto team = g.memory.u16(layout::Titles + uint32_t(category) * 100 + uint32_t(slot) * 2);
if (team != 0xffff) winners[category] = g.club_name(team);
}
rows.emplace(season, std::move(winners));
}
return rows;
}
void capture_title_history(GameState& g) { g.title_history = title_history_rows(g); }
void record_title_holder(GameState& g, int category, uint16_t winner) {
if (category < 0 || category >= 9 || g.season < 0 || winner >= g.club_ids.size())
throw FormatError("long career: invalid title award");
capture_title_history(g);
const auto name = g.club_name(winner);
g.memory.set16(layout::Titles + uint32_t(category) * 100 + uint32_t(std::min(g.season, 49)) * 2, winner);
g.title_history[uint32_t(g.season)][size_t(category)] = name;
}
void shift_legacy_title_history(GameState& g) {
if (g.season <= 49) return;
for (uint32_t category = 0; category < 9; ++category) {
for (uint32_t i = 0; i < 98; ++i)
g.memory.set8(layout::Titles + category * 100 + i,
g.memory.u8(layout::Season_SeasonEndSteps_RuntimeField + category * 100 + i));
g.memory.set16(layout::Season_SeasonEndSteps_RuntimeField2 + category * 100, 0xffff);
}
}
Bytes encode_long_career(const GameState& g) {
if (g.player_statistics.empty() && g.title_history.empty()) return {};
Bytes b; put(b, 1, 4); put(b, g.player_statistics.size(), 4); put(b, g.title_history.size(), 4);
for (const auto& [identity, s] : g.player_statistics) {
put(b, identity, 4); for (const auto n : s.appearances) put(b, n, 8);
for (const auto n : {s.total, s.goals, s.assists}) put(b, n, 8);
}
for (const auto& [season, names] : g.title_history) {
if (season > 32767) throw FormatError("long career: archived season exceeds native calendar range");
put(b, season, 4);
for (const auto& name : names) {
if (name.size() > UINT16_MAX) throw FormatError("long career: title name too long");
put(b, name.size(), 2); b.insert(b.end(), name.begin(), name.end());
}
}
return b;
}
void decode_long_career(GameState& g, const Bytes& bytes) {
Reader r{bytes};
if (r.get(4) != 1) throw FormatError("long career: unsupported extension version");
const auto players = r.get(4), seasons = r.get(4);
if (players > (bytes.size() - r.pos) / 52 || seasons > 32768)
throw FormatError("long career: invalid extension counts");
PlayerStatisticsArchive stats; TitleHistoryArchive history;
for (uint64_t i = 0; i < players; ++i) {
const auto identity = uint32_t(r.get(4));
if (identity > 0xffffff || (identity & 0xfff) == 0xfff) throw FormatError("long career: invalid archived identity");
PlayerClubStatistics s; for (auto& n : s.appearances) n = r.get(8);
s.total = r.get(8); s.goals = r.get(8); s.assists = r.get(8);
if (!stats.emplace(identity, s).second) throw FormatError("long career: duplicate archived identity");
}
for (uint64_t i = 0; i < seasons; ++i) {
const auto season = uint32_t(r.get(4));
if (season > 32767) throw FormatError("long career: invalid archived season");
std::array<std::string, 9> names; for (auto& name : names) name = r.string();
if (!history.emplace(season, std::move(names)).second) throw FormatError("long career: duplicate archived season");
}
if (r.pos != bytes.size()) throw FormatError("long career: trailing extension bytes");
g.player_statistics = std::move(stats); g.title_history = std::move(history);
}
}
+31
View File
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <array>
#include <cstdint>
#include <map>
#include <string>
#include "formats/binary.hpp"
namespace bmh {
struct GameState;
struct PlayerClubStatistics {
std::array<uint64_t, 3> appearances{};
uint64_t total = 0, goals = 0, assists = 0;
bool operator==(const PlayerClubStatistics&) const = default;
};
// Optional OBMHEXT1 block, outside the Original guest address space. Payload v1.
inline constexpr uint32_t kLongCareerExtension = 0x4f424c43;
using PlayerStatisticsArchive = std::map<uint32_t, PlayerClubStatistics>;
using TitleHistoryArchive = std::map<uint32_t, std::array<std::string, 9>>;
PlayerClubStatistics player_club_statistics(const GameState&, int team, int player,
const std::array<uint8_t, 0x58>& board);
void record_player_statistics(GameState&, int manager, int row, int player, int competition_class, int kind);
void reset_player_statistics(GameState&, int manager, int player);
void swap_statistics_clubs(GameState&, int first, int second);
TitleHistoryArchive title_history_rows(const GameState&);
void capture_title_history(GameState&);
void record_title_holder(GameState&, int category, uint16_t winner);
void shift_legacy_title_history(GameState&);
Bytes encode_long_career(const GameState&);
void decode_long_career(GameState&, const Bytes&);
}
+9 -27
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>
@@ -241,6 +242,7 @@ void player_statistic(GameState& g, int type, int player, int manager, int slot,
if (cls == 3 && (g.player_bonus.at(player) & 0x7F) < 0x7F) g.player_bonus.at(player)++;
if (manager >= 0) {
pay_bonus(g, manager, slot, 2, true);
record_player_statistics(g, manager, slot, player, cls, kind);
if (cls < 3) g.tactics.at(board + 7 + cls)++;
wr16(g.tactics, board + 0x48, uint16_t(rd16(g.tactics, board + 0x48) + 1));
}
@@ -248,13 +250,17 @@ void player_statistic(GameState& g, int type, int player, int manager, int slot,
} else if (kind == 1) { // goal
if (manager >= 0) {
pay_bonus(g, manager, slot, 0, true);
record_player_statistics(g, manager, slot, player, cls, kind);
wr16(g.tactics, board + 0x4a, uint16_t(rd16(g.tactics, board + 0x4a) + 1));
if (cls == 0) g.manager_records.at(size_t(manager) * kManagerRecord + 0x1ae + std::min(minute, 89) / 5)++;
}
// league goals in bits 2-7 (a 64th goal carries into bit 8, as in the original)
if (cls == 0) p.w364 = (w364 & 0xFFFFFF03u) | ((((w364 >> 2) & 0x3F) << 2) + 4);
} else if (kind == 2) { // assist
if (manager >= 0) wr16(g.tactics, board + 0x4c, uint16_t(rd16(g.tactics, board + 0x4c) + 1));
if (manager >= 0) {
record_player_statistics(g, manager, slot, player, cls, kind);
wr16(g.tactics, board + 0x4c, uint16_t(rd16(g.tactics, board + 0x4c) + 1));
}
if (cls == 0) p.w368 = (p.w368 & 0xFF03FFFFu) | ((((p.w368 >> 18) & 0x3F) + 1) << 18);
}
}
@@ -676,30 +682,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 +724,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
@@ -799,7 +781,7 @@ void advance_league_rounds(GameState& g, uint32_t competitions, WatcomRandom& ra
if (g.memory.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && winner)
winner(g, {0, uint16_t(champion)});
if (g.memory.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && g.memory.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2)) g.memory.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2, 0);
g.memory.set16(::bmh::layout::Titles + uint32_t(std::min<int>(g.season, 0x31)) * 2, uint16_t(champion));
record_title_holder(g, 0, uint16_t(champion));
const int manager = g.manager_of(champion);
if (manager >= 0) {
const size_t at = size_t(manager) * kManagerRecord + 0x8a4;
+54 -9
View File
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/messages.hpp"
#include "game/schedule.hpp"
#include <algorithm>
#include <cstdio>
#include <limits>
namespace bmh {
@@ -112,13 +114,8 @@ std::string message_text_following(const GameState& g, uint32_t pointer_variable
return text;
}
std::string format_number(const GameState& g, int32_t value, int flags) {
if (flags & 0x100) {
// ConvertCurrency: currency conversion (1/1 unless the savegame says otherwise)
const int32_t mul = g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1;
const int32_t div = g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1;
if (div != 0) value = value * mul / div;
}
namespace {
std::string format_number_digits(const GameState& g, int64_t value, int flags) {
// FormatGroupedDigits: digits from the right; with grouping (bit 0x40 clear) a dot before the
// 4th, 8th and 12th character; padded to the width (bits 0-5), leading blanks for the
// dots a wide field reserves
@@ -126,12 +123,12 @@ std::string format_number(const GameState& g, int32_t value, int flags) {
const int width = flags & 0x3F;
int blanks = group && width > 3 ? (width - 4) / 3 + 1 : 0;
const bool negative = value < 0;
uint32_t v = negative ? uint32_t(-int64_t(value)) : uint32_t(value);
uint64_t v = negative ? uint64_t(-(value + 1)) + 1 : uint64_t(value);
std::string reversed;
int dots = 0;
while (v != 0) {
const size_t n = reversed.size();
if (group && (n == 3 || n == 7 || n == 11)) reversed.push_back('.'), blanks--, dots++;
if (group && n % 4 == 3) reversed.push_back('.'), blanks--, dots++;
reversed.push_back(char('0' + v % 10));
v /= 10;
}
@@ -148,6 +145,54 @@ std::string format_number(const GameState& g, int32_t value, int flags) {
return s;
}
} // namespace
std::string format_number(const GameState& g, int32_t value, int flags) {
if (flags & 0x100) {
// ConvertCurrency: currency conversion (1/1 unless the savegame says otherwise)
const int32_t mul = g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1;
const int32_t div = g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1;
if (div != 0) value = value * mul / div;
}
return format_number_digits(g, value, flags);
}
std::string format_number_wide(const GameState& g, int64_t value, int flags) {
if (flags & 0x100) {
const int32_t mul = g.memory.has(layout::CurrencyMultiplier) ? int32_t(g.memory.u32(layout::CurrencyMultiplier)) : 1;
const int32_t div = g.memory.has(layout::CurrencyDivisor) ? int32_t(g.memory.u32(layout::CurrencyDivisor)) : 1;
if (div != 0) {
const bool negative = (value < 0) != ((mul < 0) != (div < 0));
const uint64_t magnitude = value < 0 ? uint64_t(-(value + 1)) + 1 : uint64_t(value);
const uint64_t multiplier = mul < 0 ? uint64_t(-int64_t(mul)) : uint64_t(mul);
const uint64_t divisor = div < 0 ? uint64_t(-int64_t(div)) : uint64_t(div);
const uint64_t limit = uint64_t(std::numeric_limits<int64_t>::max()) + uint64_t(negative);
// Split before multiplication, keeping exact truncation without
// requiring nonportable 128-bit integers for currency conversion.
const uint64_t whole = magnitude / divisor;
if (multiplier && whole > limit / multiplier)
throw FormatError("wide currency amount exceeds display range");
const uint64_t base = whole * multiplier;
const uint64_t fraction = (magnitude % divisor) * multiplier / divisor;
if (fraction > limit - base)
throw FormatError("wide currency amount exceeds display range");
const uint64_t converted = base + fraction;
value = negative ? (converted == uint64_t(std::numeric_limits<int64_t>::max()) + 1
? std::numeric_limits<int64_t>::min() : -int64_t(converted)) : int64_t(converted);
}
}
return format_number_digits(g, value, flags);
}
std::string format_amount(const GameState& g, int32_t value) { return format_number(g, value, 0x101); }
void install_message_texts(const LeImage& exe) {
kContractEndsSoonText = exe.cstring(kEnglishCompetitions ? ::bmh::layout::EnglishContractExpiryWarningText : ::bmh::layout::ContractExpiryWarningText);
kMastersQualificationText = kEnglishCompetitions ? "Masters entry confirmed. Your participation bonus has been credited." : exe.cstring(::bmh::layout::MastersQualificationText);
kMastersWinnerText = kEnglishCompetitions ? "Masters title won. Your prize money has been credited." : exe.cstring(::bmh::layout::MastersWinnerText);
kIndoorInvitationText = kEnglishCompetitions ? "Indoor event entry bonus credited for " : exe.cstring(::bmh::layout::IndoorInvitationText);
kChampionshipBonusText = kEnglishCompetitions ? "League title bonus credited." : exe.cstring(::bmh::layout::ChampionshipBonusText);
kFriendlyPayerPrefixText = kEnglishCompetitions ? "Your share: " : exe.cstring(::bmh::layout::NationalFriendlyPayerPrefixText);
}
} // namespace bmh
+8
View File
@@ -16,6 +16,7 @@
#include <string>
#include <vector>
#include "formats/le.hpp"
#include "game/state.hpp"
namespace bmh {
@@ -59,6 +60,11 @@ inline std::string kIndoorInvitationText;
inline std::string kChampionshipBonusText;
inline std::string kFriendlyPayerPrefixText;
// Installs the six texts above from the game image (the English game uses its own wording).
// Both career sessions call it at start; standalone engine tools (week_check, the season sims)
// must call it too, or these messages lose their text (#14: the indoor entry bonus mail).
void install_message_texts(const LeImage& exe);
// FormatNumber(buf, value, 0x101, ""): an amount of money as the messages show it: the
// value converted with CurrencyMultiplier / CurrencyDivisor, digits grouped by dots, then " EU".
std::string format_amount(const GameState& g, int32_t value);
@@ -66,5 +72,7 @@ std::string format_amount(const GameState& g, int32_t value);
// FormatNumber(buf, value, flags, ""): bits 0-5 the field width, bit 0x40 no dot grouping,
// bit 0x100 an amount of money (converted, " EU" appended).
std::string format_number(const GameState& g, int32_t value, int flags);
// Read-only aggregates can exceed a native save word; preserve currency and padding.
std::string format_number_wide(const GameState& g, int64_t value, int flags);
} // namespace bmh
+14 -19
View File
@@ -1,10 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "game/month.hpp"
#include "game/trace.hpp"
#include <algorithm>
#include <array>
#include <bit>
#include <cstdio>
#include <cstdlib>
#include <optional>
@@ -482,11 +484,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 +514,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;
@@ -666,7 +655,7 @@ void board_month(GameState& g, int m, WatcomRandom& rand, MinuteReport& report,
for (int s = 0; s < 24; s++) g.tactics.at(board(s) + 0xb) &= 0x7F;
}
// MonthChange2: share prices grow by 2.5 %, dividends, loans between the managers.
// MonthChange2: share prices grow by 0.25 %, dividends, loans between the managers.
void shares_and_loans(GameState& g) {
StaticMemory& mem = g.memory;
std::vector<uint8_t>& r = g.manager_records;
@@ -677,12 +666,16 @@ void shares_and_loans(GameState& g) {
uint32_t price = mem.u32(at);
price += ((price / 10000) * 0x19 / 10) * 10;
mem.set32(at, price);
// OpenBMH deviates from the original: keep the price product in 64 bits
// until division, retaining per-unit truncation and recipient policy.
const uint64_t unit_dividend = (uint64_t(price) * uint32_t(kShareFactor[k])) / 10000;
// (a bug of the original: only the last manager's dividend is kept and it is booked
// for the manager after the last one)
int32_t dividend = 0;
for (int m = 0; m < managers; m++)
dividend = int32_t(mem.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c) *
((price * uint32_t(kShareFactor[k])) / 10000));
dividend = std::bit_cast<int32_t>(uint32_t(
mem.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c) *
unit_dividend));
book_money(g, managers, -dividend, true);
add32(r, size_t(managers) * kRecord + 0x870, dividend);
}
@@ -706,6 +699,8 @@ void shares_and_loans(GameState& g) {
} // namespace
void monthly_shares_and_loans(GameState& g) { shares_and_loans(g); }
bool list_transfer_player(GameState& g, int slot, WatcomRandom& rand, MinuteReport& report) {
return list_player(g, slot, rand, report);
}
@@ -1001,7 +996,7 @@ void month_change(GameState& g, WatcomRandom& rand, MinuteReport& report, GameRa
if (report.unsupported) return;
// 5. shares and loans
turn_step = "month_change: shares";
shares_and_loans(g);
monthly_shares_and_loans(g);
}
} // namespace bmh
+3
View File
@@ -28,6 +28,9 @@ namespace bmh {
// `game` is needed when a player leaves at the end of his contract (MonthChange).
void month_change(GameState& g, WatcomRandom& rand, MinuteReport& report, GameRandom* game = nullptr);
// The investment/loan phase, retaining the original dividend recipient policy.
void monthly_shares_and_loans(GameState& g);
// CareerFirstSteps: new players on the transfer list (part of the month change; also at the
// start of a season).
void new_transfer_list_entries(GameState& g, WatcomRandom& rand, MinuteReport& report);
+5
View File
@@ -74,6 +74,11 @@ void new_board_entry(GameState& g, int manager, int index, int slot, WatcomRando
uint8_t* e = &g.tactics.at(size_t(manager) * kBoard + size_t(index) * kBoardSlot);
std::memset(e + 7, 0, 3);
std::memset(e + 0x19, 0, 0x24);
// OpenBMH deviates from the original: a new arrival must not inherit the
// previous occupant's retirement/refusal/month-processing flags.
e[0xb] = 0;
std::memset(e + 0x48, 0, 6); // Fresh arrivals do not inherit the previous player's totals.
reset_player_statistics(g, manager, g.squad_slots.at(size_t(slot)) & 0xfff);
e[10] = 2;
for (int k = 0; k < 4; k++) e[2 + k] = index < 2 ? 1 : uint8_t(rand.range(2, 0x27));
e[0x3f] = 0xff;
+8 -1
View File
@@ -228,15 +228,22 @@ bool undo_reschedule(GameState& g, int manager, int day) {
if (std::none_of(moved.begin(), moved.end(), [&](const LeagueMatchRef& m) { return m.day == day; })) return false;
const int team = manager_team(g, manager);
// UndoReschedule(day, 1, team): every replay of the club on that day, whatever its league
int kept = 0; // local_18: the replays of other clubs that stay on the day
for (int e = 0; e < kPostponedEntries; e++) {
const uint32_t at = kPostponed + uint32_t(e) * 6;
if (g.memory.u16(at) != uint16_t(day)) continue;
const int league = g.memory.u8(at + 3), round = g.memory.u8(at + 2), m = g.memory.u8(at + 4);
const Fixture f = round_fixtures(league, round).at(size_t(m));
if (f.home != team && f.away != team) continue;
if (f.home != team && f.away != team) { ++kept; continue; }
g.results.at(result_at(league, round, m)) = kNotPlayed;
g.memory.set16(at, 0);
}
// with no replay left the day loses its replay bit 0x4000 again (calendar high byte & 0xbf),
// so it can be a target once more
if (kept == 0) {
const uint32_t high = kCalendar + uint32_t(day) * 2 + 1;
g.memory.set8(high, uint8_t(g.memory.u8(high) & 0xbf));
}
return true;
}
+2 -2
View File
@@ -15,8 +15,8 @@
// matchday the 0xCE turns into 0xCD (matchday_setup) and the match is played on the
// new day like a winter postponement.
// 4. A click on the new day of a moved match takes the move back (UndoReschedule(day, 1,
// team)): the entry is freed and the result byte is 0xCC again. The calendar keeps bit
// 0x4000, as in the original.
// team)): the entry is freed and the result byte is 0xCC again. When no replay of another
// club stays on that day, the day loses bit 0x4000 again and can be a target once more.
//
// Everything here works on the saved GameState only: no random numbers are drawn, so a
// rescheduled career stays deterministic.
+14 -2
View File
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/save.hpp"
#include "game/bank_robbery.hpp"
#include "game/calendar.hpp"
#include <cstdio>
#include <cstring>
@@ -25,7 +27,7 @@ void put32(Bytes& d, size_t at, uint32_t x) {
for (int i = 0; i < 4 && at + size_t(i) < d.size(); i++) d[at + size_t(i)] = uint8_t(x >> (8 * i));
}
// DeskDate2(date, buffer, 0): "TT.MM.JJJJ" of a day counter (day 0 = 1 July 2026; a
// DeskDate2(date, buffer, 0): "TT.MM.JJJJ" of a day counter (day 0 = 1 July of the supplied edition; a
// four-year leap cycle that starts with the third year).
std::string date_text(uint32_t counter) {
static const int kDays[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
@@ -45,7 +47,7 @@ std::string date_text(uint32_t counter) {
if (++month == 13) month = 1, ++years;
}
char buf[16];
std::snprintf(buf, sizeof buf, "%02d.%02d.%04d", day, month, 2026 + years);
std::snprintf(buf, sizeof buf, "%02d.%02d.%04d", day, month, calendar_epoch().year + years);
return buf;
}
@@ -125,6 +127,16 @@ Bytes save_stream(const GameState& live) {
for (uint32_t i = 0; i < size; ++i) bytes[i] = g.memory.u8(at + i);
extension.push_back({at, std::move(bytes)});
}
auto history = encode_long_career(g);
if (!history.empty()) extension.push_back({kLongCareerExtension, std::move(history)});
if (g.memory.has(kBankRobberyMonthExtension)) {
if (!g.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
throw FormatError("savegame: truncated bank robbery monthly guard");
Bytes months(kBankRobberyMonthBytes);
for (uint32_t i = 0; i < months.size(); ++i)
months[i] = g.memory.u8(kBankRobberyMonthExtension + i);
extension.push_back({kBankRobberyMonthExtension, std::move(months)});
}
append_save_extension(stream, extension);
return stream;
}
+44 -24
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
@@ -789,6 +787,7 @@ void change_places(GameState& g, int a, int b) {
mem.set32(::bmh::layout::Career_RemoveJoinLoans_RuntimeField + k * 4, (e & 0xfff) | uint32_t(seller) << 12 | uint32_t(buyer) << 22);
}
if (!g.club_table.empty() && a < 0xa8 && b < 0xa8) swap_bytes(g.club_table, size_t(a) * 0x4a, size_t(b) * 0x4a, 0x4a);
swap_statistics_clubs(g, a, b);
std::swap(g.club_ids.at(size_t(a)), g.club_ids.at(size_t(b)));
swap_bytes(g.club_heap_bc, size_t(a) * 2, size_t(b) * 2, 2);
std::swap(g.team_morale.at(size_t(a)), g.team_morale.at(size_t(b)));
@@ -1106,8 +1105,6 @@ bool release_player(GameState& g, int slot, GameRandom& game, WatcomRandom& rand
return true;
}
namespace {
// CareerSeasonSetup3: the players' new season. Records and boards of the managers restart
// (with new advertising offers, TransferListCountdown2); then every squad and pool slot: players
// out for their career recover now and then with a human club's good doctor, else leave;
@@ -1171,10 +1168,16 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
uint8_t count = 0xff; // local_20
int8_t owner = -1; // local_24: the club's human manager
size_t board_first = 0; // local_3c
std::vector<bool> processed(g.players.size(), false);
for (int s = 0; s < 0xc00 && !report.unsupported; s++) {
for (;;) {
const int player = g.squad_slots.at(size_t(s)) & 0xFFF;
if (player == 0xFFF) break;
// OpenBMH deviates from the original: age/retire each player
// once, even when a temporary offer row references his club
// slot or regeneration moves him to a later free-agent slot.
if (processed.at(size_t(player))) break;
processed.at(size_t(player)) = true;
const int team = slot_team(s);
if (team != int(last_team)) { // (-1 for the pool never equals 0xFFFF)
count = 0xff;
@@ -1236,7 +1239,9 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
// a year older
p.w368 &= 0xf8003fffu;
int age = int16_t(((p.w364 >> 21) & 0x1f) + 1);
if (s < 0xb70 && rand.range(0x10, 0x16) < age && owner == -1) {
// OpenBMH deviates from the original: includes transfer-market
// players in retirement so the five-bit age cannot wrap to 16.
if (rand.range(0x10, 0x16) < age && owner == -1) {
if (count != 0xff) count = uint8_t(squad_count(g, team, 2) + loans[team]);
if (count > 0xd) {
count--;
@@ -1254,6 +1259,10 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
if (std::getenv("BMH_TRACE"))
std::printf(" [release slot %d player %d team %d age %u count %u]\n", s, player, team, (p.w364 >> 21) & 0x1f, count);
if (!release_player(g, s, game, rand, report)) return;
// Club releases compact their squad in remove_from_seller. Pool
// releases have no club: retire this source entry explicitly after
// the regenerated player has been placed in the free-agent pool.
if (team < 0) g.squad_slots.at(size_t(s)) = 0x0fff;
}
}
g.lineups_frozen = false;
@@ -1264,6 +1273,8 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
std::fill(g.results.begin(), g.results.end(), uint8_t(0xcc));
}
namespace {
// The end of the CareerSession_RuntimeError_RuntimeField4 branch of DailyInterest: histories beyond 50 seasons shift
// (SeasonEndSteps), the managers' season record starts (ManagerOf(m, 0, -2)), the
// limited game length counts down (CareerDuration), the days pass (DayStepRest) up to the
@@ -1274,10 +1285,7 @@ SeasonTransitionOutcome season_end_steps(GameState& g, GameRandom& game, WatcomR
TransferAllocatorContext allocator) {
StaticMemory& mem = g.memory;
if (g.season > 0x31) { // SeasonEndSteps
for (uint32_t k = 0; k < 9; k++) {
for (uint32_t i = 0; i < 0x62; i++) mem.set8(::bmh::layout::Titles + k * 100 + i, mem.u8(::bmh::layout::Season_SeasonEndSteps_RuntimeField + k * 100 + i));
mem.set16(::bmh::layout::Season_SeasonEndSteps_RuntimeField2 + k * 100, 0xffff);
}
shift_legacy_title_history(g);
for (size_t m = 0; m < g.manager_teams.size(); m++) {
for (size_t i = 0; i < 0x93; i++) rec8(g, int(m), 0xda + i) = rec8(g, int(m), 0xdd + i);
const size_t at = m * 0xB0C + 0x2aa;
@@ -1600,6 +1608,7 @@ SeasonTransitionOutcome season_transition(GameState& g, GameRandom& game, Watcom
}
g.memory.set8(::bmh::layout::CareerSession_RuntimeError_RuntimeField4, 0);
if (g.memory.has(::bmh::layout::Season_SeasonTransition_RuntimeField)) g.memory.set8(::bmh::layout::Season_SeasonTransition_RuntimeField, 0);
capture_title_history(g); // Preserve the current window before it advances/shifts.
g.season = int16_t(g.season + 1); // SeasonIndex
reset_club_moods(g, game, rand);
european_setup(g, game, rand, cup_draw);
@@ -1639,6 +1648,16 @@ SeasonTransitionOutcome season_transition(GameState& g, GameRandom& game, Watcom
namespace bmh {
void initialize_european_qualification_seed(GameState& g) {
constexpr uint32_t entry = layout::CupTable + 14 * 0x28;
if (g.memory.u16(entry + 0x22) == 0 && g.memory.u16(entry + 0x24) == 0) {
// OpenBMH deviates from the original: initializes the empty EM qualifier
// seeds with national teams, preventing club zero from entering the EM.
g.memory.set16(entry + 0x22, 357);
g.memory.set16(entry + 0x24, 358);
}
}
bool career_season_setup(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteReport& report,
const std::function<void(const char*)>& pause,
const SeasonCupDrawHook& cup_draw) {
@@ -1658,6 +1677,7 @@ bool career_season_setup(GameState& g, GameRandom& game, WatcomRandom& rand, Min
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField5, uint16_t(first_small + 0x1f));
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField4, uint16_t(first_small + 0x13));
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField3, uint16_t(foreign + 1));
initialize_european_qualification_seed(g);
mem.set16(::bmh::layout::Career_CompetitionPointersEnglish_ExecutableField28, 0);
mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField6, 0);
mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField5, 7);
+13 -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
@@ -187,6 +187,14 @@ void cup_group_overview_effects(GameState& g, int group_index);
// LeagueName: the name of a league below 5 (with its letter, e.g. for the third divisions).
std::string league_name(const GameState& g, int league);
// New careers: fill the original uninitialized EM qualification placeholders;
// preserve any nonzero seeds supplied by the installation.
void initialize_european_qualification_seed(GameState& g);
// Season boundary: reset manager boards, age/retire players and clear seasonal
// histories. Kept separate from cup draws, accounts and calendar advancement.
void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteReport& report);
// MonthChange(absolute squad slot): the player leaves his club for the free agents with new
// values (W and game draws) and an age W(4, 15); his club closes the gap (ReleasePlayer,
// with a human club its tactics board as well). False if the source ownership/state
+27
View File
@@ -2,6 +2,7 @@
#include "game/stadium_blocks.hpp"
#include "game/matchday.hpp"
#include "formats/le.hpp"
#include <algorithm>
#include <limits>
@@ -63,6 +64,32 @@ bool valid_resolved_offer(const StandBlockOffer& offer, const StadiumBlockExpans
}
} // namespace
StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage& image) {
// OpenBMH deviates from the original: allow 144,000 standard places and
// size-aware construction times while retaining edition-owned unit prices.
static constexpr std::array<uint32_t, 8> minima{
14000, 24000, 14000, 20000, 14000, 24000, 14000, 20000};
StadiumBlockExpansionConstants out;
uint32_t total = 0;
for (size_t i = 0; i < minima.size(); ++i) {
out.price_per_1000[i] = image.u32(
layout::CareerSession_DispatchStadium_RuntimeField + uint32_t((i + 8) * 4));
const auto original = uint32_t(image.u8(
layout::CareerSession_Invalid_RuntimeField + uint32_t(i))) * 1000;
out.max_places[i] = std::max(original, minima[i]);
total += out.max_places[i];
const auto source_weeks = image.u8(
layout::CareerSession_DispatchStadium_RuntimeField2 + uint32_t((i + 22) * 5));
const auto weeks = std::max<uint32_t>(source_weeks, 2 * (out.max_places[i] / 1000));
if (weeks > 255)
throw FormatError("stadium: expanded construction period exceeds saved byte");
out.weeks[i] = uint8_t(weeks);
}
if (total > 255000)
throw FormatError("stadium: combined stand limits exceed saved capacity byte");
return out;
}
std::optional<StadiumBlockExpansionQuote> quote_stadium_block_expansion(
const GameState& g, int manager, StadiumBlockSlot slot, uint32_t total_target_places,
uint8_t desired_features, int company_price_percent,
+4
View File
@@ -20,6 +20,10 @@ struct StadiumBlockExpansionConstants {
std::array<uint32_t, 8> max_places{};
};
// OpenBMH1.0.3 expands standard A-H limits to at least144k total. Prices
// still come from the edition; larger blocks have at least2weeks per1000places.
StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage&);
// An immutable quote binds the Source owner and every record/table value that
// affects the quote. Commit recomputes this value before it touches money.
struct StadiumBlockExpansionQuote {
+13 -1
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/state.hpp"
#include "game/bank_robbery.hpp"
#include <stdexcept>
@@ -99,7 +100,16 @@ GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
g.foreign_strength = bytes(::bmh::layout::ForeignClubStrength);
g.memory = StaticMemory(save);
// memory OpenBMH saves behind the trailer (the English cup blocks, career.hpp)
for (const auto& b : save.extension()) {
bool long_career_seen=false,robbery_months_seen=false;
for(const auto& b:save.extension()){
if(b.address==kLongCareerExtension){
if(long_career_seen)throw FormatError("long career: duplicate extension block");
decode_long_career(g,b.bytes);long_career_seen=true;continue;
}
if(b.address==kBankRobberyMonthExtension){
if(robbery_months_seen||b.bytes.size()!=kBankRobberyMonthBytes)throw FormatError("savegame: invalid or duplicate bank robbery monthly guard");
robbery_months_seen=true;
}
if (!g.memory.has(b.address)) g.memory.add_block(b.address, uint32_t(b.bytes.size()));
for (size_t i = 0; i < b.bytes.size(); ++i) g.memory.set8(b.address + uint32_t(i), b.bytes[i]);
}
@@ -110,6 +120,8 @@ GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
g.stadium_names = save.pool(3);
g.player_name_offsets = words16(::bmh::layout::PlayerNameOffsets);
g.season = int16_t(save.data(::bmh::layout::SeasonIndex)[0] | save.data(::bmh::layout::SeasonIndex)[1] << 8);
if (!g.title_history.empty() && (g.season < 0 || g.title_history.rbegin()->first > uint32_t(g.season)))
throw FormatError("long career: archived season is beyond the saved calendar");
return g;
}
+3
View File
@@ -17,6 +17,7 @@
#include "formats/textd.hpp"
#include "game/memory.hpp"
#include "game/random.hpp"
#include "game/long_career.hpp"
#include "game/reality_motion.hpp"
namespace bmh {
@@ -36,6 +37,8 @@ constexpr uint16_t kEmptySlot = 0x0FFF;
constexpr uint16_t kSlotInLineup = 0x8000;
struct GameState {
PlayerStatisticsArchive player_statistics;
TitleHistoryArchive title_history;
std::vector<uint16_t> squad_slots; // *SquadSlots, all squads back to back (see squad_range)
std::vector<Player> players; // *PlayerConditionTechniqueForm / *PlayerSkillWords / *PlayerIdentityWords, names not filled
std::vector<uint8_t> team_morale; // *TeamMorale, per team: bits 0-5 morale / 2, bits 6-7 flags
+48 -20
View File
@@ -1,12 +1,15 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/week.hpp"
#include "game/calendar.hpp"
#include "game/bank_robbery.hpp"
#include "game/matchday.hpp"
#include "game/lineup.hpp"
#include "game/schedule.hpp"
#include <algorithm>
#include <bit>
namespace bmh {
@@ -23,6 +26,23 @@ void wr32(std::vector<uint8_t>& v, size_t o, int32_t x) {
} // namespace
DailyInterestAmounts daily_interest_amounts(int32_t cash, int32_t deposit, int32_t credit) {
// OpenBMH deviates from the original: widen products before annual-rate
// division so valid native account amounts do not overflow intermediate sums.
// Preserve truncation at each original division, including deposit / 10000.
DailyInterestAmounts result;
if (cash < 0) {
const int64_t with_credit = int64_t(cash) + credit;
int64_t borrowing = with_credit < 0 ? with_credit * 18 / -36500 : 0;
borrowing += std::max(int64_t(cash), -int64_t(credit)) * 12 / -36500;
result.borrowing = int32_t(borrowing);
} else {
result.cash_and_deposit = cash / -36500;
}
result.cash_and_deposit += int32_t(int64_t(deposit / 10000) * 20000 / -36500);
return result;
}
void daily_interest(GameState& g, WatcomRandom& rand) {
// (DailyInterest before the day step: the training camp visits of today are over)
for (size_t m = 0; m < g.manager_teams.size(); m++) g.manager_records.at(m * kManagerRecord + 0x21f) &= 0x7f;
@@ -31,25 +51,29 @@ void daily_interest(GameState& g, WatcomRandom& rand) {
const int32_t balance = rd32(g.manager_records, rec + 0x314);
const int32_t deposit = rd32(g.manager_records, rec + 0x318);
const int32_t credit = rd32(g.manager_records, rec + 0x31c);
int32_t amount = 0; // positive = cost
const auto interest = daily_interest_amounts(balance, deposit, credit);
if (balance < 0) {
if (balance + credit < 0) amount = ((balance + credit) * 18) / -36500;
int32_t used = -credit < balance ? balance : -credit;
amount += (used * 12) / -36500;
wr32(g.manager_records, rec + 0x89c, rd32(g.manager_records, rec + 0x89c) + amount);
book_money(g, k, amount, true);
amount = 0;
} else {
amount = balance / -36500;
const auto statistic = uint32_t(rd32(g.manager_records, rec + 0x89c)) + uint32_t(interest.borrowing);
wr32(g.manager_records, rec + 0x89c, std::bit_cast<int32_t>(statistic));
book_money(g, k, interest.borrowing, true);
}
amount += ((deposit / 10000) * 20000) / -36500;
wr32(g.manager_records, rec + 0x870, rd32(g.manager_records, rec + 0x870) - amount);
book_money(g, k, amount, true);
if (rd32(g.manager_records, rec + 0x314) > 100000000) { // read again after the bookings
int32_t extra = int32_t(rand.range(10000, 20000)) * 1000;
// BookMoney2 with the statistics flag set: counts as an expense (+0x8a0)
wr32(g.manager_records, rec + 0x8a0, rd32(g.manager_records, rec + 0x8a0) + extra);
book_money(g, k, extra, true);
const auto statistic = uint32_t(rd32(g.manager_records, rec + 0x870)) - uint32_t(interest.cash_and_deposit);
wr32(g.manager_records, rec + 0x870, std::bit_cast<int32_t>(statistic));
book_money(g, k, interest.cash_and_deposit, true);
if (rd32(g.manager_records, rec + 0x314) > 100000000) {
const auto robbery_month = bank_robbery_month_key(g.date);
const auto guard = bank_robbery_guard_month(g, k);
// OpenBMH deviates from the original: an unknown history receives
// a grace month; later losses occur at most once per source month.
if (!guard) {
set_bank_robbery_guard_month(g, k, robbery_month);
} else if (*guard != robbery_month) {
const int32_t extra = int32_t(rand.range(10000, 20000)) * 1000;
const auto expense = uint32_t(rd32(g.manager_records, rec + 0x8a0)) + uint32_t(extra);
wr32(g.manager_records, rec + 0x8a0, std::bit_cast<int32_t>(expense));
book_money(g, k, extra, true);
set_bank_robbery_guard_month(g, k, robbery_month);
}
}
}
}
@@ -93,9 +117,7 @@ int attribute(Player& p, int area, bool write, int delta, int max) {
} // namespace
int weekday_code(uint32_t date) {
int c = int(date % 7) + 2;
if (c > 6) c = int(date % 7) - 5;
return c;
return int((date % 7 + uint32_t(calendar_epoch().weekday)) % 7);
}
void familiarity_decay(GameState& g, GameRandom& game, WatcomRandom& rand) {
@@ -369,6 +391,12 @@ void stock_market(GameState& g, GameRandom& game) {
namespace bmh {
uint32_t bank_robbery_month_key(uint32_t date) {
const int month = month_code(date);
while (date > 0 && month_code(date - 1) == month) --date;
return date;
}
int month_code(uint32_t date) {
// DeskState_DeskDate_RuntimeField: days per month (index 1-12; February 29 in leap years)
uint8_t days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+6
View File
@@ -28,6 +28,12 @@ namespace bmh {
// cleared for every manager.
void daily_interest(GameState& g, WatcomRandom& rand);
struct DailyInterestAmounts {
int32_t borrowing = 0;
int32_t cash_and_deposit = 0; // Negative amounts are interest income.
};
DailyInterestAmounts daily_interest_amounts(int32_t cash, int32_t deposit, int32_t credit);
} // namespace bmh
namespace bmh {
+44 -1
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/weekly.hpp"
#include "game/desk_actions.hpp"
#include "game/pending_offer.hpp"
#include "game/human_buyer_sale.hpp"
#include "game/transfer_bid.hpp"
@@ -215,7 +216,7 @@ void manager_offers(GameState& g, int manager, WatcomRandom& rand, MinuteReport&
if (kind == 14) {
for (int k = 0; k < 6; k++) {
const uint32_t held = g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(k) * 0x1c);
const uint32_t value = uint32_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c) * uint32_t(kShareFactor[k])) / 10000;
const uint32_t value = uint32_t((uint64_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c)) * uint32_t(kShareFactor[k])) / 10000);
sum += int(uint32_t(rand.range(10, 20)) * (held * value));
}
if (sum == 0) continue;
@@ -1637,6 +1638,7 @@ static TransferOfferListView project_transfer_offer_list_impl(const GameState& g
view.player = player;
view.seller = g.memory.u16(list + 8) & 0x7fff;
view.seller_manager = g.manager_of(view.seller);
offer_bases(g.memory, list, -1, view.asking_fee, view.asking_monthly_salary);
for (int bid = 0; bid < 4; ++bid) view.offers[size_t(bid)].bid_index = bid;
if (view.seller_manager >= 0 && g.memory.has(::bmh::layout::DeskActions_Unsupported_RuntimeField + uint32_t(view.seller_manager)))
view.seller_loan_count = g.memory.u8(::bmh::layout::DeskActions_Unsupported_RuntimeField + uint32_t(view.seller_manager));
@@ -2621,6 +2623,47 @@ PendingOfferResult process_national_nomination_pending_after_desk(GameState& g,
return process_natural_pending_offers_after_desk(g,request,game,rand,hooks,report);
}
TransferActionResult accept_manager_transfer_offer(GameState& g, int manager, int entry,
int expected_player, int bid, WatcomRandom& rand, MinuteReport& report, TransferAllocatorContext allocator) {
TransferActionResult result;
const auto view = project_transfer_offer_list(g, entry);
if (!view.valid || manager < 0 || view.seller_manager != manager ||
view.player != expected_player || bid < 0 || bid >= 4) return result;
const auto& offer = view.offers[size_t(bid)];
if (!offer.present) return result;
if (!offer.affordable) { result.status = TransferActionStatus::insufficient_funds; return result; }
if (!offer.has_squad_room) { result.status = TransferActionStatus::no_squad_room; return result; }
if (!offer.passes_foreign_limit || !offer.loan_permitted) {
result.status = TransferActionStatus::blocked_by_board; return result;
}
if (!offer.transaction_supported) { result.status = TransferActionStatus::unsupported; return result; }
const uint32_t list = kTransferList + uint32_t(entry) * kListEntry;
auto staged = g;
auto staged_rand = rand;
const uint32_t salary_at = list + 0x0c + uint32_t(bid) * 4;
const auto salary = staged.memory.u32(salary_at);
staged.memory.set32(salary_at, (salary * 10u) >> 3);
uint32_t fee_pct = 0, salary_pct = 0;
const bool rated = evaluate_bid(staged, list, bid, fee_pct, salary_pct, staged_rand, report);
staged.memory.set32(salary_at, salary);
if (!rated || report.unsupported) { result.status = TransferActionStatus::unsupported; return result; }
if (!salary_pct) { result.status = TransferActionStatus::rejected; return result; }
if (!accept_transfer_bid_immediately(staged, entry, bid, staged_rand, report,
allocator) || report.unsupported) {
result.status = TransferActionStatus::unsupported; return result;
}
const auto buyer_range = squad_range(offer.buyer);
const bool moved = std::any_of(staged.squad_slots.begin() + buyer_range.first,
staged.squad_slots.begin() + buyer_range.first + buyer_range.count,
[&](uint16_t slot) { return (slot & 0xfff) == expected_player; });
if (!moved) { result.status = TransferActionStatus::unsupported; return result; }
g = std::move(staged); rand = staged_rand;
result.status = TransferActionStatus::accepted;
result.player = expected_player; result.list_entry = entry;
result.fee = int32_t(offer.fee); result.annual_salary = int32_t(offer.monthly_salary);
return result;
}
bool accept_transfer_bid_immediately(GameState& g, int entry, int bid, WatcomRandom& rand,
MinuteReport& report, TransferAllocatorContext allocator) {
if (entry < 0 || entry >= 40 || bid < 0 || bid >= 4) return false;
+11 -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"
@@ -26,6 +25,8 @@ namespace {
constexpr uint32_t kEnFileOffset = 0x496d;
constexpr uint32_t kEnDataStart = ::bmh::layout::EnDataStart, kEnDataEnd = ::bmh::layout::Career_CompetitionPointersEnglish_RuntimeField;
constexpr uint32_t kFltdSize = 507925;
constexpr uint32_t kEnglishCalendarDateSetup = 0x684;
constexpr uint32_t kEnglishOverwriteQuestionPointer = 0x6c43c;
// The German image the engine expects: LE objects from layout field, data object GermanDataSegmentBegin-layout field.
constexpr uint32_t kDeBase = 0x10000, kDeEnd = ::bmh::layout::GermanImageEnd;
// A zero byte in the German BSS: the empty string of empty_pointers entries.
@@ -119,8 +120,16 @@ LeImage translate_fltd(const fs::path& fltd_exe) {
}
}
}
// Preserve the English date-setup operands in the shared epoch slot. The
// English routine uses a different stack layout; the calendar reader
// verifies that layout before reading its year and weekday.
for (uint32_t i = 0; i < 14; ++i)
put(layout::CalendarDateSetup + i, en(kEnglishCalendarDateSetup + i));
// The native 11x11 pointer is an edition-owned indexed bitmap.
for (uint32_t i = 0; i < 11 * 11; ++i)
put(::bmh::layout::OriginalPointerPixels + i,
en(::bmh::layout::EnglishOriginalPointerPixels + i));
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
apply_rule_base(out);
return out;
}
+15 -1
View File
@@ -96,6 +96,9 @@
{::bmh::layout::TeamStatistics_Render_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation72, {}},
{::bmh::layout::DeskDrawers_Curve_ExecutableField, 24, Kind::copy, ::bmh::layout::EnglishLayoutTranslation160, {}},
{::bmh::layout::DeskState_FormatError_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation161, {}},
{::bmh::layout::Desktop_Render_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishDesktopBinSourceX, {}},
{::bmh::layout::Desktop_Render_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishDesktopBinSourceY, {}},
{::bmh::layout::Desktop_Render_RuntimeField3, 2, Kind::copy, ::bmh::layout::EnglishDesktopSocketSourceX, {}},
{::bmh::layout::Tactics_DrawSetting_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation224, {}},
{::bmh::layout::Tactics_DrawSetting_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation225, {}},
{::bmh::layout::Tactics_DrawSetting_RuntimeField3, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation226, {}},
@@ -119,7 +122,15 @@
{::bmh::layout::TransferMarket_Click_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation246, {}},
{::bmh::layout::TransferMarket_Click_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation246, {}},
{::bmh::layout::TransferMarket_Click_RuntimeField3, 74, Kind::copy, ::bmh::layout::EnglishLayoutTranslation247, {}},
{::bmh::layout::Bank_OriginalToUtf8_RuntimeField, 144, Kind::empty_pointers, 0, {}},
// Keep the overwrite pointer's next entry exactly four bytes away: copy
// entries extend to their following destination, while other slots stay empty.
{::bmh::layout::Bank_OriginalToUtf8_RuntimeField,
::bmh::layout::SaveLoad_OverwriteQuestionPointer - ::bmh::layout::Bank_OriginalToUtf8_RuntimeField,
Kind::empty_pointers, 0, {}},
{::bmh::layout::SaveLoad_OverwriteQuestionPointer, 4, Kind::copy, kEnglishOverwriteQuestionPointer, {}},
{::bmh::layout::SaveLoad_OverwriteQuestionPointer + 4,
::bmh::layout::Bank_OriginalToUtf8_RuntimeField + 144 - (::bmh::layout::SaveLoad_OverwriteQuestionPointer + 4),
Kind::empty_pointers, 0, {}},
{::bmh::layout::Analytics_FormatError_ExecutableField, 72, Kind::copy, ::bmh::layout::EnglishLayoutTranslation50, {}}, // EN196f1: graph labels, distinct from fund-name suffixes
{::bmh::layout::AdGroupId, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation51, {}},
{::bmh::layout::GameEnd_SourceHyphenator_ExecutableField, 18, Kind::copy, ::bmh::layout::EnglishLayoutTranslation52, {}},
@@ -222,6 +233,9 @@
{::bmh::layout::ClubPlayerDetail_ClubPlayerDetailRedraw_RuntimeField2, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation156, {}},
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField7, 10, Kind::copy, ::bmh::layout::EnglishLayoutTranslation157, {}},
{::bmh::layout::Pitch_Render_RuntimeField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation163, {}},
{::bmh::layout::PitchPreferenceDepthBases, 4, Kind::copy, ::bmh::layout::EnglishPitchPreferenceDepthBases, {}},
{::bmh::layout::PitchPreferenceRed, 10, Kind::copy, ::bmh::layout::EnglishPitchPreferenceRed, {}},
{::bmh::layout::PitchPreferenceGreen, 10, Kind::copy, ::bmh::layout::EnglishPitchPreferenceGreen, {}},
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation176, {}},
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation177, {}},
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField3, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation178, {}},
+1 -1
View File
@@ -379,7 +379,7 @@ ResolvedGame resolve_game(const fs::path& input, const fs::path& cache) {
const fs::path marker = prepared / ".openbmh-english";
// the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built
// by another version is built again
constexpr const char* kTranslation = "english translation 12"; // 12: contract warning ContractExpiryWarningText; 11: statistics windows, graph labels/count classes, streaks and national-badge banks
constexpr const char* kTranslation = "english translation 16"; // 16: overwrite question pointer (15: original pitch affinity tables and pointer bitmap)
std::string built;
{
std::ifstream in(marker);
+9
View File
@@ -80,6 +80,10 @@ target_link_libraries(openbmh_ui PRIVATE bmhui ${BMH_SDL_TARGET})
add_executable(ui_setup_tests tests.cpp)
target_link_libraries(ui_setup_tests PRIVATE bmhui)
bmh_add_data_test(NAME ui_setup_tests COMMAND ui_setup_tests "${BMH_DATA}")
add_executable(ui_save_load_tests save_load_tests.cpp)
target_link_libraries(ui_save_load_tests PRIVATE bmhui)
bmh_add_data_test(NAME ui_save_load_tests COMMAND ui_save_load_tests "${BMH_DATA}")
add_executable(ui_national_friendly_tests ../../tests/national_friendly_ui_tests.cpp)
target_link_libraries(ui_national_friendly_tests PRIVATE bmhui)
add_test(NAME ui_national_friendly_tests COMMAND ui_national_friendly_tests)
@@ -90,6 +94,7 @@ set(BMH_UI_REFERENCE_SAVE "" CACHE FILEPATH "Optional original LABA0012 desktop
add_executable(ui_desktop_tests desktop_tests.cpp)
target_link_libraries(ui_desktop_tests PRIVATE bmhui)
set(BMH_TEST_UI_DESKTOP_TESTS_INPUT_1 "" CACHE PATH "External input 1 for ui_desktop_tests; not distributed")
bmh_add_data_test(NAME ui_desktop_input_tests COMMAND ui_desktop_tests "${BMH_DATA}" --input-only)
bmh_add_data_test(NAME ui_desktop_tests REQUIRED_OPTIONS BMH_TEST_UI_DESKTOP_TESTS_INPUT_1 COMMAND ui_desktop_tests "${BMH_DATA}" "${BMH_UI_REFERENCE_SAVE}"
"${BMH_TEST_UI_DESKTOP_TESTS_INPUT_1}")
set(BMH_UI_PREPARATION_SAVE "" CACHE FILEPATH "Optional original LABA0020 reference after observed menu entry effects; never bundled")
@@ -239,3 +244,7 @@ bmh_add_data_test(NAME transfer_history_tests COMMAND transfer_history_tests "${
add_executable(sportschau_ui_tests ../../tests/sportschau_ui_tests.cpp)
target_link_libraries(sportschau_ui_tests PRIVATE bmhui)
bmh_add_data_test(NAME sportschau_ui_tests COMMAND sportschau_ui_tests "${BMH_DATA}")
add_executable(live_score_reveal_tests live_score_reveal_tests.cpp)
target_link_libraries(live_score_reveal_tests PRIVATE bmhui)
add_test(NAME live_score_reveal_tests COMMAND live_score_reveal_tests)
+63 -31
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "ui/advertising.hpp"
#include "ui/game_end.hpp"
@@ -87,7 +88,7 @@ int32_t original_share_adjustment(const GameState& game, int manager, bool incom
if (income) {
for (int k = 0; k < 6; ++k) {
const uint32_t shares = game.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c);
const uint32_t unit = uint32_t(shares) * uint32_t(kShareUnits[size_t(k)]) / 10000;
const uint32_t unit = uint32_t((uint64_t(shares) * uint32_t(kShareUnits[size_t(k)])) / 10000);
const uint32_t owned = game.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(k) * 0x1c);
amount = wrap_add(amount, signed32(unit * owned));
}
@@ -182,10 +183,9 @@ AdvertisingFinancePreview original_finance_preview_impl(const GameState& game, i
std::array<int, 13>{0,31,28,31,30,31,30,31,31,30,31,30,31}[size_t(month)];
income = wrap_add(income, wrap_neg(wrap_mul(original_finance_adjustment(game, manager), month_factor)));
// OpenBMH deviates from the original: uses the supported youth-academy cap and its saved cost fields.
// OriginalFinancePreview(0): pure amount of BMHExeXa, record +0x854/+0x858,
// OriginalFinancePreview(0): pure amount of BMHExeXa, record +0x854/+0x858,
// MonthlyPay flags 0x0a (salary+bonus without statistic writes), and six
// saved supported rule profile cost words. The cap for index 1 comes from TeamLeague3.
// saved monthly environment budgets.
int32_t expenses = 0;
for (int i = 0; i < 14; ++i) expenses = wrap_add(expenses, kFacilityCost[size_t(i)]);
for (int i = 14; i < 22; ++i)
@@ -202,18 +202,8 @@ AdvertisingFinancePreview original_finance_preview_impl(const GameState& game, i
expenses = wrap_add(expenses, signed32(u32(game.tactics, board + 0x50)));
expenses = wrap_add(expenses, int32_t(bonus));
}
const int team = int(u32(game.manager_records, rec + 0x290) & 0xffff);
const int league = team > 0x164 ? 0 : team_league(team); // TeamLeague2
const int32_t youth_cap = league == 0 ? 1500000 : league == 1 ? 1000000 :
league <= 3 ? 580000 : 280000;
for (int k = 0; k < 6; ++k) {
int32_t item = mem_i32(game, ::bmh::layout::Spending + uint32_t(manager) * 0x24 + uint32_t(k) * 4);
if (k == 0 || k == 2) {
// MonthlyExpenses clears these indexes unconditionally (CMP AX,3 / CMP AX,1).
item = 0;
} else if (k == 1 && item != 0) {
item = u32(game.manager_records, rec + 0x880) < uint32_t(youth_cap) ? youth_cap : 0;
}
const int32_t item = environment_monthly_cost(game, manager, k);
expenses = wrap_add(expenses, item);
}
expenses = wrap_add(expenses, wrap_neg(original_share_adjustment(game, manager, false)));
@@ -689,16 +679,14 @@ Image AdvertisingScreen::render() const {
draw_finance(state_.finance_preview.expenses_text, 198, 222);
text(image, 254, 218, state_.finance_preview.balance_text, 0x6b, 64);
if (selected_contract_ >= 0) {
const auto& contract = selected_contract_ < kBoardCount
? state_.boards[size_t(selected_contract_)]
: selected_contract_ == 14 ? state_.shirt : state_.television;
if (selected_contract_ < 16) {
const int i = selected_contract_;
rectangle(image, exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + uint32_t(i) * 2), exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + uint32_t(i) * 2),
exe.u16(::bmh::layout::Advertising_Click_RuntimeField5 + uint32_t(i) * 2), exe.u16(::bmh::layout::Advertising_Click_RuntimeField6 + uint32_t(i) * 2), 0x27);
}
const auto& offer_list = state_.offers[size_t(selected_contract_)];
// The original details panel follows the pointer until the offer browser owns it.
const int details_target = offer_open_ ? selected_contract_ :
hovered_target_ >= 0 && hovered_target_ < 16 ? hovered_target_ : -1;
if (details_target >= 0) {
const auto& contract = details_target < kBoardCount
? state_.boards[size_t(details_target)]
: details_target == 14 ? state_.shirt : state_.television;
const auto& offer_list = state_.offers[size_t(details_target)];
const bmh::AdvertisingOfferCandidate* offer = nullptr;
if (offer_open_ && selected_offer_ >= 0)
for (const auto& candidate : offer_list.offers)
@@ -742,7 +730,7 @@ Image AdvertisingScreen::render() const {
}
text(image, 156, 185, show_offer ? state_.offer_label : state_.bonus_label, 0x6c, 34);
text(image, 191, 185, original_to_utf8(exe_.cstring(::bmh::layout::Advertising_FormatError_ExecutableField)) + (show_offer
? state_.offer_amount_text[size_t(selected_contract_)][size_t(selected_offer_)]
? state_.offer_amount_text[size_t(details_target)][size_t(selected_offer_)]
: contract.amount_text), 0x6c, 100);
if (!offer_open_ && contract.active && contract.months_remaining == 0 &&
contract.extension_months != 0)
@@ -771,10 +759,12 @@ Image AdvertisingScreen::render() const {
button(image, 164, 191, 66, state_.accept_label);
}
}
if (selected_spending_slot_ >= 16 && selected_spending_slot_ <= 18) {
const uint32_t i = uint32_t(selected_spending_slot_);
rectangle(image, exe_.u16(::bmh::layout::Advertising_Click_RuntimeField3 + i * 2), exe_.u16(::bmh::layout::Advertising_Click_RuntimeField4 + i * 2),
exe_.u16(::bmh::layout::Advertising_Click_RuntimeField5 + i * 2), exe_.u16(::bmh::layout::Advertising_Click_RuntimeField6 + i * 2), 0x27);
if (hovered_target_ >= 0) {
const uint32_t at = uint32_t(hovered_target_) * 2;
rectangle(image, exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + at),
exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + at),
exe.u16(::bmh::layout::Advertising_Click_RuntimeField5 + at),
exe.u16(::bmh::layout::Advertising_Click_RuntimeField6 + at), 0x27);
}
if (spending_calculator_open_ && spending_backdrop_) image = *spending_backdrop_;
if (notification_open()) draw_notification(image);
@@ -868,6 +858,7 @@ void AdvertisingScreen::draw_notification(Image& out) const {
bool AdvertisingScreen::dismiss_notification() {
if (!notification_open()) return false;
notification_dismissed_ = true;
refresh_hover();
return true;
}
@@ -904,6 +895,7 @@ void AdvertisingScreen::open_spending_calculator(int display_slot) {
void AdvertisingScreen::close_spending_calculator() {
spending_calculator_open_ = false;
spending_backdrop_.reset();
refresh_hover();
}
bool AdvertisingScreen::accept_spending_calculator() {
@@ -951,6 +943,7 @@ bool AdvertisingScreen::text(std::string_view input) {
void AdvertisingScreen::begin_offer_browser(int display_slot) {
selected_contract_ = display_slot;
hovered_target_ = display_slot;
offer_open_ = true;
selected_offer_ = -1;
const auto& offers = state_.offers[size_t(display_slot)].offers;
@@ -1010,11 +1003,41 @@ bool AdvertisingScreen::reject_action(std::string reason) {
(void)utf8_to_original(reason);
if (pending_->kind == AdvertisingActionKind::set_spending) close_spending_calculator();
pending_.reset();
refresh_hover();
feedback_ = std::move(reason);
return true;
}
void AdvertisingScreen::refresh_hover() {
if (pointer_position_) (void)move((*pointer_position_)[0], (*pointer_position_)[1]);
else hovered_target_ = -1;
}
bool AdvertisingScreen::move(int x, int y) {
// Modal input freezes the parent view, but its last physical position must
// be sampled again as soon as that modal returns.
pointer_position_ = std::array<int, 2>{x, y};
if (close_requested_ || pending_ || notification_open() || spending_calculator_open_ || offer_open_)
return false;
int target = -1;
for (int i = 0; i < 19; ++i) {
const uint32_t at = uint32_t(i) * 2;
const int left = exe_.u16(::bmh::layout::Advertising_Click_RuntimeField3 + at);
const int top = exe_.u16(::bmh::layout::Advertising_Click_RuntimeField4 + at);
const int width = exe_.u16(::bmh::layout::Advertising_Click_RuntimeField5 + at);
const int height = exe_.u16(::bmh::layout::Advertising_Click_RuntimeField6 + at);
if (x >= left && x < left + width && y >= top && y < top + height) {
target = i;
break;
}
}
if (target == hovered_target_) return false;
hovered_target_ = target;
return true;
}
bool AdvertisingScreen::click(int x, int y) {
pointer_position_ = std::array<int, 2>{x, y};
if (close_requested_ || pending_ || x < 0 || y < 0 || x >= 320 || y >= 240) return false;
if (notification_open()) return dismiss_notification();
if (spending_calculator_open_) {
@@ -1045,6 +1068,7 @@ bool AdvertisingScreen::click(int x, int y) {
offer_open_ = false;
selected_offer_ = -1;
feedback_.clear();
refresh_hover();
return true;
}
if (x >= 164 && x <= 229 && y >= 191 && y <= 200) {
@@ -1066,6 +1090,7 @@ bool AdvertisingScreen::click(int x, int y) {
const int right = left + exe_.u16(::bmh::layout::Advertising_Click_RuntimeField5 + uint32_t(i) * 2);
const int bottom = top + exe_.u16(::bmh::layout::Advertising_Click_RuntimeField6 + uint32_t(i) * 2);
if (x >= left && x < right && y >= top && y < bottom) {
(void)move(x, y);
const auto& projected = state_.offers[size_t(i)];
const bool renewal_due = projected.contract_slot >= 0 && projected.contract_slot < 16 &&
(projected.contract_bytes[6] & 0x7f) != 0 && projected.contract_bytes[5] == 0;
@@ -1096,6 +1121,7 @@ bool AdvertisingScreen::click(int x, int y) {
const int right = left + exe_.u16(::bmh::layout::Advertising_Click_RuntimeField5 + uint32_t(i) * 2);
const int bottom = top + exe_.u16(::bmh::layout::Advertising_Click_RuntimeField6 + uint32_t(i) * 2);
if (x >= left && x < right && y >= top && y < bottom) {
(void)move(x, y);
selected_contract_ = -1;
selected_spending_slot_ = i;
open_spending_calculator(i);
@@ -1120,7 +1146,12 @@ bool AdvertisingScreen::key(std::string_view value) {
return text(value);
}
if (value == "ESC") {
if (offer_open_) { offer_open_ = false; selected_offer_ = -1; return true; }
if (offer_open_) {
offer_open_ = false;
selected_offer_ = -1;
refresh_hover();
return true;
}
close_requested_ = true;
return true;
}
@@ -1132,6 +1163,7 @@ std::string AdvertisingScreen::state_json() const {
if (!result.empty() && result.back() == '}') result.pop_back();
result += ",\"spending_calculator_open\":" +
std::string(spending_calculator_open_ ? "true" : "false") +
",\"hovered_target\":" + std::to_string(hovered_target_) +
",\"selected_spending_slot\":" + std::to_string(selected_spending_slot_) +
",\"spending_input\":" + std::to_string(spending_input_) +
",\"notification_open\":" + std::string(notification_open() ? "true" : "false");
+6
View File
@@ -105,6 +105,7 @@ public:
AdvertisingScreen(const std::filesystem::path& data, AdvertisingState state,
uint64_t request_id_seed = 1);
Image render() const;
bool move(int x, int y);
bool click(int x, int y);
bool key(std::string_view key);
bool open_offers(int display_slot);
@@ -112,6 +113,8 @@ public:
const std::optional<AdvertisingRequest>& pending() const { return pending_; }
bool reject_action(std::string reason);
int selected_contract() const { return selected_contract_; }
int hovered_target() const { return hovered_target_; }
std::optional<std::array<int, 2>> pointer_position() const { return pointer_position_; }
int selected_offer() const { return selected_offer_; }
bool offer_open() const { return offer_open_; }
bool spending_calculator_open() const { return spending_calculator_open_; }
@@ -136,6 +139,8 @@ private:
std::optional<Image> badge_atlas_;
std::optional<Image> spending_backdrop_;
int selected_contract_ = -1;
int hovered_target_ = -1;
std::optional<std::array<int, 2>> pointer_position_;
int selected_spending_slot_ = -1;
int selected_offer_ = -1;
uint64_t next_request_id_ = 1;
@@ -157,6 +162,7 @@ private:
bool accept_spending_calculator();
void close_spending_calculator();
bool dismiss_notification();
void refresh_hover();
void draw_spending_calculator(Image&) const;
void draw_notification(Image&) const;
void pattern_rect(Image&, int x, int y, int width, int height) const;
+90 -6
View File
@@ -3,6 +3,7 @@
#include "ui/advertising.hpp"
#include "ui/source_notice_test_helpers.hpp"
#include <algorithm>
#include <array>
#include <filesystem>
#include <functional>
@@ -167,17 +168,17 @@ int main(int argc, char** argv) {
cap_fixture.memory.set32(::bmh::layout::Spending + 4, 99);
cap_fixture.memory.set32(::bmh::layout::Spending, 111);
cap_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 1543400,
"costs 0/2 stay zero while the youth-cost item uses the source league cap");
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 43832,
"all three youth budgets enter the monthly finance preview");
put32(cap_fixture.manager_records, 0x880, 1500000);
const auto no_cap_preview = advertising_from_game(cap_fixture, 0).finance_preview;
check(no_cap_preview.expenses == 43400,
"the youth-cost item is suppressed once funds reach the strict source threshold");
check(no_cap_preview.expenses == 43832,
"ordinary monthly youth budgets continue after the former academy threshold");
GameState ignored_cost_fixture = finance_fixture;
ignored_cost_fixture.memory.set32(::bmh::layout::Spending, 111);
ignored_cost_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43400,
"legacy routine clears cost items zero and two regardless of their saved values");
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43733,
"the youngest and oldest youth budgets both enter expenses");
GameState loan_fixture = finance_fixture;
loan_fixture.memory.set32(::bmh::layout::Loans + 8, 100);
const auto loan_preview = advertising_from_game(loan_fixture, 0).finance_preview;
@@ -281,6 +282,54 @@ int main(int argc, char** argv) {
check(pixel(first, exe.u16(::bmh::layout::Advertising_Click_RuntimeField3) + x, exe.u16(::bmh::layout::Advertising_Click_RuntimeField4) + y) ==
pixel(logos, x, y),
"active board logos use the original KB/34 partner sprite and hitbox coordinates");
// Motion alone must display the original rectangle and details; it must
// never open negotiations, spending, or emit an engine action.
AdvertisingScreen hover(data, state);
for (int target = 0; target < 19; ++target) {
const uint32_t at = uint32_t(target) * 2;
const int x = exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + at);
const int y = exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + at);
const int width = exe.u16(::bmh::layout::Advertising_Click_RuntimeField5 + at);
const int height = exe.u16(::bmh::layout::Advertising_Click_RuntimeField6 + at);
check(hover.move(x + 1, y + 1) && hover.hovered_target() == target &&
!hover.move(x + 2, y + 2) && !hover.pending() && !hover.offer_open() &&
!hover.spending_calculator_open() && hover.selected_contract() == -1,
"pointer motion follows every original advertising target without an action");
const auto highlighted = hover.render();
for (int dx = 0; dx < width; ++dx)
check(pixel(highlighted, x + dx, y) == 0x27 &&
pixel(highlighted, x + dx, y + height - 1) == 0x27,
"hover paints the original yellow top and bottom rectangle edges");
for (int dy = 0; dy < height; ++dy)
check(pixel(highlighted, x, y + dy) == 0x27 &&
pixel(highlighted, x + width - 1, y + dy) == 0x27,
"hover paints the original yellow left and right rectangle edges");
check(hover.move(-1, -1) && hover.hovered_target() == -1 &&
hover.render().pixels == first.pixels && !hover.move(-1, -1),
"leaving a target restores both the outline and details without sticky selection");
}
const int empty_slot = int(std::find_if(state.boards.begin(), state.boards.end(),
[](const auto& contract) { return !contract.active; }) - state.boards.begin());
check(empty_slot < 14 && !state.space_available_text.empty(),
"fixture provides an empty advertising surface and edition-specific help");
auto no_help_state = state;
no_help_state.space_available_text.clear();
AdvertisingScreen no_help(data, no_help_state);
const int empty_x = exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + empty_slot * 2) + 1;
const int empty_y = exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + empty_slot * 2) + 1;
check(hover.move(empty_x, empty_y) && no_help.move(empty_x, empty_y) &&
hover.render().pixels != no_help.render().pixels &&
state.space_available_text == original_to_utf8(message_text(game,
::bmh::layout::Advertising_FormatError_TextPointer7)),
"empty-surface hover renders help from the installation's actual TEXTD pointer");
AdvertisingScreen spending_hover(data, state);
const int spending_x = exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + 17 * 2) + 1;
const int spending_y = exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + 17 * 2) + 1;
check(spending_hover.move(spending_x, spending_y) && hover.move(spending_x, spending_y) &&
hover.render().pixels == spending_hover.render().pixels,
"moving directly from empty-surface help to spending clears the contract detail panel");
check(game.manager_records == records_before,
"all hover targets and help rendering leave the manager records unchanged");
check(screen.click(exe.u16(::bmh::layout::Advertising_Click_RuntimeField3) + 1, exe.u16(::bmh::layout::Advertising_Click_RuntimeField4) + 1) &&
screen.selected_contract() == 0,
"a board click selects a local read-only details panel");
@@ -295,6 +344,9 @@ int main(int argc, char** argv) {
screen.key("ESC") && screen.close_requested() && !screen.key("LEFT"),
"ESC closes an existing offer browser before the screen");
} else {
check(screen.move(-1, -1) && screen.render().pixels == first.pixels &&
screen.selected_contract() == 0,
"a clicked contract without offers does not leave a sticky outline or details");
check(screen.key("ESC") && screen.close_requested() && !screen.key("LEFT"),
"without a saved offer, ESC closes the contract details directly");
}
@@ -318,6 +370,10 @@ int main(int argc, char** argv) {
const bool opened = offers.open_offers(0);
check(opened && offers.offer_open() && offers.selected_offer() == 5,
"opening the source offer browser selects the highest saved raw offer");
const auto offer_pixels = offers.render().pixels;
check(!offers.move(empty_x, empty_y) && offers.render().pixels == offer_pixels &&
offers.selected_offer() == 5 && !offers.pending(),
"offer browser keeps its input and details when the pointer crosses the parent targets");
check(offers.click(140, 164) && offers.selected_offer() == 4 &&
!offers.click(190, 195) && !offers.pending(),
"an empty raw slot cannot create an acceptance request");
@@ -351,6 +407,17 @@ int main(int argc, char** argv) {
offers.close_requested(),
"cancel closes the offer browser first; a second ESC closes the screen");
AdvertisingScreen resumed_offers(data, offer_state);
const auto closed_offer_pixels = resumed_offers.render().pixels;
check(resumed_offers.open_offers(0) && !resumed_offers.move(-1, -1) &&
resumed_offers.key("ESC") && resumed_offers.hovered_target() == -1 &&
resumed_offers.render().pixels == closed_offer_pixels,
"offer ESC rechecks the pointer moved during the modal without another motion event");
check(resumed_offers.open_offers(0) && resumed_offers.click(110, 195) &&
resumed_offers.hovered_target() == -1 &&
resumed_offers.render().pixels == closed_offer_pixels,
"offer cancel rechecks its own click position and removes the old target outline");
// The three source spending controls open the original calculator. All
// editing remains local; only J/Enter on a changed value creates a
// manager/revision-bound request for the app controller.
@@ -377,6 +444,9 @@ int main(int argc, char** argv) {
"the original merchandise hitbox opens its calculator with the saved value");
const auto calculator_art = load_vga(asset_path(data / "KB", "6.VGA"));
const auto calculator_image = merchandise.render();
check(!merchandise.move(empty_x, empty_y) &&
merchandise.render().pixels == calculator_image.pixels && !merchandise.pending(),
"spending calculator retains its captured parent and does not hover through it");
check(calculator_image.pixels[size_t(55) * 320 + 103] == calculator_art.pixels[0],
"the calculator opens over the original advertising screen using KB/6 at source coordinates");
check(merchandise.text("200000") && merchandise.spending_input() == 200000 &&
@@ -411,6 +481,20 @@ int main(int argc, char** argv) {
unchanged_budget.spending_input() == 10000 && unchanged_budget.key("J") &&
!unchanged_budget.pending() && !unchanged_budget.spending_calculator_open(),
"accepting an unchanged monthly budget closes locally without an engine request");
AdvertisingScreen resumed_budget(data, spending_state);
const auto closed_budget_pixels = resumed_budget.render().pixels;
check(resumed_budget.click(budget_x, budget_y) && !resumed_budget.move(-1, -1) &&
resumed_budget.key("ESC") && resumed_budget.hovered_target() == -1 &&
resumed_budget.render().pixels == closed_budget_pixels,
"calculator ESC restores the current off-target pointer without another motion event");
AdvertisingScreen expected_parent(data, spending_state);
check(expected_parent.move(empty_x, empty_y) &&
resumed_budget.click(budget_x, budget_y) && !resumed_budget.move(empty_x, empty_y) &&
resumed_budget.key("J") && !resumed_budget.pending() &&
resumed_budget.hovered_target() == empty_slot &&
resumed_budget.render().pixels == expected_parent.render().pixels,
"unchanged calculator acceptance resumes hover over the current parent target");
AdvertisingScreen preset_budget(data, spending_state, 0x300000018ULL);
const int preset0_x = 103 + exe.u16(::bmh::layout::Advertising_Click_RuntimeField + 15 * 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/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;}
+23 -26
View File
@@ -100,8 +100,8 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
}
state.credit_currency = {g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1,
g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1};
const auto currency = [&](int32_t amount, int flags) {
std::string value = format_number(g, amount, flags);
const auto currency = [&](int64_t amount, int flags) {
std::string value = format_number_wide(g, amount, flags);
// FormatNumber appends currency (CurrencySuffixText) and the caller's Bank_FormatError_ExecutableField suffix.
value += exe.cstring(::bmh::layout::Bank_FormatError_ExecutableField);
return original_to_utf8(value);
@@ -141,8 +141,8 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
fund.owned = g.memory.u16(at + 0x14 + uint32_t(manager) * 2);
fund.max_to_buy = fund.price == 0 ? 0 : max_fund_units(g, manager, int(i));
fund.name = original_to_utf8(message_text(g, ::bmh::layout::Bank_OriginalToUtf8_TextPointer3 + uint32_t(i) * 4));
fund.unit_price_text = currency(wrap_i32(fund.price), 0x108);
fund.average_paid_text = currency(fund.owned ? wrap_i32(fund.paid / fund.owned) : 0, 0x108);
fund.unit_price_text = currency(fund.price, 0x108);
fund.average_paid_text = currency(fund.owned ? fund.paid / fund.owned : 0, 0x108);
fund.quantity_text = original_to_utf8(format_number(g, fund.owned, 0x82) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField2));
fund.one_quantity_text = original_to_utf8(format_number(g, 1, 0x82) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField2));
const uint32_t suffix = exe.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField + uint32_t(i) * 8);
@@ -154,49 +154,46 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
// and the separate overdraft limit. All inputs are copied/read-only.
state.finance_values[0] = state.balance;
state.finance_values[1] = state.deposit;
int32_t investment_value = 0, investment_gain = 0;
// OpenBMH deviates from the original: read-only totals use wide arithmetic;
// individual saved account, price, holding and paid fields are unchanged.
int64_t investment_value = 0, investment_gain = 0;
for (size_t i = 0; i < state.funds.size(); ++i) {
const uint32_t price = g.memory.u32(::bmh::layout::FundBlock + uint32_t(i) * 0x1c);
const uint32_t held = g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(i) * 0x1c);
const int32_t value = wrap_i32(price * held);
investment_value = wrap_sum(investment_value, value);
const int32_t paid = wrap_i32(g.memory.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField5 + uint32_t(i) * 0x1c + uint32_t(manager) * 4));
if (held) investment_gain = wrap_sum(investment_gain, wrap_i32(uint32_t(value) - uint32_t(paid)));
const int64_t value = int64_t(price) * held;
investment_value += value;
const int64_t paid = g.memory.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField5 + uint32_t(i) * 0x1c + uint32_t(manager) * 4);
if (held) investment_gain += value - paid;
}
state.finance_values[2] = investment_value;
state.finance_gains[0] = investment_gain;
int32_t stock_value = 0, stock_gain = 0;
int64_t stock_value = 0, stock_gain = 0;
for (size_t i = 0; i < state.stocks.size(); ++i) {
const int32_t value = wrap_i32(uint32_t(state.stocks[i].price) * state.stocks[i].owned);
stock_value = wrap_sum(stock_value, value);
if (state.stocks[i].owned) stock_gain = wrap_sum(stock_gain, wrap_i32(uint32_t(value) - uint32_t(state.stocks[i].paid)));
const int64_t value = int64_t(state.stocks[i].price) * state.stocks[i].owned;
stock_value += value;
if (state.stocks[i].owned) stock_gain += value - state.stocks[i].paid;
}
state.finance_values[3] = stock_value;
state.finance_gains[1] = stock_gain;
int32_t debts = 0, debt_assets = 0;
int64_t debts = 0, debt_assets = 0;
for (uint32_t loan = 0; loan < 5; ++loan) {
const uint32_t at = ::bmh::layout::Analytics_SourceAssetMaskE_RuntimeField + uint32_t(manager) * 0x78 + loan * 0x18;
const uint32_t borrowed = g.memory.u32(at);
const uint32_t repaid = g.memory.u32(at + 0x10);
debts = wrap_sum(debts, wrap_i32(borrowed - repaid));
debt_assets = wrap_sum(debt_assets, wrap_i32(borrowed));
debts += int64_t(borrowed) - repaid;
debt_assets += borrowed;
}
state.finance_values[4] = debts;
int32_t net = state.balance;
net = wrap_sum(net, state.deposit);
net = wrap_sum(net, investment_value);
net = wrap_sum(net, stock_value);
net = wrap_sum(net, wrap_i32(0u - uint32_t(debt_assets)));
state.finance_values[5] = net;
state.finance_values[5] = int64_t(state.balance) + state.deposit + investment_value + stock_value - debt_assets;
state.finance_values[6] = state.credit_line;
for (size_t i = 0; i < state.finance_value_text.size(); ++i)
state.finance_value_text[i] = currency(state.finance_values[i], 0x188);
for (size_t i = 0; i < state.finance_gains.size(); ++i) {
const int32_t gain = state.finance_gains[i];
const int64_t gain = state.finance_gains[i];
const uint32_t sign_address = gain < 0 ? ::bmh::layout::Bank_OriginalToUtf8_ExecutableField5 : gain > 0 ? ::bmh::layout::Bank_OriginalToUtf8_ExecutableField6 : ::bmh::layout::Bank_OriginalToUtf8_ExecutableField7;
const int32_t magnitude = gain < 0 ? wrap_i32(0u - uint32_t(gain)) : gain;
const int64_t magnitude = gain < 0 ? -gain : gain;
state.finance_gain_text[i] = original_to_utf8(exe.cstring(sign_address) +
format_number(g, magnitude, 0x101) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
format_number_wide(g, magnitude, 0x101) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
// 0x101 appends; Source preserves market value and adds signed gain in parentheses.
if (state.finance_values[i + 2] != 0)
state.finance_value_text[i + 2] += original_to_utf8(exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField4)) + state.finance_gain_text[i];
@@ -226,7 +223,7 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
state.finance_fund_labels[i] = original_to_utf8(format_number(g, fund.owned, 0x82) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField2) +
message_text(g, ::bmh::layout::Bank_OriginalToUtf8_TextPointer3 + uint32_t(i) * 4) +
exe.cstring(exe.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField + uint32_t(i) * 8 + (fund.owned > 1 ? 4 : 0))));
state.finance_fund_prices[i] = original_to_utf8("(" + format_number(g, wrap_i32(fund.price), 0x108) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
state.finance_fund_prices[i] = original_to_utf8("(" + format_number_wide(g, fund.price, 0x108) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
}
for (size_t i = 0; i < state.stocks.size(); ++i) {
const auto& stock = state.stocks[i];
+2 -2
View File
@@ -28,8 +28,8 @@ struct BankState {
std::string investment_limit_text;
int manager_portrait = 0, badge_sprite = 0;
// MaxSharesToBuy case 1: the seven read-only values shown in the finance view.
std::array<int32_t, 7> finance_values{};
std::array<int32_t, 2> finance_gains{};
std::array<int64_t, 7> finance_values{};
std::array<int64_t, 2> finance_gains{};
std::array<std::string, 7> finance_value_text{};
std::array<std::string, 2> finance_gain_text{};
// Case 4 (bank credit) readonly values as seen before any local edits.
+8 -5
View File
@@ -28,7 +28,7 @@ void rect(Image& out, int x, int y, int w, int h, uint8_t color) {
for (int yy = std::max(0, y); yy < std::min(out.height, y + h); ++yy)
for (int xx = std::max(0, x); xx < std::min(out.width, x + w); ++xx) out.at(xx, yy) = color;
}
std::string padded(int value, int width = 2) {
std::string padded(uint64_t value, int width = 2) {
std::string s = std::to_string(value);
if (int(s.size()) < width) s.insert(0, size_t(width - int(s.size())), '%');
return s;
@@ -110,7 +110,10 @@ ClubInfoProjection club_info_from_game(const GameState& g, int team,
player.cards = g.player_cards[id];
player.bonus = g.player_bonus[id];
}
if (board) player.manager_board = std::move(board);
if (board) {
player.manager_board = std::move(board);
if (player.player_id >= 0) player.statistics = player_club_statistics(g, team, player.player_id, *player.manager_board);
}
if (!player.borrowed && player.player_id >= 0) {
for (int loan = 0; loan < 200; ++loan) {
const uint32_t address = ::bmh::layout::Career_RemoveJoinLoans_RuntimeField + uint32_t(loan) * 4;
@@ -296,9 +299,9 @@ Image ClubInfoScreen::render() const {
std::string attrs = padded(p.bonus & 127, 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
if (p.manager_board) {
const auto& b = *p.manager_board;
attrs += padded(b[7], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + padded(b[9], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
Bytes raw(b.begin(), b.end()); attrs += padded(le16(raw, 0x48), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
padded(le16(raw, 0x4a), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + padded(le16(raw, 0x4c), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField);
attrs += padded(p.statistics ? p.statistics->appearances[0] : b[7], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + padded(p.statistics ? p.statistics->appearances[2] : b[9], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
Bytes raw(b.begin(), b.end()); attrs += padded((p.statistics ? p.statistics->total : le16(raw, 0x48)), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
padded((p.statistics ? p.statistics->goals : le16(raw, 0x4a)), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + padded((p.statistics ? p.statistics->assists : le16(raw, 0x4c)), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField);
}
text(out, 165, baseline, attrs, 0x6c);
}
Loaded 100 of 190 files, more files were not shown because too many files have changed in this diff. Show more