Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
aa53c6e2e2 | ||
|
|
a3d1948fcd |
No files matched your search
@@ -3,7 +3,7 @@ name: Build without game data
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main, release/1.0]
|
||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
@@ -36,8 +36,13 @@ jobs:
|
|||||||
- name: Install Linux build dependencies
|
- name: Install Linux build dependencies
|
||||||
if: runner.os == 'Linux'
|
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
|
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
|
- 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
|
- name: Set up MSVC x64
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
uses: ilammy/msvc-dev-cmd@a102174a2b586eec2ea151a69e6fd14404a8ce7c # v1.13.0
|
uses: ilammy/msvc-dev-cmd@a102174a2b586eec2ea151a69e6fd14404a8ce7c # v1.13.0
|
||||||
@@ -62,10 +67,20 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
test "$(uname -m)" = arm64
|
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
|
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
|
- name: Build products and every runnable test
|
||||||
run: cmake --build build --config Release --parallel 2
|
run: python3 tools/ci/build_runnable_tests.py --build build --config Release --parallel 2
|
||||||
- name: Run synthetic tests and report data tests as skipped
|
- 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
|
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
|
- name: Package products and licenses
|
||||||
run: python3 tools/package/make_package.py --build build --out dist --platform ${{ matrix.platform }}
|
run: python3 tools/package/make_package.py --build build --out dist --platform ${{ matrix.platform }}
|
||||||
- name: Package corresponding source and pinned dependencies
|
- name: Package corresponding source and pinned dependencies
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-only
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
name: Prepare release packages
|
name: Prepare verified release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -7,34 +7,59 @@ on:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
actions: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
|
||||||
uses: ./.github/workflows/ci.yml
|
|
||||||
draft:
|
draft:
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
actions: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
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
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||||
with:
|
with:
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
run-id: ${{ steps.ci.outputs.run_id }}
|
||||||
pattern: OpenBMH-*
|
pattern: OpenBMH-*
|
||||||
path: dist
|
path: dist
|
||||||
merge-multiple: true
|
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
|
- name: Create draft for review
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
RELEASE_TAG: ${{ github.ref_name }}
|
RELEASE_TAG: ${{ github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
for package in dist/*.zip; do
|
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
|
||||||
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
|
|
||||||
+53
-9
@@ -1,8 +1,15 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-only
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
cmake_minimum_required(VERSION 3.24)
|
cmake_minimum_required(VERSION 3.24)
|
||||||
project(OpenBMH VERSION 0.1.0 LANGUAGES CXX C)
|
project(OpenBMH VERSION 1.0.0 LANGUAGES CXX C)
|
||||||
|
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)
|
# 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 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
@@ -39,7 +46,7 @@ function(bmh_add_data_test)
|
|||||||
set(T_DATA_DIR "${BMH_DATA}")
|
set(T_DATA_DIR "${BMH_DATA}")
|
||||||
endif()
|
endif()
|
||||||
set(reason "")
|
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
|
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
|
cli_soak ui_cup_draw_tests league_pairings_tests ui_pending_offer_tests
|
||||||
reality_reporter_layout_tests season_cup_draw_app_tests
|
reality_reporter_layout_tests season_cup_draw_app_tests
|
||||||
@@ -62,7 +69,7 @@ function(bmh_add_data_test)
|
|||||||
message(FATAL_ERROR "Invalid game data directory for ${T_NAME}: ${T_DATA_DIR}")
|
message(FATAL_ERROR "Invalid game data directory for ${T_NAME}: ${T_DATA_DIR}")
|
||||||
endif()
|
endif()
|
||||||
foreach(option IN LISTS T_REQUIRED_OPTIONS)
|
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}")
|
set(reason "External test input not supplied: ${option}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
@@ -202,7 +209,6 @@ add_library(bmhcore STATIC
|
|||||||
src/formats/textd.cpp
|
src/formats/textd.cpp
|
||||||
src/formats/fbm.cpp
|
src/formats/fbm.cpp
|
||||||
src/formats/le.cpp
|
src/formats/le.cpp
|
||||||
src/formats/rule_base.cpp
|
|
||||||
src/formats/m3d.cpp
|
src/formats/m3d.cpp
|
||||||
src/formats/savestate.cpp
|
src/formats/savestate.cpp
|
||||||
src/game/schedule.cpp
|
src/game/schedule.cpp
|
||||||
@@ -239,6 +245,7 @@ add_library(bmhcore STATIC
|
|||||||
src/game/weekly.cpp
|
src/game/weekly.cpp
|
||||||
src/game/messages.cpp
|
src/game/messages.cpp
|
||||||
src/game/table.cpp
|
src/game/table.cpp
|
||||||
|
src/game/calendar.cpp
|
||||||
src/game/week.cpp
|
src/game/week.cpp
|
||||||
src/game/lineup.cpp
|
src/game/lineup.cpp
|
||||||
src/game/national.cpp
|
src/game/national.cpp
|
||||||
@@ -365,9 +372,7 @@ bmh_add_data_test(NAME reschedule_tests REQUIRED_OPTIONS BMH_TEST_RESCHEDULE_TES
|
|||||||
|
|
||||||
add_executable(environment_tests tests/environment_tests.cpp)
|
add_executable(environment_tests tests/environment_tests.cpp)
|
||||||
target_link_libraries(environment_tests PRIVATE bmhcore)
|
target_link_libraries(environment_tests PRIVATE bmhcore)
|
||||||
set(BMH_TEST_ENVIRONMENT_TESTS_INPUT_1 "" CACHE PATH "External input 1 for environment_tests; not distributed")
|
add_test(NAME environment_tests COMMAND environment_tests)
|
||||||
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_executable(youth_academy_tests tests/youth_academy_tests.cpp)
|
add_executable(youth_academy_tests tests/youth_academy_tests.cpp)
|
||||||
target_link_libraries(youth_academy_tests PRIVATE bmhcore)
|
target_link_libraries(youth_academy_tests PRIVATE bmhcore)
|
||||||
@@ -443,7 +448,8 @@ add_executable(openbmh_play
|
|||||||
target_link_libraries(openbmh_play PRIVATE bmhui bmhlaunch_dialog openbmh_audio ${BMH_SDL_TARGET})
|
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
|
# 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)
|
# 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)
|
if(MSVC)
|
||||||
target_compile_options(openbmh_play PRIVATE /utf-8)
|
target_compile_options(openbmh_play PRIVATE /utf-8)
|
||||||
# App sources also compile in headless tests/helpers without target /utf-8.
|
# App sources also compile in headless tests/helpers without target /utf-8.
|
||||||
@@ -482,6 +488,7 @@ if(MSVC)
|
|||||||
endif()
|
endif()
|
||||||
bmh_add_data_test(NAME app_controller_tests COMMAND app_controller_tests "${BMH_DATA}")
|
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")
|
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}"
|
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}")
|
--delay-settings-only "${BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1}")
|
||||||
|
|
||||||
@@ -622,6 +629,7 @@ add_executable(openbmh_cli
|
|||||||
src/cli/seat_hub.cpp
|
src/cli/seat_hub.cpp
|
||||||
src/cli/json.cpp
|
src/cli/json.cpp
|
||||||
${BMH_APP_SESSION_SOURCE})
|
${BMH_APP_SESSION_SOURCE})
|
||||||
|
target_include_directories(openbmh_cli PRIVATE "${CMAKE_BINARY_DIR}/generated")
|
||||||
target_link_libraries(openbmh_cli PRIVATE bmhui bmhlaunch)
|
target_link_libraries(openbmh_cli PRIVATE bmhui bmhlaunch)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(openbmh_cli PRIVATE ws2_32) # --listen (Winsock)
|
target_link_libraries(openbmh_cli PRIVATE ws2_32) # --listen (Winsock)
|
||||||
@@ -1070,6 +1078,25 @@ if(MSVC)
|
|||||||
endif()
|
endif()
|
||||||
add_test(NAME launch_unit_tests COMMAND launch_unit_tests)
|
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)
|
add_executable(fixture_table_tests tests/fixture_table_tests.cpp)
|
||||||
target_link_libraries(fixture_table_tests PRIVATE bmhcore)
|
target_link_libraries(fixture_table_tests PRIVATE bmhcore)
|
||||||
add_test(NAME fixture_table_unit_tests COMMAND fixture_table_tests)
|
add_test(NAME fixture_table_unit_tests COMMAND fixture_table_tests)
|
||||||
@@ -1088,3 +1115,20 @@ foreach(dependency IN ITEMS SDL2 miniz lzma_sdk nfd)
|
|||||||
string(JSON package_dependencies SET "${package_dependencies}" "${dependency}" "\"${dependency_path}\"")
|
string(JSON package_dependencies SET "${package_dependencies}" "${dependency}" "\"${dependency_path}\"")
|
||||||
endforeach()
|
endforeach()
|
||||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/package-dependencies.json" CONTENT "${package_dependencies}\n")
|
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)
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# Contributing to OpenBMH
|
# 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.
|
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,42 @@
|
|||||||
# OpenBMH
|
# OpenBMH
|
||||||
|
|
||||||
A modern and faithful open source rebuild of the *Bundesliga Manager Hattrick* engine.
|
A faithful, standalone community reconstruction of *Bundesliga Manager Hattrick*, using the player's original installation and SDL2 interface.
|
||||||
|
|
||||||
OpenBMH is a standalone C++20 engine with an SDL2 interface for *Bundesliga Manager Hattrick* (1994/95) and its English edition, *Football Limited*. The project develops a playable reconstruction alongside a platform for new rules, content and interfaces. Keeping the familiar game enjoyable and making it easier to extend are equally important goals.
|
OpenBMH 1.0 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.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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.
|
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
|
## 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.
|
1. Have your own supported game installation available.
|
||||||
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
|
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:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
OpenBMH --data "path/to/game" --save-directory "path/to/saves"
|
||||||
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
|
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).
|
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
|
## 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.
|
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
|
## Build from source
|
||||||
|
|
||||||
The following recipes target v0.1.0. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
|
The following recipes target OpenBMH 1.0 release candidates. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
|
||||||
|
|
||||||
Clone the public repository, then run the commands for your system:
|
Clone the public repository, then run the commands for your system:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/rezmer/openbmh.git
|
git clone https://github.com/Weyoune/openbmh.git
|
||||||
cd openbmh
|
cd openbmh
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -50,7 +48,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 -S . -B build-windows -G "Visual Studio 17 2022" -A x64
|
||||||
cmake --build build-windows --config Release
|
cmake --build build-windows --config Release
|
||||||
ctest --test-dir build-windows -C Release --output-on-failure
|
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
|
### Linux
|
||||||
@@ -62,7 +60,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 -S . -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||||
cmake --build build-linux
|
cmake --build build-linux
|
||||||
ctest --test-dir build-linux --output-on-failure
|
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.
|
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 +75,7 @@ brew install cmake ninja
|
|||||||
cmake -S . -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64
|
cmake -S . -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||||
cmake --build build-macos
|
cmake --build build-macos
|
||||||
ctest --test-dir build-macos --output-on-failure
|
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.
|
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 +101,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.
|
OpenBMH's own code and documentation are licensed under **GNU GPL version 3 only**, SPDX **GPL-3.0-only**. [LICENSE](LICENSE) contains the unchanged GPLv3 text; the example wording in its appendix does not change this project's version choice. Game content has separate ownership and is not covered by this license.
|
||||||
|
|
||||||
Release source is identified by the matching version tag: [v0.1.0](https://github.com/rezmer/openbmh/tree/v0.1.0) for this version. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
|
Every published binary release identifies its matching source tag and provides a corresponding source archive. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
|
||||||
|
|
||||||
Bundled components retain their own licenses, including Nuked OPL3 under LGPL-2.1-or-later. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and [ACKNOWLEDGEMENTS.md](ACKNOWLEDGEMENTS.md).
|
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.
|
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
|
## Windows
|
||||||
|
|
||||||
@@ -45,8 +45,19 @@ Use native toolchain/dependency architectures consistently. A terminal executabl
|
|||||||
## Run with your data
|
## Run with your data
|
||||||
|
|
||||||
```sh
|
```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
|
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.
|
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 |
|
| 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 |
|
| `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`
|
### `Balance`
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Text, encoding and editions
|
# 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.
|
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.
|
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.
|
- 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.
|
- 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.
|
- 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.
|
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.
|
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.
|
||||||
+9
-14
@@ -6,32 +6,27 @@ See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These en
|
|||||||
describe deliberate changes; they are not a list of every known compatibility limit.
|
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/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/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
|
||||||
- [src/formats/le.hpp](../src/formats/le.hpp): applies a shared supported rule profile when loading editions with different rule-table values.
|
|
||||||
- [src/formats/rule_base.cpp](../src/formats/rule_base.cpp): normalizes live-scene defaults, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit across supported editions.
|
|
||||||
- [src/formats/rule_base.hpp](../src/formats/rule_base.hpp): normalizes live-scene options, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit.
|
|
||||||
- [src/game/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/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
- [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/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.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/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/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): supports owner-bound designated set-piece selection.
|
||||||
- [src/game/lineup.hpp](../src/game/lineup.hpp): disables the foreign-player limit and 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.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/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): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||||
- [src/game/season.cpp](../src/game/season.cpp): uses the enhanced youth-academy season settlement and player-generation rules.
|
- [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.hpp](../src/game/season.hpp): uses the enhanced youth-academy season settlement and player-generation rules.
|
- [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/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.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/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.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/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/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/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
|
||||||
|
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
|
||||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): omits DOS drive and delete buttons in the directory-confined save/load view.
|
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): omits DOS drive and delete buttons in the directory-confined save/load view.
|
||||||
|
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): permits cancelling host file dialogs with the right mouse button.
|
||||||
+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
|
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.
|
||||||
|
|
||||||
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.
|
|
||||||
@@ -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_RuntimeField` | `0xa50f0` | German-compatible image / runtime field |
|
||||||
| `Environment_FormatError_RuntimeField2` | `0xa50f6` | German-compatible image / runtime field |
|
| `Environment_FormatError_RuntimeField2` | `0xa50f6` | German-compatible image / runtime field |
|
||||||
| `Environment_Render_TextPointer` | `0xaeb74` | 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 |
|
| `Environment_SetEnvironment_ExecutableField` | `0xaf394` | German-compatible image / runtime field |
|
||||||
| `EuropeNameTable` | `0xae710` | German-compatible image / runtime field |
|
| `EuropeNameTable` | `0xae710` | German-compatible image / runtime field |
|
||||||
| `EventPasses` | `0xa2ba1` | German-compatible image / runtime field |
|
| `EventPasses` | `0xa2ba1` | German-compatible image / runtime field |
|
||||||
@@ -1490,6 +1495,9 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
|||||||
| `Pitch_Render_TextPointer3` | `0xae0f0` | German-compatible image / runtime field |
|
| `Pitch_Render_TextPointer3` | `0xae0f0` | German-compatible image / runtime field |
|
||||||
| `Pitch_Render_TextPointer4` | `0xae0f4` | German-compatible image / runtime field |
|
| `Pitch_Render_TextPointer4` | `0xae0f4` | German-compatible image / runtime field |
|
||||||
| `Pitch_Render_TextPointer5` | `0xae0f8` | German-compatible image / runtime field |
|
| `Pitch_Render_TextPointer5` | `0xae0f8` | German-compatible image / runtime field |
|
||||||
|
| `PitchOrderPositionPointers` | `0xa2a37` | German-compatible image / runtime field |
|
||||||
|
| `PitchOrderZoneMasks` | `0xa2a4b` | German-compatible image / runtime field |
|
||||||
|
| `PitchOrderZoneTextPointers` | `0xae818` | German-compatible image / runtime field |
|
||||||
| `Placements` | `0xbd38c` | German-compatible image / runtime field |
|
| `Placements` | `0xbd38c` | German-compatible image / runtime field |
|
||||||
| `PlainBackground` | `0xa2569` | German-compatible image / runtime field |
|
| `PlainBackground` | `0xa2569` | German-compatible image / runtime field |
|
||||||
| `PlanTicketPrice` | `0xa4856` | German-compatible image / runtime field |
|
| `PlanTicketPrice` | `0xa4856` | German-compatible image / runtime field |
|
||||||
@@ -1983,3 +1991,13 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
|||||||
| `EnglishSixTeamFixtureTable` | `0x6eed4` | English image adapter |
|
| `EnglishSixTeamFixtureTable` | `0x6eed4` | English image adapter |
|
||||||
| `EnglishTwelveTeamFixtureTable` | `0x6f0bc` | English image adapter |
|
| `EnglishTwelveTeamFixtureTable` | `0x6f0bc` | English image adapter |
|
||||||
| `EnglishTwentyTeamFixtureTable` | `0x6ee40` | 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,32 +0,0 @@
|
|||||||
# OpenBMH v0.1.0
|
|
||||||
|
|
||||||
OpenBMH reconstructs the Bundesliga Manager Hattrick engine in C++20. The graphical client uses SDL2; the console provides command batches and local manager-client transports over the same career session. This release needs a supported game installation supplied by the player. No original executable, artwork, music, text database, manual or saved game is included.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
The engine includes career management, leagues and cups, transfers and contracts, finances, training and camps, stadium management, live match interventions, audio playback and normal saves. Supported actions remain subject to mode, manager and phase restrictions; an unimplemented path reports an explicit error rather than an invented result. The project aims for recognisable behaviour and plausible results, not a promise that every original version produces identical events.
|
|
||||||
|
|
||||||
German game editions are the primary compatibility target. **Football Limited support is experimental.** English installation loading and edition-specific text/layout data are supported paths, while original V2.20 save import, English audio and remaining competition/interface differences have limitations. Check current issues before relying on a particular English workflow.
|
|
||||||
|
|
||||||
## Compatibility decisions
|
|
||||||
|
|
||||||
OpenBMH uses shared rule values across supported German editions, with installation-specific content read from the selected data. It includes safety handling around invalid input, calendar boundaries, capacity checks and suspended operations. See [compatibility decisions](../../COMPATIBILITY.md) and [architecture](../../architecture.md). This is an independent reconstruction, not an official update to the original game.
|
|
||||||
|
|
||||||
## Running
|
|
||||||
|
|
||||||
Extract the package to a separate directory or alongside your installation. `openbmh_play` can select a game directory, executable or a ZIP/7z containing one supported installation. Use an explicit writable save directory when the original directory is read-only, and keep backups.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
|
||||||
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
|
|
||||||
```
|
|
||||||
|
|
||||||
Version 0.1 ships binary packages for Windows x64, macOS on Apple silicon (arm64, macOS 11 or later) and Linux x64. The Linux package passes the automated build and tests but has not yet been played natively; reports are welcome. The macOS package is not signed or notarized, so Gatekeeper asks for confirmation on first start: open it once via right-click → Open, or allow it under System Settings → Privacy & Security. Packages and their native platform results are listed with the release assets. The [build instructions](../../BUILDING.md) cover Windows, Linux and macOS source builds; an instruction is not a claim of native acceptance. Linux's default file dialog backend requires GTK3 system libraries. A macOS terminal executable is distinct from a signed application bundle.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
The matching application source tag is [v0.1.0](https://github.com/rezmer/openbmh/tree/v0.1.0). Source/build and relinking materials for linked components must also accompany or be offered with binary releases under their licenses.
|
|
||||||
|
|
||||||
OpenBMH-owned code and documentation use GPL-3.0-only. Third-party components retain their licenses; the full texts accompany the package. Read [LICENSE](../../../LICENSE) and [THIRD_PARTY_NOTICES](../../../THIRD_PARTY_NOTICES.md). These licenses do not grant rights to original game content.
|
|
||||||
|
|
||||||
For reports, include the OpenBMH version, data edition, independently written steps and the observed result. Do not upload original files, game screenshots, recordings, text collections or saved games to public issues.
|
|
||||||
@@ -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,19 @@
|
|||||||
|
# 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,35 @@
|
|||||||
|
# Classic 1.0 candidate 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.
|
||||||
|
- 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,4 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
|
#include "game/calendar.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "app/career_session.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);
|
kNewcomerFirst = exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField);
|
||||||
kNewcomerCount = exe.u16(::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6);
|
kNewcomerCount = exe.u16(::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6);
|
||||||
// EXE strings the engine posts (messages.hpp)
|
// EXE strings the engine posts (messages.hpp)
|
||||||
kContractEndsSoonText = exe.cstring(kEnglishCompetitions ? ::bmh::layout::EnglishContractExpiryWarningText : ::bmh::layout::ContractExpiryWarningText);
|
install_message_texts(exe);
|
||||||
kMastersQualificationText = kEnglishCompetitions ? "Masters entry confirmed. Your participation bonus has been credited." : exe.cstring(::bmh::layout::MastersQualificationText);
|
install_career_rules(exe);
|
||||||
kMastersWinnerText = kEnglishCompetitions ? "Masters title won. Your prize money has been credited." : exe.cstring(::bmh::layout::MastersWinnerText);
|
install_environment_rules(exe);
|
||||||
kIndoorInvitationText = kEnglishCompetitions ? "Indoor event entry bonus credited for " : exe.cstring(::bmh::layout::IndoorInvitationText);
|
install_original_badge_policy(exe);
|
||||||
kChampionshipBonusText = kEnglishCompetitions ? "League title bonus credited." : exe.cstring(::bmh::layout::ChampionshipBonusText);
|
install_calendar_rules(exe);
|
||||||
kFriendlyPayerPrefixText = kEnglishCompetitions ? "Your share: " : exe.cstring(::bmh::layout::NationalFriendlyPayerPrefixText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed)
|
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.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];
|
notice.portrait=next.state.manager_records[record+0x221];
|
||||||
const int club=next.state.manager_teams[size_t(manager)];
|
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())
|
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])|
|
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;
|
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 &&
|
const bool consumed = (request.column == 7 &&
|
||||||
((request.row <= 6) || request.row == 7 || request.row == 9 || request.row == 10 ||
|
((request.row <= 6) || request.row == 7 || request.row == 9 || request.row == 10 ||
|
||||||
(scoped_settings && request.row == 8))) ||
|
(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.
|
// 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));
|
request.row == 7 || request.row == 8 || request.row == 10 || request.row == 12 || request.row == 15));
|
||||||
if (!consumed || old >= 200) {
|
if (!consumed || old >= 200) {
|
||||||
error = "Diese Einstellung ist noch nicht verfügbar.";
|
error = "Diese Einstellung ist noch nicht verfügbar.";
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "app/controller.hpp"
|
#include "app/controller.hpp"
|
||||||
#include "app/window_actions.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.manager_name.push_back(char(game.manager_records[record+0xa8+i]));
|
||||||
out.portrait=game.manager_records[record+0x221];
|
out.portrait=game.manager_records[record+0x221];
|
||||||
out.manager_slot=manager;
|
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())
|
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]|
|
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;
|
uint16_t(game.club_heap_78[size_t(team)*2+1])<<8)&0x1ff;
|
||||||
|
|||||||
+190
-246
@@ -1,5 +1,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.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
|
// 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.
|
// career initialised by the engine (app/career_session.hpp) and its desk.
|
||||||
//
|
//
|
||||||
@@ -9,6 +11,7 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -23,6 +26,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/controller.hpp"
|
#include "app/controller.hpp"
|
||||||
|
#include "app/quit_confirmation.hpp"
|
||||||
#include "launch/archive.hpp"
|
#include "launch/archive.hpp"
|
||||||
#include "launch/file_dialog.hpp"
|
#include "launch/file_dialog.hpp"
|
||||||
#include "launch/game_data.hpp"
|
#include "launch/game_data.hpp"
|
||||||
@@ -73,6 +77,18 @@ static void show_start_error(const std::string& text) {
|
|||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenBMH", text.c_str(), nullptr);
|
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
|
#ifdef _WIN32
|
||||||
// The game is a Windows GUI program (no console window on double-click). Started from a
|
// 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).
|
// console, it writes --version, --help and start errors there (kernel32 AttachConsole).
|
||||||
@@ -97,7 +113,7 @@ int main(int argc, char** argv) {
|
|||||||
fs::path data, save_directory;
|
fs::path data, save_directory;
|
||||||
uint32_t seed = uint32_t(std::chrono::system_clock::now().time_since_epoch().count());
|
uint32_t seed = uint32_t(std::chrono::system_clock::now().time_since_epoch().count());
|
||||||
bool muted = false, music_enabled = true;
|
bool muted = false, music_enabled = true;
|
||||||
int live_frame_ms = 10;
|
int live_frame_ms = 0;
|
||||||
bool live_frame_ms_explicit = false;
|
bool live_frame_ms_explicit = false;
|
||||||
if (const char* configured = std::getenv("BMH_LIVE_FRAME_MS")) {
|
if (const char* configured = std::getenv("BMH_LIVE_FRAME_MS")) {
|
||||||
live_frame_ms = std::clamp(std::atoi(configured), 0, 1000);
|
live_frame_ms = std::clamp(std::atoi(configured), 0, 1000);
|
||||||
@@ -128,7 +144,7 @@ int main(int argc, char** argv) {
|
|||||||
std::printf("OpenBMH %s\n", bmh::kOpenBmhVersion);
|
std::printf("OpenBMH %s\n", bmh::kOpenBmhVersion);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (is("--help") || is("-h")) {
|
} 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");
|
"[--save-directory <directory>] [--mute] [--volume <0..1>] [--no-music] [--live-frame-ms <0..1000>]\n");
|
||||||
return 0;
|
return 0;
|
||||||
} else if (args[i].rfind("--", 0) != 0 && data.empty()) {
|
} else if (args[i].rfind("--", 0) != 0 && data.empty()) {
|
||||||
@@ -205,6 +221,8 @@ int main(int argc, char** argv) {
|
|||||||
ui::SportschauTeamInfo sportschau_team_info(data);
|
ui::SportschauTeamInfo sportschau_team_info(data);
|
||||||
ui::CompetitionWinnerScreen competition_winner(data);
|
ui::CompetitionWinnerScreen competition_winner(data);
|
||||||
const auto season_exe = load_le(ui::asset_path(data, "BMH.exe"));
|
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 {
|
try {
|
||||||
if (!playback.initialize_original(app::original_audio_assets(data, season_exe), audio_error))
|
if (!playback.initialize_original(app::original_audio_assets(data, season_exe), audio_error))
|
||||||
std::fprintf(stderr, "audio: %s\n", audio_error.c_str());
|
std::fprintf(stderr, "audio: %s\n", audio_error.c_str());
|
||||||
@@ -344,7 +362,7 @@ int main(int argc, char** argv) {
|
|||||||
if (screen.close_requested()) return renewed_expired_player ? 1 : 0;
|
if (screen.close_requested()) return renewed_expired_player ? 1 : 0;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (quit_confirmation.poll(&event)) {
|
||||||
if (event.type == SDL_QUIT) {
|
if (event.type == SDL_QUIT) {
|
||||||
running = false;
|
running = false;
|
||||||
staged = before;
|
staged = before;
|
||||||
@@ -446,7 +464,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||||
while (running) {
|
while (running) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (quit_confirmation.poll(&event)) {
|
||||||
if (event.type == SDL_QUIT) { running = false; return; }
|
if (event.type == SDL_QUIT) { running = false; return; }
|
||||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) return;
|
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) return;
|
||||||
@@ -460,7 +478,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||||
while (running) {
|
while (running) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (quit_confirmation.poll(&event)) {
|
||||||
if (event.type == SDL_QUIT) { running = false; return; }
|
if (event.type == SDL_QUIT) { running = false; return; }
|
||||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) return;
|
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) return;
|
||||||
@@ -473,19 +491,13 @@ int main(int argc, char** argv) {
|
|||||||
SDL_Delay(20); // Source timer unit used by the traced intro path.
|
SDL_Delay(20); // Source timer unit used by the traced intro path.
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
SDL_Event close;
|
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
|
running = false; // platform close is the only intro-loop escape
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto wait_source_retraces = [&](unsigned count) {
|
auto wait_source_retraces = [&](unsigned count) {
|
||||||
// SDL has no VGA status-port equivalent. Approximate Source's
|
// Keep the VGA cadence on 60/120/144-Hz host displays alike.
|
||||||
// retrace waits with the active display's reported refresh period;
|
constexpr auto refresh_hz = ui::kOriginalRefreshHz;
|
||||||
// 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
|
|
||||||
const Uint64 frequency = SDL_GetPerformanceFrequency();
|
const Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||||
const Uint64 ticks_per_wait = (frequency + Uint64(refresh_hz) - 1) / Uint64(refresh_hz);
|
const Uint64 ticks_per_wait = (frequency + Uint64(refresh_hz) - 1) / Uint64(refresh_hz);
|
||||||
for (unsigned i = 0; running && i < count; ++i) {
|
for (unsigned i = 0; running && i < count; ++i) {
|
||||||
@@ -493,7 +505,7 @@ int main(int argc, char** argv) {
|
|||||||
while (running && SDL_GetPerformanceCounter() - started < ticks_per_wait) {
|
while (running && SDL_GetPerformanceCounter() - started < ticks_per_wait) {
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
SDL_Event close;
|
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
|
running = false; // platform close is the only animation-loop escape
|
||||||
if (running) SDL_Delay(1);
|
if (running) SDL_Delay(1);
|
||||||
}
|
}
|
||||||
@@ -543,7 +555,7 @@ int main(int argc, char** argv) {
|
|||||||
bool skipped = false;
|
bool skipped = false;
|
||||||
while (running && !skipped && SDL_GetTicks() - start < duration) {
|
while (running && !skipped && SDL_GetTicks() - start < duration) {
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) running = false;
|
if (input.type == SDL_QUIT) running = false;
|
||||||
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_LEFT)
|
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_LEFT)
|
||||||
skipped = true;
|
skipped = true;
|
||||||
@@ -566,14 +578,14 @@ int main(int argc, char** argv) {
|
|||||||
bool skip = false;
|
bool skip = false;
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
if (step.minute_wait) {
|
if (step.minute_wait) {
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) running = false;
|
if (input.type == SDL_QUIT) running = false;
|
||||||
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_LEFT)
|
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_LEFT)
|
||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SDL_PumpEvents();
|
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;
|
if (!running) return true;
|
||||||
const std::string title = "OpenBMH - sportschau_replay_" + std::to_string(fixture.group) +
|
const std::string title = "OpenBMH - sportschau_replay_" + std::to_string(fixture.group) +
|
||||||
@@ -673,8 +685,7 @@ int main(int argc, char** argv) {
|
|||||||
view.manager_name += char(state.manager_records[base + 0xa8 + i]);
|
view.manager_name += char(state.manager_records[base + 0xa8 + i]);
|
||||||
view.body = event.text;
|
view.body = event.text;
|
||||||
view.portrait = state.manager_records[base + 0x221];
|
view.portrait = state.manager_records[base + 0x221];
|
||||||
view.badge_fallback = event.team == 0x0fff || (event.team > 89 && event.team < 138) ||
|
view.badge_fallback = original_badge_fallback(event.team);
|
||||||
(event.team > 167 && event.team < 357);
|
|
||||||
view.badge_sprite = view.badge_fallback ? 0 : le16(state.club_heap_78, size_t(event.team) * 2) & 0x1ff;
|
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),
|
ui::GameEndTaxDialog screen(data, std::move(view), game_end_options(state),
|
||||||
event.kind == SeasonTaxEventKind::outcome ? season_backdrop : std::optional<Image>{});
|
event.kind == SeasonTaxEventKind::outcome ? season_backdrop : std::optional<Image>{});
|
||||||
@@ -688,7 +699,7 @@ int main(int argc, char** argv) {
|
|||||||
auto pressed = ui::GameEndTaxDialog::Button::none;
|
auto pressed = ui::GameEndTaxDialog::Button::none;
|
||||||
while (running) {
|
while (running) {
|
||||||
SDL_Event input;
|
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_QUIT) { running = false; return false; }
|
||||||
if (input.type == SDL_MOUSEBUTTONDOWN) {
|
if (input.type == SDL_MOUSEBUTTONDOWN) {
|
||||||
if (event.kind != SeasonTaxEventKind::question &&
|
if (event.kind != SeasonTaxEventKind::question &&
|
||||||
@@ -727,7 +738,7 @@ int main(int argc, char** argv) {
|
|||||||
const auto started = SDL_GetTicks();
|
const auto started = SDL_GetTicks();
|
||||||
while (running && Uint32(SDL_GetTicks() - started) < animation.wait_milliseconds()) {
|
while (running && Uint32(SDL_GetTicks() - started) < animation.wait_milliseconds()) {
|
||||||
SDL_Event input;
|
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.
|
// Source param4=0: clicks/keys cannot change this script or RNG.
|
||||||
SDL_Delay(10);
|
SDL_Delay(10);
|
||||||
}
|
}
|
||||||
@@ -744,7 +755,7 @@ int main(int argc, char** argv) {
|
|||||||
// events for the next Original input boundary; only handle SDL exit.
|
// events for the next Original input boundary; only handle SDL exit.
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
SDL_Event quit;
|
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);
|
if (running) SDL_Delay(10);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -799,7 +810,7 @@ int main(int argc, char** argv) {
|
|||||||
if (timed && Uint32(SDL_GetTicks() - started) >= 70 * 3 * 20)
|
if (timed && Uint32(SDL_GetTicks() - started) >= 70 * 3 * 20)
|
||||||
return complete(PendingOfferAnswer::yes);
|
return complete(PendingOfferAnswer::yes);
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; return PendingOfferAnswer::unsupported; }
|
if (input.type == SDL_QUIT) { running = false; return PendingOfferAnswer::unsupported; }
|
||||||
const bool question_deadline = question && poll_process_timer(true,true);
|
const bool question_deadline = question && poll_process_timer(true,true);
|
||||||
if (question_deadline && pressed == ui::GameEndTaxDialog::Button::none)
|
if (question_deadline && pressed == ui::GameEndTaxDialog::Button::none)
|
||||||
@@ -869,7 +880,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP); // DecodeTaxAnimationScript/SDLFlushEvents redraw boundary
|
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP); // DecodeTaxAnimationScript/SDLFlushEvents redraw boundary
|
||||||
while (running) {
|
while (running) {
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; return PendingOfferTransferChoice{}; }
|
if (input.type == SDL_QUIT) { running = false; return PendingOfferTransferChoice{}; }
|
||||||
std::optional<int> bid;
|
std::optional<int> bid;
|
||||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||||
@@ -898,7 +909,7 @@ int main(int argc, char** argv) {
|
|||||||
bool acknowledged=false;
|
bool acknowledged=false;
|
||||||
while(running && !acknowledged) {
|
while(running && !acknowledged) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while(SDL_PollEvent(&event)) {
|
while(quit_confirmation.poll(&event)) {
|
||||||
if(event.type==SDL_QUIT){running=false;break;}
|
if(event.type==SDL_QUIT){running=false;break;}
|
||||||
if(event.type==SDL_MOUSEBUTTONDOWN &&
|
if(event.type==SDL_MOUSEBUTTONDOWN &&
|
||||||
(event.button.button==SDL_BUTTON_LEFT || event.button.button==SDL_BUTTON_RIGHT)) {
|
(event.button.button==SDL_BUTTON_LEFT || event.button.button==SDL_BUTTON_RIGHT)) {
|
||||||
@@ -961,7 +972,7 @@ int main(int argc, char** argv) {
|
|||||||
draw();
|
draw();
|
||||||
while (running) {
|
while (running) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (quit_confirmation.poll(&event)) {
|
||||||
if (event.type == SDL_QUIT) { running = false; return -1; }
|
if (event.type == SDL_QUIT) { running = false; return -1; }
|
||||||
ui::OutgoingTransferRequest action;
|
ui::OutgoingTransferRequest action;
|
||||||
if (event.type == SDL_MOUSEMOTION) continue;
|
if (event.type == SDL_MOUSEMOTION) continue;
|
||||||
@@ -1078,7 +1089,7 @@ int main(int argc, char** argv) {
|
|||||||
while (running) {
|
while (running) {
|
||||||
if (deadline_expired()) return true; //ClubInfoFromGame event8 returns to its owning caller.
|
if (deadline_expired()) return true; //ClubInfoFromGame event8 returns to its owning caller.
|
||||||
SDL_Event input;
|
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_QUIT) { running = false; return false; }
|
||||||
if (deadline_expired()) return true;
|
if (deadline_expired()) return true;
|
||||||
ui::ClubInfoRequest request;
|
ui::ClubInfoRequest request;
|
||||||
@@ -1179,7 +1190,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
while (running && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON_LMASK)) {
|
while (running && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON_LMASK)) {
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while (SDL_PollEvent(&input))
|
while (quit_confirmation.poll(&input))
|
||||||
if (input.type == SDL_QUIT) { running = false; return; }
|
if (input.type == SDL_QUIT) { running = false; return; }
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
if (running) SDL_Delay(10);
|
if (running) SDL_Delay(10);
|
||||||
@@ -1247,7 +1258,7 @@ int main(int argc, char** argv) {
|
|||||||
while (running) {
|
while (running) {
|
||||||
if (const auto complete = expire_card()) return *complete;
|
if (const auto complete = expire_card()) return *complete;
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; return std::nullopt; }
|
if (input.type == SDL_QUIT) { running = false; return std::nullopt; }
|
||||||
if (const auto complete = expire_card()) return *complete;
|
if (const auto complete = expire_card()) return *complete;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
@@ -1309,7 +1320,7 @@ int main(int argc, char** argv) {
|
|||||||
while (running) {
|
while (running) {
|
||||||
if (deadline_expired()) return; //LeagueCalculations frees its child before4f548 polls again.
|
if (deadline_expired()) return; //LeagueCalculations frees its child before4f548 polls again.
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; return; }
|
if (input.type == SDL_QUIT) { running = false; return; }
|
||||||
if (deadline_expired()) return;
|
if (deadline_expired()) return;
|
||||||
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_RIGHT)
|
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_RIGHT)
|
||||||
@@ -1393,7 +1404,7 @@ int main(int argc, char** argv) {
|
|||||||
while(running&&!outcome) {
|
while(running&&!outcome) {
|
||||||
if(expire_range())break;
|
if(expire_range())break;
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while(SDL_PollEvent(&input)) {
|
while(quit_confirmation.poll(&input)) {
|
||||||
if(input.type==SDL_QUIT){running=false;break;}
|
if(input.type==SDL_QUIT){running=false;break;}
|
||||||
if(expire_range())break;
|
if(expire_range())break;
|
||||||
bool changed=false;
|
bool changed=false;
|
||||||
@@ -1449,7 +1460,7 @@ int main(int argc, char** argv) {
|
|||||||
while(running) {
|
while(running) {
|
||||||
if(deadline_expired())return std::nullopt;
|
if(deadline_expired())return std::nullopt;
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while(SDL_PollEvent(&input)) {
|
while(quit_confirmation.poll(&input)) {
|
||||||
if(input.type==SDL_QUIT){running=false;break;}
|
if(input.type==SDL_QUIT){running=false;break;}
|
||||||
if(deadline_expired())return std::nullopt;
|
if(deadline_expired())return std::nullopt;
|
||||||
bool changed=false;
|
bool changed=false;
|
||||||
@@ -1543,7 +1554,7 @@ int main(int argc, char** argv) {
|
|||||||
// Source ignores the first OriginalMouseSound poll's gameplay result, then
|
// Source ignores the first OriginalMouseSound poll's gameplay result, then
|
||||||
// presents the starting scene before its ten option-delay polls.
|
// presents the starting scene before its ten option-delay polls.
|
||||||
SDL_Event initial;
|
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();
|
show_draw();
|
||||||
while (running && screen.advance_step()) {
|
while (running && screen.advance_step()) {
|
||||||
if (screen.present_needed()) show_draw();
|
if (screen.present_needed()) show_draw();
|
||||||
@@ -1551,7 +1562,7 @@ int main(int argc, char** argv) {
|
|||||||
if (!running) return;
|
if (!running) return;
|
||||||
if (screen.input_poll_needed()) {
|
if (screen.input_poll_needed()) {
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; return; }
|
if (input.type == SDL_QUIT) { running = false; return; }
|
||||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||||
(input.button.button == SDL_BUTTON_LEFT || input.button.button == SDL_BUTTON_RIGHT)) {
|
(input.button.button == SDL_BUTTON_LEFT || input.button.button == SDL_BUTTON_RIGHT)) {
|
||||||
@@ -1586,7 +1597,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||||
while (running) {
|
while (running) {
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; return; }
|
if (input.type == SDL_QUIT) { running = false; return; }
|
||||||
if (input.type != SDL_MOUSEBUTTONDOWN) continue;
|
if (input.type != SDL_MOUSEBUTTONDOWN) continue;
|
||||||
if (input.button.button == SDL_BUTTON_RIGHT) return;
|
if (input.button.button == SDL_BUTTON_RIGHT) return;
|
||||||
@@ -1623,7 +1634,7 @@ int main(int argc, char** argv) {
|
|||||||
while (running && screen.phase() == ui::AlternateScorePhase::Calculator) {
|
while (running && screen.phase() == ui::AlternateScorePhase::Calculator) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (quit_confirmation.poll(&event)) {
|
||||||
if (event.type == SDL_QUIT) { running = false; return; }
|
if (event.type == SDL_QUIT) { running = false; return; }
|
||||||
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT) {
|
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT) {
|
||||||
right_cancel = true;
|
right_cancel = true;
|
||||||
@@ -1688,6 +1699,11 @@ int main(int argc, char** argv) {
|
|||||||
std::optional<Uint64> timed_notice_presented_at;
|
std::optional<Uint64> timed_notice_presented_at;
|
||||||
std::optional<Uint8> timed_notice_release;
|
std::optional<Uint8> timed_notice_release;
|
||||||
auto handle = [&](const ui::FlowResult& r) {
|
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())
|
if (const auto* desk = flow.desktop())
|
||||||
for (const auto id : desk->take_sound_ids()) app::original_audio_command(playback, id);
|
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) {
|
if (r.request == ui::FlowRequest::kickoff || r.request == ui::FlowRequest::end_session) {
|
||||||
@@ -1749,11 +1765,57 @@ int main(int argc, char** argv) {
|
|||||||
auto live_lineup = ui::lineup_from_game(lineup_state, season_exe, live_revision);
|
auto live_lineup = ui::lineup_from_game(lineup_state, season_exe, live_revision);
|
||||||
live_lineup.in_match = true;
|
live_lineup.in_match = true;
|
||||||
live_lineup.entry_prepared = true;
|
live_lineup.entry_prepared = true;
|
||||||
ui::LineupScreen screen(data, std::move(live_lineup));
|
// The live menu owns the same native display word and both pages
|
||||||
SDL_SetWindowTitle(window, "OpenBMH - live_lineup");
|
// as the desk. A separate team-sheet parent can hide a saved
|
||||||
|
// pitch page and strand its navigation request after return.
|
||||||
|
ui::PitchScreen screen(data, std::move(live_lineup),
|
||||||
|
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||||
|
const auto live_title = [&] {
|
||||||
|
return (screen.extras().native_display_word & 8)
|
||||||
|
? "OpenBMH - live_pitch" : "OpenBMH - live_lineup";
|
||||||
|
};
|
||||||
|
SDL_SetWindowTitle(window, live_title());
|
||||||
bool closed = false;
|
bool closed = false;
|
||||||
std::optional<SDL_MouseButtonEvent> lineup_down;
|
const auto apply_live_pitch = [&](const ui::PitchRequest& action) {
|
||||||
std::optional<SDL_MouseButtonEvent> lineup_right_down;
|
if (action.kind == ui::PitchRequestKind::none) return;
|
||||||
|
if (action.kind == ui::PitchRequestKind::open_player_info) {
|
||||||
|
try {
|
||||||
|
if (action.row < 0 || size_t(action.row) >= screen.state().players.size() ||
|
||||||
|
screen.state().players.at(size_t(action.row)).player_id != action.player_id)
|
||||||
|
throw FormatError("live player information request is stale");
|
||||||
|
auto services = session->live_club_modal_services(live_revision);
|
||||||
|
const ClubPlayerDetailSelection selection{selected_team, action.player_id,
|
||||||
|
action.row, action.row, -1};
|
||||||
|
if (!present_player_detail)
|
||||||
|
throw FormatError("live player information presenter stopped");
|
||||||
|
const auto return_parent = present_player_detail(services, selection, screen.render());
|
||||||
|
if (!return_parent) throw FormatError("live player information presenter stopped");
|
||||||
|
if (*return_parent) closed = true;
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::fprintf(stderr, "live player information: %s\n", e.what());
|
||||||
|
}
|
||||||
|
screen.resolve_local_navigation();
|
||||||
|
} else {
|
||||||
|
const auto result = dispatch_pitch(action);
|
||||||
|
if (result.status == app::LiveSubstitutionStatus::applied) {
|
||||||
|
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
||||||
|
updated.in_match = true; updated.entry_prepared = true;
|
||||||
|
screen.acknowledge(std::move(updated),
|
||||||
|
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||||
|
} else if (result.status == app::LiveSubstitutionStatus::source_notice) {
|
||||||
|
show_live_substitution_notice(result, screen.render(), live_title());
|
||||||
|
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
||||||
|
updated.in_match = true; updated.entry_prepared = true;
|
||||||
|
screen = ui::PitchScreen(data, std::move(updated),
|
||||||
|
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||||
|
} else {
|
||||||
|
screen.reject_action(result.error.empty()
|
||||||
|
? "Der Spielerwechsel ist nicht freigegeben." : result.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SDL_SetWindowTitle(window, live_title());
|
||||||
|
};
|
||||||
|
bool left_held = false, left_release_consumed = false, right_held = false;
|
||||||
while (running && !closed) {
|
while (running && !closed) {
|
||||||
const Image image = screen.render();
|
const Image image = screen.render();
|
||||||
for (size_t i = 0; i < pixels.size(); ++i)
|
for (size_t i = 0; i < pixels.size(); ++i)
|
||||||
@@ -1764,193 +1826,40 @@ int main(int argc, char** argv) {
|
|||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
SDL_Event modal;
|
SDL_Event modal;
|
||||||
bool redrawn = false;
|
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_QUIT) { running = false; closed = true; break; }
|
||||||
if (modal.type == SDL_KEYDOWN && modal.key.keysym.sym == SDLK_ESCAPE) {
|
if (modal.type == SDL_KEYDOWN && modal.key.keysym.sym == SDLK_ESCAPE) {
|
||||||
screen.key("ESC"); closed = true; break;
|
screen.key("ESC"); closed = true; break;
|
||||||
}
|
}
|
||||||
if (modal.type == SDL_MOUSEBUTTONDOWN && modal.button.button == SDL_BUTTON_RIGHT)
|
if (modal.type == SDL_MOUSEBUTTONDOWN && modal.button.button == SDL_BUTTON_LEFT) {
|
||||||
lineup_right_down = modal.button;
|
left_held = true;
|
||||||
else if (modal.type == SDL_MOUSEBUTTONUP && lineup_right_down &&
|
const auto action = screen.pointer_down(modal.button.x, modal.button.y);
|
||||||
modal.button.button == SDL_BUTTON_RIGHT &&
|
left_release_consumed = screen.take_source_down_release_barrier();
|
||||||
modal.button.x == lineup_right_down->x && modal.button.y == lineup_right_down->y) {
|
// Native page/order controls act on DOWN. ACK before
|
||||||
lineup_right_down.reset();
|
// polling another event; their UP cannot toggle twice.
|
||||||
screen.click(modal.button.x, modal.button.y, true);
|
apply_live_pitch(action);
|
||||||
|
redrawn = true;
|
||||||
|
} else if (modal.type == SDL_MOUSEBUTTONUP && modal.button.button == SDL_BUTTON_LEFT && left_held) {
|
||||||
|
left_held = false;
|
||||||
|
if (!left_release_consumed)
|
||||||
|
apply_live_pitch(screen.click(modal.button.x, modal.button.y));
|
||||||
|
left_release_consumed = false;
|
||||||
|
redrawn = true;
|
||||||
|
} else if (modal.type == SDL_MOUSEBUTTONDOWN && modal.button.button == SDL_BUTTON_RIGHT) {
|
||||||
|
right_held = true;
|
||||||
|
(void)screen.pointer_down(modal.button.x, modal.button.y, true);
|
||||||
|
(void)screen.take_source_down_release_barrier();
|
||||||
|
redrawn = true;
|
||||||
|
} else if (modal.type == SDL_MOUSEBUTTONUP && modal.button.button == SDL_BUTTON_RIGHT && right_held) {
|
||||||
|
right_held = false;
|
||||||
|
// Mouse movement between DOWN and UP must not leave
|
||||||
|
// a closed modal or an accepted request suspended.
|
||||||
if (screen.close_requested()) closed = true;
|
if (screen.close_requested()) closed = true;
|
||||||
redrawn = true;
|
redrawn = true;
|
||||||
}
|
} else if (modal.type == SDL_MOUSEMOTION) {
|
||||||
if (modal.type == SDL_MOUSEBUTTONDOWN && modal.button.button == SDL_BUTTON_LEFT)
|
|
||||||
lineup_down = modal.button;
|
|
||||||
else if (modal.type == SDL_MOUSEBUTTONUP && lineup_down &&
|
|
||||||
modal.button.button == SDL_BUTTON_LEFT &&
|
|
||||||
modal.button.x == lineup_down->x && modal.button.y == lineup_down->y) {
|
|
||||||
lineup_down.reset();
|
|
||||||
const auto request = screen.click(modal.button.x, modal.button.y);
|
|
||||||
if (request.kind == ui::LineupRequestKind::swap_players) {
|
|
||||||
const auto result = dispatch(request);
|
|
||||||
if (result.status == app::LiveSubstitutionStatus::applied) {
|
|
||||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
|
||||||
updated.in_match = true; updated.entry_prepared = true;
|
|
||||||
screen.acknowledge(std::move(updated));
|
|
||||||
redrawn = true;
|
|
||||||
} else if (result.status == app::LiveSubstitutionStatus::source_notice) {
|
|
||||||
show_live_substitution_notice(result, screen.render(),
|
|
||||||
"OpenBMH - live_lineup");
|
|
||||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
|
||||||
updated.in_match = true; updated.entry_prepared = true;
|
|
||||||
screen = ui::LineupScreen(data, std::move(updated));
|
|
||||||
redrawn = true;
|
|
||||||
} else {
|
|
||||||
screen.reject_action(result.error.empty()
|
|
||||||
? "Der Spielerwechsel ist nicht freigegeben."
|
|
||||||
: result.error);
|
|
||||||
redrawn = true;
|
|
||||||
}
|
|
||||||
} else if (request.kind == ui::LineupRequestKind::open_player_info) {
|
|
||||||
const auto& player = screen.state().players.at(size_t(request.first_row));
|
|
||||||
try {
|
|
||||||
if (player.player_id != request.first_player)
|
|
||||||
throw FormatError("live player information request is stale");
|
|
||||||
auto services = session->live_club_modal_services(live_revision);
|
|
||||||
const ClubPlayerDetailSelection selection{selected_team, request.first_player,
|
|
||||||
request.first_row, request.first_row, -1};
|
|
||||||
if (!present_player_detail)
|
|
||||||
throw FormatError("live player information presenter stopped");
|
|
||||||
const auto return_parent = present_player_detail(services, selection, screen.render());
|
|
||||||
if (!return_parent) throw FormatError("live player information presenter stopped");
|
|
||||||
if (*return_parent) closed = true;
|
|
||||||
SDL_SetWindowTitle(window, "OpenBMH - live_lineup");
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
std::fprintf(stderr, "live player information: %s\n", e.what());
|
|
||||||
}
|
|
||||||
screen.resolve_local_navigation(request.kind);
|
|
||||||
redrawn = true;
|
|
||||||
} else if (request.kind == ui::LineupRequestKind::open_pitch) {
|
|
||||||
bool returned_to_lineup = false;
|
|
||||||
try {
|
|
||||||
ui::PitchScreen pitch(data, screen.state(),
|
|
||||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
|
||||||
auto pitch_entry = pitch.request_page_control(1);
|
|
||||||
app::LiveSubstitutionResult entry_result;
|
|
||||||
if (pitch_entry.kind == ui::PitchRequestKind::none ||
|
|
||||||
(entry_result = dispatch_pitch(pitch_entry)).status !=
|
|
||||||
app::LiveSubstitutionStatus::applied) {
|
|
||||||
if (pitch_entry.kind != ui::PitchRequestKind::none)
|
|
||||||
pitch.reject_action(entry_result.error.empty()
|
|
||||||
? "Source pitch entry was rejected" : entry_result.error);
|
|
||||||
throw FormatError(entry_result.error.empty()
|
|
||||||
? "Source pitch entry could not be acknowledged" : entry_result.error);
|
|
||||||
}
|
|
||||||
auto entered_lineup = ui::lineup_from_game(state, season_exe, live_revision);
|
|
||||||
entered_lineup.in_match = true; entered_lineup.entry_prepared = true;
|
|
||||||
pitch.acknowledge(std::move(entered_lineup),
|
|
||||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
|
||||||
SDL_SetWindowTitle(window, "OpenBMH - live_pitch");
|
|
||||||
bool pitch_closed = false;
|
|
||||||
std::optional<SDL_MouseButtonEvent> pitch_down;
|
|
||||||
std::optional<SDL_MouseButtonEvent> pitch_right_down;
|
|
||||||
std::optional<ui::PitchRequest> pitch_down_request;
|
|
||||||
Uint32 pitch_down_at = 0;
|
|
||||||
while (running && !pitch_closed) {
|
|
||||||
const Image pitch_image = pitch.render();
|
|
||||||
for (size_t i = 0; i < pixels.size(); ++i)
|
|
||||||
pixels[i] = palette.argb[pitch_image.pixels[i]];
|
|
||||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
|
||||||
SDL_RenderClear(renderer);
|
|
||||||
SDL_RenderCopy(renderer, texture, nullptr, nullptr);
|
|
||||||
SDL_RenderPresent(renderer);
|
|
||||||
SDL_Event child;
|
|
||||||
bool pitch_redrawn = false;
|
|
||||||
while (SDL_PollEvent(&child)) {
|
|
||||||
if (child.type == SDL_QUIT) { running = false; pitch_closed = true; break; }
|
|
||||||
if (child.type == SDL_KEYDOWN && child.key.keysym.sym == SDLK_ESCAPE) {
|
|
||||||
pitch.key("ESC"); pitch_closed = true; closed = true; break;
|
|
||||||
}
|
|
||||||
if (child.type == SDL_MOUSEBUTTONDOWN && child.button.button == SDL_BUTTON_LEFT) {
|
|
||||||
pitch_down = child.button; pitch_down_at = SDL_GetTicks();
|
|
||||||
pitch_down_request = pitch.pointer_down(child.button.x, child.button.y);
|
|
||||||
} else if (child.type == SDL_MOUSEBUTTONDOWN && child.button.button == SDL_BUTTON_RIGHT) {
|
|
||||||
pitch_right_down = child.button;
|
|
||||||
(void)pitch.pointer_down(child.button.x, child.button.y, true);
|
|
||||||
} else if (child.type == SDL_MOUSEBUTTONUP && pitch_down &&
|
|
||||||
child.button.button == SDL_BUTTON_LEFT &&
|
|
||||||
child.button.x == pitch_down->x && child.button.y == pitch_down->y) {
|
|
||||||
pitch_down.reset();
|
|
||||||
auto action = pitch_down_request.value_or(ui::PitchRequest{});
|
|
||||||
pitch_down_request.reset();
|
|
||||||
if (SDL_GetTicks() - pitch_down_at > 500)
|
|
||||||
action = pitch.save_formation(child.button.x, child.button.y);
|
|
||||||
else if (action.kind == ui::PitchRequestKind::none)
|
|
||||||
action = pitch.click(child.button.x, child.button.y);
|
|
||||||
if (action.kind == ui::PitchRequestKind::open_player_info) {
|
|
||||||
try {
|
|
||||||
if (action.row < 0 || size_t(action.row) >= pitch.state().players.size() ||
|
|
||||||
pitch.state().players.at(size_t(action.row)).player_id != action.player_id)
|
|
||||||
throw FormatError("live pitch player information request is stale");
|
|
||||||
auto services = session->live_club_modal_services(live_revision);
|
|
||||||
const ClubPlayerDetailSelection selection{selected_team, action.player_id,
|
|
||||||
action.row, action.row, -1};
|
|
||||||
if (!present_player_detail)
|
|
||||||
throw FormatError("live pitch player information presenter stopped");
|
|
||||||
const auto return_parent = present_player_detail(services, selection, pitch.render());
|
|
||||||
if (!return_parent)
|
|
||||||
throw FormatError("live pitch player information presenter stopped");
|
|
||||||
SDL_SetWindowTitle(window, "OpenBMH - live_pitch");
|
|
||||||
if (*return_parent) { pitch_closed = true; closed = true; }
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
std::fprintf(stderr, "live pitch player information: %s\n", e.what());
|
|
||||||
}
|
|
||||||
pitch.resolve_local_navigation(); pitch_redrawn = true;
|
|
||||||
} else if (action.kind != ui::PitchRequestKind::none) {
|
|
||||||
const auto result = dispatch_pitch(action);
|
|
||||||
if (result.status == app::LiveSubstitutionStatus::applied) {
|
|
||||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
|
||||||
updated.in_match = true; updated.entry_prepared = true;
|
|
||||||
pitch.acknowledge(std::move(updated),
|
|
||||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
|
||||||
if (action.kind == ui::PitchRequestKind::select_pitch_page &&
|
|
||||||
action.page_control == 1) {
|
|
||||||
pitch_closed = true; returned_to_lineup = true;
|
|
||||||
}
|
|
||||||
} else if (result.status == app::LiveSubstitutionStatus::source_notice) {
|
|
||||||
show_live_substitution_notice(result, pitch.render(),
|
|
||||||
"OpenBMH - live_pitch");
|
|
||||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
|
||||||
updated.in_match = true; updated.entry_prepared = true;
|
|
||||||
pitch = ui::PitchScreen(data, std::move(updated),
|
|
||||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
|
||||||
} else {
|
|
||||||
pitch.reject_action(result.error.empty()
|
|
||||||
? "Der Spielerwechsel ist nicht freigegeben."
|
|
||||||
: result.error);
|
|
||||||
}
|
|
||||||
pitch_redrawn = true;
|
|
||||||
} else pitch_redrawn = true;
|
|
||||||
} else if (child.type == SDL_MOUSEBUTTONUP && pitch_right_down &&
|
|
||||||
child.button.button == SDL_BUTTON_RIGHT &&
|
|
||||||
child.button.x == pitch_right_down->x &&
|
|
||||||
child.button.y == pitch_right_down->y) {
|
|
||||||
pitch_right_down.reset();
|
|
||||||
if (pitch.close_requested()) { pitch_closed = true; closed = true; break; }
|
|
||||||
pitch_redrawn = true;
|
|
||||||
} else if (child.type == SDL_MOUSEMOTION)
|
|
||||||
pitch_redrawn |= pitch.move(child.motion.x, child.motion.y);
|
|
||||||
}
|
|
||||||
if (!pitch_redrawn && !pitch_closed && running) SDL_Delay(8);
|
|
||||||
}
|
|
||||||
SDL_SetWindowTitle(window, "OpenBMH - live_lineup");
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
std::fprintf(stderr, "live pitch: %s\n", e.what());
|
|
||||||
}
|
|
||||||
if (returned_to_lineup) {
|
|
||||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
|
||||||
updated.in_match = true; updated.entry_prepared = true;
|
|
||||||
screen = ui::LineupScreen(data, std::move(updated));
|
|
||||||
} else if (!closed) screen.resolve_local_navigation(request.kind);
|
|
||||||
redrawn = true;
|
|
||||||
} else redrawn = true;
|
|
||||||
} else if (modal.type == SDL_MOUSEMOTION)
|
|
||||||
redrawn |= screen.move(modal.motion.x, modal.motion.y);
|
redrawn |= screen.move(modal.motion.x, modal.motion.y);
|
||||||
|
}
|
||||||
|
if (closed) break;
|
||||||
}
|
}
|
||||||
if (!redrawn && !closed) SDL_Delay(8);
|
if (!redrawn && !closed) SDL_Delay(8);
|
||||||
}
|
}
|
||||||
@@ -2087,7 +1996,7 @@ int main(int argc, char** argv) {
|
|||||||
show_dialog();
|
show_dialog();
|
||||||
while (running && !outcome) {
|
while (running && !outcome) {
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; break; }
|
if (input.type == SDL_QUIT) { running = false; break; }
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (input.type == SDL_TEXTINPUT) {
|
if (input.type == SDL_TEXTINPUT) {
|
||||||
@@ -2187,7 +2096,7 @@ int main(int argc, char** argv) {
|
|||||||
while (running && !closed) {
|
while (running && !closed) {
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
bool redrawn = false;
|
bool redrawn = false;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; break; }
|
if (input.type == SDL_QUIT) { running = false; break; }
|
||||||
if (input.type == SDL_MOUSEMOTION) {
|
if (input.type == SDL_MOUSEMOTION) {
|
||||||
const bool changed = table_screen ? table_screen->move(input.motion.x, input.motion.y)
|
const bool changed = table_screen ? table_screen->move(input.motion.x, input.motion.y)
|
||||||
@@ -2265,7 +2174,8 @@ int main(int argc, char** argv) {
|
|||||||
live_frame_shown = true;
|
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)
|
if (live_frame_shown && !live_skipped && frame_delay > 0)
|
||||||
SDL_Delay(Uint32(frame_delay));
|
SDL_Delay(Uint32(frame_delay));
|
||||||
},
|
},
|
||||||
@@ -2296,7 +2206,7 @@ int main(int argc, char** argv) {
|
|||||||
offer_dirty = false;
|
offer_dirty = false;
|
||||||
}
|
}
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (quit_confirmation.poll(&event)) {
|
||||||
if (event.type == SDL_QUIT) { running = false; return -1; }
|
if (event.type == SDL_QUIT) { running = false; return -1; }
|
||||||
std::optional<int> answer;
|
std::optional<int> answer;
|
||||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||||
@@ -2365,7 +2275,7 @@ int main(int argc, char** argv) {
|
|||||||
rendered_phase = phase;
|
rendered_phase = phase;
|
||||||
}
|
}
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (quit_confirmation.poll(&event)) {
|
||||||
if (event.type == SDL_QUIT) { running = false; return; }
|
if (event.type == SDL_QUIT) { running = false; return; }
|
||||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))
|
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))
|
||||||
@@ -2393,7 +2303,7 @@ int main(int argc, char** argv) {
|
|||||||
bool dismissed = false;
|
bool dismissed = false;
|
||||||
while (running && !dismissed) {
|
while (running && !dismissed) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (quit_confirmation.poll(&event)) {
|
||||||
if (event.type == SDL_QUIT) { running = false; return; }
|
if (event.type == SDL_QUIT) { running = false; return; }
|
||||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||||
@@ -2547,7 +2457,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
SDL_Event modal;
|
SDL_Event modal;
|
||||||
bool redrawn = false;
|
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_QUIT) { running = false; closed = true; break; }
|
||||||
if (modal.type == SDL_MOUSEBUTTONDOWN &&
|
if (modal.type == SDL_MOUSEBUTTONDOWN &&
|
||||||
(modal.button.button == SDL_BUTTON_LEFT || modal.button.button == SDL_BUTTON_RIGHT))
|
(modal.button.button == SDL_BUTTON_LEFT || modal.button.button == SDL_BUTTON_RIGHT))
|
||||||
@@ -2612,7 +2522,7 @@ int main(int argc, char** argv) {
|
|||||||
bool resumed = false;
|
bool resumed = false;
|
||||||
while (running && !resumed) {
|
while (running && !resumed) {
|
||||||
SDL_Event paused_event;
|
SDL_Event paused_event;
|
||||||
while (SDL_PollEvent(&paused_event)) {
|
while (quit_confirmation.poll(&paused_event)) {
|
||||||
if (paused_event.type == SDL_QUIT) {
|
if (paused_event.type == SDL_QUIT) {
|
||||||
quit = true;
|
quit = true;
|
||||||
live_skipped = true;
|
live_skipped = true;
|
||||||
@@ -2725,11 +2635,12 @@ int main(int argc, char** argv) {
|
|||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
};
|
};
|
||||||
render_file();
|
render_file();
|
||||||
|
focus_filename_input(renderer);
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
while (running && !finished) {
|
while (running && !finished) {
|
||||||
SDL_Event file_input;
|
SDL_Event file_input;
|
||||||
bool file_changed = false;
|
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_QUIT) { running = false; break; }
|
||||||
if (file_input.type == SDL_MOUSEBUTTONUP &&
|
if (file_input.type == SDL_MOUSEBUTTONUP &&
|
||||||
(file_input.button.button == SDL_BUTTON_LEFT ||
|
(file_input.button.button == SDL_BUTTON_LEFT ||
|
||||||
@@ -2747,6 +2658,9 @@ int main(int argc, char** argv) {
|
|||||||
case SDLK_DOWN: key = "DOWN"; break;
|
case SDLK_DOWN: key = "DOWN"; break;
|
||||||
case SDLK_LEFT: key = "LEFT"; break;
|
case SDLK_LEFT: key = "LEFT"; break;
|
||||||
case SDLK_RIGHT: key = "RIGHT"; break;
|
case SDLK_RIGHT: key = "RIGHT"; break;
|
||||||
|
case SDLK_a:
|
||||||
|
if (file_input.key.keysym.mod & (KMOD_CTRL | KMOD_GUI)) key = "SELECT_ALL";
|
||||||
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
if (!key.empty()) file_changed |= file_screen.key(key);
|
if (!key.empty()) file_changed |= file_screen.key(key);
|
||||||
@@ -2786,7 +2700,7 @@ int main(int argc, char** argv) {
|
|||||||
while (running && !closed) {
|
while (running && !closed) {
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; break; }
|
if (input.type == SDL_QUIT) { running = false; break; }
|
||||||
if (readme) {
|
if (readme) {
|
||||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||||
@@ -2900,7 +2814,7 @@ int main(int argc, char** argv) {
|
|||||||
const bool source_phase_start = minute == 1 ||
|
const bool source_phase_start = minute == 1 ||
|
||||||
(state.indoor ? minute == 21 : (minute == 46 || minute == 91 || minute == 106));
|
(state.indoor ? minute == 21 : (minute == 46 || minute == 91 || minute == 106));
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (quit_confirmation.poll(&event)) {
|
||||||
if (event.type == SDL_QUIT) { quit = true; live_skipped = true; }
|
if (event.type == SDL_QUIT) { quit = true; live_skipped = true; }
|
||||||
else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)
|
else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)
|
||||||
live_skipped = true;
|
live_skipped = true;
|
||||||
@@ -3021,7 +2935,7 @@ int main(int argc, char** argv) {
|
|||||||
present(live_screen.render_ball(frame, event.displacement, index, chance));
|
present(live_screen.render_ball(frame, event.displacement, index, chance));
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
SDL_Event quit_event;
|
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;
|
running = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3058,7 +2972,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
SDL_Event quit_event;
|
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;
|
running = false;
|
||||||
live_chance_context.reset();
|
live_chance_context.reset();
|
||||||
return;
|
return;
|
||||||
@@ -3090,7 +3004,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
SDL_Event input;
|
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;
|
running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3112,7 +3026,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
bool acknowledged = false;
|
bool acknowledged = false;
|
||||||
while (running && !acknowledged) {
|
while (running && !acknowledged) {
|
||||||
while (SDL_PollEvent(&input)) {
|
while (quit_confirmation.poll(&input)) {
|
||||||
if (input.type == SDL_QUIT) { running = false; break; }
|
if (input.type == SDL_QUIT) { running = false; break; }
|
||||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||||
(input.button.button == SDL_BUTTON_LEFT || input.button.button == SDL_BUTTON_RIGHT)) {
|
(input.button.button == SDL_BUTTON_LEFT || input.button.button == SDL_BUTTON_RIGHT)) {
|
||||||
@@ -3147,7 +3061,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
||||||
SDL_RenderClear(renderer);SDL_RenderCopy(renderer,texture,nullptr,nullptr);SDL_RenderPresent(renderer);
|
SDL_RenderClear(renderer);SDL_RenderCopy(renderer,texture,nullptr,nullptr);SDL_RenderPresent(renderer);
|
||||||
SDL_PumpEvents();SDL_Event input;
|
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
|
// FirstThen holds the first frame for 40 retraces; later frames
|
||||||
// use saved Main_FormatError_RuntimeField2. Keyboard/mouse input remains for the minute hook.
|
// 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);
|
const int retraces=index==0?40:(state.memory.has(::bmh::layout::Main_FormatError_RuntimeField2)?state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField2):0);
|
||||||
@@ -3173,7 +3087,7 @@ int main(int argc, char** argv) {
|
|||||||
if (event.kind != 2 && app::match_sound_enabled(state))
|
if (event.kind != 2 && app::match_sound_enabled(state))
|
||||||
app::original_audio_command(playback, 17); // EventImpl/SDLPumpEvents, no injury whistle.
|
app::original_audio_command(playback, 17); // EventImpl/SDLPumpEvents, no injury whistle.
|
||||||
SDL_PumpEvents();SDL_Event input;
|
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 int pause=event.kind==0?3:4;
|
||||||
const uint32_t address=::bmh::layout::Main_FormatError_ExecutableFieldUnsigned+uint32_t(pause*9);
|
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;
|
const int saved=state.memory.has(address)?state.memory.u8(address):0;
|
||||||
@@ -3197,7 +3111,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
||||||
SDL_RenderClear(renderer);SDL_RenderCopy(renderer,texture,nullptr,nullptr);SDL_RenderPresent(renderer);
|
SDL_RenderClear(renderer);SDL_RenderCopy(renderer,texture,nullptr,nullptr);SDL_RenderPresent(renderer);
|
||||||
SDL_PumpEvents();SDL_Event input;
|
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 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 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;
|
const int delay=live_frame_ms_explicit?live_frame_ms:(saved<6?saved/2:saved)*20;
|
||||||
@@ -3261,16 +3175,16 @@ int main(int argc, char** argv) {
|
|||||||
present(reality_surface,reality_colors,"OpenBMH - live_reality_report_"+round_identity);
|
present(reality_surface,reality_colors,"OpenBMH - live_reality_report_"+round_identity);
|
||||||
}
|
}
|
||||||
SDL_PumpEvents();SDL_Event input;
|
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
|
// Consume only the Source exit for this scene. Other input remains
|
||||||
// queued for the existing live-minute/manager intervention boundary.
|
// 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) {
|
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) {
|
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;
|
return false;
|
||||||
}, [&](const PhaseResultRequest& request, const std::vector<MatchGroup>& groups,
|
}, [&](const PhaseResultRequest& request, const std::vector<MatchGroup>& groups,
|
||||||
@@ -3683,18 +3597,42 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
SDL_StartTextInput();
|
SDL_StartTextInput();
|
||||||
|
bool filename_input_active = false;
|
||||||
|
std::array<bool, 2> setup_button_down{};
|
||||||
while (running) {
|
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() &&
|
if(timed_notice_presented_at && flow.timed_notice_open() &&
|
||||||
SDL_GetTicks64()-*timed_notice_presented_at>=70*3*20)
|
SDL_GetTicks64()-*timed_notice_presented_at>=70*3*20)
|
||||||
handle(flow.expire_timed_notice());
|
handle(flow.expire_timed_notice());
|
||||||
service_process_timer();
|
service_process_timer();
|
||||||
if (!running) break;
|
if (!running) break;
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
while (SDL_PollEvent(&e)) {
|
while (quit_confirmation.poll(&e)) {
|
||||||
if (e.type == SDL_QUIT) {
|
if (e.type == SDL_QUIT) {
|
||||||
running = false;
|
running = false;
|
||||||
break;
|
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) {
|
if(e.type==SDL_MOUSEBUTTONUP&&timed_notice_release&&e.button.button==*timed_notice_release) {
|
||||||
timed_notice_release.reset();continue;
|
timed_notice_release.reset();continue;
|
||||||
}
|
}
|
||||||
@@ -3750,7 +3688,8 @@ int main(int argc, char** argv) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE &&
|
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;
|
running = false;
|
||||||
if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_LEFT)
|
if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_LEFT)
|
||||||
press = Press{e.button.x, e.button.y, SDL_GetTicks(), flow.screen_name(),
|
press = Press{e.button.x, e.button.y, SDL_GetTicks(), flow.screen_name(),
|
||||||
@@ -3866,6 +3805,11 @@ int main(int argc, char** argv) {
|
|||||||
std::fprintf(stderr, "input: %s\n", err.what());
|
std::fprintf(stderr, "input: %s\n", err.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (e.type == SDL_KEYDOWN && flow.screen_name() == "save_load" &&
|
||||||
|
e.key.keysym.sym == SDLK_a && (e.key.keysym.mod & (KMOD_CTRL | KMOD_GUI))) {
|
||||||
|
handle(flow.send_key("SELECT_ALL"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (e.type == SDL_KEYDOWN && (e.key.keysym.sym == SDLK_RETURN || e.key.keysym.sym == SDLK_BACKSPACE ||
|
if (e.type == SDL_KEYDOWN && (e.key.keysym.sym == SDLK_RETURN || e.key.keysym.sym == SDLK_BACKSPACE ||
|
||||||
(flow.screen_name() == "save_load" && (e.key.keysym.sym == SDLK_UP ||
|
(flow.screen_name() == "save_load" && (e.key.keysym.sym == SDLK_UP ||
|
||||||
e.key.keysym.sym == SDLK_DOWN || e.key.keysym.sym == SDLK_PAGEUP || e.key.keysym.sym == SDLK_PAGEDOWN)) ||
|
e.key.keysym.sym == SDLK_DOWN || e.key.keysym.sym == SDLK_PAGEUP || e.key.keysym.sym == SDLK_PAGEDOWN)) ||
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -1,11 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// 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 console and desktop share all six monthly environment budgets.
|
||||||
// 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.
|
|
||||||
|
|
||||||
#include "app/desktop_actions.hpp"
|
#include "app/desktop_actions.hpp"
|
||||||
#include "cli/console/console.hpp"
|
#include "cli/console/console.hpp"
|
||||||
@@ -19,20 +13,21 @@ using namespace detail;
|
|||||||
void Console::register_environment_commands() {
|
void Console::register_environment_commands() {
|
||||||
auto show = [this] {
|
auto show = [this] {
|
||||||
const EnvironmentState s = environment_state(session_->state(), active_slot());
|
const EnvironmentState s = environment_state(session_->state(), active_slot());
|
||||||
std::vector<std::vector<std::string>> rows = {
|
std::vector<std::vector<std::string>> rows;
|
||||||
{"AssistantCoach", std::to_string(s.level[kCoTrainer]), money(s.monthly[kCoTrainer])},
|
constexpr const char* names[] = {"YouthYoungest", "YouthAcademy", "YouthOldest", "AssistantCoach", "Doctor", "Physio"};
|
||||||
{"Doctor", std::to_string(s.level[kDoctor]), money(s.monthly[kDoctor])},
|
for (int i = 0; i < kEnvironmentItems; ++i)
|
||||||
{"Physio", std::to_string(s.level[kPhysio]), money(s.monthly[kPhysio])},
|
rows.push_back({names[i], std::to_string(s.level[size_t(i)]), money(s.monthly[size_t(i)])});
|
||||||
{"YouthAcademy", s.monthly[kYouthAcademy] != 0 ? "on" : "off", money(s.youth_price) + " per season"}};
|
emit_table({"Item", "Level", "MonthlyCosts"}, rows);
|
||||||
emit_table({"Item", "Level", "Costs"}, rows);
|
rows.clear();
|
||||||
emit('i', std::string("youth academy: ") + (s.youth_paid ? "paid this season" : s.youth_open ? "can be started (July/August)"
|
for (size_t i = 0; i < 3; ++i)
|
||||||
: "too late for this season"));
|
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] {
|
openers_[24] = [this, show] {
|
||||||
open_window("Environment");
|
open_window("Environment");
|
||||||
show();
|
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) {
|
auto apply = [this, show](int item, int level) {
|
||||||
std::string error;
|
std::string error;
|
||||||
const auto r=app::EnvironmentActions(*session_).set_console(
|
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)},
|
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},
|
"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"))); });
|
[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) {
|
[this, apply](const Values& v) {
|
||||||
const bool on = environment_state(session_->state(), active_slot()).monthly[kYouthAcademy] != 0;
|
const bool on = environment_state(session_->state(), active_slot()).monthly[kYouthAcademy] != 0;
|
||||||
const bool want = v.choice("state") == 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"));
|
if (on == want) emit('+', std::string("youth academy already ") + (on ? "on" : "off"));
|
||||||
else apply(kYouthAcademy, want ? 6 : 0);
|
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 EnglishLayoutTranslation157 = 0x6e094;
|
||||||
inline constexpr auto EnglishLayoutTranslation158 = 0x6e0b8;
|
inline constexpr auto EnglishLayoutTranslation158 = 0x6e0b8;
|
||||||
inline constexpr auto EnglishLayoutTranslation159 = 0x6e0bb;
|
inline constexpr auto EnglishLayoutTranslation159 = 0x6e0bb;
|
||||||
inline constexpr auto EnglishLayoutTranslation16 = 0x6be4f;
|
inline constexpr auto EnglishLayoutTranslation16 = 0x6be50;
|
||||||
inline constexpr auto EnglishLayoutTranslation160 = 0x6e0d8;
|
inline constexpr auto EnglishLayoutTranslation160 = 0x6e0d8;
|
||||||
inline constexpr auto EnglishLayoutTranslation161 = 0x6e110;
|
inline constexpr auto EnglishLayoutTranslation161 = 0x6e110;
|
||||||
inline constexpr auto EnglishLayoutTranslation162 = 0x6e11c;
|
inline constexpr auto EnglishLayoutTranslation162 = 0x6e11c;
|
||||||
@@ -986,7 +986,7 @@ inline constexpr auto EnglishLayoutTranslation7 = 0x6be0c;
|
|||||||
inline constexpr auto EnglishLayoutTranslation70 = 0x6d270;
|
inline constexpr auto EnglishLayoutTranslation70 = 0x6d270;
|
||||||
inline constexpr auto EnglishLayoutTranslation71 = 0x6d272;
|
inline constexpr auto EnglishLayoutTranslation71 = 0x6d272;
|
||||||
inline constexpr auto EnglishLayoutTranslation72 = 0x6d274;
|
inline constexpr auto EnglishLayoutTranslation72 = 0x6d274;
|
||||||
inline constexpr auto EnglishLayoutTranslation73 = 0x6d29c;
|
inline constexpr auto EnglishLayoutTranslation73 = 0x6d29d;
|
||||||
inline constexpr auto EnglishLayoutTranslation74 = 0x6d3b4;
|
inline constexpr auto EnglishLayoutTranslation74 = 0x6d3b4;
|
||||||
inline constexpr auto EnglishLayoutTranslation75 = 0x6d404;
|
inline constexpr auto EnglishLayoutTranslation75 = 0x6d404;
|
||||||
inline constexpr auto EnglishLayoutTranslation76 = 0x6d408;
|
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_RuntimeField = 0xa50f0;
|
||||||
inline constexpr auto Environment_FormatError_RuntimeField2 = 0xa50f6;
|
inline constexpr auto Environment_FormatError_RuntimeField2 = 0xa50f6;
|
||||||
inline constexpr auto Environment_Render_TextPointer = 0xaeb74;
|
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 Environment_SetEnvironment_ExecutableField = 0xaf394;
|
||||||
inline constexpr auto EuropeNameTable = 0xae710;
|
inline constexpr auto EuropeNameTable = 0xae710;
|
||||||
inline constexpr auto EventPasses = 0xa2ba1;
|
inline constexpr auto EventPasses = 0xa2ba1;
|
||||||
@@ -1471,6 +1476,9 @@ inline constexpr auto Pitch_Render_TextPointer2 = 0xae0ec;
|
|||||||
inline constexpr auto Pitch_Render_TextPointer3 = 0xae0f0;
|
inline constexpr auto Pitch_Render_TextPointer3 = 0xae0f0;
|
||||||
inline constexpr auto Pitch_Render_TextPointer4 = 0xae0f4;
|
inline constexpr auto Pitch_Render_TextPointer4 = 0xae0f4;
|
||||||
inline constexpr auto Pitch_Render_TextPointer5 = 0xae0f8;
|
inline constexpr auto Pitch_Render_TextPointer5 = 0xae0f8;
|
||||||
|
inline constexpr auto PitchOrderPositionPointers = 0xa2a37;
|
||||||
|
inline constexpr auto PitchOrderZoneMasks = 0xa2a4b;
|
||||||
|
inline constexpr auto PitchOrderZoneTextPointers = 0xae818;
|
||||||
inline constexpr auto Placements = 0xbd38c;
|
inline constexpr auto Placements = 0xbd38c;
|
||||||
inline constexpr auto PlainBackground = 0xa2569;
|
inline constexpr auto PlainBackground = 0xa2569;
|
||||||
inline constexpr auto PlanTicketPrice = 0xa4856;
|
inline constexpr auto PlanTicketPrice = 0xa4856;
|
||||||
@@ -1964,4 +1972,19 @@ inline constexpr auto EnglishFourTeamFixtureTable = 0x6eea0;
|
|||||||
inline constexpr auto EnglishSixTeamFixtureTable = 0x6eed4;
|
inline constexpr auto EnglishSixTeamFixtureTable = 0x6eed4;
|
||||||
inline constexpr auto EnglishTwelveTeamFixtureTable = 0x6f0bc;
|
inline constexpr auto EnglishTwelveTeamFixtureTable = 0x6f0bc;
|
||||||
inline constexpr auto EnglishTwentyTeamFixtureTable = 0x6ee40;
|
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
|
||||||
|
|
||||||
|
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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/le.hpp"
|
#include "formats/le.hpp"
|
||||||
#include "formats/rule_base.hpp"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fstream>
|
#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);
|
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");
|
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()));
|
LeImage img = LeImage::from_bytes(base, Bytes(raw.begin() + sizeof kImageMagic + 8, raw.end()));
|
||||||
apply_rule_base(img);
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
auto u8 = [&](size_t o) -> uint32_t {
|
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;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -29,7 +29,7 @@ public:
|
|||||||
// The string a pointer variable at `address` points to (e.g. Weekly_AdvertisingOffers_TextPointer).
|
// 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)); }
|
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_); }
|
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) {
|
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];
|
for (size_t i = 0; i < count; ++i) bytes_.at(address - base_ + i) = bytes[i];
|
||||||
}
|
}
|
||||||
@@ -51,10 +51,8 @@ private:
|
|||||||
Bytes bytes_;
|
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.
|
// 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);
|
LeImage load_le(const std::filesystem::path& path);
|
||||||
|
|
||||||
// The OpenBMH image format: "OPENBMH-IMAGE" NUL, u32 base, u32 size, the bytes. load_le()
|
// 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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
|
#include "game/environment.hpp"
|
||||||
#include "game/balance_plan.hpp"
|
#include "game/balance_plan.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -160,13 +161,6 @@ uint32_t catering_per_game(const GameState& g, int m, int32_t gate) {
|
|||||||
return sum;
|
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
|
// 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
|
// Redraw2): recomputes the items if `refresh` asks for it, then the spectator income
|
||||||
// and the totals.
|
// 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);
|
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]);
|
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);
|
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;
|
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) {
|
for (int k = 0; k < 3; ++k) {
|
||||||
const int32_t limit = youth_limit(g, m);
|
const auto value = environment_monthly_cost(g, m, k);
|
||||||
if (uint32_t(rec32(g, m, 0x880)) < uint32_t(limit)) r[9] = wrap(int64_t(r[9]) + limit);
|
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 < 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));
|
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));
|
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));
|
costs = wrap(int64_t(costs) + monthly_pay(g, m, 0xa));
|
||||||
for (int k = 0; k < 6; ++k) {
|
for (int k = 0; k < 6; ++k) {
|
||||||
int32_t value = mem32(g, ::bmh::layout::Spending + uint32_t(m) * 0x24 + uint32_t(k) * 4);
|
const int32_t value = environment_monthly_cost(g, m, k);
|
||||||
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;
|
|
||||||
costs = wrap(int64_t(costs) + value);
|
costs = wrap(int64_t(costs) + value);
|
||||||
}
|
}
|
||||||
costs = wrap(int64_t(costs) - shares_and_loans(g, m, 2, 0) + int(rec8(g, m, 0x179)) * 1000);
|
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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#pragma once
|
#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
|
// 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
|
// 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
|
// 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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "game/career.hpp"
|
#include "game/career.hpp"
|
||||||
|
#include "game/lineup.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -20,11 +21,29 @@ constexpr int kLeagueTeams = 138; // CareerSession_DispatchLineup_RuntimeFie
|
|||||||
|
|
||||||
// LeagueSizes: clubs per league; LeagueStrengthRanges: (minimum, maximum) strength per league.
|
// LeagueSizes: clubs per league; LeagueStrengthRanges: (minimum, maximum) strength per league.
|
||||||
// (the clubs per league are kLeagueSizes, schedule.hpp)
|
// (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}};
|
{85, 95}, {90, 95}, {75, 95}, {80, 95}};
|
||||||
|
|
||||||
} // namespace
|
} // 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) {
|
void generate_player(GameState& g, int id, int level_flags, GameRandom& game, WatcomRandom& rand) {
|
||||||
Player& p = g.players.at(size_t(id));
|
Player& p = g.players.at(size_t(id));
|
||||||
const bool keep_age = (level_flags & 0x1000) != 0, exact = (level_flags & 0x2000) != 0;
|
const bool keep_age = (level_flags & 0x1000) != 0, exact = (level_flags & 0x2000) != 0;
|
||||||
|
|||||||
@@ -24,6 +24,10 @@
|
|||||||
|
|
||||||
namespace bmh {
|
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.
|
// 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
|
// 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
|
// `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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "game/environment.hpp"
|
#include "game/environment.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstdlib>
|
||||||
#include "game/messages.hpp"
|
#include <utility>
|
||||||
#include "game/schedule.hpp"
|
|
||||||
#include "game/week.hpp"
|
|
||||||
|
|
||||||
namespace bmh {
|
namespace bmh {
|
||||||
|
|
||||||
namespace {
|
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
|
uint32_t youth_at(int manager) { return layout::EnvironmentYouthTeams + uint32_t(manager) * 0x24; }
|
||||||
constexpr size_t kRecordSize = 0xb0c;
|
uint32_t spending_at(int manager, int item) {
|
||||||
constexpr size_t kYouthPaid = 0x880; // youth expenses booked this season
|
return layout::Spending + uint32_t(manager) * 0x24 + uint32_t(item) * 4;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
void validate_manager(const GameState& g, int manager) {
|
||||||
// YouthOpen: July (unless the Bundesliga is past its 17th round) or August
|
if (manager < 0 || size_t(manager) >= g.manager_teams.size() ||
|
||||||
bool youth_open(const GameState& g) {
|
!g.memory.has(youth_at(manager) + 8) || !g.memory.has(spending_at(manager, 5) + 3))
|
||||||
const int month = month_code(g.date);
|
throw FormatError("environment: invalid manager or truncated budgets");
|
||||||
if (month == 7) return !(g.league_rounds.at(0) > 0x11);
|
|
||||||
return month == 8;
|
|
||||||
}
|
}
|
||||||
|
int direction(int value) { return (value > 0) - (value < 0); }
|
||||||
bool youth_paid(const GameState& g, int manager) {
|
int signed_clamp(int value, int low, int high) {
|
||||||
const size_t at = size_t(manager) * kRecordSize + kYouthPaid;
|
return std::clamp(int(int8_t(uint8_t(value))), low, high);
|
||||||
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;
|
bool legacy_academy(const GameState& g, int manager) {
|
||||||
return paid >= uint32_t(youth_price(g, 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 environment_state(const GameState& g, int manager) {
|
||||||
EnvironmentState s;
|
if (!supported_environment) throw FormatError("environment: this original program variant is not verified");
|
||||||
for (int i = 0; i < kEnvironmentItems; i++) {
|
validate_manager(g, manager);
|
||||||
s.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
|
EnvironmentState result;
|
||||||
// the stars (SizeT7): staff value / step, the academy 6 when on, 0/2 none
|
for (int i = 0; i < kEnvironmentItems; ++i) {
|
||||||
if (i >= 3) s.level[size_t(i)] = std::clamp(s.monthly[size_t(i)] / (kUnit[i] * 1000), 0, 6);
|
result.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
|
||||||
else if (i == kYouthAcademy) s.level[size_t(i)] = s.monthly[size_t(i)] != 0 ? 6 : 0;
|
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);
|
for (uint32_t i = 0; i < 3; ++i) {
|
||||||
s.youth_paid = youth_paid(g, manager);
|
result.youth_strength[i] = g.memory.u8(youth_at(manager) + i);
|
||||||
s.youth_open = youth_open(g);
|
result.youth_position[i] = g.memory.u8(youth_at(manager) + 3 + i);
|
||||||
return s;
|
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");
|
||||||
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.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
g.memory.set32(at, uint32_t(value));
|
|
||||||
if (result == EnvironmentResult::changed && value == before) result = EnvironmentResult::unchanged;
|
|
||||||
return result;
|
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
|
} // namespace bmh
|
||||||
+21
-33
@@ -1,47 +1,35 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#pragma once
|
#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 <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "game/random.hpp"
|
||||||
|
#include "formats/le.hpp"
|
||||||
#include "game/state.hpp"
|
#include "game/state.hpp"
|
||||||
|
|
||||||
namespace bmh {
|
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;
|
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 {
|
struct EnvironmentState {
|
||||||
std::array<int32_t, kEnvironmentItems> monthly{}; // Spending values
|
std::array<int32_t, kEnvironmentItems> monthly{};
|
||||||
std::array<int, kEnvironmentItems> level{}; // the stars the screen draws (0..6)
|
std::array<int, kEnvironmentItems> level{};
|
||||||
int32_t youth_price = 0; // the season price of the academy for the club's league
|
std::array<uint8_t, 3> youth_strength{}, youth_position{}, youth_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
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EnvironmentState environment_state(const GameState& g, int manager);
|
EnvironmentState environment_state(const GameState& g, int manager);
|
||||||
|
// Preserve already saved lump-sum academy contracts until the user edits them.
|
||||||
enum class EnvironmentResult : uint8_t { changed, unchanged, too_late, contract_runs, invalid };
|
int32_t environment_monthly_cost(const GameState& g, int manager, int item);
|
||||||
|
bool environment_academy_active(const GameState& g, int manager);
|
||||||
// A click on `item` at `level` (0..6; for the academy any level > 0 means "on" and a click on
|
enum class EnvironmentResult : uint8_t { changed, unchanged, invalid };
|
||||||
// an active academy switches it off). `message` gets the original's message box text, if any.
|
// 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);
|
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
|
} // namespace bmh
|
||||||
+54
-2
@@ -1,6 +1,9 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "game/lineup.hpp"
|
#include "game/lineup.hpp"
|
||||||
|
#include "formats/le.hpp"
|
||||||
|
#include "game/match.hpp"
|
||||||
|
#include "game/weekly.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -10,6 +13,7 @@
|
|||||||
namespace bmh {
|
namespace bmh {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
bool original_foreign_limit_enabled = false;
|
||||||
|
|
||||||
// Position type by formation depth x (table at layout field).
|
// 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};
|
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) {
|
static void auto_lineup_impl(GameState& g, int team, int mode, int manager) {
|
||||||
if (team >= 138 && team != kNoTeam) return; // teams without squads
|
if (team >= 138 && team != kNoTeam) return; // teams without squads
|
||||||
if (g.lineups_frozen) return; // LineupRuntimeField (the season change)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// OpenBMH deviates from the original: disables the foreign-player limit in the supported rule profile.
|
if (original_foreign_limit_enabled) {
|
||||||
// (foreign-player limit ForeignPlayerLimitEnabled is off in the supported rule profile)
|
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
|
// 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).
|
// (relative to the squad start) in bits 0-4 of his card word (*PlayerCards).
|
||||||
if (!first_eleven_only && !g.player_cards.empty())
|
if (!first_eleven_only && !g.player_cards.empty())
|
||||||
|
|||||||
+7
-3
@@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#pragma once
|
#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.
|
// 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
|
// 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.
|
// 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
|
// 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 <cstdint>
|
||||||
#include <array>
|
#include <array>
|
||||||
@@ -30,6 +30,10 @@
|
|||||||
#include "game/state.hpp"
|
#include "game/state.hpp"
|
||||||
|
|
||||||
namespace bmh {
|
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`
|
// Games: in-place quicksort (Hoare partition, middle element as pivot) of `keys`
|
||||||
// descending (ascending if `ascending`), comparing as unsigned 32-bit, moving `items`
|
// 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,
|
int formation, uint8_t expected_weights,
|
||||||
const std::array<uint8_t, 22>& formation_positions);
|
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
|
// supported rule profile NormalizePitchSetPieceSource/NormalizePitchSetPieceSource3/NormalizePitchSetPieceSource2/NormalizePitchSetPieceSource4: deterministic, owner-bound
|
||||||
// set-piece presentation state. Stored takers are player_id+1; zero is AUTO.
|
// 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);
|
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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
|
#include "game/environment.hpp"
|
||||||
#include "game/matchday.hpp"
|
#include "game/matchday.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#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.
|
// ManagerOf(manager, 0, value): the manager's position of this season.
|
||||||
static void store_season_position(GameState& g, int manager, int value) {
|
static void store_season_position(GameState& g, int manager, int value) {
|
||||||
int season = std::min(g.season, 0x31);
|
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++) {
|
for (int league = kFirst[c]; league < kFirst[c] + kCount[c]; league++) {
|
||||||
if (league == 0) {
|
if (league == 0) {
|
||||||
for (size_t m = 0; m < g.manager_teams.size(); m++) {
|
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;
|
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));
|
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
|
uint8_t& d = g.manager_records.at(rec + 0x220); // point deduction countdown
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "game/messages.hpp"
|
#include "game/messages.hpp"
|
||||||
|
#include "game/schedule.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#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); }
|
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
|
} // namespace bmh
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "formats/le.hpp"
|
||||||
#include "game/state.hpp"
|
#include "game/state.hpp"
|
||||||
|
|
||||||
namespace bmh {
|
namespace bmh {
|
||||||
@@ -59,6 +60,11 @@ inline std::string kIndoorInvitationText;
|
|||||||
inline std::string kChampionshipBonusText;
|
inline std::string kChampionshipBonusText;
|
||||||
inline std::string kFriendlyPayerPrefixText;
|
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
|
// 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".
|
// value converted with CurrencyMultiplier / CurrencyDivisor, digits grouped by dots, then " EU".
|
||||||
std::string format_amount(const GameState& g, int32_t value);
|
std::string format_amount(const GameState& g, int32_t value);
|
||||||
|
|||||||
+3
-15
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
|
#include "game/environment.hpp"
|
||||||
#include "game/month.hpp"
|
#include "game/month.hpp"
|
||||||
#include "game/trace.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
|
// OriginalFinancePreview(1): the month's expenses of a human manager: facility maintenance
|
||||||
// (BMHExeXa), record +0x854/+0x858, the wages of the squad (MonthlyPay with flags
|
// (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
|
// 14), all six monthly environment budgets and the debt
|
||||||
// supported rule profile patch MonthlyExpenses, which also drops the youth groups 0 and 2) and the debt
|
|
||||||
// service (+0x179 x 1000); each booked in the statistics.
|
// service (+0x179 x 1000); each booked in the statistics.
|
||||||
int32_t monthly_expenses(GameState& g, int m) {
|
int32_t monthly_expenses(GameState& g, int m) {
|
||||||
std::vector<uint8_t>& r = g.manager_records;
|
std::vector<uint8_t>& r = g.manager_records;
|
||||||
@@ -514,18 +513,7 @@ int32_t monthly_expenses(GameState& g, int m) {
|
|||||||
}
|
}
|
||||||
sum += wages;
|
sum += wages;
|
||||||
for (int k = 0; k < 6; k++) {
|
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));
|
const int32_t v = environment_monthly_cost(g, m, k);
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
if (k >= 3 && k <= 5) add32(r, rec + 0x878 + size_t(k) * 4, v);
|
if (k >= 3 && k <= 5) add32(r, rec + 0x878 + size_t(k) * 4, v);
|
||||||
else add32(r, rec + 0x880, v);
|
else add32(r, rec + 0x880, v);
|
||||||
sum += 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;
|
if (std::none_of(moved.begin(), moved.end(), [&](const LeagueMatchRef& m) { return m.day == day; })) return false;
|
||||||
const int team = manager_team(g, manager);
|
const int team = manager_team(g, manager);
|
||||||
// UndoReschedule(day, 1, team): every replay of the club on that day, whatever its league
|
// 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++) {
|
for (int e = 0; e < kPostponedEntries; e++) {
|
||||||
const uint32_t at = kPostponed + uint32_t(e) * 6;
|
const uint32_t at = kPostponed + uint32_t(e) * 6;
|
||||||
if (g.memory.u16(at) != uint16_t(day)) continue;
|
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 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));
|
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.results.at(result_at(league, round, m)) = kNotPlayed;
|
||||||
g.memory.set16(at, 0);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
// matchday the 0xCE turns into 0xCD (matchday_setup) and the match is played on the
|
// matchday the 0xCE turns into 0xCD (matchday_setup) and the match is played on the
|
||||||
// new day like a winter postponement.
|
// new day like a winter postponement.
|
||||||
// 4. A click on the new day of a moved match takes the move back (UndoReschedule(day, 1,
|
// 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
|
// team)): the entry is freed and the result byte is 0xCC again. When no replay of another
|
||||||
// 0x4000, as in the original.
|
// 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
|
// Everything here works on the saved GameState only: no random numbers are drawn, so a
|
||||||
// rescheduled career stays deterministic.
|
// rescheduled career stays deterministic.
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "game/save.hpp"
|
#include "game/save.hpp"
|
||||||
|
#include "game/calendar.hpp"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#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));
|
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).
|
// four-year leap cycle that starts with the third year).
|
||||||
std::string date_text(uint32_t counter) {
|
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};
|
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;
|
if (++month == 13) month = 1, ++years;
|
||||||
}
|
}
|
||||||
char buf[16];
|
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;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+41
-20
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
|
#include "game/environment.hpp"
|
||||||
#include "game/season.hpp"
|
#include "game/season.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -641,25 +642,21 @@ namespace {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// 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.
|
||||||
// YouthAcademyPlayer(manager) with the supported rule profile patch (SeasonOperation2, SeasonOperation3, SeasonOperation4,
|
// The middle youth budget enables the existing enhanced academy recruitment.
|
||||||
// SeasonOperation5): the youth academy's player at the season accounts. Only when the academy
|
// Old lump-sum contracts remain eligible after their saved season payment.
|
||||||
// was paid in full this season (record +0x880 reached the league's price, TeamLeague3) and
|
// Player search, strength bands, age and board setup retain the shared rules.
|
||||||
// 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.
|
|
||||||
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report) {
|
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 team = g.manager_teams.at(size_t(m));
|
||||||
const int league = club_league(team);
|
const int league = club_league(team);
|
||||||
const uint32_t price = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
if (!environment_academy_active(g, m)) return false;
|
||||||
if (uint32_t(rec32(g, m, 0x880)) < price) return false;
|
|
||||||
if (squad_count(g, team, 3) > 0x16) 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);
|
const SquadRange own = squad_range(team);
|
||||||
if (game.range(0, 0) != 0) return false;
|
if (game.range(0, 0) != 0) return false;
|
||||||
for (int t = 0xf;; --t) {
|
for (int t = 0xf;; --t) {
|
||||||
@@ -708,6 +705,7 @@ namespace {
|
|||||||
void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report,
|
void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report,
|
||||||
const SeasonTaxHooks& tax_hooks, SeasonTaxState& tax_state) {
|
const SeasonTaxHooks& tax_hooks, SeasonTaxState& tax_state) {
|
||||||
for (size_t i = 0; i < 0xc; i++) rec8(g, m, 0x754 + i) = 0;
|
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)
|
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);
|
g.memory.set8(::bmh::layout::Season_SeasonAccounts_RuntimeField + uint32_t(m), 0);
|
||||||
season_event(g, m, game, rand, report);
|
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);
|
const SquadRange range = squad_range(team);
|
||||||
for (size_t s = 0; s < 24; s++)
|
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);
|
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.
|
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||||
// YouthAcademyPlayer: the youth academy's player (supported rule profile), posted as Season_SeasonAccounts_TextPointer
|
// 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 (youth_academy_player(g, m, game, rand, report)) post_text(g, m, text_id(::bmh::layout::Season_SeasonAccounts_TextPointer));
|
||||||
if (report.unsupported) return;
|
if (report.unsupported) return;
|
||||||
if (league == 0 && pos < 100) rec8(g, m, 0x21c) = 1; // the best human club of the first division
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// CareerSeasonSetup3: the players' new season. Records and boards of the managers restart
|
// CareerSeasonSetup3: the players' new season. Records and boards of the managers restart
|
||||||
// (with new advertising offers, TransferListCountdown2); then every squad and pool slot: players
|
// (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;
|
// 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
|
uint8_t count = 0xff; // local_20
|
||||||
int8_t owner = -1; // local_24: the club's human manager
|
int8_t owner = -1; // local_24: the club's human manager
|
||||||
size_t board_first = 0; // local_3c
|
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 (int s = 0; s < 0xc00 && !report.unsupported; s++) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const int player = g.squad_slots.at(size_t(s)) & 0xFFF;
|
const int player = g.squad_slots.at(size_t(s)) & 0xFFF;
|
||||||
if (player == 0xFFF) break;
|
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);
|
const int team = slot_team(s);
|
||||||
if (team != int(last_team)) { // (-1 for the pool never equals 0xFFFF)
|
if (team != int(last_team)) { // (-1 for the pool never equals 0xFFFF)
|
||||||
count = 0xff;
|
count = 0xff;
|
||||||
@@ -1236,7 +1238,9 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
|
|||||||
// a year older
|
// a year older
|
||||||
p.w368 &= 0xf8003fffu;
|
p.w368 &= 0xf8003fffu;
|
||||||
int age = int16_t(((p.w364 >> 21) & 0x1f) + 1);
|
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 != 0xff) count = uint8_t(squad_count(g, team, 2) + loans[team]);
|
||||||
if (count > 0xd) {
|
if (count > 0xd) {
|
||||||
count--;
|
count--;
|
||||||
@@ -1254,6 +1258,10 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
|
|||||||
if (std::getenv("BMH_TRACE"))
|
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);
|
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;
|
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;
|
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));
|
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
|
// 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
|
// (SeasonEndSteps), the managers' season record starts (ManagerOf(m, 0, -2)), the
|
||||||
// limited game length counts down (CareerDuration), the days pass (DayStepRest) up to 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 {
|
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,
|
bool career_season_setup(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteReport& report,
|
||||||
const std::function<void(const char*)>& pause,
|
const std::function<void(const char*)>& pause,
|
||||||
const SeasonCupDrawHook& cup_draw) {
|
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_RuntimeField5, uint16_t(first_small + 0x1f));
|
||||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField4, uint16_t(first_small + 0x13));
|
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField4, uint16_t(first_small + 0x13));
|
||||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField3, uint16_t(foreign + 1));
|
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::Career_CompetitionPointersEnglish_ExecutableField28, 0);
|
||||||
mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField6, 0);
|
mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField6, 0);
|
||||||
mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField5, 7);
|
mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField5, 7);
|
||||||
|
|||||||
+13
-5
@@ -1,7 +1,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#pragma once
|
#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).
|
// 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
|
// 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.
|
// offer slots (transfer list entries 0x28..0x2b, OfferSlots) are freed.
|
||||||
void free_offer_slots(GameState& g);
|
void free_offer_slots(GameState& g);
|
||||||
|
|
||||||
// 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.
|
||||||
// YouthAcademyPlayer (supported rule profile youth academy, season accounts): when manager `m` paid the academy in
|
// Annual recruitment with an active middle youth budget (or a paid legacy
|
||||||
// full this season (+0x880) and has room, a young player of a computer club joins his squad
|
// academy contract), provided the squad has room. Shared player strength bands
|
||||||
// with values by the league (see season.cpp). Returns whether one came.
|
// remain in effect; see season.cpp.
|
||||||
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report);
|
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
|
// 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).
|
// 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);
|
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
|
// 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,
|
// 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
|
// 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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "game/week.hpp"
|
#include "game/week.hpp"
|
||||||
|
#include "game/calendar.hpp"
|
||||||
|
|
||||||
#include "game/matchday.hpp"
|
#include "game/matchday.hpp"
|
||||||
#include "game/lineup.hpp"
|
#include "game/lineup.hpp"
|
||||||
@@ -93,9 +94,7 @@ int attribute(Player& p, int area, bool write, int delta, int max) {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int weekday_code(uint32_t date) {
|
int weekday_code(uint32_t date) {
|
||||||
int c = int(date % 7) + 2;
|
return int((date % 7 + uint32_t(calendar_epoch().weekday)) % 7);
|
||||||
if (c > 6) c = int(date % 7) - 5;
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void familiarity_decay(GameState& g, GameRandom& game, WatcomRandom& rand) {
|
void familiarity_decay(GameState& g, GameRandom& game, WatcomRandom& rand) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "formats/binary.hpp"
|
#include "formats/binary.hpp"
|
||||||
#include "formats/rule_base.hpp"
|
|
||||||
#include "launch/archive.hpp"
|
#include "launch/archive.hpp"
|
||||||
#include "launch/game_data.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));
|
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
|
||||||
apply_rule_base(out);
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,9 @@
|
|||||||
{::bmh::layout::TeamStatistics_Render_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation72, {}},
|
{::bmh::layout::TeamStatistics_Render_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation72, {}},
|
||||||
{::bmh::layout::DeskDrawers_Curve_ExecutableField, 24, Kind::copy, ::bmh::layout::EnglishLayoutTranslation160, {}},
|
{::bmh::layout::DeskDrawers_Curve_ExecutableField, 24, Kind::copy, ::bmh::layout::EnglishLayoutTranslation160, {}},
|
||||||
{::bmh::layout::DeskState_FormatError_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation161, {}},
|
{::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_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation224, {}},
|
||||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation225, {}},
|
{::bmh::layout::Tactics_DrawSetting_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation225, {}},
|
||||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField3, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation226, {}},
|
{::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";
|
const fs::path marker = prepared / ".openbmh-english";
|
||||||
// the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built
|
// the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built
|
||||||
// by another version is built again
|
// 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::string built;
|
||||||
{
|
{
|
||||||
std::ifstream in(marker);
|
std::ifstream in(marker);
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ target_link_libraries(openbmh_ui PRIVATE bmhui ${BMH_SDL_TARGET})
|
|||||||
add_executable(ui_setup_tests tests.cpp)
|
add_executable(ui_setup_tests tests.cpp)
|
||||||
target_link_libraries(ui_setup_tests PRIVATE bmhui)
|
target_link_libraries(ui_setup_tests PRIVATE bmhui)
|
||||||
bmh_add_data_test(NAME ui_setup_tests COMMAND ui_setup_tests "${BMH_DATA}")
|
bmh_add_data_test(NAME ui_setup_tests COMMAND ui_setup_tests "${BMH_DATA}")
|
||||||
|
|
||||||
|
add_executable(ui_save_load_tests save_load_tests.cpp)
|
||||||
|
target_link_libraries(ui_save_load_tests PRIVATE bmhui)
|
||||||
|
bmh_add_data_test(NAME ui_save_load_tests COMMAND ui_save_load_tests "${BMH_DATA}")
|
||||||
add_executable(ui_national_friendly_tests ../../tests/national_friendly_ui_tests.cpp)
|
add_executable(ui_national_friendly_tests ../../tests/national_friendly_ui_tests.cpp)
|
||||||
target_link_libraries(ui_national_friendly_tests PRIVATE bmhui)
|
target_link_libraries(ui_national_friendly_tests PRIVATE bmhui)
|
||||||
add_test(NAME ui_national_friendly_tests COMMAND ui_national_friendly_tests)
|
add_test(NAME ui_national_friendly_tests COMMAND ui_national_friendly_tests)
|
||||||
|
|||||||
+4
-14
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
|
#include "game/environment.hpp"
|
||||||
#include "ui/advertising.hpp"
|
#include "ui/advertising.hpp"
|
||||||
#include "ui/game_end.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)];
|
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)));
|
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
|
// 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;
|
int32_t expenses = 0;
|
||||||
for (int i = 0; i < 14; ++i) expenses = wrap_add(expenses, kFacilityCost[size_t(i)]);
|
for (int i = 0; i < 14; ++i) expenses = wrap_add(expenses, kFacilityCost[size_t(i)]);
|
||||||
for (int i = 14; i < 22; ++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, signed32(u32(game.tactics, board + 0x50)));
|
||||||
expenses = wrap_add(expenses, int32_t(bonus));
|
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) {
|
for (int k = 0; k < 6; ++k) {
|
||||||
int32_t item = mem_i32(game, ::bmh::layout::Spending + uint32_t(manager) * 0x24 + uint32_t(k) * 4);
|
const int32_t item = environment_monthly_cost(game, manager, k);
|
||||||
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;
|
|
||||||
}
|
|
||||||
expenses = wrap_add(expenses, item);
|
expenses = wrap_add(expenses, item);
|
||||||
}
|
}
|
||||||
expenses = wrap_add(expenses, wrap_neg(original_share_adjustment(game, manager, false)));
|
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 + 4, 99);
|
||||||
cap_fixture.memory.set32(::bmh::layout::Spending, 111);
|
cap_fixture.memory.set32(::bmh::layout::Spending, 111);
|
||||||
cap_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
|
cap_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
|
||||||
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 1543400,
|
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 43832,
|
||||||
"costs 0/2 stay zero while the youth-cost item uses the source league cap");
|
"all three youth budgets enter the monthly finance preview");
|
||||||
put32(cap_fixture.manager_records, 0x880, 1500000);
|
put32(cap_fixture.manager_records, 0x880, 1500000);
|
||||||
const auto no_cap_preview = advertising_from_game(cap_fixture, 0).finance_preview;
|
const auto no_cap_preview = advertising_from_game(cap_fixture, 0).finance_preview;
|
||||||
check(no_cap_preview.expenses == 43400,
|
check(no_cap_preview.expenses == 43832,
|
||||||
"the youth-cost item is suppressed once funds reach the strict source threshold");
|
"ordinary monthly youth budgets continue after the former academy threshold");
|
||||||
GameState ignored_cost_fixture = finance_fixture;
|
GameState ignored_cost_fixture = finance_fixture;
|
||||||
ignored_cost_fixture.memory.set32(::bmh::layout::Spending, 111);
|
ignored_cost_fixture.memory.set32(::bmh::layout::Spending, 111);
|
||||||
ignored_cost_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
|
ignored_cost_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
|
||||||
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43400,
|
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43733,
|
||||||
"legacy routine clears cost items zero and two regardless of their saved values");
|
"the youngest and oldest youth budgets both enter expenses");
|
||||||
GameState loan_fixture = finance_fixture;
|
GameState loan_fixture = finance_fixture;
|
||||||
loan_fixture.memory.set32(::bmh::layout::Loans + 8, 100);
|
loan_fixture.memory.set32(::bmh::layout::Loans + 8, 100);
|
||||||
const auto loan_preview = advertising_from_game(loan_fixture, 0).finance_preview;
|
const auto loan_preview = advertising_from_game(loan_fixture, 0).finance_preview;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/balance_plan.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;
|
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");
|
if(portrait>14)throw FormatError("balance: invalid Source manager portrait");
|
||||||
const int team=g.manager_teams[size_t(d.manager)];
|
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;}
|
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);
|
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;}
|
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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/club_player_detail.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);
|
club.original_short_name=club.original_short_name.substr(raw>>4,(raw&15)+1);
|
||||||
}
|
}
|
||||||
// SourceBadgeFallback consults the selector only for real atlas clubs.
|
// 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");
|
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;
|
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);}
|
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]){
|
for(size_t i=0;i<2;++i)if(projection_.clubs[i]){
|
||||||
auto& club=*projection_.clubs[i];const int id=club.runtime_team;
|
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"));
|
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
|
// TextWidth national/foreign names: longest word, then remove two
|
||||||
|
|||||||
+3
-2
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/cup_draw.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;}
|
copy(screen,panel,0,0,29,22,261,203);bottom=screen;drawing=screen;present=true;flush=true;}
|
||||||
else {draw_overview();drawing=screen;}
|
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;
|
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")));
|
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 {
|
void source_badge(Image& out,const CupDrawClub& c,int x,int y) const {
|
||||||
source_frame(out,x,y);
|
source_frame(out,x,y);
|
||||||
const int id=c.runtime_id,selector=c.badge_selector&0x1ff;
|
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);
|
copy(out,widgets,8,0,x,y,38,38);
|
||||||
else {
|
else {
|
||||||
const int atlas=selector>>3;copy(out,badges.at(atlas),(selector&7)*38,0,x,y,38,38);
|
const int atlas=selector>>3;copy(out,badges.at(atlas),(selector&7)*38,0,x,y,38,38);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/desk_state.hpp"
|
#include "ui/desk_state.hpp"
|
||||||
|
#include "game/calendar.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -461,7 +463,11 @@ void validate_desk_state(const DeskState& d) {
|
|||||||
|
|
||||||
DeskDate desk_date(uint32_t counter, const LeImage& exe) {
|
DeskDate desk_date(uint32_t counter, const LeImage& exe) {
|
||||||
if (counter == 0xffff || counter > 3000000) throw FormatError("desk: unsupported date counter");
|
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;
|
int cycle = 3, years = 0;
|
||||||
while (counter > uint32_t(364 + (cycle == 4))) {
|
while (counter > uint32_t(364 + (cycle == 4))) {
|
||||||
if (cycle == 4) { cycle = 0; --counter; }
|
if (cycle == 4) { cycle = 0; --counter; }
|
||||||
@@ -478,7 +484,7 @@ DeskDate desk_date(uint32_t counter, const LeImage& exe) {
|
|||||||
d.day -= month_days();
|
d.day -= month_days();
|
||||||
if (++d.month == 13) { d.month = 1; ++years; }
|
if (++d.month == 13) { d.month = 1; ++years; }
|
||||||
}
|
}
|
||||||
d.year = 2026 + years;
|
d.year = epoch.year + years;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,8 +606,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
|||||||
*d.next_opponent < int(g.club_ids.size())) {
|
*d.next_opponent < int(g.club_ids.size())) {
|
||||||
const int opponent = *d.next_opponent;
|
const int opponent = *d.next_opponent;
|
||||||
d.next_opponent_name = g.club_name(opponent);
|
d.next_opponent_name = g.club_name(opponent);
|
||||||
const bool fallback = opponent == 0x0fff ||
|
const bool fallback = original_badge_fallback(opponent,&exe);
|
||||||
(opponent > 0x59 && (opponent < 0x8a || opponent > 0xa7) && opponent < 0x165);
|
|
||||||
d.next_opponent_badge_fallback = fallback;
|
d.next_opponent_badge_fallback = fallback;
|
||||||
if (!fallback) {
|
if (!fallback) {
|
||||||
const size_t badge_at = size_t(opponent) * 2;
|
const size_t badge_at = size_t(opponent) * 2;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ struct DeskState {
|
|||||||
uint64_t revision = 0;
|
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);
|
DeskDate desk_date(uint32_t day_counter, const LeImage& executable);
|
||||||
DeskState desk_from_save(const SaveState&, const LeImage&, uint64_t revision = 0);
|
DeskState desk_from_save(const SaveState&, const LeImage&, uint64_t revision = 0);
|
||||||
// Uses authoritative typed fields where StaticMemory contains stale copies.
|
// Uses authoritative typed fields where StaticMemory contains stale copies.
|
||||||
|
|||||||
@@ -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"));
|
const std::filesystem::path data = argv[1]; const auto exe = bmh::test::load_executable(asset_path(data,"BMH.exe"));
|
||||||
paired_selection_matrix(exe);
|
paired_selection_matrix(exe);
|
||||||
if(argc>3)paired_saved_projection(argv[3],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;
|
using namespace std::chrono;
|
||||||
const sys_days epoch = year{2026}/7/1;
|
const sys_days epoch = year{2026}/7/1;
|
||||||
for (uint32_t i = 0; i < 1461; ++i) {
|
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())) &&
|
check(d.year == int(oracle.year()) && d.month == int(unsigned(oracle.month())) &&
|
||||||
d.day == int(unsigned(oracle.day())),"calendar/leap boundary mismatch");
|
d.day == int(unsigned(oracle.day())),"calendar/leap boundary mismatch");
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-14
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/environment.hpp"
|
#include "ui/environment.hpp"
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ const char* result_name(EnvironmentRequestKind kind) {
|
|||||||
bool generic_badge(int club) {
|
bool generic_badge(int club) {
|
||||||
// SourceBadgeFallback gates on the runtime club ID, before looking up its W sprite.
|
// SourceBadgeFallback gates on the runtime club ID, before looking up its W sprite.
|
||||||
const unsigned team = unsigned(club) & 0xfff;
|
const unsigned team = unsigned(club) & 0xfff;
|
||||||
return team == 0xfff || (team >= 90 && team <= 137) || (team >= 168 && team <= 356);
|
return original_badge_fallback(int(team));
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -72,6 +73,11 @@ EnvironmentView environment_from_game(const bmh::GameState& game, uint64_t revis
|
|||||||
view.values = bmh::environment_state(game, manager);
|
view.values = bmh::environment_state(game, manager);
|
||||||
for (int i = 0; i < kEnvironmentItems; ++i)
|
for (int i = 0; i < kEnvironmentItems; ++i)
|
||||||
view.cost_text[size_t(i)] = bmh::format_number(game, view.values.monthly[size_t(i)], 0x185);
|
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.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.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;
|
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]; }
|
for (size_t i = 0; i < s.values.monthly.size(); ++i) { if (i) out << ','; out << s.values.monthly[i]; }
|
||||||
out << "],\"level\":[";
|
out << "],\"level\":[";
|
||||||
for (size_t i = 0; i < s.values.level.size(); ++i) { if (i) out << ','; out << s.values.level[i]; }
|
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\":"
|
out << "],\"youth_teams\":[";
|
||||||
<< (s.values.youth_paid ? "true" : "false") << ",\"youth_open\":"
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
<< (s.values.youth_open ? "true" : "false") << '}';
|
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();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,9 +205,6 @@ Image EnvironmentScreen::render() const {
|
|||||||
throw FormatError("environment: Original badge crop outside atlas");
|
throw FormatError("environment: Original badge crop outside atlas");
|
||||||
crop(out, badge_atlas_, badge_x, 0, 0x8c, 0x61, 0x26, 0x26);
|
crop(out, badge_atlas_, badge_x, 0, 0x8c, 0x61, 0x26, 0x26);
|
||||||
for (int item = 0; item < kEnvironmentItems; ++item) {
|
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);
|
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);
|
crop(out, tiles_, item * 0x33, 0x46, x, y, 0x33, 0x29);
|
||||||
// CallsTwiceForUpperLowerCaptionStrips calls LoadGameEndTaxAnimationAssets twice for the upper and lower caption strips.
|
// 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;
|
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 - 10, x + 0x36, y - 1);
|
||||||
panel(x - 4, y + 0x29, x + 0x36, y + 0x31);
|
panel(x - 4, y + 0x29, x + 0x36, y + 0x31 + (item < 3 ? 6 : 0));
|
||||||
const int unit = item == kYouthAcademy ? 1 : item >= 3 ? 5000 : 1;
|
const int count = state_.values.level[size_t(item)];
|
||||||
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);
|
|
||||||
for (int star = 0; star < count; ++star)
|
for (int star = 0; star < count; ++star)
|
||||||
crop(out, tiles_, 0x1e, 0x1e, x + star * 9, y - 8, 7, 6, 0);
|
crop(out, tiles_, 0x1e, 0x1e, x + star * 9, y - 8, 7, 6, 0);
|
||||||
// The tile artwork already contains its Source caption. CallsTwiceForUpperLowerCaptionStrips draws
|
// The tile artwork already contains its Source caption. CallsTwiceForUpperLowerCaptionStrips draws
|
||||||
// the dynamic expense in the lower strip at baseline y+0x30; a second
|
// the dynamic expense in the lower strip at baseline y+0x30; a second
|
||||||
// invented TEXTD caption here overwrote the baked-in names and shifted
|
// invented TEXTD caption here overwrote the baked-in names and shifted
|
||||||
// the cost down into the hit area.
|
// 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);
|
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;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EnvironmentScreen::pointer_down(int x, int y, bool right) {
|
bool EnvironmentScreen::pointer_down(int x, int y, bool right) {
|
||||||
|
if (pending_) return false;
|
||||||
press_seen_ = true;
|
press_seen_ = true;
|
||||||
pending_.reset();
|
|
||||||
pressed_item_ = pressed_level_ = -1;
|
pressed_item_ = pressed_level_ = -1;
|
||||||
pressed_right_ = right;
|
pressed_right_ = right;
|
||||||
if (right) return true;
|
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);
|
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) {
|
if (x >= left - 9 && x <= left + 0x36 && y >= top - 10 && y <= top + 0x29) {
|
||||||
pressed_item_ = item;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ struct EnvironmentView {
|
|||||||
std::string club_name;
|
std::string club_name;
|
||||||
uint16_t badge_sprite = 0;
|
uint16_t badge_sprite = 0;
|
||||||
std::array<std::string, 6> cost_text{};
|
std::array<std::string, 6> cost_text{};
|
||||||
|
std::array<std::string, 3> youth_position_text{}, youth_league_text{};
|
||||||
bool decorated_background = true;
|
bool decorated_background = true;
|
||||||
bool gradient_text = true;
|
bool gradient_text = true;
|
||||||
bool solid_panel_background = false;
|
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 panel = load_vga(asset_path(data / "KB", "56.VGA"));
|
||||||
const auto body = load_font(asset_path(data / "F", "BMH3.FNT"));
|
const auto body = load_font(asset_path(data / "F", "BMH3.FNT"));
|
||||||
SpriteFont sprite(data);
|
SpriteFont sprite(data);
|
||||||
// All four visible groups exercise an empty and an occupied star rail.
|
// All six visible groups exercise an empty and an occupied star rail.
|
||||||
state.values.monthly[1] = 0;
|
for (int item = 0; item < 6; ++item) {
|
||||||
for (int item = 3; item < 6; ++item) state.values.monthly[size_t(item)] = 10000;
|
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) {
|
for (int mode = 0; mode < 3; ++mode) {
|
||||||
state.decorated_background = mode != 1;
|
state.decorated_background = mode != 1;
|
||||||
state.plain_background = mode == 2;
|
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);
|
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) {
|
for (int y = 0; y < 240; ++y) for (int x = 0; x < 320; ++x) {
|
||||||
bool foreground = x >= 125 && x <= 195 && y >= 82 && y <= 151;
|
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);
|
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),
|
if (!foreground) check(pixel(actual, x, y) == pixel(base, x, y),
|
||||||
"Source KB129/flat background, centered title and active club footer");
|
"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(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 &&
|
check(actual.at(139, 96) == 0x46 && actual.at(178, 96) == 0x40 &&
|
||||||
actual.at(139, 135) == 0x40, "Source badge frame and corner overwrite order");
|
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);
|
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)
|
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),
|
check(pixel(actual, tx + x, ty + y) == pixel(art, item * 51 + x, 70 + y),
|
||||||
"legacy routine tile is opaque, without a fabricated c0 comparekey");
|
"legacy routine tile is opaque, without a fabricated c0 comparekey");
|
||||||
// The Source upper panel is copied first; each nonzero star pixel
|
// The Source upper panel is copied first; each nonzero star pixel
|
||||||
// replaces it. A zero in the star bitmap exposes that panel.
|
// 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) {
|
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);
|
uint8_t expected = state.solid_panel_background ? 0x42 : pixel(panel, x - 1, y - 20);
|
||||||
for (int n = 0; n < stars; ++n)
|
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");
|
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;
|
const int width = body.text_width(cost), left = tx + 25 - width / 2;
|
||||||
Image mask(width, body.height);
|
Image mask(width, body.height);
|
||||||
body.draw(mask, 0, 0, cost, 1);
|
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() &&
|
check(screen.key("ESC").kind == EnvironmentRequestKind::none && !screen.close_requested() &&
|
||||||
screen.state_json() == held, "back cannot steal a held staff control before its release");
|
screen.state_json() == held, "back cannot steal a held staff control before its release");
|
||||||
const auto request = screen.release(x + 31, y + 5);
|
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.manager_slot == state.manager_slot && request.runtime_club == state.runtime_club &&
|
||||||
request.revision == 17 && request.owner == owner,
|
request.revision == 17 && request.owner == owner,
|
||||||
"tile release emits a typed, manager/revision-owned level request");
|
"tile release emits a typed, manager/revision-owned level request");
|
||||||
@@ -182,13 +184,13 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
auto updated = state;
|
auto updated = state;
|
||||||
updated.revision = 18;
|
updated.revision = 18;
|
||||||
updated.values.level[3] = 3;
|
updated.values.level[3] = 4;
|
||||||
updated.values.monthly[3] = 15000;
|
updated.values.monthly[3] = 20000;
|
||||||
updated.cost_text[3] = format_number(game, 15000, 0x185);
|
updated.cost_text[3] = format_number(game, 20000, 0x185);
|
||||||
updated.owner.revision = 18;
|
updated.owner.revision = 18;
|
||||||
screen.acknowledge(updated);
|
screen.acknowledge(updated);
|
||||||
check(!screen.pending() && screen.state().revision == 18 &&
|
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");
|
"valid source mutation ACK refreshes the screen and clears the pending action");
|
||||||
|
|
||||||
const auto notice = environment_notice_dialog(game, state.manager_slot,
|
const auto notice = environment_notice_dialog(game, state.manager_slot,
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/game_end.hpp"
|
#include "ui/game_end.hpp"
|
||||||
|
|
||||||
@@ -288,7 +289,7 @@ Image GameEndTaxDialog::render(std::optional<Button> pressed) const {
|
|||||||
}
|
}
|
||||||
bool source_badge_fallback(int token) {
|
bool source_badge_fallback(int token) {
|
||||||
const int club=token&0x0fff;
|
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,
|
void draw_source_dialog(Image& out,const SourceDialogAssets& assets,const TaxDialogProjection& p,
|
||||||
bool gradient,std::optional<GameEndTaxDialog::Button> pressed) {
|
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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/incoming_transfer.hpp"
|
#include "ui/incoming_transfer.hpp"
|
||||||
#include "ui/game_end.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) {
|
bool source_neutral_seller_token(int token) {
|
||||||
return (token >= 90 && token <= 137) || token == 0x0fff ||
|
return original_badge_fallback(token);
|
||||||
(token >= 168 && token <= 356);
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // 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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/manager.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 {
|
void ManagerScreen::badge(Image& out, int x, int y, int id) const {
|
||||||
border(out, x, y);
|
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;
|
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"));
|
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);
|
copy(out, atlas, (sprite & 7) * 38, 0, x, y, 38, 38);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/pending_offer.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.
|
// reserves 14 for the manager-placeholder tile drawn from KB0.VGA.
|
||||||
if (out.portrait > 14) throw FormatError("pending offer UI: invalid Source manager portrait");
|
if (out.portrait > 14) throw FormatError("pending offer UI: invalid Source manager portrait");
|
||||||
|
|
||||||
out.badge_fallback = team == 0x0fff || (team > 89 && team < 138) ||
|
out.badge_fallback = original_badge_fallback(team);
|
||||||
(team > 167 && team < 357);
|
|
||||||
if (out.badge_fallback) {
|
if (out.badge_fallback) {
|
||||||
out.badge_sprite = 0;
|
out.badge_sprite = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+64
-15
@@ -195,6 +195,7 @@ PitchScreen::PitchScreen(const std::filesystem::path& data,LineupState state,Pit
|
|||||||
PitchScreen::PitchScreen(const PitchScreen& other)
|
PitchScreen::PitchScreen(const PitchScreen& other)
|
||||||
:PitchScreen(other.data_,other.state_,other.extras_){
|
:PitchScreen(other.data_,other.state_,other.extras_){
|
||||||
pending_=other.pending_;selected_=other.selected_;hovered_=other.hovered_;ghost_=other.ghost_;
|
pending_=other.pending_;selected_=other.selected_;hovered_=other.hovered_;ghost_=other.ghost_;
|
||||||
|
order_hover_grid_=other.order_hover_grid_;
|
||||||
scroll_=other.scroll_;close_=other.close_;return_team_=other.return_team_;rejection_=other.rejection_;
|
scroll_=other.scroll_;close_=other.close_;return_team_=other.return_team_;rejection_=other.rejection_;
|
||||||
weights_dirty_=other.weights_dirty_;
|
weights_dirty_=other.weights_dirty_;
|
||||||
shooter_editor_open_=other.shooter_editor_open_;shooter_selection_=other.shooter_selection_;
|
shooter_editor_open_=other.shooter_editor_open_;shooter_selection_=other.shooter_selection_;
|
||||||
@@ -311,14 +312,18 @@ Image PitchScreen::render()const{
|
|||||||
for(auto[row,baseline]:rows())if(baseline>34&&baseline<107&&(selected_==row||hovered_==row)){
|
for(auto[row,baseline]:rows())if(baseline>34&&baseline<107&&(selected_==row||hovered_==row)){
|
||||||
copy(out,background_,13,baseline-5,13,baseline-5,51,6);
|
copy(out,background_,13,baseline-5,13,baseline-5,51,6);
|
||||||
text(out,13,baseline,state_.players.at(row).name,selected_==row?0x27:0x3e);}
|
text(out,13,baseline,state_.players.at(row).name,selected_==row?0x27:0x3e);}
|
||||||
if(shooter_editor_open_&&zone_cover_open_){
|
const auto eligible_order_row = [&](std::optional<int> row) {
|
||||||
// TestsTemporaryDisplayBitCallsBeff tests the temporary 0x80 display bit and calls DerivesRedCoverage
|
return row && *row >= 0 && *row < 11 &&
|
||||||
// for each healthy active starter. DerivesRedCoverage derives the red coverage
|
(state_.players.at(size_t(*row)).slot & 0x8000) &&
|
||||||
// bounds from the native ORDER bytes at player+2..+4 and clips them
|
((state_.players.at(size_t(*row)).attributes.w364 >> 16) & 0x1f) == 0;
|
||||||
// to the Source pitch's x=3..192 / y=113..219 area.
|
};
|
||||||
for(int row=0;row<11;++row){
|
std::optional<int> order_row;
|
||||||
const auto& p=state_.players.at(size_t(row));
|
if(eligible_order_row(hovered_))order_row=hovered_;
|
||||||
if(!(p.slot&0x8000)||((p.attributes.w364>>16)&0x1f)!=0)continue;
|
else if(eligible_order_row(selected_))order_row=selected_;
|
||||||
|
// Both the order page's hovered player and the taker editor's coverage
|
||||||
|
// toggle use the native ORDER geometry and VGA plane-7 mask.
|
||||||
|
const auto draw_coverage = [&](const LineupPlayer& p) {
|
||||||
|
if(!(p.slot&0x8000)||((p.attributes.w364>>16)&0x1f)!=0)return;
|
||||||
const int depth=int8_t(p.board[0x41]),lane=int8_t(p.board[0x42]);
|
const int depth=int8_t(p.board[0x41]),lane=int8_t(p.board[0x42]);
|
||||||
const int order_x=p.board[2],order_y=p.board[3];
|
const int order_x=p.board[2],order_y=p.board[3];
|
||||||
const int zone_count=p.board[4]/2;
|
const int zone_count=p.board[4]/2;
|
||||||
@@ -355,7 +360,11 @@ Image PitchScreen::render()const{
|
|||||||
source_mask_copy(out,atlas_,0xc4,0x59,draw_x0,lower,draw_x1-draw_x0,1);
|
source_mask_copy(out,atlas_,0xc4,0x59,draw_x0,lower,draw_x1-draw_x0,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
if(shooter_editor_open_&&zone_cover_open_){
|
||||||
|
for(int row=0;row<11;++row)draw_coverage(state_.players.at(size_t(row)));
|
||||||
|
}else if(order_panel_open_&&order_row){
|
||||||
|
draw_coverage(state_.players.at(size_t(*order_row)));
|
||||||
}
|
}
|
||||||
for(int row=0;row<11;++row){const auto& p=state_.players.at(row);if(!(p.slot&0x8000))continue;
|
for(int row=0;row<11;++row){const auto& p=state_.players.at(row);if(!(p.slot&0x8000))continue;
|
||||||
jersey(out,p,int8_t(p.board[0x41]),int8_t(p.board[0x42]),selected_==row||hovered_==row?3:0);}
|
jersey(out,p,int8_t(p.board[0x41]),int8_t(p.board[0x42]),selected_==row||hovered_==row?3:0);}
|
||||||
@@ -423,8 +432,40 @@ Image PitchScreen::render()const{
|
|||||||
text(out,243,baseline+6,details,0x69);
|
text(out,243,baseline+6,details,0x69);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(extras_.mode!=1&&order_panel_open_&&selected_&&*selected_<11){
|
if(extras_.mode!=1&&order_panel_open_){
|
||||||
const auto& player=state_.players.at(size_t(*selected_));
|
// The original panel includes its eight atlas controls and up to six
|
||||||
|
// marked substitutes above the order bars; none are generated artwork.
|
||||||
|
for(int side=0;side<2;++side)for(int aspect=0;aspect<4;++aspect)
|
||||||
|
copy(out,atlas_,196+aspect*16,56+side*12,243+side*58,179+aspect*12,15,12,0xc0);
|
||||||
|
int bench_row=0;
|
||||||
|
for(const auto& player:state_.players){
|
||||||
|
if(bench_row==6)break;
|
||||||
|
if(player.player_id<0||!(player.slot&0x4000))continue;
|
||||||
|
const int baseline=118+7*bench_row++;
|
||||||
|
text(out,243,baseline,exe_.string_at_pointer(::bmh::layout::PitchOrderPositionPointers+
|
||||||
|
player.attributes.position()*4),0x6b);
|
||||||
|
std::string name=player.name;
|
||||||
|
while(!name.empty()&&font_.text_width(name)>48)name.pop_back();
|
||||||
|
text(out,252,baseline,name,0x6b);
|
||||||
|
text(out,302,baseline,"("+std::to_string(player.attributes.strength())+")",0x6b);
|
||||||
|
}
|
||||||
|
if(order_hover_grid_){
|
||||||
|
const auto [depth,lane]=*order_hover_grid_;
|
||||||
|
const auto mask=exe_.u16(::bmh::layout::PitchOrderZoneMasks+lane*38+std::min(depth,18)*2);
|
||||||
|
std::string position,zone;
|
||||||
|
const auto label=[&](int bit)->const std::string&{
|
||||||
|
return texts_[(::bmh::layout::PitchOrderZoneTextPointers-::bmh::layout::TextPointerTable)/4+bit];
|
||||||
|
};
|
||||||
|
for(int bit=0;bit<6;++bit)if(mask&(1<<bit)){position=label(bit);break;}
|
||||||
|
for(int bit=6;bit<14;++bit)if(mask&(1<<bit))zone+=label(bit);
|
||||||
|
while(!position.empty()&&font_.text_width(position)>78)position.pop_back();
|
||||||
|
while(!zone.empty()&&font_.text_width(zone)>78)zone.pop_back();
|
||||||
|
text(out,241,165,position,0x6b);
|
||||||
|
text(out,241,173,zone,0x69);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(extras_.mode!=1&&order_panel_open_&&order_row){
|
||||||
|
const auto& player=state_.players.at(size_t(*order_row));
|
||||||
for(int aspect=0;aspect<4;++aspect){
|
for(int aspect=0;aspect<4;++aspect){
|
||||||
const int y=181+12*aspect,value=player.board[size_t(2+aspect)];
|
const int y=181+12*aspect,value=player.board[size_t(2+aspect)];
|
||||||
if(value){copy(out,atlas_,0x103,0x3b,0x103,y,value,9,0xc0);
|
if(value){copy(out,atlas_,0x103,0x3b,0x103,y,value,9,0xc0);
|
||||||
@@ -529,10 +570,15 @@ PitchRequest PitchScreen::order_request(int aspect,int value){
|
|||||||
}
|
}
|
||||||
PitchRequest PitchScreen::click(int x,int y,bool right){
|
PitchRequest PitchScreen::click(int x,int y,bool right){
|
||||||
if(pending_||close_)return {};
|
if(pending_||close_)return {};
|
||||||
if(right){if(selected_){selected_.reset();ghost_.reset();}else {close_=true;zone_cover_open_=false;}return {};}
|
|
||||||
const uint16_t display_word=shooter_editor_open_
|
const uint16_t display_word=shooter_editor_open_
|
||||||
? uint16_t(extras_.native_display_word&0xff0f)
|
? uint16_t(extras_.native_display_word&0xff0f)
|
||||||
: extras_.native_display_word;
|
: extras_.native_display_word;
|
||||||
|
if(right){
|
||||||
|
if((display_word&0x08)==0){sheet_->click(x,y,true);close_=sheet_->close_requested();}
|
||||||
|
else if(selected_){selected_.reset();ghost_.reset();}
|
||||||
|
else {close_=true;zone_cover_open_=false;}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
if((display_word&0x08)==0){
|
if((display_word&0x08)==0){
|
||||||
// On the full-sheet redraw, PitchScreen presents its original footer
|
// On the full-sheet redraw, PitchScreen presents its original footer
|
||||||
// controls at (1,215) and (58,215): data A/B and the pitch/team page.
|
// controls at (1,215) and (58,215): data A/B and the pitch/team page.
|
||||||
@@ -694,8 +740,11 @@ PitchRequest PitchScreen::save_formation(int x,int y){
|
|||||||
pending_=r;return r;
|
pending_=r;return r;
|
||||||
}
|
}
|
||||||
bool PitchScreen::move(int x,int y){if(pending_||close_)return false;
|
bool PitchScreen::move(int x,int y){if(pending_||close_)return false;
|
||||||
|
if((extras_.native_display_word&0x08)==0)return sheet_->move(x,y);
|
||||||
const auto old=hovered_;const auto oldghost=ghost_;hovered_=hit_row(x,y);ghost_=selected_?grid(x,y):std::nullopt;
|
const auto old=hovered_;const auto oldghost=ghost_;hovered_=hit_row(x,y);ghost_=selected_?grid(x,y):std::nullopt;
|
||||||
return old!=hovered_||oldghost!=ghost_;
|
const auto old_grid=order_hover_grid_;
|
||||||
|
order_hover_grid_=order_panel_open_?grid(x,y):std::nullopt;
|
||||||
|
return old!=hovered_||oldghost!=ghost_||old_grid!=order_hover_grid_;
|
||||||
}
|
}
|
||||||
PitchRequest PitchScreen::key(std::string_view key){
|
PitchRequest PitchScreen::key(std::string_view key){
|
||||||
// PitchScreen's desktop pages cancel selection/return on mouse event 8.
|
// PitchScreen's desktop pages cancel selection/return on mouse event 8.
|
||||||
@@ -862,12 +911,12 @@ void PitchScreen::acknowledge(LineupState s,PitchExtras e){
|
|||||||
if(kind==PitchRequestKind::set_player_marking){marking_target_row_.reset();}
|
if(kind==PitchRequestKind::set_player_marking){marking_target_row_.reset();}
|
||||||
state_=std::move(s);extras_=std::move(e);sheet_=std::move(new_sheet);badge_=std::move(new_badge);
|
state_=std::move(s);extras_=std::move(e);sheet_=std::move(new_sheet);badge_=std::move(new_badge);
|
||||||
scroll_=0;
|
scroll_=0;
|
||||||
if(kind!=PitchRequestKind::set_player_order){selected_.reset();hovered_.reset();ghost_.reset();}
|
if(kind!=PitchRequestKind::set_player_order){selected_.reset();hovered_.reset();ghost_.reset();order_hover_grid_.reset();}
|
||||||
pending_.reset();rejection_.clear();
|
pending_.reset();rejection_.clear();
|
||||||
}
|
}
|
||||||
void PitchScreen::reject_action(std::string reason){if(!pending_||reason.empty())throw FormatError("pitch: rejection requires pending action and reason");
|
void PitchScreen::reject_action(std::string reason){if(!pending_||reason.empty())throw FormatError("pitch: rejection requires pending action and reason");
|
||||||
if(sheet_->pending())sheet_=std::make_unique<LineupScreen>(data_,state_);
|
if(sheet_->pending())sheet_=std::make_unique<LineupScreen>(data_,state_);
|
||||||
pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();marking_target_row_.reset();rejection_=std::move(reason);
|
pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();order_hover_grid_.reset();marking_target_row_.reset();rejection_=std::move(reason);
|
||||||
}
|
}
|
||||||
void PitchScreen::resolve_local_navigation(){
|
void PitchScreen::resolve_local_navigation(){
|
||||||
if(!pending_||pending_->kind!=PitchRequestKind::open_player_info)
|
if(!pending_||pending_->kind!=PitchRequestKind::open_player_info)
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ private:
|
|||||||
std::optional<PitchRequest> pending_;
|
std::optional<PitchRequest> pending_;
|
||||||
std::optional<int> selected_, hovered_;
|
std::optional<int> selected_, hovered_;
|
||||||
std::optional<std::pair<int,int>> ghost_;
|
std::optional<std::pair<int,int>> ghost_;
|
||||||
|
std::optional<std::pair<int,int>> order_hover_grid_;
|
||||||
int scroll_ = 0;
|
int scroll_ = 0;
|
||||||
bool close_ = false, return_team_ = false;
|
bool close_ = false, return_team_ = false;
|
||||||
bool weights_dirty_ = false; // original local_30: reapply current AA after a weight change
|
bool weights_dirty_ = false; // original local_30: reapply current AA after a weight change
|
||||||
|
|||||||
+37
-1
@@ -249,12 +249,48 @@ int main(int argc,char**argv){try{
|
|||||||
hidden_page.click(241,215).kind==PitchRequestKind::none))&&
|
hidden_page.click(241,215).kind==PitchRequestKind::none))&&
|
||||||
hidden_page.save_formation(250,166).kind==PitchRequestKind::none&&!hidden_page.pending(),
|
hidden_page.save_formation(250,166).kind==PitchRequestKind::none&&!hidden_page.pending(),
|
||||||
"inactive Source AA page ignores hidden formation, weight and held-save coordinates");
|
"inactive Source AA page ignores hidden formation, weight and held-save coordinates");
|
||||||
if(word==0x08||word==0x28)for(int y=110;y<131;++y)for(int x=243;x<278;++x)
|
if(word==0x08)for(int y=110;y<131;++y)for(int x=243;x<278;++x)
|
||||||
check(before.pixels[size_t(y)*before.width+x]==0x42,"inactive Source page does not draw the KB2 formation panel");
|
check(before.pixels[size_t(y)*before.width+x]==0x42,"inactive Source page does not draw the KB2 formation panel");
|
||||||
check(hidden_page.extras().formations==aa.formations&&
|
check(hidden_page.extras().formations==aa.formations&&
|
||||||
hidden_page.extras().automatic_weights==aa.automatic_weights,
|
hidden_page.extras().automatic_weights==aa.automatic_weights,
|
||||||
"ignored AA input preserves authoritative templates and packed weights");
|
"ignored AA input preserves authoritative templates and packed weights");
|
||||||
}
|
}
|
||||||
|
auto order_lineup=s;auto order_extras=e;order_extras.native_display_word=0x28;
|
||||||
|
order_lineup.players[0].board[2]=12;order_lineup.players[0].board[3]=10;
|
||||||
|
order_lineup.players[0].board[4]=20;order_lineup.players[0].board[5]=8;
|
||||||
|
PitchScreen orders(data,order_lineup,order_extras);
|
||||||
|
auto order_idle=orders.render();
|
||||||
|
auto order_atlas=load_vga(asset_path(data/"KB","2.VGA"));
|
||||||
|
for(int side=0;side<2;++side)for(int aspect=0;aspect<4;++aspect)
|
||||||
|
for(int y=0;y<12;++y)for(int x=0;x<15;++x){
|
||||||
|
const auto value=order_atlas.at(196+aspect*16+x,56+side*12+y);
|
||||||
|
if(value!=0xc0)check(order_idle.at(243+side*58+x,179+aspect*12+y)==value,
|
||||||
|
"Anweis controls use all eight original atlas sprites");
|
||||||
|
}
|
||||||
|
check(orders.move(20,38),"Anweis accepts hover over the first starter");
|
||||||
|
auto order_hover=orders.render();int coverage_changes=0;
|
||||||
|
for(int y=111;y<220;++y)for(int x=3;x<193;++x)
|
||||||
|
if((order_idle.at(x,y)^order_hover.at(x,y))&0x80)++coverage_changes;
|
||||||
|
check(coverage_changes>100&&!orders.pending()&&orders.state().revision==s.revision&&
|
||||||
|
orders.state().players[0].board==order_lineup.players[0].board,
|
||||||
|
"hover previews the red ORDER coverage without selecting or mutating a player");
|
||||||
|
check(orders.move(150,200),"moving over an empty pitch cell updates its position hints");
|
||||||
|
auto hints=orders.render();int hint_pixels=0;
|
||||||
|
for(int y=159;y<=173;++y)for(int x=241;x<319;++x)
|
||||||
|
if(hints.at(x,y)!=order_idle.at(x,y))++hint_pixels;
|
||||||
|
check(hint_pixels>0&&!orders.pending(),"Anweis cell hints come from runtime zone masks and texts");
|
||||||
|
PitchScreen orders_copy=orders;
|
||||||
|
check(orders_copy.render().pixels==hints.pixels,"copying a preview preserves its hovered position hints");
|
||||||
|
orders.move(220,100);
|
||||||
|
check(orders.render().pixels==order_idle.pixels,"leaving Anweis hover restores the idle page");
|
||||||
|
auto cancel_extras=e;cancel_extras.native_display_word=0;
|
||||||
|
PitchScreen team_cancel(data,s,cancel_extras);
|
||||||
|
team_cancel.click(20,38);
|
||||||
|
team_cancel.pointer_down(310,230,true);
|
||||||
|
check(!team_cancel.close_requested()&&!team_cancel.pending(),
|
||||||
|
"a live-compatible full sheet first cancels its selected player on right press");
|
||||||
|
team_cancel.pointer_down(309,229,true);
|
||||||
|
check(team_cancel.close_requested(),"the next right press leaves the full sheet");
|
||||||
auto hall_pages=aa;hall_pages.indoor=true;
|
auto hall_pages=aa;hall_pages.indoor=true;
|
||||||
PitchScreen hall_transition(data,s,hall_pages);
|
PitchScreen hall_transition(data,s,hall_pages);
|
||||||
const auto instructions=hall_transition.click(210,154);
|
const auto instructions=hall_transition.click(210,154);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/player_card.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"));
|
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){
|
if(state_.loan)for(size_t i=0;i<2;++i){
|
||||||
const int club=i?state_.loan->borrower:state_.loan->owner;
|
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"));
|
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);}
|
if(atlas_.width==314){Image padded(320,atlas_.height);padded.blit(atlas_,0,0);atlas_=std::move(padded);}
|
||||||
|
|||||||
+24
-10
@@ -8,6 +8,7 @@
|
|||||||
#include <system_error>
|
#include <system_error>
|
||||||
|
|
||||||
#include "ui/manager.hpp"
|
#include "ui/manager.hpp"
|
||||||
|
#include "ui/host_path.hpp"
|
||||||
#include "ui/setup.hpp"
|
#include "ui/setup.hpp"
|
||||||
#include "formats/fbm.hpp"
|
#include "formats/fbm.hpp"
|
||||||
|
|
||||||
@@ -101,6 +102,9 @@ SaveLoadScreen::SaveLoadScreen(const std::filesystem::path& data, std::filesyste
|
|||||||
});
|
});
|
||||||
} else feedback_ = "VERZEICHNIS NICHT VERFUEGBAR";
|
} else feedback_ = "VERZEICHNIS NICHT VERFUEGBAR";
|
||||||
if (mode_ == SaveLoadMode::save && !entries_.empty()) filename_ = path_to_utf8(entries_.front().path.stem());
|
if (mode_ == SaveLoadMode::save && !entries_.empty()) filename_ = path_to_utf8(entries_.front().path.stem());
|
||||||
|
// OpenBMH deviates from the original: focuses the host save filename on entry and selects an existing name for replacement.
|
||||||
|
filename_focus_ = mode_ == SaveLoadMode::save;
|
||||||
|
filename_selected_ = filename_focus_ && !filename_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
Image SaveLoadScreen::render() const {
|
Image SaveLoadScreen::render() const {
|
||||||
@@ -121,12 +125,15 @@ Image SaveLoadScreen::render() const {
|
|||||||
button(out, field_x, directory_y, field_width);
|
button(out, field_x, directory_y, field_width);
|
||||||
button(out, field_x, filename_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, 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);
|
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 &&
|
const std::string displayed_filename = mode_ == SaveLoadMode::load && selected_ >= 0 &&
|
||||||
size_t(selected_) < entries_.size() ? path_to_utf8(entries_[size_t(selected_)].path.stem()) : filename_;
|
size_t(selected_) < entries_.size() ? path_to_utf8(entries_[size_t(selected_)].path.stem()) : filename_;
|
||||||
text(out, 106, 216, displayed_filename, 0x6c, 140, footer_font_, true);
|
text(out, 106, 216, displayed_filename, filename_selected_ ? 0x27 : 0x6c, 140, footer_font_, true);
|
||||||
|
|
||||||
if (entries_.size() > 15) {
|
if (entries_.size() > 15) {
|
||||||
button(out, 206, 183, 56, original_to_utf8(exe_.cstring(::bmh::layout::SaveLoad_Render_ExecutableField)));
|
button(out, 206, 183, 56, original_to_utf8(exe_.cstring(::bmh::layout::SaveLoad_Render_ExecutableField)));
|
||||||
@@ -282,7 +289,9 @@ bool SaveLoadScreen::select_row(int y) {
|
|||||||
if (row < 0 || row >= int(entries_.size())) return false;
|
if (row < 0 || row >= int(entries_.size())) return false;
|
||||||
selected_ = row;
|
selected_ = row;
|
||||||
if (mode_ == SaveLoadMode::save) filename_ = path_to_utf8(entries_[size_t(row)].path.stem());
|
if (mode_ == SaveLoadMode::save) filename_ = path_to_utf8(entries_[size_t(row)].path.stem());
|
||||||
filename_focus_ = false; overwrite_armed_ = false; feedback_.clear();
|
filename_focus_ = mode_ == SaveLoadMode::save;
|
||||||
|
filename_selected_ = filename_focus_;
|
||||||
|
overwrite_armed_ = false; feedback_.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +321,9 @@ void SaveLoadScreen::request_action() {
|
|||||||
|
|
||||||
bool SaveLoadScreen::click(int x, int y, bool right) {
|
bool SaveLoadScreen::click(int x, int y, bool right) {
|
||||||
if (info_) { info_.reset(); return true; }
|
if (info_) { info_.reset(); return true; }
|
||||||
if (pending_ || right) return false;
|
if (pending_) return false;
|
||||||
|
// OpenBMH deviates from the original: permits cancelling host file dialogs with the right mouse button.
|
||||||
|
if (right) { close_requested_ = true; return true; }
|
||||||
if (x >= 206 && y >= 60 && y <= 169)
|
if (x >= 206 && y >= 60 && y <= 169)
|
||||||
return false; // Source drive/delete controls have no host mapping in this slice.
|
return false; // Source drive/delete controls have no host mapping in this slice.
|
||||||
if (entries_.size() > 15 && x >= 206 && x <= 262 && y >= 183 && y <= 193) {
|
if (entries_.size() > 15 && x >= 206 && x <= 262 && y >= 183 && y <= 193) {
|
||||||
@@ -329,7 +340,7 @@ bool SaveLoadScreen::click(int x, int y, bool right) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (mode_ == SaveLoadMode::save && x >= 52 && x < 262 && y >= 209 && y < 219) {
|
if (mode_ == SaveLoadMode::save && x >= 52 && x < 262 && y >= 209 && y < 219) {
|
||||||
filename_focus_ = true; feedback_.clear(); return true;
|
filename_focus_ = true; filename_selected_ = true; feedback_.clear(); return true;
|
||||||
}
|
}
|
||||||
if (x >= 52 && x < 262 && y >= 196 && y < 206) return false;
|
if (x >= 52 && x < 262 && y >= 196 && y < 206) return false;
|
||||||
return false;
|
return false;
|
||||||
@@ -350,13 +361,15 @@ bool SaveLoadScreen::key(std::string_view value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mode_ == SaveLoadMode::save && filename_focus_) {
|
if (mode_ == SaveLoadMode::save && filename_focus_) {
|
||||||
|
if (value == "SELECT_ALL") { filename_selected_ = true; return true; }
|
||||||
if (value == "BACKSPACE") {
|
if (value == "BACKSPACE") {
|
||||||
if (!filename_.empty()) {
|
if (filename_selected_) filename_.clear();
|
||||||
|
else if (!filename_.empty()) {
|
||||||
size_t last = filename_.size() - 1;
|
size_t last = filename_.size() - 1;
|
||||||
while (last > 0 && (uint8_t(filename_[last]) & 0xc0) == 0x80) --last;
|
while (last > 0 && (uint8_t(filename_[last]) & 0xc0) == 0x80) --last;
|
||||||
filename_.erase(last);
|
filename_.erase(last);
|
||||||
}
|
}
|
||||||
overwrite_armed_ = false; return true;
|
filename_selected_ = false; overwrite_armed_ = false; return true;
|
||||||
}
|
}
|
||||||
if (value == "ENTER") { request_action(); return true; }
|
if (value == "ENTER") { request_action(); return true; }
|
||||||
}
|
}
|
||||||
@@ -365,9 +378,10 @@ bool SaveLoadScreen::key(std::string_view value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SaveLoadScreen::text(std::string_view value) {
|
bool SaveLoadScreen::text(std::string_view value) {
|
||||||
if (info_ || mode_ != SaveLoadMode::save || !filename_focus_ || pending_ || value.empty() ||
|
if (info_ || mode_ != SaveLoadMode::save || !filename_focus_ || pending_ || value.empty()) return false;
|
||||||
!valid_filename(filename_ + std::string(value))) return false;
|
const std::string next = (filename_selected_ ? std::string{} : filename_) + std::string(value);
|
||||||
filename_ += value;
|
if (!valid_filename(next)) return false;
|
||||||
|
filename_ = next; filename_selected_ = false;
|
||||||
overwrite_armed_ = false; feedback_.clear(); return true;
|
overwrite_armed_ = false; feedback_.clear(); return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ private:
|
|||||||
std::vector<SaveLoadEntry> entries_;
|
std::vector<SaveLoadEntry> entries_;
|
||||||
int selected_ = 0, scroll_ = 0;
|
int selected_ = 0, scroll_ = 0;
|
||||||
std::string filename_, feedback_;
|
std::string filename_, feedback_;
|
||||||
bool filename_focus_ = false, overwrite_armed_ = false, close_requested_ = false;
|
bool filename_focus_ = false, filename_selected_ = false;
|
||||||
|
bool overwrite_armed_ = false, close_requested_ = false;
|
||||||
int last_clicked_row_ = -1;
|
int last_clicked_row_ = -1;
|
||||||
std::optional<SaveLoadRequest> pending_;
|
std::optional<SaveLoadRequest> pending_;
|
||||||
struct InfoRow { std::string manager, club, league; };
|
struct InfoRow { std::string manager, club, league; };
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "ui/save_load.hpp"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
using namespace bmh;
|
||||||
|
using namespace bmh::ui;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void check(bool value, const char* message) {
|
||||||
|
if (!value) throw std::runtime_error(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
try {
|
||||||
|
if (argc != 2) throw std::runtime_error("save/load tests require externally supplied game assets");
|
||||||
|
const auto root = std::filesystem::temp_directory_path() /
|
||||||
|
("openbmh-file-input-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||||
|
std::filesystem::create_directories(root);
|
||||||
|
struct Cleanup {
|
||||||
|
std::filesystem::path path;
|
||||||
|
~Cleanup() { std::error_code error; std::filesystem::remove_all(path, error); }
|
||||||
|
} cleanup{root};
|
||||||
|
const Image backdrop(320, 240, 0x42);
|
||||||
|
for (const auto [kind, extension] : {
|
||||||
|
std::pair{SaveLoadFileKind::game, ".FBM"},
|
||||||
|
std::pair{SaveLoadFileKind::settings, ".EIN"},
|
||||||
|
std::pair{SaveLoadFileKind::menu_layout, ".MEN"}}) {
|
||||||
|
std::ofstream(root / (std::string("Existing") + extension)) << "authored filename fixture";
|
||||||
|
SaveLoadScreen load(argv[1], root, SaveLoadMode::load, 0, 7, backdrop, true, kind);
|
||||||
|
check(load.click(0, 0, true) && load.close_requested() && !load.pending(),
|
||||||
|
"right-click closes every file picker without submitting a load");
|
||||||
|
SaveLoadScreen save(argv[1], root, SaveLoadMode::save, 0, 7, backdrop, true, kind);
|
||||||
|
check(save.text("Custom"), "a save picker accepts a new name immediately after opening");
|
||||||
|
check(save.text(" Name"), "subsequent text appends to the edited name");
|
||||||
|
save.key("ENTER");
|
||||||
|
check(save.pending() && save.pending()->path.filename() == std::string("Custom Name") + extension &&
|
||||||
|
!save.pending()->overwrite, "new typing replaces the prefilled filename and keeps its file kind");
|
||||||
|
check(!save.click(0, 0, true) && !save.close_requested(),
|
||||||
|
"a submitted file operation retains ownership until acknowledged or rejected");
|
||||||
|
save.reject("authored refusal");
|
||||||
|
check(save.click(0, 0, true) && save.close_requested(),
|
||||||
|
"a rejected save can be cancelled with the right mouse button");
|
||||||
|
SaveLoadScreen edit(argv[1], root, SaveLoadMode::save, 0, 7, backdrop, true, kind);
|
||||||
|
edit.click(120, 214); edit.key("BACKSPACE");
|
||||||
|
check(edit.text("Long Name") && edit.key("SELECT_ALL") && edit.text("Short"),
|
||||||
|
"clicking and select-all permit replacing a whole filename");
|
||||||
|
check(edit.text("\xc3\x84") && edit.key("BACKSPACE"), "backspace removes a complete UTF-8 character");
|
||||||
|
edit.key("ENTER");
|
||||||
|
check(edit.pending() && edit.pending()->path.filename() == std::string("Short") + extension,
|
||||||
|
"editing and UTF-8 deletion preserve the resulting host filename");
|
||||||
|
}
|
||||||
|
std::cout << "save/load input checks passed\n";
|
||||||
|
return 0;
|
||||||
|
} catch (const std::exception& error) {
|
||||||
|
std::cerr << error.what() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/season_promotion.hpp"
|
#include "ui/season_promotion.hpp"
|
||||||
|
|
||||||
@@ -181,7 +182,7 @@ SeasonPromotionProjection season_promotion_from_game(
|
|||||||
rows.reserve(event.count);
|
rows.reserve(event.count);
|
||||||
for(size_t i=0;i<event.count;++i) {
|
for(size_t i=0;i<event.count;++i) {
|
||||||
const uint16_t id=ids[i]&0x0fff;
|
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;
|
uint16_t badge=0;
|
||||||
if(!fallback) {
|
if(!fallback) {
|
||||||
const size_t at=size_t(id)*2;
|
const size_t at=size_t(id)*2;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/sportschau.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) {
|
for (size_t side = 0; side < badge_words.size(); ++side) {
|
||||||
const int team = side == 0 ? fixture_.home_team : fixture_.away_team;
|
const int team = side == 0 ? fixture_.home_team : fixture_.away_team;
|
||||||
if (team == 0x0fff) continue; // SourceBadgeFallback uses its generic missing-club icon.
|
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 (!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");
|
if (badge_words[side] == 0xffff) throw FormatError("sportschau: missing live Source badge word");
|
||||||
const unsigned atlas = (badge_words[side] & 0x01ff) >> 3;
|
const unsigned atlas = (badge_words[side] & 0x01ff) >> 3;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/sprite_font.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)
|
SpriteFont::SpriteFont(const std::filesystem::path& data_directory)
|
||||||
: atlas_(load_vga(asset_path(data_directory / "KB", "54.VGA"))),
|
: atlas_(load_vga(asset_path(data_directory / "KB", "54.VGA"))),
|
||||||
exe_(load_le(asset_path(data_directory, "BMH.exe"))) {
|
exe_(load_le(asset_path(data_directory, "BMH.exe"))) {
|
||||||
|
install_original_badge_policy(exe_);
|
||||||
if (atlas_.height < 21 || atlas_.width <= 0)
|
if (atlas_.height < 21 || atlas_.width <= 0)
|
||||||
throw FormatError("sprite font: unsupported KB/54 atlas");
|
throw FormatError("sprite font: unsupported KB/54 atlas");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/team_statistics.hpp"
|
#include "ui/team_statistics.hpp"
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@ TeamStatisticsProjection team_statistics_from_game(const GameState& game, int te
|
|||||||
TeamStatisticsProjection out;
|
TeamStatisticsProjection out;
|
||||||
out.runtime_team = team;
|
out.runtime_team = team;
|
||||||
out.mode = mode;
|
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;
|
out.badge_heap = game.club_heap_78;
|
||||||
if (team != 0x165) {
|
if (team != 0x165) {
|
||||||
int region_team = team;
|
int region_team = team;
|
||||||
|
|||||||
@@ -98,8 +98,10 @@ int main(int argc, char** argv) {
|
|||||||
training_camp_price_text(content, 7) == "& 350.000",
|
training_camp_price_text(content, 7) == "& 350.000",
|
||||||
"FLTD prices use its actual base price, pound prefix and one-half conversion");
|
"FLTD prices use its actual base price, pound prefix and one-half conversion");
|
||||||
} else {
|
} else {
|
||||||
check(training_camp_price_text(content, 0) == "150.000" + texts[17],
|
auto currency_sample = content;
|
||||||
"German default price text remains unchanged");
|
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"));
|
auto widgets = load_vga(asset_path(data / "KB", "52.VGA"));
|
||||||
for(int i=0;i<9;++i){
|
for(int i=0;i<9;++i){
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "ui/transfer_market.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];
|
out.portrait=game.manager_records[base+0x221];
|
||||||
if(out.portrait>14)throw FormatError("poach notice: invalid Original portrait");
|
if(out.portrait>14)throw FormatError("poach notice: invalid Original portrait");
|
||||||
const int team=game.manager_teams[size_t(manager)];
|
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(!out.badge_fallback) {
|
||||||
if(team<0 || size_t(team)*2+2>game.club_heap_78.size())throw FormatError("poach notice: missing badge selector");
|
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;
|
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
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#pragma once
|
#pragma once
|
||||||
// The OpenBMH version. CMake sets OPENBMH_VERSION from project(... VERSION ...) in the top
|
// Only the product entry points include the generated version, so changing a
|
||||||
// CMakeLists.txt - the one place to change it; this fallback only serves other builds.
|
// release number does not rebuild the game, test suites or third-party code.
|
||||||
#ifndef OPENBMH_VERSION
|
#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
|
#endif
|
||||||
|
|
||||||
namespace bmh {
|
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.level[3] == 6 &&
|
||||||
flow.environment()->state().values.monthly[3] == 30000,
|
flow.environment()->state().values.monthly[3] == 30000,
|
||||||
"valid environment transaction commits once and keeps the source screen open");
|
"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);
|
(void)flow.pointer_down(10, 10, true);
|
||||||
const auto close = flow.click(10, 10, true);
|
const auto close = flow.click(10, 10, true);
|
||||||
check(close.request == FlowRequest::submenu_closed && !flow.in_environment() && flow.screen_name() == "desktop",
|
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();
|
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 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 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) {
|
for(const auto [row,col]:cells) {
|
||||||
auto state=settings_from_game(game,manager,revision,exe);const size_t index=size_t(row*9+col);
|
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");
|
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 {
|
try {
|
||||||
if (argc != 2 && argc != 3 && argc != 4) throw std::runtime_error("app_controller_tests requires data directory [optional Original save]");
|
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];
|
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") {
|
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_live_delay_settings_writer(data,argv[3]);check_gameplay_switches_writer(data,argv[3]);
|
||||||
check_settings_refusal_controller(data,argv[3]);return 0;
|
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;}
|
||||||
+72
-82
@@ -1,91 +1,81 @@
|
|||||||
#include "runtime_fixture_tables.hpp"
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
#include "test_inputs.hpp"
|
#include "game/environment.hpp"
|
||||||
// The club environment (desk menu 24, src/game/environment.hpp) on a real savegame: staff
|
#include "ui/live_timing.hpp"
|
||||||
// levels, and the supported edition youth academy - only in July/August, the league's season price,
|
|
||||||
// no switching off once paid.
|
|
||||||
|
|
||||||
#include <filesystem>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#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;
|
using namespace bmh;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
|
||||||
void check(bool ok, const std::string& message) {
|
GameState fixture() {
|
||||||
if (!ok) throw std::runtime_error(message);
|
GameState g;
|
||||||
}
|
g.manager_teams = {0, 1};
|
||||||
|
g.manager_records.resize(2 * 0xb0c);
|
||||||
void set_rec32(GameState& g, size_t o, uint32_t v) {
|
g.league_rounds.resize(1);
|
||||||
for (int i = 0; i < 4; i++) g.manager_records.at(o + size_t(i)) = uint8_t(v >> (8 * i));
|
g.memory.add_block(layout::EnvironmentYouthTeams, 0x90);
|
||||||
}
|
for (uint32_t m = 0; m < 2; ++m)
|
||||||
|
for (uint32_t i = 0; i < 3; ++i) {
|
||||||
void environment_test(GameState g) {
|
g.memory.set8(layout::EnvironmentYouthTeams + m * 0x24 + i, uint8_t(60 - i * 10));
|
||||||
// staff: level * 5 000
|
g.memory.set8(layout::EnvironmentYouthTeams + m * 0x24 + i + 3, 6);
|
||||||
check(set_environment(g, 0, kDoctor, 4) != EnvironmentResult::invalid, "doctor level");
|
g.memory.set8(layout::EnvironmentYouthTeams + m * 0x24 + i + 6, uint8_t(i));
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
const auto exe = bmh::test::load_executable(std::filesystem::path(argv[1]) / "BMH.exe");
|
return g;
|
||||||
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)};
|
void budgets() {
|
||||||
GameState g = GameState::from_save(SaveState(file.stream, counts), counts);
|
auto g = fixture();
|
||||||
competition_pointers(g.memory, exe);
|
for (int i = 0; i < 6; ++i) check(set_environment(g, 0, i, 6) == EnvironmentResult::changed, "all six budgets accept maximum");
|
||||||
const auto texts = load_textd(std::filesystem::path(argv[1]) / "TEXTD.BLK");
|
const auto s = environment_state(g, 0);
|
||||||
g.texts = &texts;
|
check(s.monthly == std::array<int32_t, 6>{12000,24000,30000,30000,30000,30000}, "six monthly costs match the supported price units");
|
||||||
environment_test(g);
|
check(environment_state(g, 1).monthly == std::array<int32_t, 6>{}, "other manager's budgets are isolated");
|
||||||
std::cout << "environment tests: ok\n";
|
check(set_environment(g, 0, kYouthAcademy, 6) == EnvironmentResult::unchanged, "repeating a level does not toggle the youth budget");
|
||||||
return 0;
|
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");
|
||||||
} catch (const std::exception& error) {
|
check(set_environment(g, 0, kYouthAcademy, 0) == EnvironmentResult::changed && !environment_academy_active(g, 0), "youth budget can be stopped");
|
||||||
std::cerr << "environment tests: " << error.what() << "\n";
|
check(set_environment(g, 0, 6, 2) == EnvironmentResult::invalid &&
|
||||||
return 1;
|
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;}
|
||||||
@@ -22,10 +22,10 @@ class PackageAllowlistTests(unittest.TestCase):
|
|||||||
with tempfile.TemporaryDirectory() as directory:
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
root = Path(directory)
|
root = Path(directory)
|
||||||
# Empty authored placeholders test names/structure, not executable behavior.
|
# 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']:
|
'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md']:
|
||||||
(root / name).write_text('synthetic')
|
(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.parent.mkdir(parents=True)
|
||||||
notes.write_text('synthetic release notes')
|
notes.write_text('synthetic release notes')
|
||||||
licenses = Path(__file__).resolve().parents[1] / 'docs' / 'licenses'
|
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,
|
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");
|
"undo frees the entry and restores 0xCC");
|
||||||
check(reschedulable_matches(undone, 0).size() == matches.size(), "the match is movable again");
|
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()
|
std::cout << "moved round " << m.round + 1 << " from day " << m.day << " to day " << target << " (" << days.size()
|
||||||
<< " days offered)\n";
|
<< " days offered)\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "formats/le.hpp"
|
#include "formats/le.hpp"
|
||||||
|
#include "game/messages.hpp"
|
||||||
|
#include "game/career.hpp"
|
||||||
|
#include "game/calendar.hpp"
|
||||||
|
#include "game/environment.hpp"
|
||||||
#include "game/schedule.hpp"
|
#include "game/schedule.hpp"
|
||||||
|
|
||||||
namespace bmh::test {
|
namespace bmh::test {
|
||||||
// Standalone engine tests explicitly install the supplied edition's scheduling
|
// 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) {
|
inline LeImage load_executable(const std::filesystem::path& path) {
|
||||||
auto executable = bmh::load_le(path);
|
auto executable = bmh::load_le(path);
|
||||||
install_fixture_tables(executable);
|
install_fixture_tables(executable);
|
||||||
|
install_message_texts(executable);
|
||||||
|
install_career_rules(executable);
|
||||||
|
install_calendar_rules(executable);
|
||||||
|
install_environment_rules(executable);
|
||||||
return 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 <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <optional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -20,6 +23,7 @@
|
|||||||
|
|
||||||
#include "app/career_session.hpp"
|
#include "app/career_session.hpp"
|
||||||
#include "game/desk_actions.hpp"
|
#include "game/desk_actions.hpp"
|
||||||
|
#include "game/save.hpp"
|
||||||
#include "game/lineup.hpp"
|
#include "game/lineup.hpp"
|
||||||
#include "game/matchday.hpp"
|
#include "game/matchday.hpp"
|
||||||
#include "game/month.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
|
// 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
|
// match score (legacy routine). The total-12 plausibility check cannot apply to that
|
||||||
// combined display score: Original week40_capture.jsonl:241 records 11:10.
|
// combined display score: Original week40_capture.jsonl:241 records 11:10.
|
||||||
@@ -150,6 +185,8 @@ int main(int argc, char** argv) {
|
|||||||
Checks checks;
|
Checks checks;
|
||||||
std::string gap;
|
std::string gap;
|
||||||
int played = 0, goals = 0, matches = 0, seasons = 0;
|
int played = 0, goals = 0, matches = 0, seasons = 0;
|
||||||
|
const char* duplicate_directory = std::getenv("SIM_DUPLICATE_DIR");
|
||||||
|
bool duplicate_captured = false;
|
||||||
try {
|
try {
|
||||||
app::CareerSession session(argv[1], argc > 4 ? uint32_t(std::stoul(argv[4])) : 1u);
|
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
|
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;
|
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;
|
ui::DeskRequest kickoff;
|
||||||
kickoff.kind = ui::DeskRequestKind::advance_turn;
|
kickoff.kind = ui::DeskRequestKind::advance_turn;
|
||||||
kickoff.manager_slot = int(g.memory.u8(::bmh::layout::ActiveManager));
|
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;
|
gap = r.reason.empty() ? error : r.reason;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (duplicate_before && capture_duplicate(*duplicate_before, g, duplicate_directory))
|
||||||
|
duplicate_captured = true;
|
||||||
if (r.kind == TurnDeskKind::CareerComplete) {
|
if (r.kind == TurnDeskKind::CareerComplete) {
|
||||||
++played;
|
++played;
|
||||||
std::printf("turn %d (day %u): career complete\n", played, r.date);
|
std::printf("turn %d (day %u): career complete\n", played, r.date);
|
||||||
@@ -330,6 +371,10 @@ int main(int argc, char** argv) {
|
|||||||
++seasons;
|
++seasons;
|
||||||
} // (the next kickoff runs the season change)
|
} // (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");
|
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_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);
|
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/binary.hpp"
|
||||||
#include "formats/font.hpp"
|
#include "formats/font.hpp"
|
||||||
#include "formats/le.hpp"
|
#include "formats/le.hpp"
|
||||||
#include "formats/rule_base.hpp"
|
|
||||||
|
|
||||||
using namespace bmh;
|
using namespace bmh;
|
||||||
using namespace bmh::ui;
|
using namespace bmh::ui;
|
||||||
|
|||||||
@@ -39,7 +39,20 @@ void youth_test(GameState g) {
|
|||||||
GameRandom game(4711);
|
GameRandom game(4711);
|
||||||
WatcomRandom rand(815);
|
WatcomRandom rand(815);
|
||||||
MinuteReport report;
|
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
|
// unpaid: nothing happens, nothing is drawn
|
||||||
|
g.memory.set32(::bmh::layout::Spending + 4, price);
|
||||||
set_rec32(g, 0x880, price - 1);
|
set_rec32(g, 0x880, price - 1);
|
||||||
check(!youth_academy_player(g, 0, game, rand, report) && game.calls() == 0 && rand.calls() == 0, "unpaid academy");
|
check(!youth_academy_player(g, 0, game, rand, report) && game.calls() == 0 && rand.calls() == 0, "unpaid academy");
|
||||||
// paid
|
// 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()
|
||||||
Loaded 100 of 107 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user