Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2a6300aad | ||
|
|
12e3e52537 | ||
|
|
6d97b60ebc | ||
|
|
e3e2262e37 | ||
|
|
184a421512 | ||
|
|
998b037d3d | ||
|
|
d43d09a378 | ||
|
|
f0ef79a119 | ||
|
|
e432f20ae7 | ||
|
|
6b942a2293 | ||
|
|
3cce6465d0 | ||
|
|
8ee062ea46 | ||
|
|
c293a35f56 | ||
|
|
81fc772a15 | ||
|
|
dcfb724ebe | ||
|
|
17ac426039 | ||
|
|
c3704878d6 | ||
|
|
c8f04d0099 | ||
|
|
b879d5be00 | ||
|
|
6a3e51038c | ||
|
|
354baf2e6f | ||
|
|
fe307dea41 | ||
|
|
245e213cca | ||
|
|
f21247a244 | ||
|
|
59be8b0b21 | ||
|
|
814583e482 | ||
|
|
e306c2c4a2 | ||
|
|
06e846416a | ||
|
|
678fce47f6 | ||
|
|
a7aa1d3713 | ||
|
|
500354cc39 | ||
|
|
856d38cc0c | ||
|
|
d9d05f83b4 | ||
|
|
c1121da116 | ||
|
|
9f1928bd9e | ||
|
|
221478b629 | ||
|
|
a447d9282a | ||
|
|
6636308cad | ||
|
|
b8183e4165 | ||
|
|
a475c1ba80 | ||
|
|
fcf6092063 | ||
|
|
f128a46104 | ||
|
|
056ac8ebea | ||
|
|
ef111342f9 | ||
|
|
b199f67eec | ||
|
|
bde8b10762 | ||
|
|
56b91ddca0 | ||
|
|
4f8e296f86 | ||
|
|
b868a236ea | ||
|
|
7ea00c7046 | ||
|
|
faaecf2eb2 | ||
|
|
906cce902d | ||
|
|
6e5fa72ed5 | ||
|
|
74ca973111 | ||
|
|
8aa849e9fa | ||
|
|
00f522c1f3 | ||
|
|
0b2354c979 | ||
|
|
978a014b87 | ||
|
|
481b525582 | ||
|
|
2552528176 | ||
|
|
3a021fc160 | ||
|
|
65b087c1d0 | ||
|
|
e1d17d8f81 | ||
|
|
7eff8a34f8 | ||
|
|
8326a23274 | ||
|
|
9bff07828a |
No files matched your search
@@ -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
|
||||
|
||||
@@ -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/RELEASE_NOTES.md
|
||||
+69
-4
@@ -1,8 +1,19 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 0.1.2 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 1.0.2 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)
|
||||
@@ -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
|
||||
@@ -239,6 +249,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
|
||||
@@ -441,7 +452,8 @@ add_executable(openbmh_play
|
||||
target_link_libraries(openbmh_play PRIVATE bmhui bmhlaunch_dialog openbmh_audio ${BMH_SDL_TARGET})
|
||||
# a game without a console window on double-click (SDL2main provides WinMain); started from a
|
||||
# console it attaches to that one for --version, --help and start errors (src/app/main.cpp)
|
||||
set_target_properties(openbmh_play PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
set_target_properties(openbmh_play PROPERTIES WIN32_EXECUTABLE TRUE OUTPUT_NAME OpenBMH)
|
||||
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.
|
||||
@@ -621,6 +633,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)
|
||||
@@ -1069,6 +1082,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)
|
||||
@@ -1087,3 +1119,36 @@ 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}")
|
||||
@@ -1,10 +1,8 @@
|
||||
# OpenBMH
|
||||
|
||||
A modern and faithful open source rebuild of the *Bundesliga Manager Hattrick* engine.
|
||||
A faithful, standalone community reconstruction of *Bundesliga Manager Hattrick*, using the player's original installation and SDL2 interface.
|
||||
|
||||
OpenBMH is a standalone C++20 engine with an SDL2 interface for *Bundesliga Manager Hattrick* (1994/95) and its English edition, *Football Limited*. The project develops a playable reconstruction alongside a platform for new rules, content and interfaces. Keeping the familiar game enjoyable and making it easier to extend are equally important goals.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
@@ -14,26 +12,28 @@ Check the [releases page](https://github.com/Weyoune/openbmh/releases) for avail
|
||||
|
||||
1. Have your own supported game installation available.
|
||||
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
|
||||
3. Start `openbmh_play` (`openbmh_play.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
3. Start `OpenBMH` (`OpenBMH.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
|
||||
From a terminal:
|
||||
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/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.2. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
|
||||
The following recipes 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:
|
||||
|
||||
@@ -50,7 +50,7 @@ Install Visual Studio 2022 or its Build Tools with **Desktop development with C+
|
||||
cmake -S . -B build-windows -G "Visual Studio 17 2022" -A x64
|
||||
cmake --build build-windows --config Release
|
||||
ctest --test-dir build-windows -C Release --output-on-failure
|
||||
.\build-windows\Release\openbmh_play.exe --data "path/to/game" --save-directory "path/to/saves"
|
||||
.\build-windows\Release\OpenBMH.exe --data "path/to/game" --save-directory "path/to/saves"
|
||||
```
|
||||
|
||||
### Linux
|
||||
@@ -62,7 +62,7 @@ sudo apt install build-essential git cmake ninja-build pkg-config libgtk-3-dev l
|
||||
cmake -S . -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build-linux
|
||||
ctest --test-dir build-linux --output-on-failure
|
||||
./build-linux/openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
||||
./build-linux/OpenBMH --data "path/to/game" --save-directory "path/to/saves"
|
||||
```
|
||||
|
||||
Use a newer CMake if your distribution ships a version older than 3.24. A Linux binary can still require system libraries such as GTK3; a ZIP is not a guarantee of portability across distributions.
|
||||
@@ -77,7 +77,7 @@ brew install cmake ninja
|
||||
cmake -S . -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||
cmake --build build-macos
|
||||
ctest --test-dir build-macos --output-on-failure
|
||||
./build-macos/openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
||||
./build-macos/OpenBMH --data "path/to/game" --save-directory "path/to/saves"
|
||||
```
|
||||
|
||||
On Intel Macs omit the arm64 setting or select `x86_64`. These commands build terminal executables; they do not create a signed application bundle.
|
||||
@@ -103,6 +103,6 @@ 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.2](https://github.com/Weyoune/openbmh/tree/v0.1.2) 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).
|
||||
+13
-2
@@ -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.
|
||||
@@ -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.
|
||||
|
||||
|
||||
+27
-21
@@ -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.
|
||||
@@ -12,26 +12,32 @@ Intentional changes in code should use the marker `OpenBMH deviates from the ori
|
||||
|
||||
The [generated differences catalogue](DIFFERENCES.md) lists these markers with links to their source files.
|
||||
|
||||
## Environment and presentation in 0.1.2
|
||||
## Application exit confirmation
|
||||
|
||||
The desktop environment provides three youth teams and three staff
|
||||
budgets, each set to zero through six stars. Youth budgets are monthly, can be
|
||||
changed throughout the season, and contribute to the finance preview, balance
|
||||
plan and booked expenses. Youth tables develop on first-division matchdays;
|
||||
promotion, relegation and age-group handover occur at the season change.
|
||||
The two previously hidden youth groups are available across data editions.
|
||||
Staff prices and the shared academy player-generation strength bands stay in
|
||||
effect. Recruitment needs an active middle youth budget and an oldest youth team
|
||||
within 25 strength points of the senior squad (the full-build mode bypasses the
|
||||
strength gate). This deliberately
|
||||
combines the six-budget environment with OpenBMH's existing player-generation rules.
|
||||
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.
|
||||
|
||||
Old saved academy lump sums remain payable once and retain their paid status.
|
||||
They are not multiplied into twelve monthly payments. Editing that tile replaces
|
||||
the old amount with the selected monthly budget. There is no new save field.
|
||||
## Original edition rules in 1.0
|
||||
|
||||
Live match minutes use the loaded original delay setting (A9), including zero,
|
||||
instead of an added fixed pause. A9 and the existing scene delays can be adjusted
|
||||
in Settings; loaded saves and EIN files retain their chosen speeds. VGA retrace
|
||||
animations use a 70-Hz reference instead of the host monitor's refresh rate.
|
||||
`--live-frame-ms` and `BMH_LIVE_FRAME_MS` remain explicit diagnostic overrides.
|
||||
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.
|
||||
|
||||
## 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.
|
||||
+5
-6
@@ -6,20 +6,19 @@ 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/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/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): uses six monthly environment budgets across data editions while retaining the shared staff prices and academy player-generation strength bands.
|
||||
- [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image.
|
||||
- [src/game/lineup.cpp](../src/game/lineup.cpp): disables the foreign-player limit in the supported rule profile.
|
||||
- [src/game/lineup.hpp](../src/game/lineup.hpp): disables the foreign-player limit and supports owner-bound designated set-piece selection.
|
||||
- [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/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/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): uses the enhanced training rules: focus strength is at least five below its target, and completed skills rotate to another focus.
|
||||
|
||||
+12
-21
@@ -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. The format concept is [OBW](formats/OBW.md). 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 (RmlUi) 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.
|
||||
@@ -1991,3 +1991,13 @@ 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 |
|
||||
|
||||
## Verified edition-dependent parameters
|
||||
|
||||
| Field | Address | Use |
|
||||
|---|---|---|
|
||||
| `CalendarDateSetup` | `0x21270` | Verified date setup: weekday byte at +4, initial year dword at +13. Original CD uses 1995/Saturday; checked Diamond editions use 2026/Wednesday. |
|
||||
| `ForeignBadgeGateInstruction` | `0x10070` | Verified original drawing gate; operand at +3 selects neutral foreign crests or individual W-sheet selectors. |
|
||||
| `EnvironmentBudgetSteps` | `0xa50ff` | Six budget increments in the verified monthly environment implementation. |
|
||||
|
||||
Calendar presentation, engine weekday processing and save-list headers share the supplied installation's epoch. The original four-year date arithmetic is preserved; this reader does not substitute a different calendar system or rewrite the installation. Unknown date setup instructions and invalid values are rejected.
|
||||
@@ -1,475 +0,0 @@
|
||||
# OBW: OpenBMH world, save and pack format (concept, format version 1.0)
|
||||
|
||||
Status: **concept** for roadmap 0.2 (open data and typed state) with preparation for 0.4 (scalable interface, content packs). Nothing here is implemented yet; the legacy formats in this directory remain authoritative for the current engine.
|
||||
|
||||
## 1. Goals and non-goals
|
||||
|
||||
Goals:
|
||||
|
||||
- One documented, versioned format for a game world (start database), a running career (save) and content packs.
|
||||
- A typed model of nations, clubs, players, staff, contracts, finances and competitions that no longer depends on the memory image of a particular executable.
|
||||
- Data-driven competitions: up to **32 leagues** (national and foreign leagues together), real-world European club cups (league phase plus knockout), and national-team competitions including qualification and a Nations-League-style tiered competition.
|
||||
- Import from the supported German editions and from Football Limited (FLTD), both for a new career and for an existing `.FBM` save.
|
||||
- Preparation for a high-resolution interface built with RmlUi: logical asset keys, high-resolution crests and icons, player photos, further languages and modern font formats.
|
||||
- Forward compatibility: readers of the same major version accept files written by later minor versions.
|
||||
|
||||
Non-goals of version 1.0:
|
||||
|
||||
- The match engine and its parameters (reserved namespace `x-matchengine`, see §3.3).
|
||||
- Network play, an editor application and a binary encoding (reserved, see §2.4).
|
||||
- Layout or screen data. Interfaces are themes (§9.6), not part of a world.
|
||||
|
||||
## 2. Container and files
|
||||
|
||||
### 2.1 Container
|
||||
|
||||
Every OBW file is a ZIP archive (deflate or stored) containing UTF-8 JSON documents. The project already links miniz (`bmh_miniz`) and has a JSON reader/writer (`src/cli/json.cpp`), so the format needs no new dependency. JSON keeps worlds diffable and editable by hand or by script.
|
||||
|
||||
| Extension | `kind` | Contents |
|
||||
|---|---|---|
|
||||
| `.obw` | `world` | Start database: everything needed to begin a career |
|
||||
| `.obs` | `save` | A world plus the running state of a career |
|
||||
| `.obp` | `pack` | Overlays and assets for worlds (names, crests, photos, texts) |
|
||||
| `.obt` | `theme` | Interface theme for the RmlUi client (§9.6) |
|
||||
|
||||
An unpacked directory with the same layout is accepted wherever an archive is, which keeps development and version control simple.
|
||||
|
||||
### 2.2 Layout
|
||||
|
||||
```
|
||||
manifest.json required, §3
|
||||
world/nations.json nations and their national teams
|
||||
world/clubs.json clubs (teams of type "club")
|
||||
world/players.json players
|
||||
world/staff.json managers, coaches, other staff
|
||||
world/stadiums.json stadiums
|
||||
world/contracts.json player and staff contracts
|
||||
world/finance.json club finances, sponsors, advertising, loans, shares
|
||||
world/competitions.json competition definitions, §6
|
||||
world/calendar.json season calendar, §7
|
||||
world/rules.json rule values (training camps, interest rates, ...)
|
||||
state/... save only, §5.9
|
||||
locale/<lang>/*.po texts, §9.3
|
||||
assets/... packs and themes only, §9
|
||||
x-<name>/... extensions, §3.3
|
||||
```
|
||||
|
||||
Every table file is an object `{"schema": "<table>@<major>.<minor>", "items": [...]}`. Tables with many rows (results, history, mail) may instead be stored as JSON Lines (`*.jsonl`, one item per line, first line the header object without `items`).
|
||||
|
||||
### 2.3 Encoding rules
|
||||
|
||||
- Text is UTF-8. Legacy single-byte text is converted on import (`iso646de_to_utf8`).
|
||||
- Money is an integer in the smallest unit of the world currency (`manifest.currency`, e.g. `{"code": "DEM", "minor_units": 0}`); no floating point for money.
|
||||
- Dates are ISO 8601 calendar dates (`"1995-07-01"`), in-game time is a date plus an optional `"minute"`.
|
||||
- Percentages and ratings are integers on the scale declared by their attribute set (§5.3).
|
||||
- Optional fields may be omitted; the schema gives their default.
|
||||
|
||||
### 2.4 Reserved
|
||||
|
||||
A compact binary encoding of large `state/` tables is reserved for a later minor version as an alternative representation of the same schema (`"encoding": "cbor"` in the table header). Readers of 1.0 reject unknown encodings with a clear error.
|
||||
|
||||
## 3. Versioning and migration
|
||||
|
||||
### 3.1 Manifest
|
||||
|
||||
```json
|
||||
{
|
||||
"format": "openbmh-world",
|
||||
"format_version": "1.0",
|
||||
"kind": "world",
|
||||
"min_reader": "1.0",
|
||||
"generator": "OpenBMH 0.2.0",
|
||||
"created": "2026-10-17",
|
||||
"title": {"default": "Season 1995/96"},
|
||||
"provenance": "import:bmh-de",
|
||||
"content_license": "local-import-only",
|
||||
"currency": {"code": "DEM", "minor_units": 0},
|
||||
"start_date": "1995-07-01",
|
||||
"languages": ["de"],
|
||||
"limits": {"leagues": 32},
|
||||
"requires": [],
|
||||
"extensions": []
|
||||
}
|
||||
```
|
||||
|
||||
- `format_version` is `major.minor`. A **minor** step only adds optional fields, tables, enum values that have a documented fallback, or new stage types guarded by `requires`. A **major** step may rename, remove or re-interpret fields.
|
||||
- `min_reader` is the lowest reader version that can use the file correctly (a writer raises it when it uses a minor feature without a safe fallback).
|
||||
- `requires` lists features without which the file cannot be played, e.g. `["stage:swiss"]`; a reader that lacks one refuses the file instead of guessing.
|
||||
- `provenance` records where the content came from: `native`, `import:bmh-de`, `import:bmh-de-classic`, `import:fltd`, or `pack:<id>`. `content_license` is free text or an SPDX identifier; `local-import-only` marks data converted from a user's own installation (§8.4).
|
||||
|
||||
### 3.2 Reading and migration
|
||||
|
||||
- Readers ignore unknown fields and tables, keep them in memory and write them back unchanged (round trip), so a newer minor version survives an older tool.
|
||||
- Missing optional fields take the schema default.
|
||||
- Older major versions are upgraded on load through a chain of migrations (`migrate_1_to_2`, `migrate_2_to_3`, ...). Writers always write the newest version; a migrated save is written under a new name unless the player confirms the upgrade.
|
||||
- Each table carries its own `schema` version, so a table can advance a minor step independently; the manifest version is the highest of them.
|
||||
|
||||
### 3.3 Extensions
|
||||
|
||||
Fields and directories whose name starts with `x-` belong to extensions (`x-matchengine`, `x-realnames`, `x-editor`). The core never interprets them, preserves them on round trip and lists active ones in `manifest.extensions` with a version, e.g. `{"id": "x-matchengine", "version": "1.0"}`.
|
||||
|
||||
### 3.4 Schemas
|
||||
|
||||
Each format version is published as JSON Schema (draft 2020-12) under `docs/formats/obw/schema/<major>.<minor>/`, one file per table. The schemas are the machine-readable specification and the basis of the validator (§10).
|
||||
|
||||
## 4. Identifiers and names
|
||||
|
||||
- Every entity has a stable string id `<type>:<key>`, e.g. `nation:de`, `club:0042`, `player:01873`, `comp:de-1`, `stadium:0042`. Keys are opaque: they never encode a real name, so a world and a pack can be published independently.
|
||||
- Ids are unique within a world and never reused within a save. The engine assigns runtime indices; files never store them.
|
||||
- Nation keys use ISO 3166-1 alpha-2 where one exists, otherwise a documented private key (`nation:x-eng` for England, `nation:x-sco`, ...).
|
||||
- Every displayed name is a localized string: `{"default": "...", "en": "...", "short": {"default": "..."}}`. `default` is required; a language entry overrides it; `short` and `abbr` are optional display variants for narrow layouts.
|
||||
- Packs overlay names, crests and photos by id (§9.5), never by position.
|
||||
|
||||
## 5. Entities
|
||||
|
||||
Field lists name the type and whether the field is required (R) or optional (O, with default). Only the main fields are listed; the schema is authoritative.
|
||||
|
||||
### 5.1 Nation (`world/nations.json`)
|
||||
|
||||
| Field | Type | | Meaning |
|
||||
|---|---|---|---|
|
||||
| `id` | string | R | `nation:<key>` |
|
||||
| `name` | localized | R | |
|
||||
| `confederation` | string | R | `uefa`, `conmebol`, `caf`, `afc`, `concacaf`, `ofc`, `other` |
|
||||
| `coefficient` | integer | O 0 | Club-competition ranking points (§6.6) |
|
||||
| `strength` | integer | O 0 | Rating of the national team when no squad is simulated |
|
||||
| `national_team` | string | O | Team id of type `national` (§5.2) |
|
||||
| `playable` | bool | O false | Whether its leagues are simulated in full |
|
||||
|
||||
### 5.2 Team (`world/clubs.json`)
|
||||
|
||||
Clubs and national teams share one entity type, distinguished by `type`.
|
||||
|
||||
| Field | Type | | Meaning |
|
||||
|---|---|---|---|
|
||||
| `id` | string | R | `club:<key>` or `nt:<nation key>` |
|
||||
| `type` | enum | R | `club`, `national`, `amateur` (newcomer pool), `foreign` (strength only) |
|
||||
| `name` | localized | R | |
|
||||
| `nation` | string | R | |
|
||||
| `stadium` | string | O | |
|
||||
| `colors` | array | O | 1 to 3 `#rrggbb` values, used for generated crests and kits |
|
||||
| `reputation`, `fans`, `strength` | integer | O | Club values on the attribute scale of the world |
|
||||
| `founded` | integer | O | Year |
|
||||
| `crest` | string | O | Asset key, default `asset:club/<key>/crest` (§9.1) |
|
||||
| `x-*` | any | O | Extensions |
|
||||
|
||||
Teams without a squad (`foreign`, or `national` in a world that does not simulate national squads) carry `strength` instead of players.
|
||||
|
||||
### 5.3 Player (`world/players.json`)
|
||||
|
||||
| Field | Type | | Meaning |
|
||||
|---|---|---|---|
|
||||
| `id` | string | R | |
|
||||
| `name` | object | R | `{"first": "...", "last": "...", "known_as": "..."}`, each a plain string; `known_as` optional |
|
||||
| `born` | date | R | Age is derived from the in-game date |
|
||||
| `nationalities` | array | R | Nation ids, first entry is the sporting nationality (national-team eligibility) |
|
||||
| `positions` | array | R | `gk`, `def`, `mid`, `fwd` in the classic set; finer positions in later attribute sets |
|
||||
| `foot` | enum | O | `left`, `right`, `both` |
|
||||
| `attribute_set` | string | O world default | e.g. `bmh-classic@1` |
|
||||
| `attributes` | object | R | Values named by the attribute set, e.g. `{"strength": 7, "technique": 5, "condition": 9, "form": 6}` |
|
||||
| `character` | object | O | Traits the attribute set defines |
|
||||
| `team` | string | O | Current team id; absent for free agents |
|
||||
| `squad_number` | integer | O | |
|
||||
| `status` | object | O | Injury, suspension and card counters per competition (save only) |
|
||||
| `photo` | string | O | Default `asset:player/<key>/photo` |
|
||||
|
||||
An attribute set is declared once in `world/rules.json` with its fields, scales and meaning, so a later, finer model can sit next to the classic one without breaking the format:
|
||||
|
||||
```json
|
||||
{"id": "bmh-classic@1", "fields": {
|
||||
"strength": {"min": 1, "max": 10},
|
||||
"technique": {"min": 1, "max": 10},
|
||||
"condition": {"min": 0, "max": 100},
|
||||
"form": {"min": 1, "max": 10}}}
|
||||
```
|
||||
|
||||
The exact list and scales of `bmh-classic@1` are fixed when the importer is written, from the fields the current engine uses (`Player` in `src/game/state.hpp`).
|
||||
|
||||
### 5.4 Staff and managers (`world/staff.json`)
|
||||
|
||||
Managers (human or computer), coaches and other employees: `id`, `name`, `born`, `nation`, `role` (`manager`, `coach`, `physio`, ...), `team`, `attributes`. In a save, `state/managers.json` adds the human manager profile: options, ratings, history, automation settings.
|
||||
|
||||
### 5.5 Contracts (`world/contracts.json`)
|
||||
|
||||
`id`, `person` (player or staff id), `team`, `start`, `end`, `salary` (money per season), `bonuses` (signing, per goal, ...), `release_clause` (O), `options` (O). One active contract per person and team; the history is kept in the save.
|
||||
|
||||
### 5.6 Stadiums (`world/stadiums.json`)
|
||||
|
||||
`id`, `name`, `capacity` split by area (`standing`, `seated`, `boxes`), `facilities` (floodlights, heating, scoreboard, ... as named levels), `pitch`, `owner` (team id or `null`).
|
||||
|
||||
### 5.7 Finance (`world/finance.json`)
|
||||
|
||||
Per team: balance, ticket prices, sponsors (shirt, boards, with duration and value), advertising, loans (amount, rate, due date), shares and other income or cost sources the engine models today. Rate tables such as the credit table live in `world/rules.json`.
|
||||
|
||||
### 5.8 Rules (`world/rules.json`)
|
||||
|
||||
Named rule values that are content of the world rather than of the engine: training-camp resorts (price, quality grades), credit-rate tables, attribute sets, points for a win, squad limits. Today these values are read from the executable of the selected edition; in OBW they are ordinary data (and the starting point of the configurable rules of roadmap 0.3).
|
||||
|
||||
### 5.9 Save state (`state/`, saves only)
|
||||
|
||||
| File | Contents |
|
||||
|---|---|
|
||||
| `state/career.json` | Current date, season, phase, active human managers, settings |
|
||||
| `state/rng.json` | State of the random generator(s) (`docs/RNG.md`), so a load continues deterministically |
|
||||
| `state/tables.json` | Standings per competition stage and group |
|
||||
| `state/results.jsonl` | Every played or scheduled match: competition, stage, round, home, away, result, after extra time / penalties |
|
||||
| `state/squads.json` | Lineups, formations, tactics per team |
|
||||
| `state/history.jsonl` | Season history: champions, cup winners, top scorers, records |
|
||||
| `state/mail.jsonl` | Messages and news |
|
||||
| `state/market.json` | Transfer list, open bids, loan offers |
|
||||
| `state/x-legacy.json` | Unmapped legacy values carried over by the importer (§8.3) |
|
||||
|
||||
## 6. Competitions
|
||||
|
||||
### 6.1 Model
|
||||
|
||||
A competition is an ordered list of **stages**. Each stage takes teams from **slots** (§6.4), plays a format and hands teams on (to the next stage, to another competition, or to a final ranking).
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "comp:de-2",
|
||||
"name": {"default": "2. Liga"},
|
||||
"type": "league",
|
||||
"nation": "nation:de",
|
||||
"tier": 2,
|
||||
"season_cycle": 1,
|
||||
"stages": [{
|
||||
"id": "regular",
|
||||
"format": "league",
|
||||
"teams": 18,
|
||||
"legs": 2,
|
||||
"points": {"win": 3, "draw": 1, "loss": 0},
|
||||
"tiebreakers": ["points", "goal_difference", "goals_for", "head_to_head", "draw_lots"],
|
||||
"matchdays": "calendar:league-weekends"
|
||||
}],
|
||||
"movement": [
|
||||
{"ranks": [1, 2], "to": "comp:de-1"},
|
||||
{"ranks": [3], "to": "comp:de-1/playoff", "role": "challenger"},
|
||||
{"ranks": [16, 18], "to": "comp:de-3"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`type` is `league` (counts towards the league limit), `cup` (national cup), `club_international`, `national_team`, `friendly` or `indoor`.
|
||||
|
||||
### 6.2 Stage formats
|
||||
|
||||
| Format | Purpose | Main parameters |
|
||||
|---|---|---|
|
||||
| `league` | Round robin | `teams`, `legs` (1, 2, n), `points`, `tiebreakers`, fixture generator |
|
||||
| `groups` | Several round robins | `groups`, `teams_per_group`, `legs`, seeding `pots`, draw constraints (e.g. no two teams of one nation) |
|
||||
| `swiss` | League phase with a fixed number of games against drawn opponents | `teams` (e.g. 36), `matches` (e.g. 8), `pots`, `home_away_balance`, one common table |
|
||||
| `knockout` | Ties | `legs` (1 or 2), `seeded`, `draw` (`open`, `seeded`, `bracket`), `extra_time`, `penalties`, `away_goals` (on/off), `neutral_venue`, `replay` (FA-Cup style) |
|
||||
| `playoff` | Ties between teams of different competitions (relegation, qualification) | as `knockout` plus the roles of the participants |
|
||||
| `final` | Single match or final tournament | `venue`, `teams` |
|
||||
|
||||
Common stage parameters: `extra_time` (minutes), `penalties`, `suspensions` (cards that lead to a ban, counted per competition or per stage), `substitutions`, `squad_registration` (size, home-grown quota), `prize_money` per round and result, `tv_money`, `gate_split`. New formats are added through a minor version with an entry in `manifest.requires`.
|
||||
|
||||
### 6.3 Fixture generation
|
||||
|
||||
A `league` or `groups` stage names a generator: `"generator": "round-robin"` (circle method, home/away balanced) works for every size. The legacy round tables of the original game remain available as `"generator": "legacy:<teams>"` for imported worlds, so imported careers keep their familiar order; they come from the user's installation, not from the format.
|
||||
|
||||
### 6.4 Slots and qualification
|
||||
|
||||
Participants are declared, not hard-coded:
|
||||
|
||||
```json
|
||||
"slots": [
|
||||
{"from": "comp:de-1", "ranks": [1, 4], "stage": "league-phase"},
|
||||
{"from": "comp:de-cup", "winner": true, "to": "comp:uel", "stage": "league-phase",
|
||||
"fallback": {"from": "comp:de-1", "next_unqualified": true}},
|
||||
{"from": "coefficient", "nation_rank": [1, 4], "places": 4},
|
||||
{"holder": "comp:ucl", "stage": "league-phase"}
|
||||
]
|
||||
```
|
||||
|
||||
A slot source is: a rank range of a stage, the winner/runner-up of a competition, the holder of a title, the next team not yet qualified (substitution rules), a coefficient ranking, or an explicit list. The engine resolves all slots at season end in the order given by `world/calendar.json`.
|
||||
|
||||
### 6.5 League pyramid
|
||||
|
||||
`movement` on a league connects tiers: promotion, relegation and playoffs between two leagues, several parallel lower leagues feeding one league (the two regional third divisions of the German editions), and a refill pool for the lowest tier (`"refill": {"from": "pool:amateur", "count": 2}`). This replaces the fixed per-edition tables in `src/game/schedule.hpp` (`kLeagueRelegation`, `kLeagueEurope`, `kGroupBelow`, `kNewcomerFirst`).
|
||||
|
||||
### 6.6 Coefficients
|
||||
|
||||
`world/rules.json` may define coefficient rankings (club and nation) with the points per result and per round reached and the number of seasons summed. They drive seeding pots and the number of European places per nation. A world may instead fix places per nation (`"places": {"nation:de": {"ucl": 4, "uel": 2}}`), which is how imported legacy worlds start.
|
||||
|
||||
### 6.7 Templates
|
||||
|
||||
The project ships competition templates under `docs/formats/obw/templates/`. They contain structure only, with neutral names:
|
||||
|
||||
- **Club competitions:** a champions cup with a 36-team league phase, a knockout playoff for places 9 to 24, round of 16 to final; a second and a third club cup in the same shape; a super cup; the knockout-only cups of the original game.
|
||||
- **National teams:** a world cup with continental qualification groups and playoffs, a continental championship with qualification, and a **tiered nations league**. The nations league has leagues A to D with groups of three or four, promotion and relegation between tiers, a final tournament for the group winners of A, and playoffs that can feed continental-championship places.
|
||||
- **National cups and side competitions:** knockout national cups (with or without replays and a qualifying round), an indoor tournament, friendlies.
|
||||
|
||||
### 6.8 National teams
|
||||
|
||||
A world that simulates national teams gives each `national` team a call-up rule: squad size, eligibility through `nationalities[0]`, selection by attribute set (best `n` by position) or by a human manager. International windows in the calendar (§7) suspend club play when the world asks for it (`"club_break": true`). Worlds without national squads use `strength` and simulate only results.
|
||||
|
||||
## 7. Calendar
|
||||
|
||||
`world/calendar.json` describes a season as dated events, independent of the executable's day table:
|
||||
|
||||
```json
|
||||
{
|
||||
"season_start": "07-01",
|
||||
"season_length_days": 365,
|
||||
"windows": [
|
||||
{"id": "summer-transfer", "type": "transfer", "from": "07-01", "to": "08-31"},
|
||||
{"id": "intl-sep", "type": "international", "from": "09-02", "to": "09-10", "club_break": true}
|
||||
],
|
||||
"series": [
|
||||
{"id": "league-weekends", "weekday": "sat", "from": "08-08", "to": "05-20", "skip": ["winter-break", "intl-*"]},
|
||||
{"id": "ucl-league-phase", "weekdays": ["tue", "wed"], "dates": ["09-16", "09-30"]}
|
||||
],
|
||||
"events": [
|
||||
{"date": "06-30", "action": "season_end"},
|
||||
{"date": "01-05", "action": "training_camp_window"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Dates are month-day within the season; the engine maps them to concrete days each year, including leap years and seasons whose first day falls on a different weekday (the cases fixed in the current calendar code). Stages refer to a series by id. Imported worlds receive a calendar generated from the edition's day table, so the familiar rhythm stays.
|
||||
|
||||
## 8. Import from BMH and Football Limited
|
||||
|
||||
### 8.1 Sources
|
||||
|
||||
The importer (planned module `src/import/`) reuses the existing loaders:
|
||||
|
||||
| Source | Loader | Result |
|
||||
|---|---|---|
|
||||
| Master database `M3D.MAN` / `M3E.MAN` | `src/formats/m3d.cpp` | Clubs, players, staff, stadiums |
|
||||
| Executable tables (league sizes, ladders, calendar, fixture tables, rule values) | `src/formats/le.cpp`, `src/launch/fltd.cpp`, `src/game/schedule.hpp` installers | Competitions, calendar, rules |
|
||||
| Text database `TEXTD.BLK` / `TEXTE.BLK` | `src/formats/textd.cpp` | Local language layer `de-original` / `en-original` |
|
||||
| Save `*.FBM` | `src/formats/fbm.cpp`, `savestate.cpp` | `state/` of a save |
|
||||
| Crests and pictures `*.VGA`, `WAPPEN.LBM` | `src/formats/vga.cpp` | Low-resolution fallback assets, local only |
|
||||
|
||||
Edition detection is the one the launcher already performs (`src/launch/game_data.cpp`).
|
||||
|
||||
### 8.2 Mapping per edition
|
||||
|
||||
Every edition has a mapping table in the importer (to be published with it as `docs/formats/obw/import.md`):
|
||||
|
||||
| Legacy league | German editions | Football Limited | OBW |
|
||||
|---|---|---|---|
|
||||
| 0 | 1st division, 18 teams | 1st division, 20 teams | `comp:<n>-1`, tier 1 |
|
||||
| 1 | 2nd division, 18 | 2nd division, 20 | tier 2 |
|
||||
| 2, 3 | Two parallel third divisions A and B, 18 each, one promotion group | 3rd and 4th division, 20 each | tier 3 (two leagues) / tiers 3 and 4 |
|
||||
| 4 | Fourth tier, 18 | Fifth league, 10 teams, not played | tier 4 / tier 5 with `"played": false` |
|
||||
| 5-8 | Four foreign leagues of 12 | Same four foreign leagues of 12 | `comp:<nation>-1` each, `nation.playable = true` |
|
||||
| Newcomer pool | 30 amateur clubs | 12 further named clubs | `pool:amateur` |
|
||||
|
||||
Cups, European cups, the indoor tournament, the English FA Cup with its qualifying stage and the League Cup become competitions with the same rules the engine applies today. Relegation places, European places and promotion groups are taken from the installed tables (`kLeagueRelegation`, `kLeagueEurope`, `kGroupBelow`), not re-typed by hand.
|
||||
|
||||
### 8.3 Fidelity
|
||||
|
||||
- A new career imported from an installation must produce the same first season in the engine as the legacy start (same fixtures, same participants), verified by the regression runs.
|
||||
- A converted `.FBM` must continue with the same results as the legacy save for a fixed number of turns.
|
||||
- Values the typed model does not yet understand go to `state/x-legacy.json` with their legacy name, so nothing is lost while the model grows area by area.
|
||||
|
||||
### 8.4 Rights
|
||||
|
||||
Imported content stays on the player's machine. The importer marks it `"provenance": "import:..."` and `"content_license": "local-import-only"`; tools refuse to bundle such a world into a distributable pack. Only worlds and packs with their own licence may be shared.
|
||||
|
||||
## 9. Assets, languages, fonts and the RmlUi interface
|
||||
|
||||
### 9.1 Asset keys
|
||||
|
||||
Data never refers to file paths. It uses logical keys:
|
||||
|
||||
| Key | Meaning |
|
||||
|---|---|
|
||||
| `asset:club/<key>/crest` | Club crest |
|
||||
| `asset:club/<key>/kit/home` | Kit |
|
||||
| `asset:player/<key>/photo` | Player photo |
|
||||
| `asset:staff/<key>/photo` | Staff photo |
|
||||
| `asset:comp/<key>/logo`, `asset:comp/<key>/trophy` | Competition logo and trophy |
|
||||
| `asset:nation/<key>/flag` | Flag |
|
||||
| `asset:stadium/<key>/image` | Stadium picture |
|
||||
| `asset:icon/<name>` | Interface icon |
|
||||
|
||||
### 9.2 Resolution and image formats
|
||||
|
||||
A resolver looks a key up in the active packs by priority (§9.5), then in the world, then falls back: original low-resolution graphics of the installation where one exists, a crest generated from `colors`, a silhouette for photos, a neutral icon.
|
||||
|
||||
- **Crests, logos, flags, icons:** SVG preferred (scales to every resolution). Otherwise PNG with alpha in size steps 64, 128, 256 and 512 px (`crest@128.png`). The resolver picks the smallest step not below the requested size.
|
||||
- **Photos:** PNG, JPEG or WebP, aspect 3:4, reference size 300×400 px, larger allowed. Faces centred; the interface crops, it never stretches.
|
||||
- **Pictures** (stadiums, backgrounds): PNG, JPEG or WebP, 16:9 reference 1920×1080.
|
||||
|
||||
Asset metadata sits next to the files in `assets/index.json`: key, files per size, author, source and licence (required).
|
||||
|
||||
### 9.3 Languages
|
||||
|
||||
- Interface texts use gettext `.po` files under `locale/<lang>/openbmh.po` (`msgctxt` for context, plural forms, mature translator tools such as Poedit and Weblate). Message ids are stable English keys.
|
||||
- Data names are localized strings inside the tables (§4); packs can add languages to them.
|
||||
- The original text databases are imported into a local layer `de-original` or `en-original`, which the classic interface uses. New interfaces use the project's own texts.
|
||||
- A fallback chain is configured by the player, e.g. `["en-GB", "en", "de"]`.
|
||||
- Text is shaped as Unicode (RmlUi supports it); no single-byte substitutions outside the legacy layer.
|
||||
|
||||
### 9.4 Fonts
|
||||
|
||||
- TrueType and OpenType (`.ttf`, `.otf`); RmlUi renders them through FreeType. Variable fonts are allowed.
|
||||
- A theme declares font families with weights, a fallback chain covering the languages it claims, and the licence of every font file (for example SIL OFL).
|
||||
- The original bitmap fonts stay for the classic interface only.
|
||||
|
||||
### 9.5 Content packs (`.obp`)
|
||||
|
||||
```json
|
||||
{
|
||||
"format": "openbmh-world",
|
||||
"format_version": "1.0",
|
||||
"kind": "pack",
|
||||
"id": "pack:example-crests",
|
||||
"title": {"default": "Example crests"},
|
||||
"targets": [{"world_provenance": "import:bmh-de"}],
|
||||
"priority": 100,
|
||||
"content_license": "CC-BY-4.0",
|
||||
"overlays": ["names", "assets", "locale"]
|
||||
}
|
||||
```
|
||||
|
||||
- A pack contains `overlay/<table>.json` files with partial entities by id (only the fields it changes), `assets/` and `locale/`.
|
||||
- Several packs stack; the higher `priority` wins per field and per asset key. A pack may not add or remove entities in 1.0 (that is a world, not a pack), which keeps saves valid when a pack is removed.
|
||||
- `targets` restricts a pack to worlds by provenance or world id.
|
||||
- The project distributes only the format, tools and its own or freely licensed material. Packs with real names, crests or photos are made and shared by their authors under their own responsibility. The team's internal real-name pack uses this format and stays private.
|
||||
|
||||
### 9.6 RmlUi themes (`.obt`)
|
||||
|
||||
- A theme contains `.rml` documents, `.rcss` style sheets, fonts, icons and its `locale/` texts, plus a manifest naming the client version it targets.
|
||||
- Interfaces bind to a **view model**, not to the world files. The client exposes data models (RmlUi data bindings) built from the application/protocol layer (`docs/protocol.md`), with ids and asset keys as values. RmlUi loads images through a file interface that resolves `asset:` keys (§9.2).
|
||||
- Neither worlds nor packs contain layout, so a theme works with every world, and the classic 320×200 interface keeps working next to it.
|
||||
|
||||
## 10. Validation and limits
|
||||
|
||||
The validator (planned `openbmh_cli --validate <file>`) checks, in this order:
|
||||
|
||||
1. Container, manifest, `format_version`, `min_reader`, `requires`.
|
||||
2. Every table against its JSON Schema.
|
||||
3. References: every id used exists and has the right type; no id is defined twice.
|
||||
4. Competition logic: slot counts match stage sizes; movements between tiers are balanced; every stage can be scheduled in the calendar; fixture generators exist for the sizes.
|
||||
5. Engine limits declared in `manifest.limits` and enforced by the engine of a version. For 1.0:
|
||||
|
||||
| Limit | Value |
|
||||
|---|---|
|
||||
| Competitions of type `league` (national and foreign) | **32** |
|
||||
| Teams per league | 4 to 24 |
|
||||
| Squad size per team | engine maximum of the attribute set |
|
||||
| Groups per stage | 16 |
|
||||
|
||||
The format itself has no fixed limits; a later engine raises them by changing `limits` and its own checks, without a format change.
|
||||
|
||||
Errors name the file, the JSON path and the rule (`clubs.json: items[41].stadium: unknown id stadium:0999`).
|
||||
|
||||
## 11. Implementation steps
|
||||
|
||||
| Step | Roadmap | Content |
|
||||
|---|---|---|
|
||||
| 1 | 0.2 | Schemas 1.0, reader/writer, validator, round-trip tests with synthetic worlds |
|
||||
| 2 | 0.2 | Importer for German editions and FLTD into `.obw`; adapter OBW → current `GameState`; regression: same first seasons |
|
||||
| 3 | 0.2 | `.FBM` → `.obs` conversion and native OBW saves; area by area the engine reads typed data instead of the memory image (clubs, players, contracts, finances, then competitions) |
|
||||
| 4 | 0.3 | `rules.json` drives the rule values; balance changes as data |
|
||||
| 5 | 0.4 | Generic competition engine (stage formats, slots, pyramid, variable league sizes up to the limits); templates for the real-world club cups and national-team competitions |
|
||||
| 6 | 0.4 | Asset resolver, packs, `.po` languages, RmlUi client with themes |
|
||||
| 7 | 0.5 | Own worlds that need no original data |
|
||||
|
||||
Each step keeps the game playable and the regression runs green; the legacy formats stay readable as import sources.
|
||||
@@ -19,7 +19,6 @@ Unless a page says otherwise, integer fields are little endian. Legacy strings u
|
||||
| Audio containers | `S/2000` through `S/2003` | [SOUND](SOUND.md) | `src/audio/container.cpp`, `original.cpp` |
|
||||
| Executable data | German LE and English X-32 images | [LE](LE.md), [executable layout](EXECUTABLE_LAYOUT.md) | `src/formats/le.cpp`, `src/launch/fltd.cpp` |
|
||||
| IFF crest template | `WAPPEN.LBM` | [WAPPEN](WAPPEN.md) | Not loaded by OpenBMH |
|
||||
| OpenBMH world, save and pack (concept) | `*.obw`, `*.obs`, `*.obp`, `*.obt` | [OBW](OBW.md) | Planned for 0.2 |
|
||||
|
||||
German and English editions can share a physical format while differing in text, league contents, executable layout and currency. Select the edition through the supplied installation; do not rename files or patch a save header to simulate another version. Original English V2.20 save import is a separate compatibility limitation from English installation support.
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -1,60 +0,0 @@
|
||||
# OpenBMH v0.1.2
|
||||
|
||||
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.
|
||||
|
||||
## Changes in 0.1.2
|
||||
|
||||
- The environment menu shows all six original artwork panels: three youth teams,
|
||||
assistant coach, doctor and physio. Youth panels include their league and rank.
|
||||
- All six monthly budgets can be set directly to zero through six stars. Youth
|
||||
development, season promotion/relegation, finance previews and monthly accounts
|
||||
share those values. Existing academy lump-sum saves retain their paid status.
|
||||
- Match-minute pacing follows the loaded original delay setting; A9 in Settings
|
||||
allows faster or slower progression. No fixed 250-ms pause is added. Retrace
|
||||
animations use the original reference rate on different host monitors.
|
||||
- External test fixtures are now recognised correctly by CMake instead of being
|
||||
reported as unavailable despite configured paths.
|
||||
|
||||
See [compatibility decisions](../../COMPATIBILITY.md) for youth recruitment and
|
||||
legacy contract handling. The previous UI corrections remain included.
|
||||
|
||||
## Changes in 0.1.1
|
||||
|
||||
- Live lineup navigation preserves the saved pitch view and allows repeated switches between the team list and pitch. Right-click can leave the dialog even when the pointer moves between press and release ([#1](https://github.com/Weyoune/openbmh/issues/1)).
|
||||
- The instruction panel restores original control symbols, substitute information, red coverage on player hover and pitch-position hints ([#2](https://github.com/Weyoune/openbmh/issues/2)).
|
||||
- Right-click cancels load/save dialogs, including settings and desktop-layout files ([#3](https://github.com/Weyoune/openbmh/issues/3)).
|
||||
- Save filenames accept typing immediately, replace a selected existing name and support Ctrl+A/Cmd+A. This also applies to desktop layouts saved as MEN files ([#4](https://github.com/Weyoune/openbmh/issues/4)).
|
||||
|
||||
These corrections passed targeted UI/controller checks and Linux SDL input replays, including normal and Reality matches, substitutions, file writing and a fresh-process reload. Physical macOS window verification remains human QA. Use packages from 0.1.1 or later to test these fixes; older 0.1.0 builds do not include them.
|
||||
|
||||
## 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. A known limitation can reject an English save made after the first calendar
|
||||
advance: the saved turn cursor may no longer match the active calendar. Initial
|
||||
save/reload works; a complete English career is not yet verified. 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.2](https://github.com/Weyoune/openbmh/tree/v0.1.2). 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.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -1,4 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -539,12 +541,11 @@ 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)
|
||||
@@ -3336,7 +3337,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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+104
-56
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/live_timing.hpp"
|
||||
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
|
||||
@@ -10,6 +11,7 @@
|
||||
#include <SDL.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -24,10 +26,12 @@
|
||||
#include <vector>
|
||||
|
||||
#include "app/controller.hpp"
|
||||
#include "app/quit_confirmation.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include "launch/file_dialog.hpp"
|
||||
#include "launch/game_data.hpp"
|
||||
#include "version.hpp"
|
||||
#include "app/video_session.hpp"
|
||||
#include "app/live_matchday_events.hpp"
|
||||
#include "audio/playback.hpp"
|
||||
#include "app/audio.hpp"
|
||||
@@ -74,6 +78,18 @@ static void show_start_error(const std::string& text) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenBMH", text.c_str(), nullptr);
|
||||
}
|
||||
|
||||
// Reattach the native editor when an in-game filename field takes focus. Cocoa
|
||||
// owns a field-editor responder in addition to SDL's TEXTINPUT enable flag.
|
||||
static void focus_filename_input(SDL_Renderer* renderer) {
|
||||
int left, top, right, bottom;
|
||||
SDL_RenderLogicalToWindow(renderer, 106, 209, &left, &top);
|
||||
SDL_RenderLogicalToWindow(renderer, 262, 219, &right, &bottom);
|
||||
const SDL_Rect field{left, top, std::max(1, right - left), std::max(1, bottom - top)};
|
||||
SDL_StopTextInput();
|
||||
SDL_SetTextInputRect(&field);
|
||||
SDL_StartTextInput();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// The game is a Windows GUI program (no console window on double-click). Started from a
|
||||
// console, it writes --version, --help and start errors there (kernel32 AttachConsole).
|
||||
@@ -129,13 +145,16 @@ int main(int argc, char** argv) {
|
||||
std::printf("OpenBMH %s\n", bmh::kOpenBmhVersion);
|
||||
return 0;
|
||||
} else if (is("--help") || is("-h")) {
|
||||
std::printf("usage: openbmh_play [<game directory | BMH.EXE | game.zip | game.7z>] [--seed <Watcom seed>] "
|
||||
std::printf("usage: OpenBMH [<game directory | BMH.EXE | game.zip | game.7z>] [--seed <Watcom seed>] "
|
||||
"[--save-directory <directory>] [--mute] [--volume <0..1>] [--no-music] [--live-frame-ms <0..1000>]\n");
|
||||
return 0;
|
||||
} else if (args[i].rfind("--", 0) != 0 && data.empty()) {
|
||||
data = launch::path_from_utf8(args[i]);
|
||||
}
|
||||
}
|
||||
std::optional<app::VideoSession> video;
|
||||
try { video.emplace(); }
|
||||
catch (const std::exception& error) { show_start_error(error.what()); return 1; }
|
||||
// the game: as given (directory, EXE or archive); else the directory OpenBMH itself lies in,
|
||||
// when it holds a playable game (the simplest install: openbmh next to BMH.EXE); else
|
||||
// chosen in the file dialog
|
||||
@@ -179,7 +198,6 @@ int main(int argc, char** argv) {
|
||||
ui::StartupFlow flow(data, save_directory);
|
||||
std::unique_ptr<app::CareerSession> session;
|
||||
uint64_t revision = 0;
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) throw FormatError(SDL_GetError());
|
||||
openbmh::audio::Playback playback;
|
||||
std::string audio_error;
|
||||
playback.initialize(audio_error); // Audio is optional; the game continues without a device.
|
||||
@@ -206,6 +224,8 @@ int main(int argc, char** argv) {
|
||||
ui::SportschauTeamInfo sportschau_team_info(data);
|
||||
ui::CompetitionWinnerScreen competition_winner(data);
|
||||
const auto season_exe = load_le(ui::asset_path(data, "BMH.exe"));
|
||||
english_game = english_game || season_exe.u8(layout::LeagueSizes) == 20;
|
||||
app::QuitConfirmation quit_confirmation(window, english_game);
|
||||
try {
|
||||
if (!playback.initialize_original(app::original_audio_assets(data, season_exe), audio_error))
|
||||
std::fprintf(stderr, "audio: %s\n", audio_error.c_str());
|
||||
@@ -345,7 +365,7 @@ int main(int argc, char** argv) {
|
||||
if (screen.close_requested()) return renewed_expired_player ? 1 : 0;
|
||||
SDL_Event event;
|
||||
bool changed = false;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) {
|
||||
running = false;
|
||||
staged = before;
|
||||
@@ -447,7 +467,7 @@ int main(int argc, char** argv) {
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
while (running) {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) return;
|
||||
@@ -461,7 +481,7 @@ int main(int argc, char** argv) {
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
while (running) {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) return;
|
||||
@@ -474,7 +494,7 @@ int main(int argc, char** argv) {
|
||||
SDL_Delay(20); // Source timer unit used by the traced intro path.
|
||||
SDL_PumpEvents();
|
||||
SDL_Event close;
|
||||
while (SDL_PeepEvents(&close, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0)
|
||||
while (quit_confirmation.peep(&close, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0)
|
||||
running = false; // platform close is the only intro-loop escape
|
||||
}
|
||||
};
|
||||
@@ -488,7 +508,7 @@ int main(int argc, char** argv) {
|
||||
while (running && SDL_GetPerformanceCounter() - started < ticks_per_wait) {
|
||||
SDL_PumpEvents();
|
||||
SDL_Event close;
|
||||
while (SDL_PeepEvents(&close, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0)
|
||||
while (quit_confirmation.peep(&close, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0)
|
||||
running = false; // platform close is the only animation-loop escape
|
||||
if (running) SDL_Delay(1);
|
||||
}
|
||||
@@ -538,7 +558,7 @@ int main(int argc, char** argv) {
|
||||
bool skipped = false;
|
||||
while (running && !skipped && SDL_GetTicks() - start < duration) {
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) running = false;
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_LEFT)
|
||||
skipped = true;
|
||||
@@ -561,14 +581,14 @@ int main(int argc, char** argv) {
|
||||
bool skip = false;
|
||||
SDL_Event input;
|
||||
if (step.minute_wait) {
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) running = false;
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_LEFT)
|
||||
skip = true;
|
||||
}
|
||||
} else {
|
||||
SDL_PumpEvents();
|
||||
while (SDL_PeepEvents(&input, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) running = false;
|
||||
while (quit_confirmation.peep(&input, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) running = false;
|
||||
}
|
||||
if (!running) return true;
|
||||
const std::string title = "OpenBMH - sportschau_replay_" + std::to_string(fixture.group) +
|
||||
@@ -668,8 +688,7 @@ int main(int argc, char** argv) {
|
||||
view.manager_name += char(state.manager_records[base + 0xa8 + i]);
|
||||
view.body = event.text;
|
||||
view.portrait = state.manager_records[base + 0x221];
|
||||
view.badge_fallback = event.team == 0x0fff || (event.team > 89 && event.team < 138) ||
|
||||
(event.team > 167 && event.team < 357);
|
||||
view.badge_fallback = original_badge_fallback(event.team);
|
||||
view.badge_sprite = view.badge_fallback ? 0 : le16(state.club_heap_78, size_t(event.team) * 2) & 0x1ff;
|
||||
ui::GameEndTaxDialog screen(data, std::move(view), game_end_options(state),
|
||||
event.kind == SeasonTaxEventKind::outcome ? season_backdrop : std::optional<Image>{});
|
||||
@@ -683,7 +702,7 @@ int main(int argc, char** argv) {
|
||||
auto pressed = ui::GameEndTaxDialog::Button::none;
|
||||
while (running) {
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return false; }
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN) {
|
||||
if (event.kind != SeasonTaxEventKind::question &&
|
||||
@@ -722,7 +741,7 @@ int main(int argc, char** argv) {
|
||||
const auto started = SDL_GetTicks();
|
||||
while (running && Uint32(SDL_GetTicks() - started) < animation.wait_milliseconds()) {
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) if (input.type == SDL_QUIT) running = false;
|
||||
while (quit_confirmation.poll(&input)) if (input.type == SDL_QUIT) running = false;
|
||||
// Source param4=0: clicks/keys cannot change this script or RNG.
|
||||
SDL_Delay(10);
|
||||
}
|
||||
@@ -739,7 +758,7 @@ int main(int argc, char** argv) {
|
||||
// events for the next Original input boundary; only handle SDL exit.
|
||||
SDL_PumpEvents();
|
||||
SDL_Event quit;
|
||||
if (SDL_PeepEvents(&quit, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) running = false;
|
||||
if (quit_confirmation.peep(&quit, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) running = false;
|
||||
if (running) SDL_Delay(10);
|
||||
}
|
||||
};
|
||||
@@ -794,7 +813,7 @@ int main(int argc, char** argv) {
|
||||
if (timed && Uint32(SDL_GetTicks() - started) >= 70 * 3 * 20)
|
||||
return complete(PendingOfferAnswer::yes);
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return PendingOfferAnswer::unsupported; }
|
||||
const bool question_deadline = question && poll_process_timer(true,true);
|
||||
if (question_deadline && pressed == ui::GameEndTaxDialog::Button::none)
|
||||
@@ -864,7 +883,7 @@ int main(int argc, char** argv) {
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP); // DecodeTaxAnimationScript/SDLFlushEvents redraw boundary
|
||||
while (running) {
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return PendingOfferTransferChoice{}; }
|
||||
std::optional<int> bid;
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||
@@ -893,7 +912,7 @@ int main(int argc, char** argv) {
|
||||
bool acknowledged=false;
|
||||
while(running && !acknowledged) {
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event)) {
|
||||
while(quit_confirmation.poll(&event)) {
|
||||
if(event.type==SDL_QUIT){running=false;break;}
|
||||
if(event.type==SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button==SDL_BUTTON_LEFT || event.button.button==SDL_BUTTON_RIGHT)) {
|
||||
@@ -956,7 +975,7 @@ int main(int argc, char** argv) {
|
||||
draw();
|
||||
while (running) {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return -1; }
|
||||
ui::OutgoingTransferRequest action;
|
||||
if (event.type == SDL_MOUSEMOTION) continue;
|
||||
@@ -1073,7 +1092,7 @@ int main(int argc, char** argv) {
|
||||
while (running) {
|
||||
if (deadline_expired()) return true; //ClubInfoFromGame event8 returns to its owning caller.
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return false; }
|
||||
if (deadline_expired()) return true;
|
||||
ui::ClubInfoRequest request;
|
||||
@@ -1174,7 +1193,7 @@ int main(int argc, char** argv) {
|
||||
SDL_PumpEvents();
|
||||
while (running && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON_LMASK)) {
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input))
|
||||
while (quit_confirmation.poll(&input))
|
||||
if (input.type == SDL_QUIT) { running = false; return; }
|
||||
SDL_PumpEvents();
|
||||
if (running) SDL_Delay(10);
|
||||
@@ -1242,7 +1261,7 @@ int main(int argc, char** argv) {
|
||||
while (running) {
|
||||
if (const auto complete = expire_card()) return *complete;
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return std::nullopt; }
|
||||
if (const auto complete = expire_card()) return *complete;
|
||||
bool changed = false;
|
||||
@@ -1304,7 +1323,7 @@ int main(int argc, char** argv) {
|
||||
while (running) {
|
||||
if (deadline_expired()) return; //LeagueCalculations frees its child before4f548 polls again.
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return; }
|
||||
if (deadline_expired()) return;
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_RIGHT)
|
||||
@@ -1388,7 +1407,7 @@ int main(int argc, char** argv) {
|
||||
while(running&&!outcome) {
|
||||
if(expire_range())break;
|
||||
SDL_Event input;
|
||||
while(SDL_PollEvent(&input)) {
|
||||
while(quit_confirmation.poll(&input)) {
|
||||
if(input.type==SDL_QUIT){running=false;break;}
|
||||
if(expire_range())break;
|
||||
bool changed=false;
|
||||
@@ -1444,7 +1463,7 @@ int main(int argc, char** argv) {
|
||||
while(running) {
|
||||
if(deadline_expired())return std::nullopt;
|
||||
SDL_Event input;
|
||||
while(SDL_PollEvent(&input)) {
|
||||
while(quit_confirmation.poll(&input)) {
|
||||
if(input.type==SDL_QUIT){running=false;break;}
|
||||
if(deadline_expired())return std::nullopt;
|
||||
bool changed=false;
|
||||
@@ -1538,7 +1557,7 @@ int main(int argc, char** argv) {
|
||||
// Source ignores the first OriginalMouseSound poll's gameplay result, then
|
||||
// presents the starting scene before its ten option-delay polls.
|
||||
SDL_Event initial;
|
||||
if (SDL_PollEvent(&initial) && initial.type == SDL_QUIT) { running = false; return; }
|
||||
if (quit_confirmation.poll(&initial) && initial.type == SDL_QUIT) { running = false; return; }
|
||||
show_draw();
|
||||
while (running && screen.advance_step()) {
|
||||
if (screen.present_needed()) show_draw();
|
||||
@@ -1546,7 +1565,7 @@ int main(int argc, char** argv) {
|
||||
if (!running) return;
|
||||
if (screen.input_poll_needed()) {
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return; }
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(input.button.button == SDL_BUTTON_LEFT || input.button.button == SDL_BUTTON_RIGHT)) {
|
||||
@@ -1581,7 +1600,7 @@ int main(int argc, char** argv) {
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
while (running) {
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return; }
|
||||
if (input.type != SDL_MOUSEBUTTONDOWN) continue;
|
||||
if (input.button.button == SDL_BUTTON_RIGHT) return;
|
||||
@@ -1618,7 +1637,7 @@ int main(int argc, char** argv) {
|
||||
while (running && screen.phase() == ui::AlternateScorePhase::Calculator) {
|
||||
SDL_Event event;
|
||||
bool changed = false;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT) {
|
||||
right_cancel = true;
|
||||
@@ -1683,6 +1702,11 @@ int main(int argc, char** argv) {
|
||||
std::optional<Uint64> timed_notice_presented_at;
|
||||
std::optional<Uint8> timed_notice_release;
|
||||
auto handle = [&](const ui::FlowResult& r) {
|
||||
if (r.request == ui::FlowRequest::end_session && !quit_confirmation.confirm()) {
|
||||
flow.reject_desk_action(english_game ? "Quit cancelled." : "Beenden abgebrochen.");
|
||||
dirty = true;
|
||||
return;
|
||||
}
|
||||
if (const auto* desk = flow.desktop())
|
||||
for (const auto id : desk->take_sound_ids()) app::original_audio_command(playback, id);
|
||||
if (r.request == ui::FlowRequest::kickoff || r.request == ui::FlowRequest::end_session) {
|
||||
@@ -1805,7 +1829,7 @@ int main(int argc, char** argv) {
|
||||
SDL_RenderPresent(renderer);
|
||||
SDL_Event modal;
|
||||
bool redrawn = false;
|
||||
while (SDL_PollEvent(&modal)) {
|
||||
while (quit_confirmation.poll(&modal)) {
|
||||
if (modal.type == SDL_QUIT) { running = false; closed = true; break; }
|
||||
if (modal.type == SDL_KEYDOWN && modal.key.keysym.sym == SDLK_ESCAPE) {
|
||||
screen.key("ESC"); closed = true; break;
|
||||
@@ -1975,7 +1999,7 @@ int main(int argc, char** argv) {
|
||||
show_dialog();
|
||||
while (running && !outcome) {
|
||||
SDL_Event input;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; break; }
|
||||
bool changed = false;
|
||||
if (input.type == SDL_TEXTINPUT) {
|
||||
@@ -2075,7 +2099,7 @@ int main(int argc, char** argv) {
|
||||
while (running && !closed) {
|
||||
SDL_Event input;
|
||||
bool redrawn = false;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; break; }
|
||||
if (input.type == SDL_MOUSEMOTION) {
|
||||
const bool changed = table_screen ? table_screen->move(input.motion.x, input.motion.y)
|
||||
@@ -2185,7 +2209,7 @@ int main(int argc, char** argv) {
|
||||
offer_dirty = false;
|
||||
}
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return -1; }
|
||||
std::optional<int> answer;
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
@@ -2254,7 +2278,7 @@ int main(int argc, char** argv) {
|
||||
rendered_phase = phase;
|
||||
}
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))
|
||||
@@ -2282,7 +2306,7 @@ int main(int argc, char** argv) {
|
||||
bool dismissed = false;
|
||||
while (running && !dismissed) {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
@@ -2436,7 +2460,7 @@ int main(int argc, char** argv) {
|
||||
SDL_RenderPresent(renderer);
|
||||
SDL_Event modal;
|
||||
bool redrawn = false;
|
||||
while (SDL_PollEvent(&modal)) {
|
||||
while (quit_confirmation.poll(&modal)) {
|
||||
if (modal.type == SDL_QUIT) { running = false; closed = true; break; }
|
||||
if (modal.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(modal.button.button == SDL_BUTTON_LEFT || modal.button.button == SDL_BUTTON_RIGHT))
|
||||
@@ -2501,7 +2525,7 @@ int main(int argc, char** argv) {
|
||||
bool resumed = false;
|
||||
while (running && !resumed) {
|
||||
SDL_Event paused_event;
|
||||
while (SDL_PollEvent(&paused_event)) {
|
||||
while (quit_confirmation.poll(&paused_event)) {
|
||||
if (paused_event.type == SDL_QUIT) {
|
||||
quit = true;
|
||||
live_skipped = true;
|
||||
@@ -2614,11 +2638,12 @@ int main(int argc, char** argv) {
|
||||
SDL_RenderPresent(renderer);
|
||||
};
|
||||
render_file();
|
||||
focus_filename_input(renderer);
|
||||
bool finished = false;
|
||||
while (running && !finished) {
|
||||
SDL_Event file_input;
|
||||
bool file_changed = false;
|
||||
while (SDL_PollEvent(&file_input)) {
|
||||
while (quit_confirmation.poll(&file_input)) {
|
||||
if (file_input.type == SDL_QUIT) { running = false; break; }
|
||||
if (file_input.type == SDL_MOUSEBUTTONUP &&
|
||||
(file_input.button.button == SDL_BUTTON_LEFT ||
|
||||
@@ -2678,7 +2703,7 @@ int main(int argc, char** argv) {
|
||||
while (running && !closed) {
|
||||
SDL_Event input;
|
||||
bool changed = false;
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; break; }
|
||||
if (readme) {
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||
@@ -2792,7 +2817,7 @@ int main(int argc, char** argv) {
|
||||
const bool source_phase_start = minute == 1 ||
|
||||
(state.indoor ? minute == 21 : (minute == 46 || minute == 91 || minute == 106));
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { quit = true; live_skipped = true; }
|
||||
else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)
|
||||
live_skipped = true;
|
||||
@@ -2913,7 +2938,7 @@ int main(int argc, char** argv) {
|
||||
present(live_screen.render_ball(frame, event.displacement, index, chance));
|
||||
SDL_PumpEvents();
|
||||
SDL_Event quit_event;
|
||||
if (SDL_PeepEvents(&quit_event, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) {
|
||||
if (quit_confirmation.peep(&quit_event, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) {
|
||||
running = false;
|
||||
break;
|
||||
}
|
||||
@@ -2950,7 +2975,7 @@ int main(int argc, char** argv) {
|
||||
SDL_RenderPresent(renderer);
|
||||
SDL_PumpEvents();
|
||||
SDL_Event quit_event;
|
||||
if (SDL_PeepEvents(&quit_event, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) {
|
||||
if (quit_confirmation.peep(&quit_event, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) {
|
||||
running = false;
|
||||
live_chance_context.reset();
|
||||
return;
|
||||
@@ -2982,7 +3007,7 @@ int main(int argc, char** argv) {
|
||||
SDL_RenderPresent(renderer);
|
||||
SDL_PumpEvents();
|
||||
SDL_Event input;
|
||||
if (SDL_PeepEvents(&input, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) {
|
||||
if (quit_confirmation.peep(&input, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) {
|
||||
running = false;
|
||||
return;
|
||||
}
|
||||
@@ -3004,7 +3029,7 @@ int main(int argc, char** argv) {
|
||||
SDL_Event input;
|
||||
bool acknowledged = false;
|
||||
while (running && !acknowledged) {
|
||||
while (SDL_PollEvent(&input)) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; break; }
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(input.button.button == SDL_BUTTON_LEFT || input.button.button == SDL_BUTTON_RIGHT)) {
|
||||
@@ -3039,7 +3064,7 @@ int main(int argc, char** argv) {
|
||||
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
||||
SDL_RenderClear(renderer);SDL_RenderCopy(renderer,texture,nullptr,nullptr);SDL_RenderPresent(renderer);
|
||||
SDL_PumpEvents();SDL_Event input;
|
||||
if (SDL_PeepEvents(&input,1,SDL_GETEVENT,SDL_QUIT,SDL_QUIT)>0) { running=false;return; }
|
||||
if (quit_confirmation.peep(&input,1,SDL_GETEVENT,SDL_QUIT,SDL_QUIT)>0) { running=false;return; }
|
||||
// FirstThen holds the first frame for 40 retraces; later frames
|
||||
// use saved Main_FormatError_RuntimeField2. Keyboard/mouse input remains for the minute hook.
|
||||
const int retraces=index==0?40:(state.memory.has(::bmh::layout::Main_FormatError_RuntimeField2)?state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField2):0);
|
||||
@@ -3065,7 +3090,7 @@ int main(int argc, char** argv) {
|
||||
if (event.kind != 2 && app::match_sound_enabled(state))
|
||||
app::original_audio_command(playback, 17); // EventImpl/SDLPumpEvents, no injury whistle.
|
||||
SDL_PumpEvents();SDL_Event input;
|
||||
if (SDL_PeepEvents(&input,1,SDL_GETEVENT,SDL_QUIT,SDL_QUIT)>0) { running=false;return; }
|
||||
if (quit_confirmation.peep(&input,1,SDL_GETEVENT,SDL_QUIT,SDL_QUIT)>0) { running=false;return; }
|
||||
const int pause=event.kind==0?3:4;
|
||||
const uint32_t address=::bmh::layout::Main_FormatError_ExecutableFieldUnsigned+uint32_t(pause*9);
|
||||
const int saved=state.memory.has(address)?state.memory.u8(address):0;
|
||||
@@ -3089,7 +3114,7 @@ int main(int argc, char** argv) {
|
||||
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
||||
SDL_RenderClear(renderer);SDL_RenderCopy(renderer,texture,nullptr,nullptr);SDL_RenderPresent(renderer);
|
||||
SDL_PumpEvents();SDL_Event input;
|
||||
if (SDL_PeepEvents(&input,1,SDL_GETEVENT,SDL_QUIT,SDL_QUIT)>0) { running=false;return; }
|
||||
if (quit_confirmation.peep(&input,1,SDL_GETEVENT,SDL_QUIT,SDL_QUIT)>0) { running=false;return; }
|
||||
const int repeats=event.stage==LiveShootoutStage::preview?4:2;
|
||||
const int saved=state.memory.has(::bmh::layout::Main_FormatError_RuntimeField6)?state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField6):0;
|
||||
const int delay=live_frame_ms_explicit?live_frame_ms:(saved<6?saved/2:saved)*20;
|
||||
@@ -3153,16 +3178,16 @@ int main(int argc, char** argv) {
|
||||
present(reality_surface,reality_colors,"OpenBMH - live_reality_report_"+round_identity);
|
||||
}
|
||||
SDL_PumpEvents();SDL_Event input;
|
||||
if (SDL_PeepEvents(&input,1,SDL_GETEVENT,SDL_QUIT,SDL_QUIT)>0) {running=false;return true;}
|
||||
if (quit_confirmation.peep(&input,1,SDL_GETEVENT,SDL_QUIT,SDL_QUIT)>0) {running=false;return true;}
|
||||
// Consume only the Source exit for this scene. Other input remains
|
||||
// queued for the existing live-minute/manager intervention boundary.
|
||||
if (SDL_PeepEvents(&input,1,SDL_PEEKEVENT,SDL_KEYDOWN,SDL_KEYDOWN)>0 &&
|
||||
if (quit_confirmation.peep(&input,1,SDL_PEEKEVENT,SDL_KEYDOWN,SDL_KEYDOWN)>0 &&
|
||||
input.key.keysym.sym==SDLK_ESCAPE) {
|
||||
SDL_PeepEvents(&input,1,SDL_GETEVENT,SDL_KEYDOWN,SDL_KEYDOWN);return true;
|
||||
quit_confirmation.peep(&input,1,SDL_GETEVENT,SDL_KEYDOWN,SDL_KEYDOWN);return true;
|
||||
}
|
||||
if (SDL_PeepEvents(&input,1,SDL_PEEKEVENT,SDL_MOUSEBUTTONDOWN,SDL_MOUSEBUTTONDOWN)>0 &&
|
||||
if (quit_confirmation.peep(&input,1,SDL_PEEKEVENT,SDL_MOUSEBUTTONDOWN,SDL_MOUSEBUTTONDOWN)>0 &&
|
||||
input.button.button==SDL_BUTTON_RIGHT) {
|
||||
SDL_PeepEvents(&input,1,SDL_GETEVENT,SDL_MOUSEBUTTONDOWN,SDL_MOUSEBUTTONDOWN);return true;
|
||||
quit_confirmation.peep(&input,1,SDL_GETEVENT,SDL_MOUSEBUTTONDOWN,SDL_MOUSEBUTTONDOWN);return true;
|
||||
}
|
||||
return false;
|
||||
}, [&](const PhaseResultRequest& request, const std::vector<MatchGroup>& groups,
|
||||
@@ -3575,18 +3600,42 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
};
|
||||
SDL_StartTextInput();
|
||||
bool filename_input_active = false;
|
||||
std::array<bool, 2> setup_button_down{};
|
||||
while (running) {
|
||||
const bool filename_open = flow.screen_name() == "save_load";
|
||||
if (filename_open && !filename_input_active) focus_filename_input(renderer);
|
||||
filename_input_active = filename_open;
|
||||
if(timed_notice_presented_at && flow.timed_notice_open() &&
|
||||
SDL_GetTicks64()-*timed_notice_presented_at>=70*3*20)
|
||||
handle(flow.expire_timed_notice());
|
||||
service_process_timer();
|
||||
if (!running) break;
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e)) {
|
||||
while (quit_confirmation.poll(&e)) {
|
||||
if (e.type == SDL_QUIT) {
|
||||
running = false;
|
||||
break;
|
||||
}
|
||||
if (e.type == SDL_WINDOWEVENT) {
|
||||
if (e.window.event == SDL_WINDOWEVENT_FOCUS_LOST) setup_button_down.fill(false);
|
||||
if (e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
|
||||
if (flow.screen_name() == "save_load") focus_filename_input(renderer);
|
||||
else SDL_StartTextInput();
|
||||
}
|
||||
}
|
||||
// A native picker/window activation can leave an unmatched UP.
|
||||
// Only a press which began on setup may toggle its options.
|
||||
if ((e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) &&
|
||||
(e.button.button == SDL_BUTTON_LEFT || e.button.button == SDL_BUTTON_RIGHT)) {
|
||||
const size_t button = e.button.button == SDL_BUTTON_LEFT ? 0 : 1;
|
||||
if (e.type == SDL_MOUSEBUTTONDOWN) setup_button_down[button] = flow.screen_name() == "setup";
|
||||
else {
|
||||
const bool owned = setup_button_down[button];
|
||||
setup_button_down[button] = false;
|
||||
if (flow.screen_name() == "setup" && !owned) continue;
|
||||
}
|
||||
}
|
||||
if(e.type==SDL_MOUSEBUTTONUP&&timed_notice_release&&e.button.button==*timed_notice_release) {
|
||||
timed_notice_release.reset();continue;
|
||||
}
|
||||
@@ -3642,7 +3691,8 @@ int main(int argc, char** argv) {
|
||||
continue;
|
||||
}
|
||||
if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE &&
|
||||
!flow.in_preparation_menu() && !flow.in_results_view() && !flow.in_readonly_view())
|
||||
!flow.in_preparation_menu() && !flow.in_results_view() && !flow.in_readonly_view() &&
|
||||
quit_confirmation.confirm())
|
||||
running = false;
|
||||
if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_LEFT)
|
||||
press = Press{e.button.x, e.button.y, SDL_GetTicks(), flow.screen_name(),
|
||||
@@ -3856,11 +3906,9 @@ int main(int argc, char** argv) {
|
||||
SDL_DestroyWindow(window);
|
||||
mouse_sound.detach(); // Remove event producers before closing the audio device.
|
||||
playback.shutdown();
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
std::fprintf(stderr, "error: %s\n", e.what());
|
||||
SDL_Quit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
@@ -1972,4 +1972,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; }
|
||||
@@ -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
@@ -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()
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,23 @@
|
||||
// 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");
|
||||
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; }
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
+20
-1
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
#include "game/environment.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
|
||||
namespace bmh {
|
||||
namespace {
|
||||
bool supported_environment = true; // Synthetic state tests explicitly use the verified monthly model.
|
||||
|
||||
uint32_t youth_at(int manager) { return layout::EnvironmentYouthTeams + uint32_t(manager) * 0x24; }
|
||||
uint32_t spending_at(int manager, int item) {
|
||||
return layout::Spending + uint32_t(manager) * 0x24 + uint32_t(item) * 4;
|
||||
@@ -29,6 +32,21 @@ uint32_t academy_paid(const GameState& g, int manager) {
|
||||
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
|
||||
}
|
||||
}
|
||||
void install_environment_rules(const LeImage& exe) {
|
||||
for (size_t i=0;i<kEnvironmentStep.size();++i) {
|
||||
const uint32_t at=layout::EnvironmentBudgetSteps+uint32_t(i);
|
||||
if (!exe.contains(at) || exe.u8(at)==0) { supported_environment=false; return; }
|
||||
kEnvironmentStep[i]=int32_t(exe.u8(at))*1000;
|
||||
}
|
||||
uint64_t fingerprint = 14695981039346656037ull;
|
||||
for (const auto [first,last] : {std::pair{layout::EnvironmentVerifiedCodeBegin,layout::EnvironmentVerifiedCodeEnd},std::pair{layout::EnvironmentVerifiedHookBegin,layout::EnvironmentVerifiedHookEnd}}) {
|
||||
if (!exe.contains(first) || !exe.contains(last-1)) { supported_environment=false; return; }
|
||||
for (uint32_t at=first;at<last;++at) fingerprint=(fingerprint ^ exe.u8(at))*1099511628211ull;
|
||||
}
|
||||
// Fingerprints identify verified behaviour, not filenames, dates or artwork.
|
||||
supported_environment = fingerprint==0xc2488a656f340e99ull || fingerprint==0x19adba7ef3eda507ull;
|
||||
}
|
||||
bool environment_rules_supported() { return supported_environment; }
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
|
||||
const auto value = g.memory.u32(spending_at(manager, item));
|
||||
if (item == kYouthAcademy && legacy_academy(g, manager) && academy_paid(g, manager) >= value) return 0;
|
||||
@@ -39,6 +57,7 @@ bool environment_academy_active(const GameState& g, int manager) {
|
||||
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
|
||||
}
|
||||
EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
if (!supported_environment) throw FormatError("environment: this original program variant is not verified");
|
||||
validate_manager(g, manager);
|
||||
EnvironmentState result;
|
||||
for (int i = 0; i < kEnvironmentItems; ++i) {
|
||||
@@ -56,6 +75,7 @@ EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
}
|
||||
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
|
||||
if (message) message->clear();
|
||||
if (!supported_environment) return EnvironmentResult::invalid;
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems ||
|
||||
level < 0 || level > 6 || !g.memory.has(spending_at(manager, item) + 3))
|
||||
return EnvironmentResult::invalid;
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "game/random.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "game/state.hpp"
|
||||
|
||||
namespace bmh {
|
||||
// Verified original-program capability; unknown environment variants are not guessed.
|
||||
void install_environment_rules(const LeImage&);
|
||||
bool environment_rules_supported();
|
||||
constexpr int kEnvironmentItems = 6;
|
||||
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
|
||||
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
|
||||
// OpenBMH deviates from the original: uses six monthly environment budgets across data editions while retaining the shared staff prices and academy player-generation strength bands.
|
||||
inline constexpr std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
// Monthly environment model verified in the supported CD and Diamond 3.6/3.7 programs.
|
||||
inline std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
struct EnvironmentState {
|
||||
std::array<int32_t, kEnvironmentItems> monthly{};
|
||||
std::array<int, kEnvironmentItems> level{};
|
||||
|
||||
+54
-2
@@ -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
@@ -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);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/messages.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
@@ -150,4 +151,13 @@ std::string format_number(const GameState& g, int32_t value, int 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
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@@ -25,7 +26,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 +46,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;
|
||||
}
|
||||
|
||||
|
||||
+26
-3
@@ -1104,8 +1104,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;
|
||||
@@ -1169,10 +1167,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;
|
||||
@@ -1234,7 +1238,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--;
|
||||
@@ -1252,6 +1258,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;
|
||||
@@ -1262,6 +1272,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
|
||||
@@ -1637,6 +1649,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) {
|
||||
@@ -1656,6 +1678,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);
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-3
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/week.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
|
||||
#include "game/matchday.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
@@ -93,9 +94,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) {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
#include "formats/rule_base.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include "launch/game_data.hpp"
|
||||
|
||||
@@ -120,7 +119,6 @@ LeImage translate_fltd(const fs::path& fltd_exe) {
|
||||
}
|
||||
}
|
||||
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
|
||||
apply_rule_base(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -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, {}},
|
||||
|
||||
@@ -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 13"; // 13: setup toggle rows, positive balance colour and desktop bar controls
|
||||
std::string built;
|
||||
{
|
||||
std::ifstream in(marker);
|
||||
|
||||
@@ -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;}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/club_player_detail.hpp"
|
||||
|
||||
@@ -50,7 +51,7 @@ ClubPlayerDetailProjection club_player_detail_from_game(const GameState& g,
|
||||
club.original_short_name=club.original_short_name.substr(raw>>4,(raw&15)+1);
|
||||
}
|
||||
// SourceBadgeFallback consults the selector only for real atlas clubs.
|
||||
if(id<=89||(id>=138&&id<=167)||id>=357){
|
||||
if(!original_badge_fallback(id,&exe)){
|
||||
if(size_t(id)*2+1>=g.club_heap_78.size())throw FormatError("club player detail: truncated badge table");
|
||||
club.badge_selector=le16(g.club_heap_78,size_t(id)*2)&0x1ff;
|
||||
}
|
||||
@@ -92,7 +93,7 @@ ClubPlayerDetailScreen::ClubPlayerDetailScreen(const std::filesystem::path& data
|
||||
if(atlas_.width==314){Image padded(320,atlas_.height);padded.blit(atlas_,0,0);atlas_=std::move(padded);}
|
||||
for(size_t i=0;i<2;++i)if(projection_.clubs[i]){
|
||||
auto& club=*projection_.clubs[i];const int id=club.runtime_team;
|
||||
if(id<=89||(id>=138&&id<=167)||id>=357){
|
||||
if(!original_badge_fallback(id,&exe_)){
|
||||
badges_[i]=load_vga(asset_path(data/"W",std::to_string(club.badge_selector>>3)+".VGA"));
|
||||
}
|
||||
// TextWidth national/foreign names: longest word, then remove two
|
||||
|
||||
+3
-2
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/cup_draw.hpp"
|
||||
|
||||
@@ -229,7 +230,7 @@ struct CupDrawScreen::Impl {
|
||||
copy(screen,panel,0,0,29,22,261,203);bottom=screen;drawing=screen;present=true;flush=true;}
|
||||
else {draw_overview();drawing=screen;}
|
||||
for(size_t i=0;i<p.count;++i){const int id=p.clubs[i].runtime_id,sel=p.clubs[i].badge_selector&0x1ff;
|
||||
if(!((id>=0x5a&&id<=0x89)||(id>=0xa8&&id<=0x164)||id==0xfff)){
|
||||
if(!original_badge_fallback(id,&exe)){
|
||||
const int atlas=sel>>3;if(!badges.contains(atlas))badges.emplace(atlas,load_vga(asset_path(data/"W",std::to_string(atlas)+".VGA")));
|
||||
}
|
||||
}
|
||||
@@ -255,7 +256,7 @@ struct CupDrawScreen::Impl {
|
||||
void source_badge(Image& out,const CupDrawClub& c,int x,int y) const {
|
||||
source_frame(out,x,y);
|
||||
const int id=c.runtime_id,selector=c.badge_selector&0x1ff;
|
||||
if((id>=0x5a&&id<=0x89)||(id>=0xa8&&id<=0x164)||id==0xfff)
|
||||
if(original_badge_fallback(id,&exe))
|
||||
copy(out,widgets,8,0,x,y,38,38);
|
||||
else {
|
||||
const int atlas=selector>>3;copy(out,badges.at(atlas),(selector&7)*38,0,x,y,38,38);
|
||||
|
||||
+23
-4
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
@@ -461,7 +463,11 @@ void validate_desk_state(const DeskState& d) {
|
||||
|
||||
DeskDate desk_date(uint32_t counter, const LeImage& exe) {
|
||||
if (counter == 0xffff || counter > 3000000) throw FormatError("desk: unsupported date counter");
|
||||
DeskDate d; d.weekday = int((counter + 2) % 7);
|
||||
// Partial data-only images use the explicitly installed calendar. Full
|
||||
// executable images must supply their verified original date setup.
|
||||
const auto epoch = exe.contains(layout::CalendarDateSetup)
|
||||
? calendar_epoch_from_executable(exe) : calendar_epoch();
|
||||
DeskDate d; d.weekday = int((counter + uint32_t(epoch.weekday)) % 7);
|
||||
int cycle = 3, years = 0;
|
||||
while (counter > uint32_t(364 + (cycle == 4))) {
|
||||
if (cycle == 4) { cycle = 0; --counter; }
|
||||
@@ -478,10 +484,22 @@ DeskDate desk_date(uint32_t counter, const LeImage& exe) {
|
||||
d.day -= month_days();
|
||||
if (++d.month == 13) { d.month = 1; ++years; }
|
||||
}
|
||||
d.year = 2026 + years;
|
||||
d.year = epoch.year + years;
|
||||
return d;
|
||||
}
|
||||
|
||||
namespace {
|
||||
void project_automation_formation(DeskState& desk, const Bytes& formations, bool indoor) {
|
||||
const int selected = desk.automation[0];
|
||||
if (selected == 0) return;
|
||||
if (selected > 8) throw FormatError("desktop: invalid automatic formation");
|
||||
const size_t offset = size_t(desk.manager_slot) * 0x160 + size_t(indoor) * 0xb0 + size_t(selected - 1) * 22;
|
||||
if (offset + 22 > formations.size()) throw FormatError("desktop: missing automatic formation");
|
||||
desk.automation_formation.emplace();
|
||||
std::copy_n(formations.begin() + offset, 22, desk.automation_formation->begin());
|
||||
}
|
||||
}
|
||||
|
||||
DeskState desk_from_save(const SaveState& s, const LeImage& exe, uint64_t revision) {
|
||||
StaticMemory memory(s);
|
||||
auto manager = block_copy(s, ::bmh::layout::ManagerRecords), tactics = block_copy(s, ::bmh::layout::TacticsBoards), options = block_copy(s, ::bmh::layout::ManagerAutomation);
|
||||
@@ -504,6 +522,7 @@ DeskState desk_from_save(const SaveState& s, const LeImage& exe, uint64_t revisi
|
||||
project_table_position(d, table_source);
|
||||
project_drawer_rows(d, exe, manager, s.pool(0), offsets, position_history,
|
||||
results_by_opponent, rounds, std::nullopt);
|
||||
project_automation_formation(d, block_copy(s, layout::Formations), false);
|
||||
d.source = "original_save_read_only"; return d;
|
||||
}
|
||||
|
||||
@@ -514,6 +533,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
auto d = project(g.memory, {g.manager_records, g.tactics, g.manager_options, g.stocks, g.club_heap_78, g.club_names,
|
||||
g.club_ids, g.squad_slots, g.players, g.team_morale, g.manager_teams, g.league_rounds},
|
||||
exe, g.level, g.date, g.season_day(), g.season, revision);
|
||||
project_automation_formation(d, g.formations, g.indoor);
|
||||
// DeskDate only auto-opens for an ordinary club manager; the national
|
||||
// runtime (0x165) suppresses this consumer while manual mailbox access remains valid.
|
||||
if (d.runtime_club != kNoTeam && d.manager_slot >= 0 && d.manager_slot < 32 && g.memory.has(::bmh::layout::MailboxRecipientMask))
|
||||
@@ -600,8 +620,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
*d.next_opponent < int(g.club_ids.size())) {
|
||||
const int opponent = *d.next_opponent;
|
||||
d.next_opponent_name = g.club_name(opponent);
|
||||
const bool fallback = opponent == 0x0fff ||
|
||||
(opponent > 0x59 && (opponent < 0x8a || opponent > 0xa7) && opponent < 0x165);
|
||||
const bool fallback = original_badge_fallback(opponent,&exe);
|
||||
d.next_opponent_badge_fallback = fallback;
|
||||
if (!fallback) {
|
||||
const size_t badge_at = size_t(opponent) * 2;
|
||||
|
||||
@@ -107,13 +107,14 @@ struct DeskState {
|
||||
bool mailbox_notification_pending = false; // MailboxRecipientMask active-manager bit; transient, non-FBM
|
||||
std::optional<DeskItem> menu_layout_shortcut; // final bar cell returns native record 53/kind 72, then dispatches MEN
|
||||
std::array<uint8_t, 5> automation{};
|
||||
std::optional<std::array<uint8_t, 22>> automation_formation;
|
||||
std::array<std::optional<bool>, 10> warnings{};
|
||||
std::vector<DeskItem> items; // Original linked-list drawing / hit-test order.
|
||||
std::string source;
|
||||
uint64_t revision = 0;
|
||||
};
|
||||
|
||||
// Original DeskDate2, including its four-year leap cycle and Wednesday epoch.
|
||||
// Original DeskDate2, including its four-year leap cycle and edition-specific epoch.
|
||||
DeskDate desk_date(uint32_t day_counter, const LeImage& executable);
|
||||
DeskState desk_from_save(const SaveState&, const LeImage&, uint64_t revision = 0);
|
||||
// Uses authoritative typed fields where StaticMemory contains stale copies.
|
||||
|
||||
+61
-10
@@ -218,7 +218,14 @@ void DesktopScreen::draw_item(Image& out, const DeskItem& item) const {
|
||||
copy(out, icons_, 97, 111, x + 3 + i * 33, y + 2, 32, 30);
|
||||
const auto value = state_.automation[i];
|
||||
if ((i == 4 ? value & 1 : value) != 0) copy(out, icons_, 129 + i * 16, 111, x + i * 33 + 10, y + 4, 17, 11);
|
||||
// Individual automatic-formation dots need a separately verified renderer.
|
||||
if (i == 0 && value != 0 && state_.automation_formation) {
|
||||
const auto& formation = *state_.automation_formation;
|
||||
// The original miniature excludes the keeper and unused positions.
|
||||
for (int row = 1; row < 11; ++row)
|
||||
if (formation[size_t(row)] != 0)
|
||||
rect(out, x + 10 + formation[size_t(row)] * 15 / 18,
|
||||
y + 5 + formation[size_t(row + 11)], 1, 1, 0x27);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
@@ -275,6 +282,20 @@ Image DesktopScreen::render() const {
|
||||
if (shortcut_hover_record_ >= 0)
|
||||
text(out, 0, 235, texts_[text_id(::bmh::layout::Desktop_Render_TextPointer + uint32_t(shortcut_hover_record_) * 4)], 0x5f, 319);
|
||||
}
|
||||
if (layout_drag_ && layout_preview_) {
|
||||
const auto selected = std::find_if(visible.items.begin(), visible.items.end(),
|
||||
[&](const DeskItem& item) { return item.id == layout_drag_->item; });
|
||||
if (selected != visible.items.end()) {
|
||||
draw_item(out, *selected);
|
||||
const auto& item = *selected;
|
||||
const int w = item.width - (item.kind >= 50 && !item.open ? 8 : 0);
|
||||
const int h = item.height - (item.kind >= 50 && !item.open ? 8 : 0);
|
||||
rect(out, item.x, item.y, w, 1, 0x27);
|
||||
rect(out, item.x, item.y + h - 1, w, 1, 0x27);
|
||||
rect(out, item.x, item.y, 1, h, 0x27);
|
||||
rect(out, item.x + w - 1, item.y, 1, h, 0x27);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -306,8 +327,30 @@ std::optional<DeskItem> DesktopScreen::folder_child_at(int x,int y) const {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
DeskRequest DesktopScreen::close_drawer(const DeskItem& item) {
|
||||
if (item.id < 1 || item.id >= 54 || item.kind < 50 || item.kind > 71 || !item.open) return {};
|
||||
const auto& record = state_.layout_records[size_t(item.id)];
|
||||
const int previous = record[6], next = record[5];
|
||||
if (previous >= 54 || next >= 54 || record[12] != item.kind ||
|
||||
state_.layout_records[size_t(previous)][5] != item.id ||
|
||||
(next != 0 && state_.layout_records[size_t(next)][6] != item.id)) return {};
|
||||
auto action = request(DeskRequestKind::change_layout, item, 2);
|
||||
action.layout_operation = DeskLayoutOperation::toggle_quickbar_drawer;
|
||||
action.layout_target_item = item.id;
|
||||
for (size_t i = 0; i < 54; ++i)
|
||||
std::copy(state_.layout_records[i].begin(), state_.layout_records[i].end(), action.layout_before.begin() + i * 16);
|
||||
action.layout_after = action.layout_before;
|
||||
action.layout_after[size_t(previous) * 16 + 5] = uint8_t(next);
|
||||
if (next != 0) action.layout_after[size_t(next) * 16 + 6] = uint8_t(previous);
|
||||
action.layout_after[size_t(item.id) * 16 + 5] = 0xff;
|
||||
action.layout_after[size_t(item.id) * 16 + 6] = 0xff;
|
||||
sound_ids_.push_back(12);
|
||||
pending_ = action;
|
||||
return action;
|
||||
}
|
||||
|
||||
DeskRequest DesktopScreen::pointer_down(int x, int y, bool right) {
|
||||
if (pending_) return {};
|
||||
if (pending_ || drawer_close_release_pending_) return {};
|
||||
if (socket_release_pending_) return {}; // DeskDate waits here for the first RMB release.
|
||||
sample_shortcut_pointer(x, y);
|
||||
shortcut_hover_record_ = -1; // DeskDate clears its tooltip on event2/event8 before dispatch.
|
||||
@@ -345,19 +388,22 @@ DeskRequest DesktopScreen::pointer_down(int x, int y, bool right) {
|
||||
const int inset = item.kind >= 50 && !item.open ? 8 : 0;
|
||||
if (item.disabled || x < item.x || y < item.y || x >= item.x + item.width - inset ||
|
||||
y >= item.y + item.height - inset) continue;
|
||||
if (!right && item.kind >= 50 && item.open && state_.drawer_handles &&
|
||||
x <= item.x + 3 && y <= item.y + 3) {
|
||||
auto action = close_drawer(item);
|
||||
drawer_close_release_pending_ = action.kind != DeskRequestKind::none;
|
||||
return action;
|
||||
}
|
||||
if (right && !state_.drawer_handles) return {};
|
||||
if (right && bin_mode_ && item.kind!=12) return {};
|
||||
if (!right && item.kind==55 && item.open && !state_.national_team &&
|
||||
x-item.x-4>34 && x-item.x-4<87) return {}; // Original ticket-price scale.
|
||||
if (!right && item.kind==64 && item.open) return {}; // Source automation controls remain clicks.
|
||||
const bool drawer_handle=item.kind>=50&&state_.drawer_handles&&x<=item.x+3&&y<=item.y+3;
|
||||
if(item.kind>=50&&!drawer_handle&&!right) return {};
|
||||
if(!right&&!drawer_handle) return {}; // Source LMB activates; RMB starts a drag.
|
||||
if (!right) return {}; // LMB closes/activates; RMB alone starts a drag.
|
||||
layout_drag_ = LayoutDrag{item.id, x - item.x, y - item.y, item.x, item.y, -1, false, false, drawer_handle, right};
|
||||
layout_preview_ = state_;
|
||||
// RemovesBinModeIcon/RestoresChildBinMode run at RMB press, even if no motion follows.
|
||||
// The existing LMB handle drag differs from that Source path; do not
|
||||
// invent its sound mapping here.
|
||||
if (right) sound_ids_.insert(sound_ids_.end(), {12, 15});
|
||||
return {};
|
||||
}
|
||||
@@ -365,7 +411,7 @@ DeskRequest DesktopScreen::pointer_down(int x, int y, bool right) {
|
||||
}
|
||||
|
||||
bool DesktopScreen::pointer_move(int x, int y) {
|
||||
if (pending_ || socket_release_pending_) return false;
|
||||
if (pending_ || socket_release_pending_ || drawer_close_release_pending_) return false;
|
||||
if (!layout_drag_ || !layout_preview_) return sample_shortcut_pointer(x, y);
|
||||
auto& drag = *layout_drag_;
|
||||
auto found = std::find_if(layout_preview_->items.begin(), layout_preview_->items.end(),
|
||||
@@ -383,6 +429,10 @@ bool DesktopScreen::pointer_move(int x, int y) {
|
||||
}
|
||||
|
||||
DeskRequest DesktopScreen::pointer_up(int x, int y, bool right) {
|
||||
if (drawer_close_release_pending_) {
|
||||
if (!right) drawer_close_release_pending_ = false;
|
||||
return {}; // The close owns its release even after the widget was removed by ACK.
|
||||
}
|
||||
if (socket_release_pending_) {
|
||||
if (right) socket_release_pending_ = false;
|
||||
return {}; // First socket RMB release is only the Source wait barrier.
|
||||
@@ -600,9 +650,9 @@ DeskRequest DesktopScreen::click(int x, int y, bool right) {
|
||||
}
|
||||
if (item.disabled || right) return {};
|
||||
if (item.kind < 50) return request(item.kind == 12 ? DeskRequestKind::advance_turn : DeskRequestKind::open_menu, item);
|
||||
// DeskDate only handles Ticket/Calendar/Automation body clicks;
|
||||
// drawer open/close is exclusively the compact quickbar operation.
|
||||
if (item.open && state_.drawer_handles && x <= item.x + 3 && y <= item.y + 3) return {};
|
||||
// The corner closes through the same transaction as the quickbar.
|
||||
if (item.open && state_.drawer_handles && x <= item.x + 3 && y <= item.y + 3)
|
||||
return close_drawer(item);
|
||||
if (item.kind == 58 && item.open) return request(DeskRequestKind::advance_turn, item);
|
||||
if (item.kind == 55 && item.open && !state_.national_team && x - item.x - 4 > 34 && x - item.x - 4 < 87)
|
||||
return request(DeskRequestKind::change_ticket_price, item, (x - item.x - 4 - 35) / 3 + 8);
|
||||
@@ -722,6 +772,7 @@ std::string DesktopScreen::state_json() const {
|
||||
",\"shortcut_hover_record\":" + std::to_string(shortcut_hover_record_) +
|
||||
",\"socket_confirmation_armed\":" + std::string(socket_confirmation_armed_ ? "true" : "false") +
|
||||
",\"bin_mode\":" + std::string(bin_mode_ ? "true" : "false") +
|
||||
",\"dragging_item\":" + (layout_drag_ ? std::to_string(layout_drag_->item) : "null") +
|
||||
",\"pending_action\":" + (pending_ ? desk_request_json(*pending_) : "null") +
|
||||
",\"last_rejection\":" + (last_rejection_.empty() ? "null" : json_quote(last_rejection_)) + "}";
|
||||
return out;
|
||||
|
||||
@@ -71,6 +71,8 @@ private:
|
||||
mutable std::vector<uint8_t> sound_ids_;
|
||||
struct LayoutDrag { int item=-1, grab_x=0, grab_y=0, start_x=0, start_y=0, folder=-1; bool moved=false, folder_child=false, drawer_handle=false, right_button=false; };
|
||||
std::optional<LayoutDrag> layout_drag_;
|
||||
bool drawer_close_release_pending_ = false;
|
||||
DeskRequest close_drawer(const DeskItem& item);
|
||||
std::optional<DeskState> layout_preview_;
|
||||
void text(Image&, int x, int baseline, std::string_view, uint8_t color, int right = -1) const;
|
||||
void sprite_text(Image&, int x, int baseline, std::string_view, int font) const;
|
||||
|
||||
@@ -601,11 +601,17 @@ int main(int argc, char** argv) {
|
||||
const std::filesystem::path data = argv[1]; const auto exe = bmh::test::load_executable(asset_path(data,"BMH.exe"));
|
||||
paired_selection_matrix(exe);
|
||||
if(argc>3)paired_saved_projection(argv[3],exe);
|
||||
// Gregorian dates are an independent oracle for the original's observed year range.
|
||||
// The date arithmetic is checked against a controlled epoch aligned with
|
||||
// the original leap cycle, independently of the installation's start year.
|
||||
auto oracle_exe = exe;
|
||||
const uint8_t oracle_year[] = {0xea,0x07,0,0};
|
||||
const uint8_t oracle_weekday = 2;
|
||||
oracle_exe.patch(layout::CalendarDateSetup+13,oracle_year,4);
|
||||
oracle_exe.patch(layout::CalendarDateSetup+4,&oracle_weekday,1);
|
||||
using namespace std::chrono;
|
||||
const sys_days epoch = year{2026}/7/1;
|
||||
for (uint32_t i = 0; i < 1461; ++i) {
|
||||
const auto d = desk_date(i,exe); const year_month_day oracle(epoch + days{i});
|
||||
const auto d = desk_date(i,oracle_exe); const year_month_day oracle(epoch + days{i});
|
||||
check(d.year == int(oracle.year()) && d.month == int(unsigned(oracle.month())) &&
|
||||
d.day == int(unsigned(oracle.day())),"calendar/leap boundary mismatch");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/environment.hpp"
|
||||
|
||||
@@ -50,7 +51,7 @@ const char* result_name(EnvironmentRequestKind kind) {
|
||||
bool generic_badge(int club) {
|
||||
// SourceBadgeFallback gates on the runtime club ID, before looking up its W sprite.
|
||||
const unsigned team = unsigned(club) & 0xfff;
|
||||
return team == 0xfff || (team >= 90 && team <= 137) || (team >= 168 && team <= 356);
|
||||
return original_badge_fallback(int(team));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
|
||||
@@ -288,7 +289,7 @@ Image GameEndTaxDialog::render(std::optional<Button> pressed) const {
|
||||
}
|
||||
bool source_badge_fallback(int token) {
|
||||
const int club=token&0x0fff;
|
||||
return club==0x0fff || (club>89&&(club<138||club>167)&&club<357);
|
||||
return original_badge_fallback(club);
|
||||
}
|
||||
void draw_source_dialog(Image& out,const SourceDialogAssets& assets,const TaxDialogProjection& p,
|
||||
bool gradient,std::optional<GameEndTaxDialog::Button> pressed) {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
namespace bmh::ui {
|
||||
// Host paths use portable separators: the legacy font's backslash glyph is Ö.
|
||||
inline std::string save_directory_label(const std::filesystem::path& directory) {
|
||||
const auto value = directory.generic_u8string();
|
||||
return std::string(value.begin(), value.end());
|
||||
}
|
||||
} // namespace bmh::ui
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/incoming_transfer.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
@@ -80,8 +81,7 @@ int source_seller_team_token(const IncomingTransferDecisionState& state) {
|
||||
}
|
||||
|
||||
bool source_neutral_seller_token(int token) {
|
||||
return (token >= 90 && token <= 137) || token == 0x0fff ||
|
||||
(token >= 168 && token <= 356);
|
||||
return original_badge_fallback(token);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
|
||||
@@ -262,7 +263,7 @@ void ManagerScreen::portrait(Image& out, int x, int y, int id) const {
|
||||
}
|
||||
void ManagerScreen::badge(Image& out, int x, int y, int id) const {
|
||||
border(out, x, y);
|
||||
if (id > 89 && id < 138) { copy(out, widgets_, 8, 0, x, y, 38, 38); return; }
|
||||
if (id>=90 && id<original_badge_gate(exe_)) { copy(out, widgets_, 8, 0, x, y, 38, 38); return; }
|
||||
int sprite = le16(db_.raw_club_badge_selectors, size_t(id) * 2) & 0x1ff;
|
||||
auto atlas = load_vga(asset_path(data_ / "W", std::to_string(sprite >> 3) + ".VGA"));
|
||||
copy(out, atlas, (sprite & 7) * 38, 0, x, y, 38, 38);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/pending_offer.hpp"
|
||||
|
||||
@@ -93,8 +94,7 @@ void manager_identity(const GameState& game, int manager, TaxDialogProjection& o
|
||||
// reserves 14 for the manager-placeholder tile drawn from KB0.VGA.
|
||||
if (out.portrait > 14) throw FormatError("pending offer UI: invalid Source manager portrait");
|
||||
|
||||
out.badge_fallback = team == 0x0fff || (team > 89 && team < 138) ||
|
||||
(team > 167 && team < 357);
|
||||
out.badge_fallback = original_badge_fallback(team);
|
||||
if (out.badge_fallback) {
|
||||
out.badge_sprite = 0;
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/player_card.hpp"
|
||||
|
||||
@@ -194,7 +195,7 @@ PlayerCardScreen::PlayerCardScreen(const std::filesystem::path& data,PlayerCardS
|
||||
badge_=load_vga(asset_path(data/"W",std::to_string(state_.badge>>3)+".VGA"));
|
||||
if(state_.loan)for(size_t i=0;i<2;++i){
|
||||
const int club=i?state_.loan->borrower:state_.loan->owner;
|
||||
if(club<=89||(club>=138&&club<=167)||club>=357)
|
||||
if(!original_badge_fallback(club,&exe_))
|
||||
loan_badges_[i]=load_vga(asset_path(data/"W",std::to_string(state_.loan->badges[i]>>3)+".VGA"));
|
||||
}
|
||||
if(atlas_.width==314){Image padded(320,atlas_.height);padded.blit(atlas_,0,0);atlas_=std::move(padded);}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <system_error>
|
||||
|
||||
#include "ui/manager.hpp"
|
||||
#include "ui/host_path.hpp"
|
||||
#include "ui/setup.hpp"
|
||||
#include "formats/fbm.hpp"
|
||||
|
||||
@@ -124,7 +125,10 @@ Image SaveLoadScreen::render() const {
|
||||
button(out, field_x, directory_y, field_width);
|
||||
button(out, field_x, filename_y, field_width);
|
||||
|
||||
const auto directory_label = original_to_utf8(text_at(texts_, ::bmh::layout::SaveLoad_Render_TextPointer3)) + path_to_utf8(directory_);
|
||||
// ISO 646-DE uses the backslash code point for Ö. Generic separators retain
|
||||
// a valid host path on Windows without displaying that unrelated glyph.
|
||||
const auto directory_label = original_to_utf8(text_at(texts_, ::bmh::layout::SaveLoad_Render_TextPointer3)) +
|
||||
save_directory_label(directory_);
|
||||
text(out, 55, 203, directory_label, 0x6c, 140, footer_font_, true);
|
||||
text(out, 55, 216, original_to_utf8(text_at(texts_, ::bmh::layout::SaveLoad_Render_TextPointer4)), 0x6c, 50, footer_font_, true);
|
||||
const std::string displayed_filename = mode_ == SaveLoadMode::load && selected_ >= 0 &&
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/season_promotion.hpp"
|
||||
|
||||
@@ -181,7 +182,7 @@ SeasonPromotionProjection season_promotion_from_game(
|
||||
rows.reserve(event.count);
|
||||
for(size_t i=0;i<event.count;++i) {
|
||||
const uint16_t id=ids[i]&0x0fff;
|
||||
const bool fallback=id==0x0fff||(id>0x59&&((id<0x8a||id>0xa7)&&id<0x165));
|
||||
const bool fallback=original_badge_fallback(id);
|
||||
uint16_t badge=0;
|
||||
if(!fallback) {
|
||||
const size_t at=size_t(id)*2;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/sportschau.hpp"
|
||||
|
||||
@@ -375,7 +376,7 @@ SportschauMatchReport::SportschauMatchReport(const std::filesystem::path& data_d
|
||||
for (size_t side = 0; side < badge_words.size(); ++side) {
|
||||
const int team = side == 0 ? fixture_.home_team : fixture_.away_team;
|
||||
if (team == 0x0fff) continue; // SourceBadgeFallback uses its generic missing-club icon.
|
||||
const bool has_source_badge = team <= 89 || (team >= 138 && team <= 167) || team >= 357;
|
||||
const bool has_source_badge = !original_badge_fallback(team);
|
||||
if (!has_source_badge) continue; // Source FormatError draws a distinct generic icon; see notes.
|
||||
if (badge_words[side] == 0xffff) throw FormatError("sportschau: missing live Source badge word");
|
||||
const unsigned atlas = (badge_words[side] & 0x01ff) >> 3;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/sprite_font.hpp"
|
||||
|
||||
@@ -20,6 +21,7 @@ std::string original_bytes(std::string_view utf8) {
|
||||
SpriteFont::SpriteFont(const std::filesystem::path& data_directory)
|
||||
: atlas_(load_vga(asset_path(data_directory / "KB", "54.VGA"))),
|
||||
exe_(load_le(asset_path(data_directory, "BMH.exe"))) {
|
||||
install_original_badge_policy(exe_);
|
||||
if (atlas_.height < 21 || atlas_.width <= 0)
|
||||
throw FormatError("sprite font: unsupported KB/54 atlas");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/team_statistics.hpp"
|
||||
|
||||
@@ -93,7 +94,7 @@ TeamStatisticsProjection team_statistics_from_game(const GameState& game, int te
|
||||
TeamStatisticsProjection out;
|
||||
out.runtime_team = team;
|
||||
out.mode = mode;
|
||||
out.source_badge_fallback = team == 0x0fff || (team >= 90 && team <= 137) || (team >= 168 && team < 0x165);
|
||||
out.source_badge_fallback = original_badge_fallback(team,&exe);
|
||||
out.badge_heap = game.club_heap_78;
|
||||
if (team != 0x165) {
|
||||
int region_team = team;
|
||||
|
||||
@@ -98,8 +98,10 @@ int main(int argc, char** argv) {
|
||||
training_camp_price_text(content, 7) == "& 350.000",
|
||||
"FLTD prices use its actual base price, pound prefix and one-half conversion");
|
||||
} else {
|
||||
check(training_camp_price_text(content, 0) == "150.000" + texts[17],
|
||||
"German default price text remains unchanged");
|
||||
auto currency_sample = content;
|
||||
currency_sample.prices[0] = 150000;
|
||||
check(training_camp_price_text(currency_sample, 0) == "150.000" + texts[17],
|
||||
"German currency suffix is retained independently of edition resort prices");
|
||||
}
|
||||
auto widgets = load_vga(asset_path(data / "KB", "52.VGA"));
|
||||
for(int i=0;i<9;++i){
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/transfer_market.hpp"
|
||||
|
||||
@@ -267,7 +268,7 @@ TaxDialogProjection poach_notice_from_game(const GameState& game,const PoachStar
|
||||
out.portrait=game.manager_records[base+0x221];
|
||||
if(out.portrait>14)throw FormatError("poach notice: invalid Original portrait");
|
||||
const int team=game.manager_teams[size_t(manager)];
|
||||
out.badge_fallback=team==0x0fff || (team>89&&team<138) || (team>167&&team<357);
|
||||
out.badge_fallback=original_badge_fallback(team);
|
||||
if(!out.badge_fallback) {
|
||||
if(team<0 || size_t(team)*2+2>game.club_heap_78.size())throw FormatError("poach notice: missing badge selector");
|
||||
out.badge_sprite=(int(game.club_heap_78[size_t(team)*2])|int(game.club_heap_78[size_t(team)*2+1])<<8)&0x1ff;
|
||||
|
||||
+7
-3
@@ -1,9 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// The OpenBMH version. CMake sets OPENBMH_VERSION from project(... VERSION ...) in the top
|
||||
// CMakeLists.txt - the one place to change it; this fallback only serves other builds.
|
||||
// Only the product entry points include the generated version, so changing a
|
||||
// release number does not rebuild the game, test suites or third-party code.
|
||||
#ifndef OPENBMH_VERSION
|
||||
#define OPENBMH_VERSION "0.1.0-dev"
|
||||
#if __has_include("openbmh_build_version.hpp")
|
||||
#include "openbmh_build_version.hpp"
|
||||
#else
|
||||
#define OPENBMH_VERSION "development"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/calendar.hpp"
|
||||
#include "game/week.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
|
||||
bmh::LeImage image(int year,int weekday) {
|
||||
constexpr uint32_t base=0x10000;
|
||||
constexpr size_t image_size=0xb0000;
|
||||
auto exe=bmh::LeImage::from_bytes(base,bmh::Bytes(image_size,0));
|
||||
const uint8_t setup[]={0xc6,0x44,0x24,0x04,uint8_t(weekday),0xc6,0x44,0x24,0x0c,0x07,0xc7,0x04,0x24,
|
||||
uint8_t(year),uint8_t(year>>8),0,0};
|
||||
exe.patch(bmh::layout::CalendarDateSetup,setup,sizeof setup);
|
||||
const uint8_t months[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
|
||||
exe.patch(bmh::layout::DeskState_DeskDate_RuntimeField,months,sizeof months);
|
||||
return exe;
|
||||
}
|
||||
int main()try {
|
||||
for(const auto [year,day]:{std::pair{1995,5},std::pair{2026,2}}) {
|
||||
auto exe=image(year,day);bmh::install_calendar_rules(exe);
|
||||
check(bmh::weekday_code(0)==day && bmh::weekday_code(7)==day,"engine weekday ignores edition epoch");
|
||||
const auto date=bmh::ui::desk_date(0,exe);
|
||||
check(date.year==year && date.month==7 && date.day==1 && date.weekday==day,"desktop date ignores edition epoch");
|
||||
bmh::GameState g;
|
||||
g.memory.add_block(bmh::layout::ManagerCount,1);
|
||||
const auto header=bmh::save_header(g);
|
||||
const auto expected="01.07."+std::to_string(year);
|
||||
check(std::string(reinterpret_cast<const char*>(header.data()+1))==expected,"save-list date ignores edition epoch");
|
||||
const auto rollover=bmh::ui::desk_date(184,exe);
|
||||
check(rollover.year==year+1 && rollover.month==1 && rollover.day==1,"edition year rollover incorrect");
|
||||
}
|
||||
auto bad=image(2026,7);bool rejected=false;
|
||||
try{bmh::install_calendar_rules(bad);}catch(const bmh::FormatError&){rejected=true;}
|
||||
check(rejected && bmh::calendar_epoch().year==2026 && bmh::calendar_epoch().weekday==2,"invalid epoch partially installed");
|
||||
auto different=image(1995,5);const uint8_t unknown=0;different.patch(bmh::layout::CalendarDateSetup,&unknown,1);
|
||||
rejected=false;try{bmh::calendar_epoch_from_executable(different);}catch(const bmh::FormatError&){rejected=true;}
|
||||
check(rejected,"unknown date routine was guessed");
|
||||
std::cout<<"Edition calendar epoch, save header and year rollover passed\n";return 0;
|
||||
}catch(const std::exception&e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,41 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/career.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
void check(bool v,const char* m){if(!v)throw std::runtime_error(m);}
|
||||
int main()try {
|
||||
using namespace bmh;
|
||||
constexpr uint32_t image_base=0x10000;
|
||||
constexpr size_t image_size=0xb0000;
|
||||
auto image=LeImage::from_bytes(image_base,Bytes(image_size,0));
|
||||
uint8_t original=7;image.patch(layout::LiveSceneOptions,&original,1);
|
||||
const auto file=std::filesystem::temp_directory_path()/"openbmh-classic-original-rules.image";
|
||||
save_image(image,file);const auto loaded=load_le(file);std::filesystem::remove(file);
|
||||
check(loaded.bytes()==image.bytes(),"Loading silently replaced original rules");
|
||||
Bytes ranges;for(int i=0;i<9;++i){ranges.push_back(uint8_t(30+i));ranges.push_back(uint8_t(40+i));}
|
||||
image.patch(layout::LeagueStrengthRanges,ranges.data(),ranges.size());install_career_rules(image);
|
||||
check(career_strength_range(0)==std::pair{30,40} && career_strength_range(8)==std::pair{38,48},"Original league ranges not installed");
|
||||
uint8_t invalid[]={90,20};image.patch(layout::LeagueStrengthRanges+16,invalid,2);bool rejected=false;
|
||||
try{install_career_rules(image);}catch(const FormatError&){rejected=true;}
|
||||
check(rejected,"Invalid original ranges accepted");
|
||||
check(career_strength_range(0)==std::pair{30,40} && career_strength_range(8)==std::pair{38,48},"Failed range installation partially changed rules");
|
||||
install_environment_rules(image);check(!environment_rules_supported(),"Unknown program code guessed an environment model");
|
||||
auto badges=LeImage::from_bytes(image_base,Bytes(256,0));
|
||||
const uint8_t legacy_gate[]={0x66,0x81,0xfb,138,0,0x7c,7};
|
||||
badges.patch(layout::ForeignBadgeGateInstruction,legacy_gate,sizeof legacy_gate);
|
||||
install_original_badge_policy(badges);check(original_badge_fallback(90)&&original_badge_fallback(137),"Older edition no longer uses its original neutral badge");
|
||||
const uint8_t extended=90;badges.patch(layout::ForeignBadgeGateInstruction+3,&extended,1);
|
||||
install_original_badge_policy(badges);check(!original_badge_fallback(90)&&!original_badge_fallback(137)&&original_badge_fallback(168)&&original_badge_fallback(0xfff),"Extended foreign badge gate is incorrect");
|
||||
check(!original_badge_fallback(0xf05a) && !original_badge_fallback(138) &&
|
||||
!original_badge_fallback(357) && original_badge_fallback(356),
|
||||
"Tagged club IDs and national/amateur badge ranges changed");
|
||||
auto truncated=LeImage::from_bytes(layout::ForeignBadgeGateInstruction+1,Bytes(6,0));
|
||||
check(original_badge_gate(truncated)==138,"Truncated badge routine was not rejected");
|
||||
const uint8_t unknown=1;badges.patch(layout::ForeignBadgeGateInstruction+3,&unknown,1);install_original_badge_policy(badges);check(original_badge_fallback(90),"Unknown badge routine guessed a crest capability");
|
||||
std::cout<<"Classic original rules retained; strength ranges and unknown-variant guard passed\n";return 0;
|
||||
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,106 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/desktop.hpp"
|
||||
#include "formats/palette.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/fbm.hpp"
|
||||
#include "formats/savestate.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include <filesystem>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
using namespace bmh;
|
||||
using namespace bmh::ui;
|
||||
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
|
||||
void capture(const std::filesystem::path& dir,const char* name,const Image& image,const Palette& palette){
|
||||
if(dir.empty())return;
|
||||
std::filesystem::create_directories(dir);
|
||||
std::ofstream out(dir/name,std::ios::binary);out<<"P6\n"<<image.width<<' '<<image.height<<"\n255\n";
|
||||
for(auto pixel:image.pixels){const auto c=palette.argb[pixel];for(int shift:{16,8,0})out.put(char(c>>shift));}
|
||||
}
|
||||
int main(int argc,char**argv)try{
|
||||
if(argc<2||!*argv[1])return 77;
|
||||
const std::filesystem::path data=argv[1],output=argc>2?argv[2]:"";
|
||||
const auto palette=load_palette(data/"M3PC.COL");
|
||||
if (argc > 3) {
|
||||
const auto file = load_savegame(argv[3]);
|
||||
check(file.checksum_ok,"reference save checksum invalid");
|
||||
const auto exe = load_le(data/"BMH.exe");
|
||||
const SaveState original(file.stream);
|
||||
const auto option_offset = original.block(layout::ManagerAutomation).offset;
|
||||
for (int selected=0; selected<=4; ++selected) {
|
||||
auto stream = file.stream;
|
||||
stream.at(option_offset)=uint8_t(selected);
|
||||
const SaveState saved(stream);
|
||||
auto projected = desk_from_save(saved,exe,1);
|
||||
check(projected.automation_formation.has_value()==(selected!=0),"formation visibility did not follow saved automation option");
|
||||
if(selected)for(size_t i=0;i<22;++i)
|
||||
check(projected.automation_formation->at(i)==saved.data(layout::Formations)[size_t(selected-1)*22+i],
|
||||
"miniature did not use the selected saved formation");
|
||||
projected.items={{1,20,20,173,40,64,0,0,true,false}};
|
||||
const auto rendered = DesktopScreen(data,projected).render();
|
||||
const std::string name="saved-formation-"+std::to_string(selected)+".ppm";
|
||||
capture(output,name.c_str(),rendered,palette);
|
||||
}
|
||||
}
|
||||
DeskState state;state.options.managers=1;state.options.duration=5;state.options.mode=3;state.options.difficulty=2;
|
||||
state.options.league=true;state.options.world=true;
|
||||
state.manager_slot=0;state.runtime_club=0;state.manager_teams={0};state.manager_name="QA";state.club_name="QA";
|
||||
DeskManagerIdentity manager;manager.runtime_club=0;manager.club_identity_key=0;manager.name="QA";manager.league=0;manager.portrait=0;manager.badge=0;
|
||||
state.managers={manager};state.league=0;state.portrait=0;state.badge=0;
|
||||
state.items={{1,20,20,173,40,64,0,0,true,false}};
|
||||
state.automation[0]=1;state.automation_formation.emplace();state.automation_formation->fill(0);
|
||||
(*state.automation_formation)[1]=18;(*state.automation_formation)[12]=3;
|
||||
const auto first=DesktopScreen(data,state).render();
|
||||
check(first.pixels[size_t(32)*320+49]==0x27,"formation player not rendered at the original miniature coordinate");
|
||||
state.automation[0]=2;(*state.automation_formation)[1]=6;(*state.automation_formation)[12]=2;
|
||||
const auto second=DesktopScreen(data,state).render();
|
||||
check(first.pixels!=second.pixels,"changing selected formation left the monitor unchanged");
|
||||
capture(output,"formation-1.ppm",first,palette);capture(output,"formation-2.ppm",second,palette);
|
||||
state.drawer_handles=true;
|
||||
state.items={{2,20,20,32,25,0,0,0,false,false},{1,20,20,173,40,64,0,0,true,false}};
|
||||
state.layout_records[0][5]=2;
|
||||
state.layout_records[2][5]=1; state.layout_records[2][6]=0;
|
||||
state.layout_records[1][5]=0; state.layout_records[1][6]=2;
|
||||
state.layout_records[1][12]=64; state.layout_records[1][13]=0x80;
|
||||
DesktopScreen widget_drag(data,state);
|
||||
widget_drag.pointer_down(21,21,true);
|
||||
widget_drag.pointer_move(61,61);
|
||||
const auto widget_move=widget_drag.pointer_up(61,61,true);
|
||||
check(widget_move.kind==DeskRequestKind::change_layout && widget_move.layout_operation==DeskLayoutOperation::move_item,
|
||||
"right-button widget movement was replaced by closing");
|
||||
DesktopScreen close(data,state);
|
||||
capture(output,"close-before.ppm",close.render(),palette);
|
||||
const auto removal=close.pointer_down(21,21,false);
|
||||
check(removal.kind==DeskRequestKind::change_layout &&
|
||||
removal.layout_operation==DeskLayoutOperation::toggle_quickbar_drawer &&
|
||||
removal.layout_target_item==1,"left corner did not request widget removal");
|
||||
check(removal.layout_after[2*16+5]==0 && removal.layout_after[16+5]==0xff &&
|
||||
removal.layout_after[16+6]==0xff,"corner removal corrupted the remaining layout chain");
|
||||
check(close.state_json().find("\"dragging_item\":null")!=std::string::npos,
|
||||
"close corner incorrectly entered drag mode");
|
||||
check(!close.pointer_move(100,100),"close press turned into movement");
|
||||
auto removed=state; removed.revision=state.revision+1; removed.items.erase(removed.items.begin()+1);
|
||||
for(size_t i=0;i<54;++i)std::copy_n(removal.layout_after.begin()+i*16,16,removed.layout_records[i].begin());
|
||||
close.acknowledge(removed);
|
||||
check(close.pointer_up(21,21,false).kind==DeskRequestKind::none,
|
||||
"close release activated the icon underneath the removed widget");
|
||||
capture(output,"close-after.ppm",close.render(),palette);
|
||||
check(close.pointer_up(21,21,false).kind==DeskRequestKind::open_menu,
|
||||
"close release barrier consumed a subsequent independent click");
|
||||
state.layout_records={}; state.layout_records[0][5]=1;
|
||||
state.items={{1,20,20,32,25,0,0,0,false,false}};state.drawer_handles=true;
|
||||
DesktopScreen drag(data,state);const auto normal=drag.render();
|
||||
const auto idle=drag.state_json();
|
||||
drag.pointer_down(25,25,true);
|
||||
check(drag.state_json()!=idle,"drag press did not invalidate the rendered desktop");
|
||||
drag.pointer_move(65,65);
|
||||
const auto moving=drag.render();
|
||||
check(moving.pixels[size_t(60)*320+60]==0x27 && moving.pixels[size_t(84)*320+91]==0x27,"moving icon lacks inclusive yellow outline");
|
||||
const auto request=drag.pointer_up(65,65,true);
|
||||
check(request.kind==DeskRequestKind::change_layout,"drag did not retain its layout transaction");
|
||||
check(drag.render().pixels==normal.pixels,"yellow preview survived release without acknowledgement");
|
||||
capture(output,"drag-normal.ppm",normal,palette);capture(output,"drag-active.ppm",moving,palette);
|
||||
std::cout<<"Automation formation changes and transient yellow drag border passed\n";return 0;
|
||||
}catch(const std::exception&e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,51 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "launch/fltd.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
int main() {
|
||||
using namespace bmh;
|
||||
std::filesystem::path root;
|
||||
try {
|
||||
root = std::filesystem::temp_directory_path() / ("openbmh-fltd-map-" +
|
||||
std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
std::filesystem::create_directory(root);
|
||||
// Authored X-32-shaped data: only tested source slots have nonzero bytes.
|
||||
Bytes source(507925);
|
||||
source[0] = 'M'; source[1] = 'Z';
|
||||
const auto put = [&](uint32_t address, uint8_t value) { source.at(address + 0x496d) = value; };
|
||||
const auto check = [](bool value, const char* message) { if (!value) throw std::runtime_error(message); };
|
||||
const uint8_t toggle_rows[] = {3, 7, 11, 13, 17, 19};
|
||||
put(layout::EnglishLayoutTranslation16 - 1, 99); // alignment padding is not a toggle row
|
||||
for (uint32_t i = 0; i < 6; ++i) put(layout::EnglishLayoutTranslation16 + i, toggle_rows[i]);
|
||||
put(layout::EnglishLayoutTranslation73 - 1, 0xfb); // negative colour precedes positive colour
|
||||
put(layout::EnglishLayoutTranslation73, 0x47);
|
||||
for (uint32_t i = 0; i < 2; ++i) {
|
||||
put(layout::EnglishDesktopBinSourceX + i, uint8_t(10 + i));
|
||||
put(layout::EnglishDesktopBinSourceY + i, uint8_t(20 + i));
|
||||
put(layout::EnglishDesktopSocketSourceX + i, uint8_t(30 + i));
|
||||
}
|
||||
const auto path = root / "FLTD.EXE";
|
||||
{ std::ofstream out(path, std::ios::binary); out.write(reinterpret_cast<const char*>(source.data()), std::streamsize(source.size())); }
|
||||
const auto image = launch::translate_fltd(path);
|
||||
for (uint32_t i = 0; i < 6; ++i)
|
||||
check(image.u8(layout::Setup_FormatError_RuntimeField8 + i) == toggle_rows[i], "toggle mapping includes alignment padding");
|
||||
check(image.u8(layout::Desktop_Copy_TextPointer) == 0xfb, "negative balance colour");
|
||||
check(image.u8(layout::Desktop_Copy_TextPointer + 1) == 0x47, "positive balance must use the next source byte");
|
||||
for (uint32_t i = 0; i < 2; ++i) {
|
||||
check(image.u8(layout::Desktop_Render_RuntimeField + i) == 10 + i, "bin source x");
|
||||
check(image.u8(layout::Desktop_Render_RuntimeField2 + i) == 20 + i, "bin source y");
|
||||
check(image.u8(layout::Desktop_Render_RuntimeField3 + i) == 30 + i, "socket source x");
|
||||
}
|
||||
std::filesystem::remove_all(root);
|
||||
std::cout << "FLTD setup, colour and desktop-control mappings passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
if (!root.empty()) { std::error_code ec; std::filesystem::remove_all(root, ec); }
|
||||
std::cerr << error.what() << '\n'; return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/host_path.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
int main() {
|
||||
try {
|
||||
// make_preferred produces actual backslashes on Windows. No installed
|
||||
// game assets or existing directory are needed for this native test.
|
||||
auto native = std::filesystem::path(u8"C:/Example/Profile/Save Games").make_preferred();
|
||||
const auto label = bmh::ui::save_directory_label(native);
|
||||
if (label != "C:/Example/Profile/Save Games" || label.find('\\') != std::string::npos)
|
||||
throw std::runtime_error("native path separators leak into the ISO 646-DE label");
|
||||
if (std::filesystem::path(std::u8string(label.begin(), label.end())) != native)
|
||||
throw std::runtime_error("displayed path does not identify the original host path");
|
||||
native = std::filesystem::path(u8"C:/Example/Büro/Spielstände").make_preferred();
|
||||
if (bmh::ui::save_directory_label(native) != "C:/Example/Büro/Spielstände")
|
||||
throw std::runtime_error("Unicode host path changed during separator normalization");
|
||||
std::cout << "Host path labels preserve Unicode and portable separators\n";
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << error.what() << '\n'; return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/lineup.hpp"
|
||||
#include "game/match.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace {
|
||||
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
|
||||
void enabled(bool value) {
|
||||
auto exe = bmh::LeImage::from_bytes(bmh::layout::ForeignPlayerLimitEnabled, bmh::Bytes{uint8_t(value)});
|
||||
bmh::install_lineup_rules(exe);
|
||||
}
|
||||
bmh::GameState fixture(int team, bool human = false, bool all_foreign = false) {
|
||||
bmh::GameState g;
|
||||
const auto range = bmh::squad_range(team);
|
||||
g.squad_slots.assign(3096, 0xfff);
|
||||
g.players.resize(range.count); g.player_bonus.resize(range.count); g.player_cards.resize(range.count, 0x9a00);
|
||||
g.team_flags.resize(138); g.formations.resize(0x160);
|
||||
g.formations[0] = 0;
|
||||
for (int p = 1; p < 11; ++p) g.formations[size_t(p)] = 7;
|
||||
const int country = bmh::team_region(team);
|
||||
for (size_t i = 0; i < range.count; ++i) {
|
||||
g.squad_slots[range.first+i] = uint16_t(i);
|
||||
auto& player = g.players[i];
|
||||
const int strength = i < 6 ? 95 : 60;
|
||||
player.w35c = 60u | uint32_t(strength) << 7 | uint32_t(strength) << 14;
|
||||
player.w364 = i == 0 || i == 11 ? 0 : 1;
|
||||
player.w368 = uint32_t(i < 6 || all_foreign ? country + 1 : country) << 27;
|
||||
}
|
||||
if (human) {
|
||||
g.manager_teams = {team}; g.manager_options = {1,0,0,0,0};
|
||||
g.manager_records.resize(0xb0c); g.tactics.resize(0x840);
|
||||
for (size_t i = 0; i < range.count; ++i) g.tactics[i*0x58+0x50] = uint8_t(i+1);
|
||||
}
|
||||
return g;
|
||||
}
|
||||
int foreign_starters(const bmh::GameState& g, int team) {
|
||||
int count = 0; const auto r = bmh::squad_range(team);
|
||||
for (int row = 0; row < 11; ++row) {
|
||||
const auto entry = g.squad_slots[r.first+size_t(row)];
|
||||
if ((entry & 0x8000) && bmh::nationality(g, entry & 0xfff) != bmh::team_region(team)) ++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
int main() try {
|
||||
enabled(false); auto unrestricted = fixture(0); bmh::auto_lineup(unrestricted,0,100);
|
||||
check(foreign_starters(unrestricted,0)==6,"disabled edition changed foreign selection");
|
||||
enabled(true);
|
||||
for (int team : {0,90}) {
|
||||
auto g = fixture(team); bmh::auto_lineup(g,team,100);
|
||||
check(foreign_starters(g,team)==(team==0?3:2),"original domestic/foreign league limit not enforced");
|
||||
}
|
||||
auto human = fixture(0,true); bmh::auto_lineup(human,0,100);
|
||||
check(foreign_starters(human,0)==3,"human assistant ignored original limit");
|
||||
for (int row=0;row<24;++row) {
|
||||
const auto entry=human.squad_slots[size_t(row)];const size_t id=entry&0xfff;
|
||||
check(human.tactics[size_t(row)*0x58+0x50]==id+1,"player salary board lost during foreign swap");
|
||||
if(entry&0xc000)check((human.player_cards[id]&31)==row,"card row index not updated after foreign swap");
|
||||
if(row<11)check(human.tactics[size_t(row)*0x58+0x41]==(row?7:0),"formation coordinate moved with replaced player");
|
||||
}
|
||||
auto shortage = fixture(0,false,true); bmh::auto_lineup(shortage,0,100);
|
||||
check(foreign_starters(shortage,0)==3,"shortage of domestic reserves did not terminate with a legal partial lineup");
|
||||
enabled(false); auto restored=fixture(0);bmh::auto_lineup(restored,0,100);
|
||||
check(restored.squad_slots==unrestricted.squad_slots && restored.player_cards==unrestricted.player_cards,
|
||||
"switching back to disabled edition did not restore unchanged selection");
|
||||
std::cout<<"Original foreign lineup limits, board swaps and edition switching passed\n";
|
||||
return 0;
|
||||
} catch(const std::exception&e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "app/video_session.hpp"
|
||||
#include <SDL_syswm.h>
|
||||
#include <cstring>
|
||||
#include <nfd.h>
|
||||
#include <iostream>
|
||||
int main() { @autoreleasepool {
|
||||
SDL_setenv("SDL_VIDEODRIVER", "cocoa", 1);
|
||||
try {
|
||||
bmh::app::VideoSession video;
|
||||
if ([NSApp activationPolicy] != NSApplicationActivationPolicyRegular) return 1;
|
||||
if (NFD_Init() != NFD_OKAY) return 2;
|
||||
NFD_Quit();
|
||||
if ([NSApp activationPolicy] != NSApplicationActivationPolicyRegular) return 3;
|
||||
SDL_Window* window=SDL_CreateWindow("Keyboard startup QA",0,0,320,240,0);
|
||||
if(!window)return 4;
|
||||
SDL_SysWMinfo info{}; SDL_VERSION(&info.version);
|
||||
if(!SDL_GetWindowWMInfo(window,&info))return 5;
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
[info.info.cocoa.window makeKeyAndOrderFront:nil];
|
||||
for(int i=0;i<100 && SDL_GetKeyboardFocus()!=window;++i){SDL_PumpEvents();SDL_Delay(10);}
|
||||
if(SDL_GetKeyboardFocus()!=window){std::cerr<<"Cocoa window did not acquire keyboard focus\n";return 6;}
|
||||
SDL_StartTextInput();
|
||||
SDL_Event input;while(SDL_PollEvent(&input)){}
|
||||
NSEvent* key=[NSEvent keyEventWithType:NSEventTypeKeyDown location:NSZeroPoint
|
||||
modifierFlags:0 timestamp:[[NSProcessInfo processInfo] systemUptime] windowNumber:[info.info.cocoa.window windowNumber]
|
||||
context:nil characters:@"q" charactersIgnoringModifiers:@"q" isARepeat:NO keyCode:12];
|
||||
[NSApp postEvent:key atStart:NO];
|
||||
bool key_received=false,text_received=false;
|
||||
for(int i=0;i<100 && !(key_received&&text_received);++i){
|
||||
while(SDL_PollEvent(&input)){
|
||||
key_received|=input.type==SDL_KEYDOWN;
|
||||
text_received|=input.type==SDL_TEXTINPUT && std::strcmp(input.text.text,"q")==0;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
SDL_DestroyWindow(window);
|
||||
if(!key_received||!text_received){std::cerr<<"Native key="<<key_received<<" text="<<text_received<<'\n';return 7;}
|
||||
std::cout<<"Native Cocoa key and text reach SDL after initial picker lifecycle\n";
|
||||
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 6;}
|
||||
return 0;
|
||||
} }
|
||||
@@ -22,10 +22,10 @@ class PackageAllowlistTests(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
# Empty authored placeholders test names/structure, not executable behavior.
|
||||
for name in ['openbmh_play', 'openbmh_cli', 'README.md', 'LICENSE',
|
||||
for name in ['OpenBMH', 'openbmh_cli', 'README.md', 'LICENSE',
|
||||
'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md']:
|
||||
(root / name).write_text('synthetic')
|
||||
notes = root / 'docs/release/0.1/RELEASE_NOTES.md'
|
||||
notes = root / 'docs/release/1.0/RELEASE_NOTES.md'
|
||||
notes.parent.mkdir(parents=True)
|
||||
notes.write_text('synthetic release notes')
|
||||
licenses = Path(__file__).resolve().parents[1] / 'docs' / 'licenses'
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "app/quit_confirmation.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
void check(bool value, const char* message) { if (!value) throw std::runtime_error(message); }
|
||||
void push(Uint32 type) {
|
||||
SDL_Event event{}; event.type = type;
|
||||
check(SDL_PushEvent(&event) == 1, "cannot enqueue authored event");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
using bmh::app::QuitConfirmation;
|
||||
try {
|
||||
check(SDL_Init(SDL_INIT_EVENTS) == 0, "SDL events initialization");
|
||||
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
|
||||
int presentations = 0, answer = 0;
|
||||
const auto present = [&](const SDL_MessageBoxData* data, int* selected) {
|
||||
++presentations;
|
||||
check(std::string(data->title) == "OpenBMH beenden?", "German prompt");
|
||||
check(std::string(data->message).find("gespeicherte") != std::string::npos, "unsaved-state warning");
|
||||
check(data->numbuttons == 2 && std::string(data->buttons[0].text) == "Abbrechen", "German buttons");
|
||||
check((data->buttons[0].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) &&
|
||||
(data->buttons[0].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT), "Enter and Escape must default to cancellation");
|
||||
*selected = answer; return 0;
|
||||
};
|
||||
QuitConfirmation german(nullptr, false, present);
|
||||
push(SDL_QUIT); push(SDL_USEREVENT);
|
||||
SDL_Event event{};
|
||||
check(german.poll(&event) == 1 && event.type == SDL_USEREVENT && presentations == 1,
|
||||
"cancelled window close must preserve subsequent UI input");
|
||||
push(SDL_QUIT);
|
||||
check(german.peep(&event, 1, SDL_PEEKEVENT, SDL_QUIT, SDL_QUIT) == 1 && presentations == 1,
|
||||
"peeking must not open or consume a dialog");
|
||||
check(german.peep(&event, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) == 0 && presentations == 2,
|
||||
"cancelled animation/live close must not abort its owner");
|
||||
answer = 1; push(SDL_QUIT);
|
||||
check(german.peep(&event, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) == 1 && event.type == SDL_QUIT,
|
||||
"confirmed close must reach existing shutdown handling");
|
||||
check(german.confirm() && presentations == 3, "confirmed shutdown must not ask twice");
|
||||
bool english_seen = false;
|
||||
QuitConfirmation english(nullptr, true, [&](const SDL_MessageBoxData* data, int* selected) {
|
||||
english_seen = std::string(data->title) == "Quit OpenBMH?" &&
|
||||
std::string(data->buttons[0].text) == "Cancel" && std::string(data->buttons[1].text) == "Quit";
|
||||
*selected = 1; return 0;
|
||||
});
|
||||
check(english.confirm() && english_seen, "Football Limited uses English confirmation");
|
||||
QuitConfirmation failed(nullptr, false, [](const SDL_MessageBoxData*, int*) { return -1; });
|
||||
check(!failed.confirm(), "failed native dialog must keep the application alive");
|
||||
SDL_Quit();
|
||||
std::cout << "Quit confirmation language, defaults, cancel, accept and event ownership passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
SDL_Quit(); std::cerr << error.what() << '\n'; return 1;
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,11 @@ void reschedule_test(GameState g) {
|
||||
check(undone.memory.u16(at) == 0 && undone.results.at(size_t(m.match) + size_t(m.round) * 10 + size_t(league) * 0x17c) == kNotPlayed,
|
||||
"undo frees the entry and restores 0xCC");
|
||||
check(reschedulable_matches(undone, 0).size() == matches.size(), "the match is movable again");
|
||||
// UndoReschedule clears the replay bit when no other replay stays on the day: the same
|
||||
// target days as before the move (issue 16)
|
||||
check((undone.memory.u16(::bmh::layout::CompetitionCalendar + uint32_t(target) * 2) & 0x4000) == 0,
|
||||
"undo clears the calendar replay bit");
|
||||
check(reschedule_target_days(undone, 0, m) == days, "the same target days after the undo");
|
||||
std::cout << "moved round " << m.round + 1 << " from day " << m.day << " to day " << target << " (" << days.size()
|
||||
<< " days offered)\n";
|
||||
}
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "formats/le.hpp"
|
||||
#include "game/messages.hpp"
|
||||
#include "game/career.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
|
||||
namespace bmh::test {
|
||||
// Standalone engine tests explicitly install the supplied edition's scheduling
|
||||
// content. CareerSession performs the same installation for normal app callers.
|
||||
// content and the message texts. CareerSession performs the same installation for
|
||||
// normal app callers.
|
||||
inline LeImage load_executable(const std::filesystem::path& path) {
|
||||
auto executable = bmh::load_le(path);
|
||||
install_fixture_tables(executable);
|
||||
install_message_texts(executable);
|
||||
install_career_rules(executable);
|
||||
install_calendar_rules(executable);
|
||||
install_environment_rules(executable);
|
||||
return executable;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/season.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
namespace {
|
||||
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
|
||||
bmh::GameState fixture(int slot, int age, bool foreign = false) {
|
||||
bmh::GameState g;
|
||||
constexpr uint32_t data_begin = 0xa0000;
|
||||
constexpr size_t data_size = 0x21000;
|
||||
g.memory.add_block(data_begin, data_size);
|
||||
g.squad_slots.assign(3096, 0xfff);
|
||||
g.squad_slots.at(size_t(slot)) = 0;
|
||||
g.players.resize(1);
|
||||
g.players[0].w364 = uint32_t(age - 16) << 21;
|
||||
g.players[0].w368 = foreign ? 1u << 27 : 0;
|
||||
g.player_bonus.assign(1, 0);
|
||||
g.date = 365;
|
||||
return g;
|
||||
}
|
||||
void run(bmh::GameState& g, bmh::GameRandom& game, bmh::WatcomRandom& rand) {
|
||||
bmh::MinuteReport report;
|
||||
bmh::season_players(g, game, rand, report);
|
||||
check(!report.unsupported, "season reset unexpectedly unsupported");
|
||||
check(!g.lineups_frozen, "season reset left lineups frozen");
|
||||
}
|
||||
}
|
||||
int main() try {
|
||||
{
|
||||
auto g = fixture(2928, 20);
|
||||
constexpr uint32_t entry = bmh::layout::CupTable + 14 * 0x28;
|
||||
g.memory.set8(entry, 0x7f);
|
||||
bmh::initialize_european_qualification_seed(g);
|
||||
check(g.memory.u16(entry + 0x22) == 357 && g.memory.u16(entry + 0x24) == 358 &&
|
||||
g.memory.u8(entry) == 0x7f, "empty EM seeds did not become national teams without changing descriptor data");
|
||||
g.memory.set16(entry + 0x22, 361); g.memory.set16(entry + 0x24, 364);
|
||||
bmh::initialize_european_qualification_seed(g);
|
||||
check(g.memory.u16(entry + 0x22) == 361 && g.memory.u16(entry + 0x24) == 364,
|
||||
"existing original national qualification seeds were overwritten");
|
||||
}
|
||||
for (const auto [slot, foreign] : {std::pair{2928, false}, {2971, false}, {2972, false}, {3071, true}}) {
|
||||
auto g = fixture(slot, 47, foreign);
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() >= 20 && g.players[0].age() <= 32,
|
||||
"old market player wrapped to age 16 instead of retiring/regenerating");
|
||||
check(std::count(g.squad_slots.begin(), g.squad_slots.end(), 0) == 1,
|
||||
"retired market player duplicated or lost during free-agent relocation");
|
||||
check(g.squad_slots[size_t(slot)] == 0xfff,
|
||||
"retired market player's source slot was not cleared");
|
||||
}
|
||||
{
|
||||
auto g = fixture(0, 20);
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() == 21 && g.squad_slots[0] == 0,
|
||||
"young club player changed ownership or age progression");
|
||||
check(game.calls() == 0 && rand.calls() == 1,
|
||||
"unchanged club ageing consumed additional random draws");
|
||||
}
|
||||
{
|
||||
auto g = fixture(0, 20);
|
||||
g.squad_slots[2968] = 0; // Cached contract/offer row still references this club player.
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() == 21 && g.squad_slots[0] == 0 && g.squad_slots[2968] == 0,
|
||||
"cached offer aged or recycled a player still owned by his club");
|
||||
check(game.calls() == 0 && rand.calls() == 1,
|
||||
"cached offer consumed a second retirement draw for its club player");
|
||||
}
|
||||
{
|
||||
auto g = fixture(3072, 47);
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() == 47 && g.squad_slots[3072] == 0 &&
|
||||
game.calls() == 0 && rand.calls() == 0,
|
||||
"non-seasonal extra slots entered the retirement loop");
|
||||
}
|
||||
{
|
||||
auto g = fixture(2928, 47); g.date = 0;
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() == 47 && game.calls() == 0 && rand.calls() == 0,
|
||||
"new-career setup unexpectedly aged market players");
|
||||
}
|
||||
std::cout << "Season player reset: market retirement and unchanged ageing passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception& e) { std::cerr << e.what() << '\n'; return 1; }
|
||||
@@ -13,6 +13,9 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
@@ -20,6 +23,7 @@
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
#include "game/matchday.hpp"
|
||||
#include "game/month.hpp"
|
||||
@@ -71,6 +75,37 @@ void check_state(const GameState& g, const std::string& when, Checks& c) {
|
||||
}
|
||||
}
|
||||
|
||||
// Optional private investigation: snapshots use their own save-envelope RNG;
|
||||
// observing a failure never consumes either gameplay stream.
|
||||
bool capture_duplicate(const GameState& before, const GameState& after,
|
||||
const std::filesystem::path& directory) {
|
||||
std::set<int> seen;
|
||||
int duplicate = -1;
|
||||
for (size_t slot = 0; slot < 2928 && slot < after.squad_slots.size(); ++slot) {
|
||||
const int id = after.squad_slots[slot] & 0xfff;
|
||||
if (id != 0xfff && !seen.insert(id).second) { duplicate = id; break; }
|
||||
}
|
||||
if (duplicate < 0) return false;
|
||||
std::filesystem::create_directories(directory);
|
||||
WatcomRandom envelope(1);
|
||||
write_savegame(directory / "before_duplicate.FBM", make_savegame(before, envelope));
|
||||
write_savegame(directory / "after_duplicate.FBM", make_savegame(after, envelope));
|
||||
std::ofstream report(directory / "duplicate.txt");
|
||||
report << "player=" << duplicate << " before_day=" << before.date << " after_day=" << after.date << '\n';
|
||||
for (const auto* state : {&before, &after}) {
|
||||
report << "day=" << state->date << " age=" << state->players.at(size_t(duplicate)).age() << '\n';
|
||||
for (size_t slot = 0; slot < state->squad_slots.size(); ++slot)
|
||||
if ((state->squad_slots[slot] & 0xfff) == duplicate)
|
||||
report << "slot=" << slot << " team=" << slot_team(int(slot)) << " flags=" << (state->squad_slots[slot] & 0xf000) << '\n';
|
||||
for (uint32_t row = 0; row < 200; ++row) {
|
||||
const auto value = state->memory.u32(layout::Career_RemoveJoinLoans_RuntimeField + row * 4);
|
||||
if (value && (value & 0xfff) == uint32_t(duplicate))
|
||||
report << "loan_row=" << row << " raw=" << value << '\n';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// The matchday just played. Cup phase 2 stores the shoot-out goals added to the
|
||||
// match score (legacy routine). The total-12 plausibility check cannot apply to that
|
||||
// combined display score: Original week40_capture.jsonl:241 records 11:10.
|
||||
@@ -150,6 +185,8 @@ int main(int argc, char** argv) {
|
||||
Checks checks;
|
||||
std::string gap;
|
||||
int played = 0, goals = 0, matches = 0, seasons = 0;
|
||||
const char* duplicate_directory = std::getenv("SIM_DUPLICATE_DIR");
|
||||
bool duplicate_captured = false;
|
||||
try {
|
||||
app::CareerSession session(argv[1], argc > 4 ? uint32_t(std::stoul(argv[4])) : 1u);
|
||||
ui::SetupOptions options; // 5 seasons, level 2, one manager, mode III, league and world
|
||||
@@ -305,6 +342,8 @@ int main(int argc, char** argv) {
|
||||
if (offer.status == TransferActionStatus::pending || offer.status == TransferActionStatus::accepted) break;
|
||||
}
|
||||
}
|
||||
std::optional<GameState> duplicate_before;
|
||||
if (duplicate_directory && !duplicate_captured) duplicate_before = g;
|
||||
ui::DeskRequest kickoff;
|
||||
kickoff.kind = ui::DeskRequestKind::advance_turn;
|
||||
kickoff.manager_slot = int(g.memory.u8(::bmh::layout::ActiveManager));
|
||||
@@ -314,6 +353,8 @@ int main(int argc, char** argv) {
|
||||
gap = r.reason.empty() ? error : r.reason;
|
||||
break;
|
||||
}
|
||||
if (duplicate_before && capture_duplicate(*duplicate_before, g, duplicate_directory))
|
||||
duplicate_captured = true;
|
||||
if (r.kind == TurnDeskKind::CareerComplete) {
|
||||
++played;
|
||||
std::printf("turn %d (day %u): career complete\n", played, r.date);
|
||||
@@ -330,6 +371,10 @@ int main(int argc, char** argv) {
|
||||
++seasons;
|
||||
} // (the next kickoff runs the season change)
|
||||
}
|
||||
if (const char* final_save = std::getenv("SIM_FINAL_SAVE")) {
|
||||
WatcomRandom envelope(1); // Diagnostic export must not change either gameplay stream.
|
||||
write_savegame(final_save, make_savegame(g, envelope));
|
||||
}
|
||||
print_first_league_results(g, "run end");
|
||||
if (std::getenv("SIM_ADVERTISING")) std::printf("%d advertising contracts accepted (SIM_ADVERTISING=1)\n", ad_contracts);
|
||||
if (std::getenv("SIM_INTERVENE")) std::printf("%d interventions (substitution at minute 30, re-rated)\n", interventions);
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "formats/binary.hpp"
|
||||
#include "formats/font.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/rule_base.hpp"
|
||||
|
||||
using namespace bmh;
|
||||
using namespace bmh::ui;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "app/video_session.hpp"
|
||||
#include <iostream>
|
||||
int main(int, char**)try {
|
||||
SDL_setenv("SDL_VIDEODRIVER","dummy",1);
|
||||
{ bmh::app::VideoSession video;
|
||||
if (!(SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO)) return 1;
|
||||
// The initial chooser executes inside this scope, not before it.
|
||||
}
|
||||
if (SDL_WasInit(SDL_INIT_VIDEO)) return 1;
|
||||
SDL_setenv("SDL_VIDEODRIVER","unavailable-openbmh-test-driver",1);
|
||||
bool rejected=false;
|
||||
try { bmh::app::VideoSession failed; } catch(const std::exception&) { rejected=true; }
|
||||
if(!rejected || SDL_WasInit(SDL_INIT_VIDEO))return 1;
|
||||
std::cout<<"Video lifetime initializes before picker and releases on early return\n";
|
||||
return 0;
|
||||
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
"""Build products and every configured test program, without unused data fixtures."""
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
TEST = re.compile(r'^add_test\((?:\[=*\[.*?\]=*\]|"[^"]*"|[^ )]+)\s+"((?:\\.|[^"\\])*)"')
|
||||
HOST = re.compile(r'(?:python(?:[0-9.]+)?|cmake|ctest)(?:\.exe)?$', re.I)
|
||||
|
||||
|
||||
def targets_for_tests(build):
|
||||
build = build.resolve(strict=True)
|
||||
targets = {'openbmh_play', 'openbmh_cli'}
|
||||
tests = 0
|
||||
for file in sorted(build.rglob('CTestTestfile.cmake')):
|
||||
for line in file.read_text(encoding='utf-8').splitlines():
|
||||
if not line.startswith('add_test('):
|
||||
continue
|
||||
match = TEST.match(line)
|
||||
if not match:
|
||||
raise RuntimeError('Unrecognized generated test command; refusing to omit a test')
|
||||
tests += 1
|
||||
command = match.group(1).replace('\\"', '"').replace('\\\\', '\\')
|
||||
executable = Path(command).resolve()
|
||||
if executable.is_relative_to(build):
|
||||
name = executable.name
|
||||
if name.lower().endswith('.exe'):
|
||||
name = name[:-4]
|
||||
targets.add('openbmh_play' if name == 'OpenBMH' else name)
|
||||
elif not HOST.fullmatch(executable.name):
|
||||
raise RuntimeError('Unrecognized external test executable; refusing to omit a test')
|
||||
if not tests:
|
||||
raise RuntimeError('No configured tests found')
|
||||
return sorted(targets), tests
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--build', type=Path, required=True)
|
||||
parser.add_argument('--config', default='Release')
|
||||
parser.add_argument('--parallel', type=int, default=2)
|
||||
parser.add_argument('--list', action='store_true')
|
||||
args = parser.parse_args()
|
||||
targets, count = targets_for_tests(args.build)
|
||||
print(f'{count} configured tests; {len(targets)} product/test build targets', flush=True)
|
||||
if args.list:
|
||||
print('\n'.join(targets))
|
||||
else:
|
||||
subprocess.run(['cmake', '--build', str(args.build), '--config', args.config,
|
||||
'--parallel', str(args.parallel), '--target', *targets], check=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
from build_runnable_tests import targets_for_tests
|
||||
|
||||
|
||||
class BuildDiscoveryTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temporary = tempfile.TemporaryDirectory(prefix='ci build ')
|
||||
self.addCleanup(self.temporary.cleanup)
|
||||
self.build = Path(self.temporary.name) / 'build'
|
||||
self.build.mkdir()
|
||||
|
||||
def write(self, text):
|
||||
(self.build / 'CTestTestfile.cmake').write_text(text, encoding='utf-8')
|
||||
|
||||
def test_required_programs_and_optional_data_skip(self):
|
||||
self.write(f'add_test([=[unit]=] "{self.build.as_posix()}/unit_suite.exe")\n'
|
||||
f'add_test([=[private]=] "{self.build.as_posix()}/openbmh_test_skip.exe" "missing input")\n'
|
||||
f'add_test([=[python]=] "{Path(sys.executable).as_posix()}" "check.py")\n')
|
||||
targets, count = targets_for_tests(self.build)
|
||||
self.assertEqual(count, 3)
|
||||
self.assertEqual(targets, ['openbmh_cli', 'openbmh_play', 'openbmh_test_skip', 'unit_suite'])
|
||||
|
||||
def test_nested_test_and_product_output_name(self):
|
||||
self.write(f'add_test([=[version]=] "{self.build.as_posix()}/OpenBMH.exe" "--version")\n')
|
||||
nested = self.build / 'src' / 'ui'
|
||||
nested.mkdir(parents=True)
|
||||
(nested / 'CTestTestfile.cmake').write_text(
|
||||
f'add_test([=[ui]=] "{nested.as_posix()}/ui_suite")\n', encoding='utf-8')
|
||||
targets, count = targets_for_tests(self.build)
|
||||
self.assertEqual(count, 2)
|
||||
self.assertEqual(targets, ['openbmh_cli', 'openbmh_play', 'ui_suite'])
|
||||
|
||||
def test_unknown_external_binary_is_not_silently_dropped(self):
|
||||
outside = self.build.parent / 'unknown-suite'
|
||||
self.write(f'add_test([=[outside]=] "{outside.as_posix()}")\n')
|
||||
with self.assertRaisesRegex(RuntimeError, 'external'):
|
||||
targets_for_tests(self.build)
|
||||
|
||||
def test_unrecognized_command_and_empty_configuration_fail(self):
|
||||
self.write('add_test(unsupported-syntax)\n')
|
||||
with self.assertRaises(RuntimeError):
|
||||
targets_for_tests(self.build)
|
||||
self.write('# no tests\n')
|
||||
with self.assertRaises(RuntimeError):
|
||||
targets_for_tests(self.build)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -10,7 +10,7 @@ import zipfile
|
||||
|
||||
|
||||
def validate(directory, windows):
|
||||
products = {'openbmh_play.exe', 'openbmh_cli.exe'} if windows else {'openbmh_play', 'openbmh_cli'}
|
||||
products = {'OpenBMH.exe', 'openbmh_cli.exe'} if windows else {'OpenBMH', 'openbmh_cli'}
|
||||
documents = {'README.md', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md'}
|
||||
licenses = {'README.md', 'LGPL-2.1.txt', 'Nuked-OPL3-notices.txt', 'LZMA-SDK.txt', 'SDL2-HIDAPI-BSD.txt',
|
||||
'SDL2-HIDAPI-options.txt', 'SDL2-HIDAPI-original.txt', 'SDL2-yuv2rgb.txt',
|
||||
@@ -33,7 +33,7 @@ def validate(directory, windows):
|
||||
if not allowed:
|
||||
raise RuntimeError('Unexpected package entry: ' + relative.as_posix())
|
||||
required = products | documents | {'docs/licenses/' + name for name in licenses}
|
||||
required.add('docs/release/0.1/RELEASE_NOTES.md')
|
||||
required.add('docs/release/1.0/RELEASE_NOTES.md')
|
||||
if required - present:
|
||||
raise RuntimeError('Missing package entries: ' + ', '.join(sorted(required - present)))
|
||||
if windows and not {'vcruntime140.dll', 'msvcp140.dll'} <= present:
|
||||
|
||||
@@ -145,8 +145,8 @@ def main():
|
||||
'--root', str(source)], check=True)
|
||||
cache = (args.build / 'CMakeCache.txt').read_text()
|
||||
import re
|
||||
version = re.search(r'^CMAKE_PROJECT_VERSION:STATIC=([^\n]+)$', cache, re.M).group(1)
|
||||
if not re.fullmatch(r'\d+\.\d+\.\d+', version):
|
||||
version = (args.build / 'product-version.txt').read_text().strip()
|
||||
if not re.fullmatch(r'\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?', version):
|
||||
raise RuntimeError('Unexpected source version')
|
||||
dependencies = json.loads((args.build / 'package-dependencies.json').read_text())
|
||||
args.out.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
import json
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
from verify_ci_release import PLATFORMS, verify
|
||||
|
||||
|
||||
class ReleaseVerificationTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temporary = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temporary.cleanup)
|
||||
self.root = Path(self.temporary.name)
|
||||
self.dist = self.root / 'dist'; self.dist.mkdir()
|
||||
self.reports = self.root / 'reports'; self.reports.mkdir()
|
||||
self.sha = 'a' * 40
|
||||
for platform in (*PLATFORMS, 'source'):
|
||||
with zipfile.ZipFile(self.dist / f'OpenBMH-1.0.0-{platform}.zip', 'w') as z:
|
||||
if platform == 'source':
|
||||
z.writestr('source/SOURCE_MANIFEST.json', json.dumps({'version': '1.0.0', 'project_commit': self.sha}))
|
||||
else:
|
||||
z.writestr('synthetic.txt', 'synthetic package')
|
||||
for platform in PLATFORMS:
|
||||
folder = self.reports / ('tests-' + platform); folder.mkdir()
|
||||
(folder / 'test-results.xml').write_text('<testsuite tests="4" failures="0" skipped="1"/>')
|
||||
|
||||
def run_verify(self, sha=None):
|
||||
return verify(self.dist, self.reports, 'v1.0.0', sha or self.sha, 123, 'example/project')
|
||||
|
||||
def test_matching_release_records_skips_and_checksums(self):
|
||||
report = self.run_verify()
|
||||
self.assertEqual(report['tests']['linux-x64']['skipped'], 1)
|
||||
self.assertEqual(len(report['archive_sha256']), 4)
|
||||
self.assertEqual(len((self.dist / 'SHA256SUMS').read_text().splitlines()), 5)
|
||||
|
||||
def test_wrong_revision_rejected(self):
|
||||
with self.assertRaisesRegex(ValueError, 'different'):
|
||||
self.run_verify('b' * 40)
|
||||
|
||||
def test_missing_platform_archive_rejected(self):
|
||||
(self.dist / 'OpenBMH-1.0.0-windows-x64.zip').unlink()
|
||||
with self.assertRaisesRegex(ValueError, 'archive set'):
|
||||
self.run_verify()
|
||||
|
||||
def test_failed_or_all_skipped_reports_rejected(self):
|
||||
path = self.reports / 'tests-windows-x64' / 'test-results.xml'
|
||||
path.write_text('<testsuite tests="4" failures="0"><testcase><failure/></testcase></testsuite>')
|
||||
with self.assertRaisesRegex(ValueError, 'failed'):
|
||||
self.run_verify()
|
||||
path.write_text('<testsuite tests="4" failures="0" skipped="4"/>')
|
||||
with self.assertRaisesRegex(ValueError, 'execute'):
|
||||
self.run_verify()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
"""Bind release archives to one successful CI revision and its test reports."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import xml.etree.ElementTree as ET
|
||||
import zipfile
|
||||
|
||||
PLATFORMS = ('windows-x64', 'macos-arm64', 'linux-x64')
|
||||
|
||||
|
||||
def verify(dist, reports, tag, source_sha, ci_run, repository):
|
||||
match = re.fullmatch(r'v([0-9]+\.[0-9]+\.[0-9]+(?:-[A-Za-z0-9][A-Za-z0-9.-]*)?)', tag)
|
||||
if not match or not re.fullmatch(r'[0-9a-f]{40}', source_sha) or ci_run <= 0:
|
||||
raise ValueError('Invalid release identity')
|
||||
version = match.group(1)
|
||||
expected = {f'OpenBMH-{version}-{p}.zip' for p in (*PLATFORMS, 'source')}
|
||||
if {p.name for p in dist.glob('*.zip')} != expected:
|
||||
raise ValueError('Release archive set does not match the tag/platforms')
|
||||
with zipfile.ZipFile(dist / f'OpenBMH-{version}-source.zip') as source:
|
||||
manifests = [n for n in source.namelist() if n.endswith('/SOURCE_MANIFEST.json')]
|
||||
if len(manifests) != 1:
|
||||
raise ValueError('Missing or ambiguous corresponding-source manifest')
|
||||
manifest = json.loads(source.read(manifests[0]))
|
||||
if manifest['version'] != version or manifest['project_commit'] != source_sha:
|
||||
raise ValueError('Corresponding source is from a different version or revision')
|
||||
tests = {}
|
||||
for platform in PLATFORMS:
|
||||
root = ET.parse(reports / ('tests-' + platform) / 'test-results.xml').getroot()
|
||||
suites = list(root.iter('testsuite'))
|
||||
if not suites or next(root.iter('failure'), None) is not None or next(root.iter('error'), None) is not None:
|
||||
raise ValueError('Missing or failed platform test results')
|
||||
values = {key: sum(int(s.get(key, '0')) for s in suites)
|
||||
for key in ('tests', 'failures', 'errors', 'skipped')}
|
||||
if values['failures'] or values['errors'] or values['tests'] <= values['skipped']:
|
||||
raise ValueError('Platform test results did not execute passing tests')
|
||||
tests[platform] = values
|
||||
archives = {name: hashlib.sha256((dist / name).read_bytes()).hexdigest() for name in sorted(expected)}
|
||||
report = {'version': version, 'tag': tag, 'source_commit': source_sha,
|
||||
'ci_run': ci_run, 'ci_url': f'https://github.com/{repository}/actions/runs/{ci_run}',
|
||||
'tests': tests, 'archive_sha256': archives}
|
||||
output = dist / 'QA-REPORT.json'
|
||||
output.write_text(json.dumps(report, indent=2) + '\n', encoding='utf-8')
|
||||
checksums = dict(archives)
|
||||
checksums[output.name] = hashlib.sha256(output.read_bytes()).hexdigest()
|
||||
(dist / 'SHA256SUMS').write_text(''.join(f'{digest} {name}\n' for name, digest in sorted(checksums.items())), encoding='utf-8')
|
||||
return report
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument('--dist', type=Path, required=True)
|
||||
p.add_argument('--reports', type=Path, required=True)
|
||||
p.add_argument('--tag', required=True)
|
||||
p.add_argument('--source-sha', required=True)
|
||||
p.add_argument('--ci-run', type=int, required=True)
|
||||
p.add_argument('--repository', required=True)
|
||||
a = p.parse_args()
|
||||
verify(a.dist, a.reports, a.tag, a.source_sha, a.ci_run, a.repository)
|
||||
print('Release archives, source revision and all platform reports verified')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -50,8 +50,8 @@ LEGACY_SYMBOLS = re.compile(
|
||||
PRIVATE_TEXT = re.compile(
|
||||
r"(?:(?<![\w}./\\])/" + r"tools/|[A-Z]:[/\\]Users[/\\]|[A-Z]:[/\\]OpenBMH[/\\]|"
|
||||
r"docs/(?:analyses|agents)/|src/ui/(?:validation|reference)/|"
|
||||
+ "bmh" + r"-work|matter" + r"most|\bMich" + r"ael\b|\bDIA" +
|
||||
r"MOND\b|(?<![\w}./\\])/" + r"root/[^\s]+|https?://(?:10\.|192\.168\.|172\.(?:1[6-9]|2[0-9]|3[01])\.)|"
|
||||
+ "bmh" + r"-work|matter" + r"most|\bMich" + r"ael\b|"
|
||||
r"(?<![\w}./\\])/" + r"root/[^\s]+|https?://(?:10\.|192\.168\.|172\.(?:1[6-9]|2[0-9]|3[01])\.)|"
|
||||
r"github\.com/[^/\s]+/openbmh[_-]dc\b)",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user