Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
310e3e2464 | ||
|
|
4fb8b2f551 | ||
|
|
f1a31c9940 |
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
|
||||
+73
-9
@@ -1,8 +1,19 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 0.1.1 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 1.0.1 LANGUAGES CXX C)
|
||||
if(APPLE)
|
||||
# Enable native languages before dependencies/subdirectories inherit rules.
|
||||
enable_language(OBJC OBJCXX)
|
||||
endif()
|
||||
set(OPENBMH_PRERELEASE "" CACHE STRING "Prerelease identifier; empty for final release")
|
||||
set(OPENBMH_PRODUCT_VERSION "${PROJECT_VERSION}")
|
||||
if(OPENBMH_PRERELEASE)
|
||||
string(APPEND OPENBMH_PRODUCT_VERSION "-${OPENBMH_PRERELEASE}")
|
||||
endif()
|
||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/product-version.txt" CONTENT "${OPENBMH_PRODUCT_VERSION}\n")
|
||||
# the one place of the version: --version of both programs and the window title (src/version.hpp)
|
||||
add_compile_definitions(OPENBMH_VERSION="${PROJECT_VERSION}")
|
||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/generated/openbmh_build_version.hpp"
|
||||
CONTENT "// SPDX-License-Identifier: GPL-3.0-only\n#pragma once\n#define OPENBMH_VERSION \"${OPENBMH_PRODUCT_VERSION}\"\n")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@@ -39,7 +50,7 @@ function(bmh_add_data_test)
|
||||
set(T_DATA_DIR "${BMH_DATA}")
|
||||
endif()
|
||||
set(reason "")
|
||||
set(external_text_tests season_transition_tests environment_tests cli_console_tests
|
||||
set(external_text_tests season_transition_tests cli_console_tests
|
||||
ui_desktop_tests ui_lineup_tests format_tests app_controller_tests bank_app_tests
|
||||
cli_soak ui_cup_draw_tests league_pairings_tests ui_pending_offer_tests
|
||||
reality_reporter_layout_tests season_cup_draw_app_tests
|
||||
@@ -62,7 +73,7 @@ function(bmh_add_data_test)
|
||||
message(FATAL_ERROR "Invalid game data directory for ${T_NAME}: ${T_DATA_DIR}")
|
||||
endif()
|
||||
foreach(option IN LISTS T_REQUIRED_OPTIONS)
|
||||
if(NOT "${${option}}" OR NOT EXISTS "${${option}}")
|
||||
if("${${option}}" STREQUAL "" OR NOT EXISTS "${${option}}")
|
||||
set(reason "External test input not supplied: ${option}")
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -202,7 +213,6 @@ add_library(bmhcore STATIC
|
||||
src/formats/textd.cpp
|
||||
src/formats/fbm.cpp
|
||||
src/formats/le.cpp
|
||||
src/formats/rule_base.cpp
|
||||
src/formats/m3d.cpp
|
||||
src/formats/savestate.cpp
|
||||
src/game/schedule.cpp
|
||||
@@ -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
|
||||
@@ -365,9 +376,7 @@ bmh_add_data_test(NAME reschedule_tests REQUIRED_OPTIONS BMH_TEST_RESCHEDULE_TES
|
||||
|
||||
add_executable(environment_tests tests/environment_tests.cpp)
|
||||
target_link_libraries(environment_tests PRIVATE bmhcore)
|
||||
set(BMH_TEST_ENVIRONMENT_TESTS_INPUT_1 "" CACHE PATH "External input 1 for environment_tests; not distributed")
|
||||
bmh_add_data_test(NAME environment_tests REQUIRED_OPTIONS BMH_TEST_ENVIRONMENT_TESTS_INPUT_1 COMMAND environment_tests "${BMH_DATA}"
|
||||
"${BMH_TEST_ENVIRONMENT_TESTS_INPUT_1}")
|
||||
add_test(NAME environment_tests COMMAND environment_tests)
|
||||
|
||||
add_executable(youth_academy_tests tests/youth_academy_tests.cpp)
|
||||
target_link_libraries(youth_academy_tests PRIVATE bmhcore)
|
||||
@@ -443,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.
|
||||
@@ -482,6 +492,7 @@ if(MSVC)
|
||||
endif()
|
||||
bmh_add_data_test(NAME app_controller_tests COMMAND app_controller_tests "${BMH_DATA}")
|
||||
set(BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 "" CACHE PATH "External input 1 for app_delay_settings_tests; not distributed")
|
||||
bmh_add_data_test(NAME app_environment_tests COMMAND app_controller_tests "${BMH_DATA}" --environment-only)
|
||||
bmh_add_data_test(NAME app_delay_settings_tests REQUIRED_OPTIONS BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 COMMAND app_controller_tests "${BMH_DATA}"
|
||||
--delay-settings-only "${BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1}")
|
||||
|
||||
@@ -622,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)
|
||||
@@ -1070,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)
|
||||
@@ -1088,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
-1
@@ -1,6 +1,6 @@
|
||||
# Contributing to OpenBMH
|
||||
|
||||
Use [issues](https://github.com/rezmer/openbmh/issues) for reproducible bugs and proposals. For a bug, include the OpenBMH version, platform, game edition, expected behaviour and the smallest sequence of actions that shows the problem. Remove personal paths and account information from diagnostic text.
|
||||
Use [issues](https://github.com/Weyoune/openbmh/issues) for reproducible bugs and proposals. For a bug, include the OpenBMH version, platform, game edition, expected behaviour and the smallest sequence of actions that shows the problem. Remove personal paths and account information from diagnostic text.
|
||||
|
||||
Keep proprietary game files out of public submissions: no executables, databases, manuals, extracted text, artwork, recordings or saved games. Prefer synthetic inputs and a short description. If an investigation requires privately owned data, coordinate an appropriate process with the maintainers instead of attaching it publicly.
|
||||
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
# 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.
|
||||
|
||||
## Get started
|
||||
|
||||
Check the [releases page](https://github.com/rezmer/openbmh/releases) for available packages and their platform notes. A Windows package uses the name `OpenBMH-<version>-windows-x64.zip`. Availability and native validation are stated for each release; source build instructions do not establish platform support on their own.
|
||||
Check the [releases page](https://github.com/Weyoune/openbmh/releases) for available packages and their platform notes. A Windows package uses the name `OpenBMH-<version>-windows-x64.zip`. Availability and native validation are stated for each release; source build instructions do not establish platform support on their own.
|
||||
|
||||
1. Have your own supported game installation available.
|
||||
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
|
||||
3. Start `openbmh_play` (`openbmh_play.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
3. Start `OpenBMH` (`OpenBMH.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
|
||||
From a terminal:
|
||||
From a terminal in the extracted package on Linux or macOS:
|
||||
|
||||
```sh
|
||||
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
||||
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
|
||||
./OpenBMH --data "path/to/game" --save-directory "path/to/saves"
|
||||
./openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
|
||||
```
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [0.1 release notes](docs/release/0.1/RELEASE_NOTES.md).
|
||||
In Windows PowerShell, use `.\OpenBMH.exe` and `.\openbmh_cli.exe` instead.
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0/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.1. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
|
||||
The following recipes build OpenBMH 1.0. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
|
||||
|
||||
Clone the public repository, then run the commands for your system:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/rezmer/openbmh.git
|
||||
git clone https://github.com/Weyoune/openbmh.git
|
||||
cd openbmh
|
||||
```
|
||||
|
||||
@@ -50,7 +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.1](https://github.com/rezmer/openbmh/tree/v0.1.1) 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.
|
||||
@@ -308,9 +308,10 @@ This index includes registered and reserved names. `ListOptions` and `Help` from
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowEnvironment` | – | staff levels and the youth academy |
|
||||
| `ShowEnvironment` | – | six monthly budgets and three youth tables |
|
||||
| `SetStaffLevel` | role:enum(AssistantCoach,Doctor,Physio), level:int(0..6) | click a staff tile: level 0..6, 5 000 a month each |
|
||||
| `SetYouthAcademy` | state:enum(On,Off) | start (July/August) or stop the youth academy |
|
||||
| `SetYouthLevel` | team:enum(Youngest,Academy,Oldest), level:int(0..6) | set a youth team’s monthly budget |
|
||||
| `SetYouthAcademy` | state:enum(On,Off) | compatibility alias: middle youth budget at level 6 or 0 |
|
||||
|
||||
### `Balance`
|
||||
|
||||
|
||||
@@ -1,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.
|
||||
|
||||
|
||||
+31
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
OpenBMH aims to preserve the familiar game while handling malformed input and unsafe edge cases explicitly. A reconstruction can remain faithful without reproducing a crash or pretending to implement an unknown path.
|
||||
|
||||
- Content such as names, text, graphics and edition-specific tables is loaded from the user's installation. OpenBMH's shared rule base supplies simulation values; selecting another data edition does not select a separate engine.
|
||||
- Content such as names, text, graphics and edition-specific tables is loaded from the user's installation. The loaded program retains its own rule-table values; loading no longer applies the former shared replacement profile.
|
||||
- Safety checks reject transactions that would exhaust required return capacity, use stale identities or lose a valid state. Unsupported operations report their limitation rather than inventing an outcome.
|
||||
- Calendar progression handles boundary days and seasonal transitions without relying on unsafe fixed-day assumptions.
|
||||
- Saves are written from the committed session state. Saving does not deliberately replay unrelated game actions.
|
||||
@@ -11,3 +11,33 @@ OpenBMH aims to preserve the familiar game while handling malformed input and un
|
||||
Intentional changes in code should use the marker `OpenBMH deviates from the original:` and explain their purpose. Adding a new behaviour or balance change requires a concrete description and relevant tests; this page is not permission to substitute guessed rules.
|
||||
|
||||
The [generated differences catalogue](DIFFERENCES.md) lists these markers with links to their source files.
|
||||
|
||||
## Application exit confirmation
|
||||
|
||||
Closing the window, exiting with Escape or confirming the desktop's exit control
|
||||
opens a native confirmation dialog. BMH data uses German text and Football
|
||||
Limited data uses English. Enter, Escape and closing the confirmation cancel the
|
||||
exit; only the explicit Quit/Beenden button permits normal shutdown. Cancelling
|
||||
keeps the current dialog or match owner alive without a turn or implicit save.
|
||||
An unavailable native message box also cancels the request. This applies to
|
||||
voluntary application exits, including quit events received during animations;
|
||||
normal completed-career handling remains separate.
|
||||
|
||||
## Original edition rules in 1.0
|
||||
|
||||
Loaded executable images retain their own rule tables. Career strength ranges are read from all nine pairs of the supplied original table.
|
||||
|
||||
The six-budget monthly environment implementation has been checked against the provided CD and Diamond 3.6/3.7 program code. Its budget increments are read from that program's own table. Capability recognition uses verified code fingerprints, never directory names. Unrecognized environment implementations cannot be edited or simulated through a guessed model; they require separate compatibility verification. Older Diamond academy patches are not silently treated as the monthly model. The old floppy executable remains unsupported, and Football Limited remains experimental.
|
||||
|
||||
Release acceptance of individual editions is recorded separately from their recognition. Source compatibility and automated tests do not establish full original-game or platform validation.
|
||||
|
||||
## 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.
|
||||
+7
-14
@@ -6,32 +6,25 @@ See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These en
|
||||
describe deliberate changes; they are not a list of every known compatibility limit.
|
||||
|
||||
- [src/app/career_session.cpp](../src/app/career_session.cpp): supports designated set-piece record initialization and validation.
|
||||
- [src/cli/console/windows_environment.cpp](../src/cli/console/windows_environment.cpp): uses monthly staff levels in increments of five thousand and the supported youth-academy controls.
|
||||
- [src/formats/le.hpp](../src/formats/le.hpp): applies a shared supported rule profile when loading editions with different rule-table values.
|
||||
- [src/formats/rule_base.cpp](../src/formats/rule_base.cpp): normalizes live-scene defaults, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit across supported editions.
|
||||
- [src/formats/rule_base.hpp](../src/formats/rule_base.hpp): normalizes live-scene options, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit.
|
||||
- [src/game/balance_plan.cpp](../src/game/balance_plan.cpp): omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
|
||||
- [src/game/balance_plan.hpp](../src/game/balance_plan.hpp): uses the supported staff and youth-academy cost categories.
|
||||
- [src/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
|
||||
- [src/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
||||
- [src/game/career.hpp](../src/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
- [src/game/desk_actions.cpp](../src/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): supports designated set-piece records and the supported transfer-editor rules.
|
||||
- [src/game/environment.hpp](../src/game/environment.hpp): enables the supported youth academy and represents staff levels in monthly increments of five thousand.
|
||||
- [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image.
|
||||
- [src/game/lineup.cpp](../src/game/lineup.cpp): disables the foreign-player limit in the supported rule profile.
|
||||
- [src/game/lineup.hpp](../src/game/lineup.hpp): disables the foreign-player limit and supports owner-bound designated set-piece selection.
|
||||
- [src/game/lineup.hpp](../src/game/lineup.hpp): supports owner-bound designated set-piece selection.
|
||||
- [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules.
|
||||
- [src/game/match_engine.cpp](../src/game/match_engine.cpp): supports designated set-piece takers, the enhanced injury tables, and the extended suspension fields.
|
||||
- [src/game/month.cpp](../src/game/month.cpp): omits the two discontinued youth-group cost categories from monthly accounts.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
- [src/game/season.hpp](../src/game/season.hpp): uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
- [src/game/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.
|
||||
- [src/game/week.hpp](../src/game/week.hpp): uses the enhanced assistant-training rules, retaining the selected skill until it reaches its maximum.
|
||||
- [src/game/weekly.cpp](../src/game/weekly.cpp): uses the supported weekly-event configuration, with its rule switch disabled.
|
||||
- [src/game/weekly.hpp](../src/game/weekly.hpp): uses the supported weekly processing and transfer rule profile.
|
||||
- [src/ui/advertising.cpp](../src/ui/advertising.cpp): uses the supported youth-academy cap and its saved cost fields.
|
||||
- [src/ui/environment.cpp](../src/ui/environment.cpp): omits the two discontinued youth groups from the environment screen.
|
||||
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
|
||||
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
|
||||
|
||||
+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. Replace fixed-layout state gradually with typed clubs, players, contracts and competitions. Keep each intermediate stage usable and cover transitions with tests.
|
||||
The SDL2 graphical client and console share the game/session layer. Community clients and automation should use the documented [console interface](CONSOLE_CLIENTS.md) and retain its ownership and revision checks.
|
||||
|
||||
## 0.3: configurable rules
|
||||
|
||||
Expose rule values and balance choices as configuration, with reproducible simulations to assess changes. Improve tactical automation, transfer decisions and scoring distributions through documented changes rather than hidden edition-specific branches.
|
||||
|
||||
## 0.4: adaptable interfaces and competitions
|
||||
|
||||
Add a scalable interface through the shared application/protocol boundary. Make league sizes and competition structures data-driven. Define content-pack formats for independently licensed artwork, names and other resources; do not distribute third-party material without permission.
|
||||
|
||||
## 0.5: independently distributable content
|
||||
|
||||
Provide original or freely licensed graphics, sound and generated football worlds so that OpenBMH can be played without proprietary game data. Support editors, new competitions and multiplayer clients built on the same engine interfaces.
|
||||
|
||||
The typed model and open format are prerequisites for flexible competitions, configurable rules and new content. See [architecture](architecture.md) for the current boundaries and [compatibility decisions](COMPATIBILITY.md) for intentional departures.
|
||||
See [architecture](architecture.md), [compatibility decisions](COMPATIBILITY.md) and [contributing](../CONTRIBUTING.md) before changing shared behaviour. No proprietary game content belongs in public code, tests or releases.
|
||||
@@ -1045,6 +1045,11 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `Environment_FormatError_RuntimeField` | `0xa50f0` | German-compatible image / runtime field |
|
||||
| `Environment_FormatError_RuntimeField2` | `0xa50f6` | German-compatible image / runtime field |
|
||||
| `Environment_Render_TextPointer` | `0xaeb74` | German-compatible image / runtime field |
|
||||
| `EnvironmentYouthTeams` | `0xbd4bc` | German-compatible image / runtime field |
|
||||
| `EnvironmentYouthPositionSuffix` | `0xa1698` | German-compatible image / runtime field |
|
||||
| `EnvironmentCostSuffix` | `0xa169d` | German-compatible image / runtime field |
|
||||
| `EnvironmentYouthLeagueTextPointer` | `0xaeb78` | German-compatible image / runtime field |
|
||||
| `EnvironmentYouthColors` | `0xa50fc` | German-compatible image / runtime field |
|
||||
| `Environment_SetEnvironment_ExecutableField` | `0xaf394` | German-compatible image / runtime field |
|
||||
| `EuropeNameTable` | `0xae710` | German-compatible image / runtime field |
|
||||
| `EventPasses` | `0xa2ba1` | German-compatible image / runtime field |
|
||||
@@ -1986,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,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,41 +0,0 @@
|
||||
# OpenBMH v0.1.1
|
||||
|
||||
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.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/rezmer/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/rezmer/openbmh/issues/2)).
|
||||
- Right-click cancels load/save dialogs, including settings and desktop-layout files ([#3](https://github.com/rezmer/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/rezmer/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 the new 0.1.1 packages 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. 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.1](https://github.com/rezmer/openbmh/tree/v0.1.1). 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,29 @@
|
||||
# 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,41 @@
|
||||
# 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,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;
|
||||
@@ -4558,9 +4559,9 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
|
||||
const bool consumed = (request.column == 7 &&
|
||||
((request.row <= 6) || request.row == 7 || request.row == 9 || request.row == 10 ||
|
||||
(scoped_settings && request.row == 8))) ||
|
||||
// B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
|
||||
// A9 match minutes; B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
|
||||
// I9 cup draw; K9 Reality report; M9 preview/shootout; P9 shot.
|
||||
(request.column == 8 && ((request.row >= 1 && request.row <= 6) ||
|
||||
(request.column == 8 && ((request.row >= 0 && request.row <= 6) ||
|
||||
request.row == 7 || request.row == 8 || request.row == 10 || request.row == 12 || request.row == 15));
|
||||
if (!consumed || old >= 200) {
|
||||
error = "Diese Einstellung ist noch nicht verfügbar.";
|
||||
|
||||
@@ -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;
|
||||
|
||||
+110
-66
@@ -1,5 +1,7 @@
|
||||
// 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
|
||||
// career initialised by the engine (app/career_session.hpp) and its desk.
|
||||
//
|
||||
@@ -9,6 +11,7 @@
|
||||
#include <SDL.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -23,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"
|
||||
@@ -73,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).
|
||||
@@ -97,7 +114,7 @@ int main(int argc, char** argv) {
|
||||
fs::path data, save_directory;
|
||||
uint32_t seed = uint32_t(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
bool muted = false, music_enabled = true;
|
||||
int live_frame_ms = 10;
|
||||
int live_frame_ms = 0;
|
||||
bool live_frame_ms_explicit = false;
|
||||
if (const char* configured = std::getenv("BMH_LIVE_FRAME_MS")) {
|
||||
live_frame_ms = std::clamp(std::atoi(configured), 0, 1000);
|
||||
@@ -128,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
|
||||
@@ -178,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.
|
||||
@@ -205,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());
|
||||
@@ -344,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;
|
||||
@@ -446,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;
|
||||
@@ -460,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;
|
||||
@@ -473,19 +494,13 @@ 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
|
||||
}
|
||||
};
|
||||
auto wait_source_retraces = [&](unsigned count) {
|
||||
// SDL has no VGA status-port equivalent. Approximate Source's
|
||||
// retrace waits with the active display's reported refresh period;
|
||||
// keep the previous frame visible and present the next frame once.
|
||||
SDL_DisplayMode mode{};
|
||||
const int display = SDL_GetWindowDisplayIndex(window);
|
||||
int refresh_hz = display >= 0 && SDL_GetCurrentDisplayMode(display, &mode) == 0
|
||||
? mode.refresh_rate : 0;
|
||||
if (refresh_hz <= 0) refresh_hz = 60; // explicit host fallback; not an Original VGA claim
|
||||
// Keep the VGA cadence on 60/120/144-Hz host displays alike.
|
||||
constexpr auto refresh_hz = ui::kOriginalRefreshHz;
|
||||
const Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||
const Uint64 ticks_per_wait = (frequency + Uint64(refresh_hz) - 1) / Uint64(refresh_hz);
|
||||
for (unsigned i = 0; running && i < count; ++i) {
|
||||
@@ -493,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);
|
||||
}
|
||||
@@ -543,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;
|
||||
@@ -566,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) +
|
||||
@@ -673,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>{});
|
||||
@@ -688,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 &&
|
||||
@@ -727,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);
|
||||
}
|
||||
@@ -744,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);
|
||||
}
|
||||
};
|
||||
@@ -799,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)
|
||||
@@ -869,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 &&
|
||||
@@ -898,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)) {
|
||||
@@ -961,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;
|
||||
@@ -1078,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;
|
||||
@@ -1179,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);
|
||||
@@ -1247,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;
|
||||
@@ -1309,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)
|
||||
@@ -1393,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;
|
||||
@@ -1449,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;
|
||||
@@ -1543,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();
|
||||
@@ -1551,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)) {
|
||||
@@ -1586,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;
|
||||
@@ -1623,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;
|
||||
@@ -1688,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) {
|
||||
@@ -1810,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;
|
||||
@@ -1980,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) {
|
||||
@@ -2080,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)
|
||||
@@ -2158,7 +2177,8 @@ int main(int argc, char** argv) {
|
||||
live_frame_shown = true;
|
||||
}
|
||||
}
|
||||
const int frame_delay = live_frame_ms_explicit ? live_frame_ms : std::max(live_frame_ms, 250);
|
||||
const int frame_delay = live_frame_ms_explicit ? live_frame_ms :
|
||||
int(ui::live_delay_milliseconds(state.memory.u8(::bmh::layout::Main_FormatError_ExecutableField)));
|
||||
if (live_frame_shown && !live_skipped && frame_delay > 0)
|
||||
SDL_Delay(Uint32(frame_delay));
|
||||
},
|
||||
@@ -2189,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 &&
|
||||
@@ -2258,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))
|
||||
@@ -2286,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)) {
|
||||
@@ -2440,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))
|
||||
@@ -2505,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;
|
||||
@@ -2618,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 ||
|
||||
@@ -2682,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 &&
|
||||
@@ -2796,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;
|
||||
@@ -2917,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;
|
||||
}
|
||||
@@ -2954,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;
|
||||
@@ -2986,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;
|
||||
}
|
||||
@@ -3008,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)) {
|
||||
@@ -3043,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);
|
||||
@@ -3069,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;
|
||||
@@ -3093,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;
|
||||
@@ -3157,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,
|
||||
@@ -3579,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;
|
||||
}
|
||||
@@ -3646,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(),
|
||||
@@ -3860,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;
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// OpenBMH deviates from the original: uses monthly staff levels in increments of five thousand and the supported youth-academy controls.
|
||||
// The club environment (menu 24, docs/CLI_CONCEPT/06-verein.md 10, H2 p. 93, supported rule profile p. 107,
|
||||
// 111): co-trainer, doctor and physio in levels of 5 000 a month, and the supported rule profile youth
|
||||
// academy that costs a season price of the league.
|
||||
//
|
||||
// The rules are the engine's (src/game/environment.hpp, a port of Image with the
|
||||
// supported rule profile patch); a command is one click of the original screen.
|
||||
// The console and desktop share all six monthly environment budgets.
|
||||
|
||||
#include "app/desktop_actions.hpp"
|
||||
#include "cli/console/console.hpp"
|
||||
@@ -19,20 +13,21 @@ using namespace detail;
|
||||
void Console::register_environment_commands() {
|
||||
auto show = [this] {
|
||||
const EnvironmentState s = environment_state(session_->state(), active_slot());
|
||||
std::vector<std::vector<std::string>> rows = {
|
||||
{"AssistantCoach", std::to_string(s.level[kCoTrainer]), money(s.monthly[kCoTrainer])},
|
||||
{"Doctor", std::to_string(s.level[kDoctor]), money(s.monthly[kDoctor])},
|
||||
{"Physio", std::to_string(s.level[kPhysio]), money(s.monthly[kPhysio])},
|
||||
{"YouthAcademy", s.monthly[kYouthAcademy] != 0 ? "on" : "off", money(s.youth_price) + " per season"}};
|
||||
emit_table({"Item", "Level", "Costs"}, rows);
|
||||
emit('i', std::string("youth academy: ") + (s.youth_paid ? "paid this season" : s.youth_open ? "can be started (July/August)"
|
||||
: "too late for this season"));
|
||||
std::vector<std::vector<std::string>> rows;
|
||||
constexpr const char* names[] = {"YouthYoungest", "YouthAcademy", "YouthOldest", "AssistantCoach", "Doctor", "Physio"};
|
||||
for (int i = 0; i < kEnvironmentItems; ++i)
|
||||
rows.push_back({names[i], std::to_string(s.level[size_t(i)]), money(s.monthly[size_t(i)])});
|
||||
emit_table({"Item", "Level", "MonthlyCosts"}, rows);
|
||||
rows.clear();
|
||||
for (size_t i = 0; i < 3; ++i)
|
||||
rows.push_back({names[i], std::to_string(s.youth_position[i] + 1), std::to_string(s.youth_league[i] + 1)});
|
||||
emit_table({"YouthTeam", "Position", "Division"}, rows);
|
||||
};
|
||||
openers_[24] = [this, show] {
|
||||
open_window("Environment");
|
||||
show();
|
||||
};
|
||||
add({"Environment", "ShowEnvironment", {}, "staff levels and the youth academy", false}, [show](const Values&) { show(); });
|
||||
add({"Environment", "ShowEnvironment", {}, "all six monthly budgets and youth tables", false}, [show](const Values&) { show(); });
|
||||
auto apply = [this, show](int item, int level) {
|
||||
std::string error;
|
||||
const auto r=app::EnvironmentActions(*session_).set_console(
|
||||
@@ -44,11 +39,14 @@ void Console::register_environment_commands() {
|
||||
add({"Environment", "SetStaffLevel", {choice("role", {"AssistantCoach", "Doctor", "Physio"}), integer("level", 0, 6)},
|
||||
"click a staff tile: level 0..6, 5 000 a month each", true},
|
||||
[apply](const Values& v) { apply(kCoTrainer + v.choice("role"), int(v.integer("level"))); });
|
||||
add({"Environment", "SetYouthAcademy", {choice("state", {"On", "Off"})}, "start (July/August) or stop the youth academy", true},
|
||||
add({"Environment", "SetYouthLevel", {choice("team", {"Youngest", "Academy", "Oldest"}), integer("level", 0, 6)},
|
||||
"set one youth team's monthly budget, level 0..6", true},
|
||||
[apply](const Values& v) { apply(v.choice("team"), int(v.integer("level"))); });
|
||||
add({"Environment", "SetYouthAcademy", {choice("state", {"On", "Off"})}, "set the middle youth budget to level 6 or 0", true},
|
||||
[this, apply](const Values& v) {
|
||||
const bool on = environment_state(session_->state(), active_slot()).monthly[kYouthAcademy] != 0;
|
||||
const bool want = v.choice("state") == 0;
|
||||
// the original's click on an active academy switches it off: click only for a change
|
||||
// Retain the old On/Off command as an alias for the middle youth budget.
|
||||
if (on == want) emit('+', std::string("youth academy already ") + (on ? "on" : "off"));
|
||||
else apply(kYouthAcademy, want ? 6 : 0);
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
@@ -1026,6 +1026,11 @@ inline constexpr auto EnglishLeagueCupSemiFinalResults = 0x7d002;
|
||||
inline constexpr auto Environment_FormatError_RuntimeField = 0xa50f0;
|
||||
inline constexpr auto Environment_FormatError_RuntimeField2 = 0xa50f6;
|
||||
inline constexpr auto Environment_Render_TextPointer = 0xaeb74;
|
||||
inline constexpr auto EnvironmentYouthTeams = 0xbd4bc;
|
||||
inline constexpr auto EnvironmentYouthPositionSuffix = 0xa1698;
|
||||
inline constexpr auto EnvironmentCostSuffix = 0xa169d;
|
||||
inline constexpr auto EnvironmentYouthLeagueTextPointer = 0xaeb78;
|
||||
inline constexpr auto EnvironmentYouthColors = 0xa50fc;
|
||||
inline constexpr auto Environment_SetEnvironment_ExecutableField = 0xaf394;
|
||||
inline constexpr auto EuropeNameTable = 0xae710;
|
||||
inline constexpr auto EventPasses = 0xa2ba1;
|
||||
@@ -1967,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
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/balance_plan.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -160,13 +161,6 @@ uint32_t catering_per_game(const GameState& g, int m, int32_t gate) {
|
||||
return sum;
|
||||
}
|
||||
|
||||
// OpenBMH deviates from the original: omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
|
||||
// TeamLeague3 (supported rule profile patch): the youth academy limit of the league
|
||||
int32_t youth_limit(const GameState& g, int m) {
|
||||
const int league = team_league(g.manager_teams.at(size_t(m)));
|
||||
return league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
}
|
||||
|
||||
// The redraw of BalanceFromGame2 (with its continuation Redraw and the patch at
|
||||
// Redraw2): recomputes the items if `refresh` asks for it, then the spectator income
|
||||
// and the totals.
|
||||
@@ -228,12 +222,12 @@ void redraw(const GameState& source, BalancePlanDraft& d) {
|
||||
r[4] = wrap(int64_t(r[4]) + int64_t(facility_income(g, m)) * months);
|
||||
const uint32_t catering = catering_per_game(g, m, r[kBalanceAverageGate]);
|
||||
r[4] = wrap(int64_t(r[4]) + int64_t((catering * uint32_t(home)) / 12) * months);
|
||||
// running costs Spending: the patch counts only the youth academy (index 1),
|
||||
// with the whole league limit while +0x880 is below it
|
||||
const uint32_t costs = ::bmh::layout::Spending + uint32_t(m) * 0x24;
|
||||
if (mem32(g, costs + 4) != 0 && int64_t(months) * mem32(g, costs + 4) != 0) {
|
||||
const int32_t limit = youth_limit(g, m);
|
||||
if (uint32_t(rec32(g, m, 0x880)) < uint32_t(limit)) r[9] = wrap(int64_t(r[9]) + limit);
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
const auto value = environment_monthly_cost(g, m, k);
|
||||
const auto raw = mem32(g, costs + uint32_t(k) * 4);
|
||||
const int count = k == kYouthAcademy && raw > kEnvironmentStep[k] * 6 ? 1 : months;
|
||||
r[9] = wrap(int64_t(r[9]) + int64_t(count) * value);
|
||||
}
|
||||
for (int k = 0; k < 3; k++) r[size_t(10 + k)] = wrap(int64_t(r[size_t(10 + k)]) + int64_t(months) * mem32(g, costs + 0xc + uint32_t(k) * 4));
|
||||
for (int k = 0; k < 2; k++) r[size_t(14 + k)] = wrap(int64_t(r[size_t(14 + k)]) + int64_t(months) * rec32(g, m, 0x854 + size_t(k) * 4));
|
||||
@@ -276,11 +270,7 @@ int32_t stadium_required_attendance(const GameState& source, int manager) {
|
||||
int32_t costs = wrap(int64_t(facility_costs(g, m)) + rec32(g, m, 0x854) + rec32(g, m, 0x858));
|
||||
costs = wrap(int64_t(costs) + monthly_pay(g, m, 0xa));
|
||||
for (int k = 0; k < 6; ++k) {
|
||||
int32_t value = mem32(g, ::bmh::layout::Spending + uint32_t(m) * 0x24 + uint32_t(k) * 4);
|
||||
if (k == 0 || k == 2) value = 0; // OpenBMH deviates from the original: omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
|
||||
// supported rule profile MonthlyExpenses
|
||||
if (k == 1 && value != 0)
|
||||
value = uint32_t(rec32(g, m, 0x880)) < uint32_t(youth_limit(g, m)) ? youth_limit(g, m) : 0;
|
||||
const int32_t value = environment_monthly_cost(g, m, k);
|
||||
costs = wrap(int64_t(costs) + value);
|
||||
}
|
||||
costs = wrap(int64_t(costs) - shares_and_loans(g, m, 2, 0) + int(rec8(g, m, 0x179)) * 1000);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// OpenBMH deviates from the original: uses the supported staff and youth-academy cost categories.
|
||||
// All three youth budgets and staff costs share the monthly environment model.
|
||||
// The balance plan ("Bilanz", desk menu 28, mode III; H2 p. 26-27; BMH.exe V2.24 + supported rule profile
|
||||
// patch): the screen BalanceFromGame2 projects the club's income and expenses for the business
|
||||
// year and lets the manager change every item. When he leaves the screen the resulting
|
||||
|
||||
@@ -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
|
||||
|
||||
+116
-86
@@ -1,103 +1,133 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "game/messages.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "game/week.hpp"
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
namespace {
|
||||
bool supported_environment = true; // Synthetic state tests explicitly use the verified monthly model.
|
||||
|
||||
constexpr uint32_t kSpending = ::bmh::layout::Spending; // + manager * 0x24 + item * 4
|
||||
constexpr size_t kRecordSize = 0xb0c;
|
||||
constexpr size_t kYouthPaid = 0x880; // youth expenses booked this season
|
||||
// EnvironmentRuntimeField: the step of each item in thousands (items 3..5: 5 000 per level)
|
||||
constexpr int kUnit[kEnvironmentItems] = {2, 4, 5, 5, 5, 5};
|
||||
|
||||
uint32_t spending_at(int manager, int item) { return kSpending + uint32_t(manager) * 0x24 + uint32_t(item) * 4; }
|
||||
|
||||
// TeamLeague3: the academy's season price by the club's league
|
||||
int32_t youth_price(const GameState& g, int manager) {
|
||||
const int league = team_league(g.manager_teams.at(size_t(manager)));
|
||||
return league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
uint32_t youth_at(int manager) { return layout::EnvironmentYouthTeams + uint32_t(manager) * 0x24; }
|
||||
uint32_t spending_at(int manager, int item) {
|
||||
return layout::Spending + uint32_t(manager) * 0x24 + uint32_t(item) * 4;
|
||||
}
|
||||
|
||||
// YouthOpen: July (unless the Bundesliga is past its 17th round) or August
|
||||
bool youth_open(const GameState& g) {
|
||||
const int month = month_code(g.date);
|
||||
if (month == 7) return !(g.league_rounds.at(0) > 0x11);
|
||||
return month == 8;
|
||||
void validate_manager(const GameState& g, int manager) {
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() ||
|
||||
!g.memory.has(youth_at(manager) + 8) || !g.memory.has(spending_at(manager, 5) + 3))
|
||||
throw FormatError("environment: invalid manager or truncated budgets");
|
||||
}
|
||||
|
||||
bool youth_paid(const GameState& g, int manager) {
|
||||
const size_t at = size_t(manager) * kRecordSize + kYouthPaid;
|
||||
const uint32_t paid = uint32_t(g.manager_records.at(at)) | uint32_t(g.manager_records.at(at + 1)) << 8 |
|
||||
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
|
||||
return paid >= uint32_t(youth_price(g, manager));
|
||||
int direction(int value) { return (value > 0) - (value < 0); }
|
||||
int signed_clamp(int value, int low, int high) {
|
||||
return std::clamp(int(int8_t(uint8_t(value))), low, high);
|
||||
}
|
||||
bool legacy_academy(const GameState& g, int manager) {
|
||||
const auto value = g.memory.u32(spending_at(manager, kYouthAcademy));
|
||||
return value == 1500000 || value == 1000000 || value == 580000 || value == 280000;
|
||||
}
|
||||
uint32_t academy_paid(const GameState& g, int manager) {
|
||||
const auto at = size_t(manager) * 0xb0c + 0x880;
|
||||
return uint32_t(g.manager_records.at(at)) | uint32_t(g.manager_records.at(at + 1)) << 8 |
|
||||
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
|
||||
}
|
||||
}
|
||||
void install_environment_rules(const LeImage& exe) {
|
||||
for (size_t i=0;i<kEnvironmentStep.size();++i) {
|
||||
const uint32_t at=layout::EnvironmentBudgetSteps+uint32_t(i);
|
||||
if (!exe.contains(at) || exe.u8(at)==0) { supported_environment=false; return; }
|
||||
kEnvironmentStep[i]=int32_t(exe.u8(at))*1000;
|
||||
}
|
||||
uint64_t fingerprint = 14695981039346656037ull;
|
||||
for (const auto [first,last] : {std::pair{layout::EnvironmentVerifiedCodeBegin,layout::EnvironmentVerifiedCodeEnd},std::pair{layout::EnvironmentVerifiedHookBegin,layout::EnvironmentVerifiedHookEnd}}) {
|
||||
if (!exe.contains(first) || !exe.contains(last-1)) { supported_environment=false; return; }
|
||||
for (uint32_t at=first;at<last;++at) fingerprint=(fingerprint ^ exe.u8(at))*1099511628211ull;
|
||||
}
|
||||
// Fingerprints identify verified behaviour, not filenames, dates or artwork.
|
||||
supported_environment = fingerprint==0xc2488a656f340e99ull || fingerprint==0x19adba7ef3eda507ull;
|
||||
}
|
||||
bool environment_rules_supported() { return supported_environment; }
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
|
||||
const auto value = g.memory.u32(spending_at(manager, item));
|
||||
if (item == kYouthAcademy && legacy_academy(g, manager) && academy_paid(g, manager) >= value) return 0;
|
||||
return int32_t(value);
|
||||
}
|
||||
bool environment_academy_active(const GameState& g, int manager) {
|
||||
const auto value = g.memory.u32(spending_at(manager, kYouthAcademy));
|
||||
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
EnvironmentState s;
|
||||
for (int i = 0; i < kEnvironmentItems; i++) {
|
||||
s.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
|
||||
// the stars (SizeT7): staff value / step, the academy 6 when on, 0/2 none
|
||||
if (i >= 3) s.level[size_t(i)] = std::clamp(s.monthly[size_t(i)] / (kUnit[i] * 1000), 0, 6);
|
||||
else if (i == kYouthAcademy) s.level[size_t(i)] = s.monthly[size_t(i)] != 0 ? 6 : 0;
|
||||
if (!supported_environment) throw FormatError("environment: this original program variant is not verified");
|
||||
validate_manager(g, manager);
|
||||
EnvironmentState result;
|
||||
for (int i = 0; i < kEnvironmentItems; ++i) {
|
||||
result.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
|
||||
result.level[size_t(i)] = std::clamp(result.monthly[size_t(i)] / kEnvironmentStep[size_t(i)], 0, 6);
|
||||
}
|
||||
s.youth_price = youth_price(g, manager);
|
||||
s.youth_paid = youth_paid(g, manager);
|
||||
s.youth_open = youth_open(g);
|
||||
return s;
|
||||
}
|
||||
|
||||
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems || level < 0 ||
|
||||
level > 6 || !g.memory.has(spending_at(manager, item) + 3))
|
||||
return EnvironmentResult::invalid;
|
||||
const uint32_t at = spending_at(manager, item);
|
||||
const int32_t before = int32_t(g.memory.u32(at));
|
||||
int32_t value = 0;
|
||||
EnvironmentResult result = EnvironmentResult::changed;
|
||||
if (item >= 3) {
|
||||
value = level * kUnit[item] * 1000;
|
||||
} else if (item == kYouthAcademy) {
|
||||
// YouthPrice: a click on an active academy means "off"
|
||||
int wanted = level;
|
||||
if (before != 0 && wanted != 0) wanted = 0;
|
||||
const int32_t price = youth_price(g, manager);
|
||||
if (!youth_paid(g, manager)) {
|
||||
if (wanted == 0) {
|
||||
value = 0;
|
||||
} else if (!youth_open(g)) {
|
||||
value = 0;
|
||||
result = EnvironmentResult::too_late;
|
||||
if (message) *message = message_text(g, ::bmh::layout::Environment_SetEnvironment_ExecutableField); // "Zu spät für diese Saison..."
|
||||
} else {
|
||||
value = price;
|
||||
}
|
||||
} else {
|
||||
// paid this season: stays on; a click meant as "off" brings the second string of
|
||||
// the same text block (*Environment_SetEnvironment_ExecutableField + 0x42)
|
||||
value = price;
|
||||
if (wanted == 0) {
|
||||
result = EnvironmentResult::contract_runs;
|
||||
if (message) {
|
||||
*message = message_text_following(g, ::bmh::layout::Environment_SetEnvironment_ExecutableField);
|
||||
// OpenBMH-authored notice when an edition has no academy tail text.
|
||||
if (message->empty()) *message = "This academy contract stays active until the season ends.";
|
||||
}
|
||||
}
|
||||
}
|
||||
for (uint32_t i = 0; i < 3; ++i) {
|
||||
result.youth_strength[i] = g.memory.u8(youth_at(manager) + i);
|
||||
result.youth_position[i] = g.memory.u8(youth_at(manager) + 3 + i);
|
||||
result.youth_league[i] = g.memory.u8(youth_at(manager) + 6 + i);
|
||||
if (result.youth_position[i] > 11 || result.youth_league[i] > 2)
|
||||
throw FormatError("environment: invalid youth table");
|
||||
}
|
||||
g.memory.set32(at, uint32_t(value));
|
||||
if (result == EnvironmentResult::changed && value == before) result = EnvironmentResult::unchanged;
|
||||
return result;
|
||||
}
|
||||
|
||||
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
|
||||
if (message) message->clear();
|
||||
if (!supported_environment) return EnvironmentResult::invalid;
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems ||
|
||||
level < 0 || level > 6 || !g.memory.has(spending_at(manager, item) + 3))
|
||||
return EnvironmentResult::invalid;
|
||||
const auto at = spending_at(manager, item);
|
||||
const auto value = uint32_t(level * kEnvironmentStep[size_t(item)]);
|
||||
if (g.memory.u32(at) == value) return EnvironmentResult::unchanged;
|
||||
g.memory.set32(at, value);
|
||||
return EnvironmentResult::changed;
|
||||
}
|
||||
void advance_youth_teams(GameState& g, int manager, WatcomRandom& rand) {
|
||||
const auto observed = environment_state(g, manager);
|
||||
std::array<uint8_t, 44> movement{};
|
||||
uint8_t step = 4;
|
||||
for (auto& value : movement) {
|
||||
value = step;
|
||||
if (step != 0 && rand.range(0, 8) == 0) --step;
|
||||
}
|
||||
const auto round = g.league_rounds.at(0);
|
||||
if (round >= movement.size()) throw FormatError("environment: youth round outside season");
|
||||
constexpr int division_strength[] = {85, 70, 57};
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
int strength = observed.youth_strength[i];
|
||||
int position = observed.youth_position[i];
|
||||
const int opponent = uint8_t(division_strength[observed.youth_league[i]] - position);
|
||||
const int ratio = strength == 0 ? 100 :
|
||||
int((((int64_t(observed.monthly[i]) * 100 / ((1 << i) * 10000)) >> 1) + 40) * 100 / strength);
|
||||
int change = direction(ratio - 100);
|
||||
if (rand.range(0, 4) == 0) change = rand.range(0, 2) - 1;
|
||||
if (std::abs(ratio - 100) <= rand.range(0, 30)) change = 0;
|
||||
if (rand.range(0, 2) == 0) strength = uint8_t(strength + change);
|
||||
strength = signed_clamp(strength, 10, 85);
|
||||
g.memory.set8(youth_at(manager) + uint32_t(i), uint8_t(strength));
|
||||
const int difference = strength - opponent;
|
||||
change = direction(difference);
|
||||
if (rand.range(0, 4) == 0) change = rand.range(0, 2) - 1;
|
||||
if (rand.range(0, 3) != 0 && std::abs(difference) * 2 < rand.range(1, 18)) change = 0;
|
||||
position = signed_clamp(uint8_t(position - change * rand.range(1, movement[round])), 0, 11);
|
||||
g.memory.set8(youth_at(manager) + 3 + uint32_t(i), uint8_t(position));
|
||||
}
|
||||
}
|
||||
void finish_youth_season(GameState& g, int manager) {
|
||||
const auto observed = environment_state(g, manager);
|
||||
for (int i = 2; i >= 0; --i) {
|
||||
auto division = observed.youth_league[size_t(i)];
|
||||
const int position = observed.youth_position[size_t(i)];
|
||||
int next_position = 5;
|
||||
if (position < 2 && division != 0) { --division; next_position = position + 10; }
|
||||
if (position > 10 && division < 2) { ++division; next_position = position - 10; }
|
||||
if (i != 0) g.memory.set8(youth_at(manager) + uint32_t(i),
|
||||
uint8_t((int(observed.youth_strength[size_t(i - 1)]) + observed.youth_strength[size_t(i)] * 2) / 3));
|
||||
g.memory.set8(youth_at(manager) + 3 + uint32_t(i), uint8_t(next_position));
|
||||
g.memory.set8(youth_at(manager) + 6 + uint32_t(i), division);
|
||||
}
|
||||
}
|
||||
} // namespace bmh
|
||||
+21
-33
@@ -1,47 +1,35 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// OpenBMH deviates from the original: enables the supported youth academy and represents staff levels in monthly increments of five thousand.
|
||||
// The club environment ("Umfeld", desk menu 24, H2 p. 93; supported rule profile manual p. 107, 111):
|
||||
// the screen Image with the supported rule profile patch (SizeT7 / EnvironmentOperation /
|
||||
// YouthPrice / YouthOpen). Six monthly running costs per manager live at
|
||||
// Spending + manager * 0x24 (u32 each); the month change books them
|
||||
// (month.cpp monthly_expenses) and the staff values steer training, injuries and healing.
|
||||
//
|
||||
// item 0, 2 the original's two other youth age groups: the patch always sets 0
|
||||
// item 1 the youth academy (supported rule profile): on or off. On it is the league's season price
|
||||
// (TeamLeague3: 1.5 M, 1 M, 580 000, 280 000), paid in full at the next month
|
||||
// change while record +0x880 (youth expenses this season) is below it. It can
|
||||
// be switched on in July and August only ("Zu spät für diese Saison...") and
|
||||
// not switched off once paid ("Der Vertrag läuft bis zum Saisonende.").
|
||||
// item 3..5 co-trainer, doctor, physio: level 0..6 times 5 000 a month (EnvironmentRuntimeField)
|
||||
//
|
||||
// A click on a tile sets the level from the mouse position (supported rule profile: one click per value).
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "game/random.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "game/state.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
// Verified original-program capability; unknown environment variants are not guessed.
|
||||
void install_environment_rules(const LeImage&);
|
||||
bool environment_rules_supported();
|
||||
constexpr int kEnvironmentItems = 6;
|
||||
enum EnvironmentItem : int { kYouthAcademy = 1, kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
|
||||
|
||||
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
|
||||
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
|
||||
// Monthly environment model verified in the supported CD and Diamond 3.6/3.7 programs.
|
||||
inline std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
struct EnvironmentState {
|
||||
std::array<int32_t, kEnvironmentItems> monthly{}; // Spending values
|
||||
std::array<int, kEnvironmentItems> level{}; // the stars the screen draws (0..6)
|
||||
int32_t youth_price = 0; // the season price of the academy for the club's league
|
||||
bool youth_paid = false; // record +0x880 reached the price: cannot be switched off
|
||||
bool youth_open = false; // July/August: the academy can still be switched on
|
||||
std::array<int32_t, kEnvironmentItems> monthly{};
|
||||
std::array<int, kEnvironmentItems> level{};
|
||||
std::array<uint8_t, 3> youth_strength{}, youth_position{}, youth_league{};
|
||||
};
|
||||
|
||||
EnvironmentState environment_state(const GameState& g, int manager);
|
||||
|
||||
enum class EnvironmentResult : uint8_t { changed, unchanged, too_late, contract_runs, invalid };
|
||||
|
||||
// A click on `item` at `level` (0..6; for the academy any level > 0 means "on" and a click on
|
||||
// an active academy switches it off). `message` gets the original's message box text, if any.
|
||||
// Preserve already saved lump-sum academy contracts until the user edits them.
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item);
|
||||
bool environment_academy_active(const GameState& g, int manager);
|
||||
enum class EnvironmentResult : uint8_t { changed, unchanged, invalid };
|
||||
// Set a monthly budget to level 0..6, without an immediate debit or random draw.
|
||||
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message = nullptr);
|
||||
|
||||
// Youth results advance with first-division matchdays. Promotion/relegation and
|
||||
// the handover to the next age group happen before annual accounts.
|
||||
void advance_youth_teams(GameState& g, int manager, WatcomRandom& rand);
|
||||
void finish_youth_season(GameState& g, int manager);
|
||||
} // namespace bmh
|
||||
+54
-2
@@ -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);
|
||||
|
||||
+2
-25
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/matchday.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -676,30 +677,6 @@ void manager_match_record(GameState& g, const MatchGroup& grp, int m, int home_g
|
||||
}
|
||||
|
||||
|
||||
// TicketPriceDraws: per human manager on a first league matchday. It once let the three
|
||||
// ticket prices drift; in this version its stores were turned into comparisons (CMP
|
||||
// instead of MOV), so only the random numbers remain.
|
||||
void ticket_price_draws(const GameState& g, int manager, WatcomRandom& rand) {
|
||||
uint8_t step[0x2c];
|
||||
int b = 4;
|
||||
for (int i = 0; i < 0x2c; i++) {
|
||||
step[i] = uint8_t(b);
|
||||
if (b != 0 && rand.range(0, 8) == 0) b--;
|
||||
}
|
||||
(void)g;
|
||||
(void)manager;
|
||||
const int round = g.league_rounds.empty() ? 0 : g.league_rounds[0];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// the direction terms depend on the prices, but only as values, not as draw counts
|
||||
if (rand.range(0, 4) == 0) rand.range(0, 2);
|
||||
rand.range(0, 30);
|
||||
rand.range(0, 2);
|
||||
if (rand.range(0, 4) == 0) rand.range(0, 2);
|
||||
if (rand.range(0, 3) != 0) rand.range(1, 18);
|
||||
rand.range(1, step[round < 0x2c ? round : 0x2b]);
|
||||
}
|
||||
}
|
||||
|
||||
// ManagerOf(manager, 0, value): the manager's position of this season.
|
||||
static void store_season_position(GameState& g, int manager, int value) {
|
||||
int season = std::min(g.season, 0x31);
|
||||
@@ -742,7 +719,7 @@ void advance_league_rounds(GameState& g, uint32_t competitions, WatcomRandom& ra
|
||||
for (int league = kFirst[c]; league < kFirst[c] + kCount[c]; league++) {
|
||||
if (league == 0) {
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++) {
|
||||
ticket_price_draws(g, int(m), rand);
|
||||
advance_youth_teams(g, int(m), rand);
|
||||
const size_t rec = m * kManagerRecord;
|
||||
if (g.league_rounds.at(0) == 0x10) wr32(g.manager_records, rec + 0x320, rd32(g.manager_records, rec + 0x308));
|
||||
uint8_t& d = g.manager_records.at(rec + 0x220); // point deduction countdown
|
||||
|
||||
@@ -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);
|
||||
|
||||
+3
-15
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/month.hpp"
|
||||
#include "game/trace.hpp"
|
||||
|
||||
@@ -482,11 +483,9 @@ void return_loans(GameState& g, WatcomRandom& rand, GameRandom* game, MinuteRepo
|
||||
}
|
||||
}
|
||||
|
||||
// OpenBMH deviates from the original: omits the two discontinued youth-group cost categories from monthly accounts.
|
||||
// OriginalFinancePreview(1): the month's expenses of a human manager: facility maintenance
|
||||
// (BMHExeXa), record +0x854/+0x858, the wages of the squad (MonthlyPay with flags
|
||||
// 14), the six running costs of Spending (the youth work capped per league by the
|
||||
// supported rule profile patch MonthlyExpenses, which also drops the youth groups 0 and 2) and the debt
|
||||
// 14), all six monthly environment budgets and the debt
|
||||
// service (+0x179 x 1000); each booked in the statistics.
|
||||
int32_t monthly_expenses(GameState& g, int m) {
|
||||
std::vector<uint8_t>& r = g.manager_records;
|
||||
@@ -514,18 +513,7 @@ int32_t monthly_expenses(GameState& g, int m) {
|
||||
}
|
||||
sum += wages;
|
||||
for (int k = 0; k < 6; k++) {
|
||||
int32_t v = int32_t(g.memory.u32(::bmh::layout::Spending + uint32_t(m) * 0x24 + uint32_t(k) * 4));
|
||||
// OpenBMH deviates from the original: omits the two discontinued youth-group cost categories from monthly accounts.
|
||||
// MonthlyExpenses (supported rule profile patch): the two other youth groups (items 0 and 2) cost
|
||||
// nothing any more, whatever the saved value
|
||||
if (k == 0 || k == 2) v = 0;
|
||||
if (k == 1 && v != 0) {
|
||||
// TeamLeague3: the limit of the league (1.5 M, 1 M, 580000, 280000); the full
|
||||
// limit is paid while +0x880 is below it, nothing after
|
||||
const int league = team_league(g.manager_teams.at(size_t(m)));
|
||||
const uint32_t limit = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
v = rd32(r, rec + 0x880) < limit ? int32_t(limit) : 0;
|
||||
}
|
||||
const int32_t v = environment_monthly_cost(g, m, k);
|
||||
if (k >= 3 && k <= 5) add32(r, rec + 0x878 + size_t(k) * 4, v);
|
||||
else add32(r, rec + 0x880, v);
|
||||
sum += v;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+41
-20
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/season.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -641,25 +642,21 @@ namespace {
|
||||
|
||||
} // namespace
|
||||
|
||||
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
// YouthAcademyPlayer(manager) with the supported rule profile patch (SeasonOperation2, SeasonOperation3, SeasonOperation4,
|
||||
// SeasonOperation5): the youth academy's player at the season accounts. Only when the academy
|
||||
// was paid in full this season (record +0x880 reached the league's price, TeamLeague3) and
|
||||
// the squad has at most 22 players (SquadCount(team, 3)). A computer club's young player
|
||||
// moves to the club: the slots 0x86f..0 of the big clubs are searched downwards (squads of
|
||||
// human managers skipped) for a player not on loan whose age (years after 16) is at most
|
||||
// G(t, t + 3), t starting at 15 and lowered by one for every pass that finds none. He leaves
|
||||
// his club (ReleasePlayer), gets new values around a level of the club's league
|
||||
// (GeneratePlayer with 0x3000: G(79, 95) first division, G(69, 85) second, G(49, 68) third,
|
||||
// G(29, 48) below), a place in the squad with a fresh board entry (PendingOfferAnswer with the
|
||||
// player id | 0xf000), mood 0x69 and an age of W(0, 4) (16..20). Returns whether a player
|
||||
// came. The original's G(0, 0) before the search is kept.
|
||||
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
// The middle youth budget enables the existing enhanced academy recruitment.
|
||||
// Old lump-sum contracts remain eligible after their saved season payment.
|
||||
// Player search, strength bands, age and board setup retain the shared rules.
|
||||
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report) {
|
||||
const int team = g.manager_teams.at(size_t(m));
|
||||
const int league = club_league(team);
|
||||
const uint32_t price = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
if (uint32_t(rec32(g, m, 0x880)) < price) return false;
|
||||
if (!environment_academy_active(g, m)) return false;
|
||||
if (squad_count(g, team, 3) > 0x16) return false;
|
||||
const auto budget = g.memory.u32(::bmh::layout::Spending + uint32_t(m) * 0x24 + kYouthAcademy * 4);
|
||||
if (budget <= uint32_t(kEnvironmentStep[kYouthAcademy] * 6) &&
|
||||
g.memory.u8(::bmh::layout::CareerDuration) != 1 &&
|
||||
int(g.memory.u8(::bmh::layout::EnvironmentYouthTeams + uint32_t(m) * 0x24 + 2)) <
|
||||
team_average(g, team, 0xf3).value - 25)
|
||||
return false;
|
||||
const SquadRange own = squad_range(team);
|
||||
if (game.range(0, 0) != 0) return false;
|
||||
for (int t = 0xf;; --t) {
|
||||
@@ -708,6 +705,7 @@ namespace {
|
||||
void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report,
|
||||
const SeasonTaxHooks& tax_hooks, SeasonTaxState& tax_state) {
|
||||
for (size_t i = 0; i < 0xc; i++) rec8(g, m, 0x754 + i) = 0;
|
||||
finish_youth_season(g, m);
|
||||
if (!g.memory.has(::bmh::layout::Season_SeasonAccounts_RuntimeField)) g.memory.add_block(::bmh::layout::Season_SeasonAccounts_RuntimeField, 4); // (runtime only, not saved)
|
||||
g.memory.set8(::bmh::layout::Season_SeasonAccounts_RuntimeField + uint32_t(m), 0);
|
||||
season_event(g, m, game, rand, report);
|
||||
@@ -720,8 +718,8 @@ void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand,
|
||||
const SquadRange range = squad_range(team);
|
||||
for (size_t s = 0; s < 24; s++)
|
||||
if (g.squad_slots.at(range.first + s) != 0x0FFF) season_bonus(g, m, int(s), uint8_t(pos), true);
|
||||
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
// YouthAcademyPlayer: the youth academy's player (supported rule profile), posted as Season_SeasonAccounts_TextPointer
|
||||
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
// Academy recruitment is posted after the youth season has settled.
|
||||
if (youth_academy_player(g, m, game, rand, report)) post_text(g, m, text_id(::bmh::layout::Season_SeasonAccounts_TextPointer));
|
||||
if (report.unsupported) return;
|
||||
if (league == 0 && pos < 100) rec8(g, m, 0x21c) = 1; // the best human club of the first division
|
||||
@@ -1106,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;
|
||||
@@ -1171,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;
|
||||
@@ -1236,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--;
|
||||
@@ -1254,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;
|
||||
@@ -1264,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
|
||||
@@ -1639,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) {
|
||||
@@ -1658,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);
|
||||
|
||||
+13
-5
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#pragma once
|
||||
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
// From one season to the next (BMH.exe V2.24 + supported rule profile patch).
|
||||
//
|
||||
// On 1 July the "Weiter" loop (DailyInterest) ends the season: CareerSession_RuntimeError_RuntimeField4 = 1, the season
|
||||
@@ -94,10 +94,10 @@ void answer_offers(GameState& g, int manager, bool accept, WatcomRandom& rand, M
|
||||
// offer slots (transfer list entries 0x28..0x2b, OfferSlots) are freed.
|
||||
void free_offer_slots(GameState& g);
|
||||
|
||||
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
// YouthAcademyPlayer (supported rule profile youth academy, season accounts): when manager `m` paid the academy in
|
||||
// full this season (+0x880) and has room, a young player of a computer club joins his squad
|
||||
// with values by the league (see season.cpp). Returns whether one came.
|
||||
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
// Annual recruitment with an active middle youth budget (or a paid legacy
|
||||
// academy contract), provided the squad has room. Shared player strength bands
|
||||
// remain in effect; see season.cpp.
|
||||
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report);
|
||||
|
||||
// ClubBalance(0): every club's mood (TeamMorale, W(20, 30)) and flags (*TeamFlags): a random
|
||||
@@ -187,6 +187,14 @@ void cup_group_overview_effects(GameState& g, int group_index);
|
||||
// LeagueName: the name of a league below 5 (with its letter, e.g. for the third divisions).
|
||||
std::string league_name(const GameState& g, int league);
|
||||
|
||||
// New careers: fill the original uninitialized EM qualification placeholders;
|
||||
// preserve any nonzero seeds supplied by the installation.
|
||||
void initialize_european_qualification_seed(GameState& g);
|
||||
|
||||
// Season boundary: reset manager boards, age/retire players and clear seasonal
|
||||
// histories. Kept separate from cup draws, accounts and calendar advancement.
|
||||
void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteReport& report);
|
||||
|
||||
// MonthChange(absolute squad slot): the player leaves his club for the free agents with new
|
||||
// values (W and game draws) and an age W(4, 15); his club closes the gap (ReleasePlayer,
|
||||
// with a human club its tactics board as well). False if the source ownership/state
|
||||
|
||||
+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);
|
||||
|
||||
+4
-14
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "ui/advertising.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
|
||||
@@ -182,10 +183,9 @@ AdvertisingFinancePreview original_finance_preview_impl(const GameState& game, i
|
||||
std::array<int, 13>{0,31,28,31,30,31,30,31,31,30,31,30,31}[size_t(month)];
|
||||
income = wrap_add(income, wrap_neg(wrap_mul(original_finance_adjustment(game, manager), month_factor)));
|
||||
|
||||
// OpenBMH deviates from the original: uses the supported youth-academy cap and its saved cost fields.
|
||||
// OriginalFinancePreview(0): pure amount of BMHExeXa, record +0x854/+0x858,
|
||||
// OriginalFinancePreview(0): pure amount of BMHExeXa, record +0x854/+0x858,
|
||||
// MonthlyPay flags 0x0a (salary+bonus without statistic writes), and six
|
||||
// saved supported rule profile cost words. The cap for index 1 comes from TeamLeague3.
|
||||
// saved monthly environment budgets.
|
||||
int32_t expenses = 0;
|
||||
for (int i = 0; i < 14; ++i) expenses = wrap_add(expenses, kFacilityCost[size_t(i)]);
|
||||
for (int i = 14; i < 22; ++i)
|
||||
@@ -202,18 +202,8 @@ AdvertisingFinancePreview original_finance_preview_impl(const GameState& game, i
|
||||
expenses = wrap_add(expenses, signed32(u32(game.tactics, board + 0x50)));
|
||||
expenses = wrap_add(expenses, int32_t(bonus));
|
||||
}
|
||||
const int team = int(u32(game.manager_records, rec + 0x290) & 0xffff);
|
||||
const int league = team > 0x164 ? 0 : team_league(team); // TeamLeague2
|
||||
const int32_t youth_cap = league == 0 ? 1500000 : league == 1 ? 1000000 :
|
||||
league <= 3 ? 580000 : 280000;
|
||||
for (int k = 0; k < 6; ++k) {
|
||||
int32_t item = mem_i32(game, ::bmh::layout::Spending + uint32_t(manager) * 0x24 + uint32_t(k) * 4);
|
||||
if (k == 0 || k == 2) {
|
||||
// MonthlyExpenses clears these indexes unconditionally (CMP AX,3 / CMP AX,1).
|
||||
item = 0;
|
||||
} else if (k == 1 && item != 0) {
|
||||
item = u32(game.manager_records, rec + 0x880) < uint32_t(youth_cap) ? youth_cap : 0;
|
||||
}
|
||||
const int32_t item = environment_monthly_cost(game, manager, k);
|
||||
expenses = wrap_add(expenses, item);
|
||||
}
|
||||
expenses = wrap_add(expenses, wrap_neg(original_share_adjustment(game, manager, false)));
|
||||
|
||||
@@ -167,17 +167,17 @@ int main(int argc, char** argv) {
|
||||
cap_fixture.memory.set32(::bmh::layout::Spending + 4, 99);
|
||||
cap_fixture.memory.set32(::bmh::layout::Spending, 111);
|
||||
cap_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
|
||||
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 1543400,
|
||||
"costs 0/2 stay zero while the youth-cost item uses the source league cap");
|
||||
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 43832,
|
||||
"all three youth budgets enter the monthly finance preview");
|
||||
put32(cap_fixture.manager_records, 0x880, 1500000);
|
||||
const auto no_cap_preview = advertising_from_game(cap_fixture, 0).finance_preview;
|
||||
check(no_cap_preview.expenses == 43400,
|
||||
"the youth-cost item is suppressed once funds reach the strict source threshold");
|
||||
check(no_cap_preview.expenses == 43832,
|
||||
"ordinary monthly youth budgets continue after the former academy threshold");
|
||||
GameState ignored_cost_fixture = finance_fixture;
|
||||
ignored_cost_fixture.memory.set32(::bmh::layout::Spending, 111);
|
||||
ignored_cost_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
|
||||
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43400,
|
||||
"legacy routine clears cost items zero and two regardless of their saved values");
|
||||
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43733,
|
||||
"the youngest and oldest youth budgets both enter expenses");
|
||||
GameState loan_fixture = finance_fixture;
|
||||
loan_fixture.memory.set32(::bmh::layout::Loans + 8, 100);
|
||||
const auto loan_preview = advertising_from_game(loan_fixture, 0).finance_preview;
|
||||
|
||||
@@ -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.
|
||||
|
||||
+23
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -722,6 +743,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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
+26
-14
@@ -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
|
||||
|
||||
@@ -72,6 +73,11 @@ EnvironmentView environment_from_game(const bmh::GameState& game, uint64_t revis
|
||||
view.values = bmh::environment_state(game, manager);
|
||||
for (int i = 0; i < kEnvironmentItems; ++i)
|
||||
view.cost_text[size_t(i)] = bmh::format_number(game, view.values.monthly[size_t(i)], 0x185);
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
view.youth_position_text[i] = format_number(game, view.values.youth_position[i] + 1, 0x81);
|
||||
view.youth_league_text[i] = format_number(game, view.values.youth_league[i] + 1, 2) +
|
||||
message_text(game, ::bmh::layout::EnvironmentYouthLeagueTextPointer);
|
||||
}
|
||||
view.decorated_background = !game.memory.has(::bmh::layout::PlainBackground) || game.memory.u8(::bmh::layout::PlainBackground) == 0;
|
||||
view.gradient_text = (!game.memory.has(::bmh::layout::TextGradientDisabled) || game.memory.u8(::bmh::layout::TextGradientDisabled) == 0);
|
||||
view.solid_panel_background = game.memory.has(::bmh::layout::SolidPanelBackground) && game.memory.u8(::bmh::layout::SolidPanelBackground) != 0;
|
||||
@@ -117,9 +123,14 @@ std::string environment_view_json(const EnvironmentView& s) {
|
||||
for (size_t i = 0; i < s.values.monthly.size(); ++i) { if (i) out << ','; out << s.values.monthly[i]; }
|
||||
out << "],\"level\":[";
|
||||
for (size_t i = 0; i < s.values.level.size(); ++i) { if (i) out << ','; out << s.values.level[i]; }
|
||||
out << "],\"youth_price\":" << s.values.youth_price << ",\"youth_paid\":"
|
||||
<< (s.values.youth_paid ? "true" : "false") << ",\"youth_open\":"
|
||||
<< (s.values.youth_open ? "true" : "false") << '}';
|
||||
out << "],\"youth_teams\":[";
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (i) out << ',';
|
||||
out << "{\"strength\":" << int(s.values.youth_strength[i])
|
||||
<< ",\"position\":" << int(s.values.youth_position[i])
|
||||
<< ",\"league\":" << int(s.values.youth_league[i]) << '}';
|
||||
}
|
||||
out << "]}";
|
||||
return out.str();
|
||||
}
|
||||
|
||||
@@ -194,9 +205,6 @@ Image EnvironmentScreen::render() const {
|
||||
throw FormatError("environment: Original badge crop outside atlas");
|
||||
crop(out, badge_atlas_, badge_x, 0, 0x8c, 0x61, 0x26, 0x26);
|
||||
for (int item = 0; item < kEnvironmentItems; ++item) {
|
||||
// OpenBMH deviates from the original: omits the two discontinued youth groups from the environment screen.
|
||||
// supported rule profile BypassesTwoDiscontinuedYouthGroups bypasses the two discontinued youth groups.
|
||||
if (item < 3 && item != kYouthAcademy) continue;
|
||||
const int x = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), y = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
|
||||
crop(out, tiles_, item * 0x33, 0x46, x, y, 0x33, 0x29);
|
||||
// CallsTwiceForUpperLowerCaptionStrips calls LoadGameEndTaxAnimationAssets twice for the upper and lower caption strips.
|
||||
@@ -215,25 +223,29 @@ Image EnvironmentScreen::render() const {
|
||||
for (int yy = top; yy <= bottom; ++yy) out.at(right, yy) = 0x40;
|
||||
};
|
||||
panel(x - 4, y - 10, x + 0x36, y - 1);
|
||||
panel(x - 4, y + 0x29, x + 0x36, y + 0x31);
|
||||
const int unit = item == kYouthAcademy ? 1 : item >= 3 ? 5000 : 1;
|
||||
const int count = item == kYouthAcademy ? (state_.values.monthly[size_t(item)] != 0 ? 6 : 0)
|
||||
: std::clamp(state_.values.monthly[size_t(item)] / unit, 0, 6);
|
||||
panel(x - 4, y + 0x29, x + 0x36, y + 0x31 + (item < 3 ? 6 : 0));
|
||||
const int count = state_.values.level[size_t(item)];
|
||||
for (int star = 0; star < count; ++star)
|
||||
crop(out, tiles_, 0x1e, 0x1e, x + star * 9, y - 8, 7, 6, 0);
|
||||
// The tile artwork already contains its Source caption. CallsTwiceForUpperLowerCaptionStrips draws
|
||||
// the dynamic expense in the lower strip at baseline y+0x30; a second
|
||||
// invented TEXTD caption here overwrote the baked-in names and shifted
|
||||
// the cost down into the hit area.
|
||||
const auto& cost = state_.cost_text[size_t(item)];
|
||||
const auto cost = state_.cost_text[size_t(item)] + exe_.cstring(::bmh::layout::EnvironmentCostSuffix);
|
||||
text(out, x + 0x32 / 2 - font_.text_width(cost) / 2, y + 0x30, cost, 0x6b);
|
||||
if (item < 3) {
|
||||
const auto caption = state_.youth_position_text[size_t(item)] +
|
||||
exe_.cstring(::bmh::layout::EnvironmentYouthPositionSuffix) + state_.youth_league_text[size_t(item)];
|
||||
text(out, x + 0x32 / 2 - font_.text_width(caption) / 2, y + 0x36,
|
||||
caption, exe_.u8(::bmh::layout::EnvironmentYouthColors + item));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool EnvironmentScreen::pointer_down(int x, int y, bool right) {
|
||||
if (pending_) return false;
|
||||
press_seen_ = true;
|
||||
pending_.reset();
|
||||
pressed_item_ = pressed_level_ = -1;
|
||||
pressed_right_ = right;
|
||||
if (right) return true;
|
||||
@@ -241,7 +253,7 @@ bool EnvironmentScreen::pointer_down(int x, int y, bool right) {
|
||||
const int left = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), top = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
|
||||
if (x >= left - 9 && x <= left + 0x36 && y >= top - 10 && y <= top + 0x29) {
|
||||
pressed_item_ = item;
|
||||
pressed_level_ = std::clamp((x - left + 4) / 9, 0, 6);
|
||||
pressed_level_ = std::clamp((x - left + 9) / 9, 0, 6);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ struct EnvironmentView {
|
||||
std::string club_name;
|
||||
uint16_t badge_sprite = 0;
|
||||
std::array<std::string, 6> cost_text{};
|
||||
std::array<std::string, 3> youth_position_text{}, youth_league_text{};
|
||||
bool decorated_background = true;
|
||||
bool gradient_text = true;
|
||||
bool solid_panel_background = false;
|
||||
|
||||
@@ -33,9 +33,11 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
|
||||
const auto panel = load_vga(asset_path(data / "KB", "56.VGA"));
|
||||
const auto body = load_font(asset_path(data / "F", "BMH3.FNT"));
|
||||
SpriteFont sprite(data);
|
||||
// All four visible groups exercise an empty and an occupied star rail.
|
||||
state.values.monthly[1] = 0;
|
||||
for (int item = 3; item < 6; ++item) state.values.monthly[size_t(item)] = 10000;
|
||||
// All six visible groups exercise an empty and an occupied star rail.
|
||||
for (int item = 0; item < 6; ++item) {
|
||||
state.values.level[size_t(item)] = item < 3 ? 0 : 2;
|
||||
state.values.monthly[size_t(item)] = state.values.level[size_t(item)] * kEnvironmentStep[size_t(item)];
|
||||
}
|
||||
for (int mode = 0; mode < 3; ++mode) {
|
||||
state.decorated_background = mode != 1;
|
||||
state.plain_background = mode == 2;
|
||||
@@ -56,9 +58,9 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
|
||||
sprite.draw(base, 5, 235, original_to_utf8(state.club_name), 5);
|
||||
for (int y = 0; y < 240; ++y) for (int x = 0; x < 320; ++x) {
|
||||
bool foreground = x >= 125 && x <= 195 && y >= 82 && y <= 151;
|
||||
for (int item : {1, 3, 4, 5}) {
|
||||
for (int item : {0, 1, 2, 3, 4, 5}) {
|
||||
const int tx = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), ty = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
|
||||
foreground |= x >= tx - 4 && x <= tx + 54 && y >= ty - 10 && y <= ty + 49;
|
||||
foreground |= x >= tx - 4 && x <= tx + 54 && y >= ty - 10 && y <= ty + 49 + (item < 3 ? 6 : 0);
|
||||
}
|
||||
if (!foreground) check(pixel(actual, x, y) == pixel(base, x, y),
|
||||
"Source KB129/flat background, centered title and active club footer");
|
||||
@@ -76,14 +78,14 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
|
||||
check(transparent_center > 0 && center_ink > 0, "central crop oracle covers transparent and ink pixels");
|
||||
check(actual.at(139, 96) == 0x46 && actual.at(178, 96) == 0x40 &&
|
||||
actual.at(139, 135) == 0x40, "Source badge frame and corner overwrite order");
|
||||
for (int item : {1, 3, 4, 5}) {
|
||||
for (int item : {0, 1, 2, 3, 4, 5}) {
|
||||
const int tx = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), ty = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
|
||||
for (int y = 0; y < 41; ++y) for (int x = 0; x < 51; ++x)
|
||||
check(pixel(actual, tx + x, ty + y) == pixel(art, item * 51 + x, 70 + y),
|
||||
"legacy routine tile is opaque, without a fabricated c0 comparekey");
|
||||
// The Source upper panel is copied first; each nonzero star pixel
|
||||
// replaces it. A zero in the star bitmap exposes that panel.
|
||||
const int stars = item == 1 ? 0 : 2;
|
||||
const int stars = state.values.level[size_t(item)];
|
||||
for (int y = ty - 9; y <= ty - 2; ++y) for (int x = tx - 3; x <= tx + 53; ++x) {
|
||||
uint8_t expected = state.solid_panel_background ? 0x42 : pixel(panel, x - 1, y - 20);
|
||||
for (int n = 0; n < stars; ++n)
|
||||
@@ -93,7 +95,7 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
|
||||
}
|
||||
check(pixel(actual, x, y) == expected, "Source star zero pixels expose the opaque KB56/flat rail");
|
||||
}
|
||||
const auto& cost = state.cost_text[size_t(item)];
|
||||
const auto cost = state.cost_text[size_t(item)] + exe.cstring(::bmh::layout::EnvironmentCostSuffix);
|
||||
const int width = body.text_width(cost), left = tx + 25 - width / 2;
|
||||
Image mask(width, body.height);
|
||||
body.draw(mask, 0, 0, cost, 1);
|
||||
@@ -171,7 +173,7 @@ int main(int argc, char** argv) {
|
||||
check(screen.key("ESC").kind == EnvironmentRequestKind::none && !screen.close_requested() &&
|
||||
screen.state_json() == held, "back cannot steal a held staff control before its release");
|
||||
const auto request = screen.release(x + 31, y + 5);
|
||||
check(request.kind == EnvironmentRequestKind::set_item && request.item == 3 && request.level == 3 &&
|
||||
check(request.kind == EnvironmentRequestKind::set_item && request.item == 3 && request.level == 4 &&
|
||||
request.manager_slot == state.manager_slot && request.runtime_club == state.runtime_club &&
|
||||
request.revision == 17 && request.owner == owner,
|
||||
"tile release emits a typed, manager/revision-owned level request");
|
||||
@@ -182,13 +184,13 @@ int main(int argc, char** argv) {
|
||||
|
||||
auto updated = state;
|
||||
updated.revision = 18;
|
||||
updated.values.level[3] = 3;
|
||||
updated.values.monthly[3] = 15000;
|
||||
updated.cost_text[3] = format_number(game, 15000, 0x185);
|
||||
updated.values.level[3] = 4;
|
||||
updated.values.monthly[3] = 20000;
|
||||
updated.cost_text[3] = format_number(game, 20000, 0x185);
|
||||
updated.owner.revision = 18;
|
||||
screen.acknowledge(updated);
|
||||
check(!screen.pending() && screen.state().revision == 18 &&
|
||||
screen.state().values.monthly[3] == 15000,
|
||||
screen.state().values.monthly[3] == 20000,
|
||||
"valid source mutation ACK refreshes the screen and clears the pending action");
|
||||
|
||||
const auto notice = environment_notice_dialog(game, state.manager_slot,
|
||||
|
||||
+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
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace bmh::ui {
|
||||
// Saved column-nine delays are source timer units. Values below six use
|
||||
// integer halving; zero genuinely disables the pause.
|
||||
constexpr uint32_t live_delay_milliseconds(uint8_t saved) {
|
||||
return uint32_t(saved < 6 ? saved / 2 : saved) * 20;
|
||||
}
|
||||
// VGA mode 13h timing is independent of the host monitor's refresh rate.
|
||||
inline constexpr unsigned kOriginalRefreshHz = 70;
|
||||
} // namespace bmh::ui
|
||||
+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 {
|
||||
|
||||
@@ -1670,6 +1670,26 @@ void check_environment_controller(const std::filesystem::path& data) {
|
||||
flow.environment()->state().values.level[3] == 6 &&
|
||||
flow.environment()->state().values.monthly[3] == 30000,
|
||||
"valid environment transaction commits once and keeps the source screen open");
|
||||
for (int item : {0, 1, 2, 4, 5}) {
|
||||
const int tx = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField + item) + 18;
|
||||
const int ty = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item) + 5;
|
||||
const auto before = session->state();
|
||||
const auto old_revision = revision;
|
||||
(void)flow.pointer_down(tx, ty);
|
||||
const auto write = flow.click(tx, ty);
|
||||
check(write.request == FlowRequest::environment_action && write.environment_action.item == item &&
|
||||
write.environment_action.level == 3 && serve(write).empty(),
|
||||
"every youth and staff tile submits its own three-star budget");
|
||||
auto expected = before;
|
||||
expected.memory.set32(::bmh::layout::Spending + uint32_t(item) * 4, uint32_t(kEnvironmentStep[size_t(item)] * 3));
|
||||
check(save_stream(session->state()) == save_stream(expected) && revision == old_revision + 1 &&
|
||||
session->rand().seed() == watcom_before.seed() && session->rand().calls() == watcom_before.calls() &&
|
||||
session->game().seed() == game_rng_before.seed() && session->game().calls() == game_rng_before.calls(),
|
||||
"a tile edit changes only its saved budget and revision, without a turn or RNG draw");
|
||||
(void)flow.pointer_down(tx, ty);
|
||||
check(serve(flow.click(tx, ty)).empty() && revision == old_revision + 1 && !flow.pending_environment(),
|
||||
"clicking the same youth or staff level again ACKs without toggling or another revision");
|
||||
}
|
||||
(void)flow.pointer_down(10, 10, true);
|
||||
const auto close = flow.click(10, 10, true);
|
||||
check(close.request == FlowRequest::submenu_closed && !flow.in_environment() && flow.screen_name() == "desktop",
|
||||
@@ -3241,7 +3261,7 @@ void check_live_delay_settings_writer(const std::filesystem::path& data,const st
|
||||
app::CareerSession session(data,8128,save_path);auto& game=session.state();
|
||||
const int manager=int(game.memory.u8(::bmh::layout::ActiveManager));uint64_t revision=1;std::string error;
|
||||
const auto exe=load_le(ui::asset_path(data,"BMH.exe"));const auto w=session.rand();const auto g=session.game();
|
||||
const std::array<std::pair<int,int>,13> cells{{{3,7},{4,7},{5,7},{6,7},{1,8},{2,8},{3,8},{4,8},{5,8},{6,8},{10,8},{12,8},{15,8}}};
|
||||
const std::array<std::pair<int,int>,14> cells{{{3,7},{4,7},{5,7},{6,7},{0,8},{1,8},{2,8},{3,8},{4,8},{5,8},{6,8},{10,8},{12,8},{15,8}}};
|
||||
for(const auto [row,col]:cells) {
|
||||
auto state=settings_from_game(game,manager,revision,exe);const size_t index=size_t(row*9+col);
|
||||
const auto old=state.cells[index];check(old<200,"real WEEK196 exposes the consumed speed/delay cell");
|
||||
@@ -6959,6 +6979,9 @@ int main(int argc, char** argv) {
|
||||
try {
|
||||
if (argc != 2 && argc != 3 && argc != 4) throw std::runtime_error("app_controller_tests requires data directory [optional Original save]");
|
||||
const std::filesystem::path data = argv[1];
|
||||
if(argc==3 && std::string_view(argv[2])=="--environment-only") {
|
||||
check_environment_controller(data);return 0;
|
||||
}
|
||||
if(argc==4 && std::string_view(argv[2])=="--delay-settings-only") {
|
||||
check_live_delay_settings_writer(data,argv[3]);check_gameplay_switches_writer(data,argv[3]);
|
||||
check_settings_refusal_controller(data,argv[3]);return 0;
|
||||
|
||||
@@ -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,73 @@
|
||||
// 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 <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.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;}
|
||||
+72
-82
@@ -1,91 +1,81 @@
|
||||
#include "runtime_fixture_tables.hpp"
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "test_inputs.hpp"
|
||||
// The club environment (desk menu 24, src/game/environment.hpp) on a real savegame: staff
|
||||
// levels, and the supported edition youth academy - only in July/August, the league's season price,
|
||||
// no switching off once paid.
|
||||
|
||||
#include <filesystem>
|
||||
#include "game/environment.hpp"
|
||||
#include "ui/live_timing.hpp"
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "formats/fbm.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/savestate.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
#include "game/career.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
|
||||
using namespace bmh;
|
||||
|
||||
namespace {
|
||||
|
||||
void check(bool ok, const std::string& message) {
|
||||
if (!ok) throw std::runtime_error(message);
|
||||
}
|
||||
|
||||
void set_rec32(GameState& g, size_t o, uint32_t v) {
|
||||
for (int i = 0; i < 4; i++) g.manager_records.at(o + size_t(i)) = uint8_t(v >> (8 * i));
|
||||
}
|
||||
|
||||
void environment_test(GameState g) {
|
||||
// staff: level * 5 000
|
||||
check(set_environment(g, 0, kDoctor, 4) != EnvironmentResult::invalid, "doctor level");
|
||||
EnvironmentState s = environment_state(g, 0);
|
||||
check(s.monthly[kDoctor] == 20000 && s.level[kDoctor] == 4, "doctor 4 x 5 000");
|
||||
check(set_environment(g, 0, kPhysio, 7) == EnvironmentResult::invalid, "level 7 is no level");
|
||||
// the other two youth groups are always 0
|
||||
set_environment(g, 0, 0, 6);
|
||||
check(environment_state(g, 0).monthly[0] == 0, "item 0 stays 0");
|
||||
// the academy out of season (the savegame is in spring)
|
||||
set_rec32(g, 0x880, 0);
|
||||
std::string message;
|
||||
check(set_environment(g, 0, kYouthAcademy, 6, &message) == EnvironmentResult::too_late, "too late in spring");
|
||||
check(message.find("Zu sp") == 0 && environment_state(g, 0).monthly[kYouthAcademy] == 0, "too late message, stays off");
|
||||
// July: on at the league's price, a second click switches it off again before it is paid
|
||||
g.date = g.season_start + 5;
|
||||
g.league_rounds.at(0) = 0;
|
||||
s = environment_state(g, 0);
|
||||
check(s.youth_open && !s.youth_paid, "July: the academy can be started");
|
||||
check(set_environment(g, 0, kYouthAcademy, 6) == EnvironmentResult::changed, "academy on");
|
||||
const int league = team_league(g.manager_teams.at(0));
|
||||
const int32_t price = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
check(environment_state(g, 0).monthly[kYouthAcademy] == price, "season price of the league");
|
||||
check(set_environment(g, 0, kYouthAcademy, 6) == EnvironmentResult::changed &&
|
||||
environment_state(g, 0).monthly[kYouthAcademy] == 0, "a click on the active academy switches it off");
|
||||
// paid this season: stays on
|
||||
set_environment(g, 0, kYouthAcademy, 6);
|
||||
set_rec32(g, 0x880, uint32_t(price));
|
||||
message.clear();
|
||||
check(set_environment(g, 0, kYouthAcademy, 0, &message) == EnvironmentResult::contract_runs, "paid: no switching off");
|
||||
check(message == bmh::test::expected_text("environment_tests.0") && environment_state(g, 0).monthly[kYouthAcademy] == price,
|
||||
"paid: the contract runs");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
try {
|
||||
check(argc == 3, "usage: environment_tests ORIGINAL_DATA SAVEGAME");
|
||||
if (!*argv[1]) {
|
||||
std::cout << "environment tests: skipped (Original data directory not configured)\n";
|
||||
return 0;
|
||||
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
|
||||
GameState fixture() {
|
||||
GameState g;
|
||||
g.manager_teams = {0, 1};
|
||||
g.manager_records.resize(2 * 0xb0c);
|
||||
g.league_rounds.resize(1);
|
||||
g.memory.add_block(layout::EnvironmentYouthTeams, 0x90);
|
||||
for (uint32_t m = 0; m < 2; ++m)
|
||||
for (uint32_t i = 0; i < 3; ++i) {
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + m * 0x24 + i, uint8_t(60 - i * 10));
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + m * 0x24 + i + 3, 6);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + m * 0x24 + i + 6, uint8_t(i));
|
||||
}
|
||||
const auto exe = bmh::test::load_executable(std::filesystem::path(argv[1]) / "BMH.exe");
|
||||
const auto file = load_savegame(argv[2]);
|
||||
const DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
GameState g = GameState::from_save(SaveState(file.stream, counts), counts);
|
||||
competition_pointers(g.memory, exe);
|
||||
const auto texts = load_textd(std::filesystem::path(argv[1]) / "TEXTD.BLK");
|
||||
g.texts = &texts;
|
||||
environment_test(g);
|
||||
std::cout << "environment tests: ok\n";
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << "environment tests: " << error.what() << "\n";
|
||||
return 1;
|
||||
}
|
||||
return g;
|
||||
}
|
||||
void budgets() {
|
||||
auto g = fixture();
|
||||
for (int i = 0; i < 6; ++i) check(set_environment(g, 0, i, 6) == EnvironmentResult::changed, "all six budgets accept maximum");
|
||||
const auto s = environment_state(g, 0);
|
||||
check(s.monthly == std::array<int32_t, 6>{12000,24000,30000,30000,30000,30000}, "six monthly costs match the supported price units");
|
||||
check(environment_state(g, 1).monthly == std::array<int32_t, 6>{}, "other manager's budgets are isolated");
|
||||
check(set_environment(g, 0, kYouthAcademy, 6) == EnvironmentResult::unchanged, "repeating a level does not toggle the youth budget");
|
||||
for (int i = 0; i < 6; ++i) check(environment_monthly_cost(g, 0, i) == s.monthly[size_t(i)], "all six selected budgets reach monthly accounting");
|
||||
check(set_environment(g, 0, kYouthAcademy, 0) == EnvironmentResult::changed && !environment_academy_active(g, 0), "youth budget can be stopped");
|
||||
check(set_environment(g, 0, 6, 2) == EnvironmentResult::invalid &&
|
||||
set_environment(g, -1, 0, 1) == EnvironmentResult::invalid &&
|
||||
set_environment(g, 0, 0, 7) == EnvironmentResult::invalid, "invalid requests rejected");
|
||||
g.memory.set32(layout::Spending + 4, 1500000);
|
||||
check(environment_monthly_cost(g, 0, 1) == 1500000 && !environment_academy_active(g, 0), "unpaid legacy contract retains one season payment");
|
||||
for (int i = 0; i < 4; ++i) g.manager_records[0x880 + size_t(i)] = uint8_t(1500000u >> (i * 8));
|
||||
check(environment_monthly_cost(g, 0, 1) == 0 && environment_academy_active(g, 0), "paid legacy contract is never debited again");
|
||||
set_environment(g, 0, 1, 2);
|
||||
check(environment_monthly_cost(g, 0, 1) == 8000 && environment_academy_active(g, 0), "an explicit edit replaces the legacy contract with a monthly budget");
|
||||
}
|
||||
void progression() {
|
||||
auto funded = fixture(), unfunded = fixture();
|
||||
for (int i = 0; i < 3; ++i) set_environment(funded, 0, i, 6);
|
||||
WatcomRandom rich(4711), poor(4711);
|
||||
for (int round = 0; round < 100; ++round) {
|
||||
funded.league_rounds[0] = unfunded.league_rounds[0] = uint8_t(round % 34);
|
||||
advance_youth_teams(funded, 0, rich);
|
||||
advance_youth_teams(unfunded, 0, poor);
|
||||
}
|
||||
const auto a = environment_state(funded, 0), b = environment_state(unfunded, 0);
|
||||
check(a.youth_strength[0] > b.youth_strength[0] && a.youth_strength[1] > b.youth_strength[1] &&
|
||||
a.youth_strength[2] > b.youth_strength[2], "investment changes development in every youth group");
|
||||
check(rich.seed() == poor.seed() && rich.calls() == poor.calls(), "budgets do not change the youth algorithm's RNG call sequence");
|
||||
check(environment_state(funded, 1).youth_position == std::array<uint8_t,3>{6,6,6}, "youth results remain manager-local");
|
||||
auto g = fixture();
|
||||
for (uint32_t i = 0; i < 3; ++i) g.memory.set8(layout::EnvironmentYouthTeams + i, uint8_t(30 + 20 * i));
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 3, 0);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 6, 1);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 4, 11);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 7, 0);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 5, 11);
|
||||
finish_youth_season(g, 0);
|
||||
const auto s = environment_state(g, 0);
|
||||
check(s.youth_league == std::array<uint8_t,3>{0,1,2} && s.youth_position == std::array<uint8_t,3>{10,1,5}, "season transition handles promotion, relegation and bottom division");
|
||||
check(s.youth_strength == std::array<uint8_t,3>{30,43,63}, "age-group handover uses previous strengths without cascading");
|
||||
}
|
||||
void timing() {
|
||||
using bmh::ui::live_delay_milliseconds;
|
||||
check(live_delay_milliseconds(0) == 0 && live_delay_milliseconds(1) == 0 &&
|
||||
live_delay_milliseconds(2) == 20 && live_delay_milliseconds(5) == 40 &&
|
||||
live_delay_milliseconds(6) == 120 && live_delay_milliseconds(30) == 600 &&
|
||||
live_delay_milliseconds(198) == 3960, "original integer delay scale includes zero and manual speed range");
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
try { budgets(); progression(); timing(); std::cout << "environment and live timing: ok\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;}
|
||||
@@ -39,7 +39,20 @@ void youth_test(GameState g) {
|
||||
GameRandom game(4711);
|
||||
WatcomRandom rand(815);
|
||||
MinuteReport report;
|
||||
auto monthly = g;
|
||||
monthly.memory.set32(::bmh::layout::Spending + 4, 8000);
|
||||
monthly.memory.set8(::bmh::layout::CareerDuration, 0);
|
||||
monthly.memory.set8(::bmh::layout::EnvironmentYouthTeams + 2, 10);
|
||||
check(team_average(monthly, team, 0xf3).value > 35, "fixture has a stronger senior squad");
|
||||
check(!youth_academy_player(monthly, 0, game, rand, report) && game.calls() == 0 && rand.calls() == 0,
|
||||
"monthly recruitment requires the oldest youth team's strength without consuming RNG on refusal");
|
||||
monthly.memory.set8(::bmh::layout::EnvironmentYouthTeams + 2, 85);
|
||||
GameRandom monthly_game(4711);
|
||||
WatcomRandom monthly_rand(815);
|
||||
check(youth_academy_player(monthly, 0, monthly_game, monthly_rand, report) && !report.unsupported,
|
||||
"an active monthly budget and sufficiently strong youth team recruit without a season lump sum");
|
||||
// unpaid: nothing happens, nothing is drawn
|
||||
g.memory.set32(::bmh::layout::Spending + 4, price);
|
||||
set_rec32(g, 0x880, price - 1);
|
||||
check(!youth_academy_player(g, 0, game, rand, report) && game.calls() == 0 && rand.calls() == 0, "unpaid academy");
|
||||
// paid
|
||||
|
||||
@@ -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()
|
||||
Loaded 100 of 106 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user