Compare commits
63
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cccbb01d3 | ||
|
|
8780d7b5a5 | ||
|
|
a279bfb6df | ||
|
|
0535764834 | ||
|
|
2f5303d9bd | ||
|
|
7cc7c3a7ea | ||
|
|
f33b381f18 | ||
|
|
39de3dc9d4 | ||
|
|
fcd6eb9204 | ||
|
|
16ae7df7f8 | ||
|
|
b8a37353cc | ||
|
|
7cfc8267b6 | ||
|
|
f12857414e | ||
|
|
81ae6ad236 | ||
|
|
38f69fa37b | ||
|
|
1e7df751a0 | ||
|
|
af634ae8ff | ||
|
|
04ff3b7656 | ||
|
|
f7d20dad9e | ||
|
|
d661ec5eb0 | ||
|
|
048f617395 | ||
|
|
249bdca1a8 | ||
|
|
b8904db92d | ||
|
|
9ec136a09f | ||
|
|
a275ffa1a9 | ||
|
|
fcb6ac14bb | ||
|
|
acdc7d5c14 | ||
|
|
0faad16148 | ||
|
|
f44de65e22 | ||
|
|
bea5478433 | ||
|
|
2d744e380c | ||
|
|
9140fb4b03 | ||
|
|
02f47f7972 | ||
|
|
564af00d8d | ||
|
|
e8ba78e135 | ||
|
|
fcbe1ebc13 | ||
|
|
8b1dc16233 | ||
|
|
9c10a2bfeb | ||
|
|
6f33f9c155 | ||
|
|
9c82cb16b5 | ||
|
|
0bfa705ec5 | ||
|
|
c6341aa4f9 | ||
|
|
8862bd4f89 | ||
|
|
a5aa4c6a08 | ||
|
|
2a2fd17d07 | ||
|
|
0e8cfe5cd9 | ||
|
|
feb6ca2717 | ||
|
|
5caf23c452 | ||
|
|
30843fc9f3 | ||
|
|
8e2f491d5e | ||
|
|
4a93d9fd88 | ||
|
|
540178b264 | ||
|
|
86e2bfd32a | ||
|
|
8baf80564a | ||
|
|
d57b6b5a96 | ||
|
|
70082ef825 | ||
|
|
f87d927c8d | ||
|
|
777039832d | ||
|
|
fc07e45bbc | ||
|
|
7482697248 | ||
|
|
7b5cd6988e | ||
|
|
c8ae7a31d2 | ||
|
|
db56c323aa |
No files matched your search
@@ -3,7 +3,7 @@ name: Build without game data
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, release/1.0, poc/1.1-international]
|
||||
branches: [main, release/1.0]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
@@ -43,7 +43,6 @@ jobs:
|
||||
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
|
||||
python3 -m unittest discover -s tools/poc -p "test_*.py"
|
||||
- name: Set up MSVC x64
|
||||
if: runner.os == 'Windows'
|
||||
uses: ilammy/msvc-dev-cmd@a102174a2b586eec2ea151a69e6fd14404a8ce7c # v1.13.0
|
||||
@@ -84,19 +83,6 @@ jobs:
|
||||
subprocess.run([str(build / ('OpenBMH' + suffix)), '--version'], check=True)
|
||||
- name: Package products and licenses
|
||||
run: python3 tools/package/make_package.py --build build --out dist --platform ${{ matrix.platform }}
|
||||
- name: Package native Windows editor
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$game = (Get-ChildItem dist/OpenBMH-*-windows-x64.zip | Select-Object -First 1).FullName
|
||||
python3 tools/package/make_editor_package.py --build build --game $game --out editor-dist
|
||||
- name: Upload native editor
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
||||
with:
|
||||
name: obdeddi-windows-x64
|
||||
path: editor-dist/*.zip
|
||||
if-no-files-found: error
|
||||
- name: Package corresponding source and pinned dependencies
|
||||
if: runner.os == 'Linux'
|
||||
run: python3 tools/package/make_source_package.py --source . --build build --out source-dist
|
||||
|
||||
@@ -62,4 +62,4 @@ jobs:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
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
|
||||
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.7/RELEASE_NOTES.md
|
||||
+67
-40
@@ -1,11 +1,11 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 1.1.0 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 1.0.7 LANGUAGES CXX C)
|
||||
if(APPLE)
|
||||
# Enable native languages before dependencies/subdirectories inherit rules.
|
||||
enable_language(OBJC OBJCXX)
|
||||
endif()
|
||||
set(OPENBMH_PRERELEASE "beta.1" CACHE STRING "Prerelease identifier; empty for final release")
|
||||
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}")
|
||||
@@ -207,21 +207,18 @@ bmh_add_data_test(NAME highscore_tests REQUIRED_OPTIONS BMH_TEST_HIGHSCORE_TESTS
|
||||
# Engine core: file formats and game logic, no platform dependencies
|
||||
add_library(bmhcore STATIC
|
||||
src/formats/binary.cpp
|
||||
src/formats/resource_bundle.cpp
|
||||
src/formats/palette.cpp
|
||||
src/formats/vga.cpp
|
||||
src/formats/font.cpp
|
||||
src/formats/textd.cpp
|
||||
src/formats/fbm.cpp
|
||||
src/formats/le.cpp
|
||||
src/formats/data_profile.cpp
|
||||
src/formats/m3d.cpp
|
||||
src/formats/savestate.cpp
|
||||
src/game/schedule.cpp
|
||||
src/game/league_pairings.cpp
|
||||
src/game/source_tip.cpp
|
||||
src/game/table_forecast.cpp
|
||||
src/game/profile_runtime.cpp
|
||||
src/game/state.cpp
|
||||
src/game/rating.cpp
|
||||
src/game/match.cpp
|
||||
@@ -235,6 +232,7 @@ add_library(bmhcore STATIC
|
||||
src/game/reality_ball.cpp
|
||||
src/game/reality_duel.cpp
|
||||
src/game/reality_reporter.cpp
|
||||
src/game/long_career.cpp
|
||||
src/game/matchday.cpp
|
||||
src/game/sportschau_replay.cpp
|
||||
src/game/sportschau_rating.cpp
|
||||
@@ -306,7 +304,6 @@ FetchContent_MakeAvailable(miniz lzma_sdk nfd)
|
||||
|
||||
add_library(bmh_miniz STATIC ${miniz_SOURCE_DIR}/miniz.c)
|
||||
target_include_directories(bmh_miniz PUBLIC ${miniz_SOURCE_DIR})
|
||||
target_link_libraries(bmhcore PRIVATE bmh_miniz)
|
||||
set(BMH_LZMA_C ${lzma_sdk_SOURCE_DIR}/C)
|
||||
add_library(bmh_7z STATIC
|
||||
${BMH_LZMA_C}/7zAlloc.c ${BMH_LZMA_C}/7zArcIn.c ${BMH_LZMA_C}/7zBuf.c ${BMH_LZMA_C}/7zCrc.c
|
||||
@@ -344,6 +341,10 @@ bmh_add_data_test(NAME format_tests REQUIRED_OPTIONS BMH_TEST_INPUTS
|
||||
REQUIRED_FILES expected-text.tsv format-players.tsv format-start.fbm
|
||||
COMMAND format_tests "${BMH_DATA}" "${BMH_REFERENCE}")
|
||||
|
||||
add_executable(stadium_extended_limits_tests tests/stadium_extended_limits_tests.cpp)
|
||||
target_link_libraries(stadium_extended_limits_tests PRIVATE bmhcore)
|
||||
add_test(NAME stadium_extended_limits_tests COMMAND stadium_extended_limits_tests)
|
||||
|
||||
add_executable(stand_block_actions_tests tests/stand_block_actions_tests.cpp)
|
||||
target_link_libraries(stand_block_actions_tests PRIVATE bmhcore)
|
||||
add_test(NAME stand_block_actions_tests COMMAND stand_block_actions_tests)
|
||||
@@ -448,12 +449,29 @@ target_link_libraries(desk_check PRIVATE bmhcore)
|
||||
add_executable(init_check tests/init_check.cpp)
|
||||
target_link_libraries(init_check PRIVATE bmhcore)
|
||||
|
||||
# The approved compressed title is embedded: no install-time sidecar dependency.
|
||||
set(BMH_START_SCREEN_DATA "${CMAKE_BINARY_DIR}/generated/start_screen_data.cpp")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/generated")
|
||||
add_custom_command(OUTPUT "${BMH_START_SCREEN_DATA}"
|
||||
COMMAND "${CMAKE_COMMAND}" "-DINPUT=${CMAKE_SOURCE_DIR}/assets/start-screen.jpg"
|
||||
"-DOUTPUT=${BMH_START_SCREEN_DATA}" -P "${CMAKE_SOURCE_DIR}/cmake/EmbedStartScreen.cmake"
|
||||
DEPENDS assets/start-screen.jpg cmake/EmbedStartScreen.cmake
|
||||
VERBATIM)
|
||||
add_library(openbmh_start_screen STATIC src/app/start_screen.cpp "${BMH_START_SCREEN_DATA}")
|
||||
target_include_directories(openbmh_start_screen PRIVATE "${CMAKE_SOURCE_DIR}/src")
|
||||
target_link_libraries(openbmh_start_screen PUBLIC ${BMH_SDL_TARGET})
|
||||
add_executable(start_screen_tests tests/start_screen_tests.cpp)
|
||||
target_include_directories(start_screen_tests PRIVATE "${CMAKE_SOURCE_DIR}/src")
|
||||
target_link_libraries(start_screen_tests PRIVATE openbmh_start_screen)
|
||||
add_test(NAME start_screen_tests COMMAND start_screen_tests)
|
||||
|
||||
# The playable program: the shared UI library connected to the engine by src/app.
|
||||
add_executable(openbmh_play
|
||||
src/app/main.cpp
|
||||
${BMH_APP_CONTROLLER_SOURCE}
|
||||
${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(openbmh_play PRIVATE bmhui bmhlaunch_dialog openbmh_audio ${BMH_SDL_TARGET})
|
||||
target_link_libraries(openbmh_play PRIVATE openbmh_start_screen)
|
||||
# a game without a console window on double-click (SDL2main provides WinMain); started from a
|
||||
# console it attaches to that one for --version, --help and start errors (src/app/main.cpp)
|
||||
set_target_properties(openbmh_play PROPERTIES WIN32_EXECUTABLE TRUE OUTPUT_NAME OpenBMH)
|
||||
@@ -496,6 +514,8 @@ if(MSVC)
|
||||
endif()
|
||||
bmh_add_data_test(NAME app_controller_tests COMMAND app_controller_tests "${BMH_DATA}")
|
||||
set(BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 "" CACHE PATH "External input 1 for app_delay_settings_tests; not distributed")
|
||||
bmh_add_data_test(NAME app_desktop_input_tests COMMAND app_controller_tests "${BMH_DATA}" --desktop-input-only)
|
||||
bmh_add_data_test(NAME app_advertising_input_tests COMMAND app_controller_tests "${BMH_DATA}" --advertising-input-only)
|
||||
bmh_add_data_test(NAME app_environment_tests COMMAND app_controller_tests "${BMH_DATA}" --environment-only)
|
||||
bmh_add_data_test(NAME app_delay_settings_tests REQUIRED_OPTIONS BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 COMMAND app_controller_tests "${BMH_DATA}"
|
||||
--delay-settings-only "${BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1}")
|
||||
@@ -516,6 +536,10 @@ add_executable(national_friendly_actions_tests tests/national_friendly_actions_t
|
||||
target_link_libraries(national_friendly_actions_tests PRIVATE bmhcore)
|
||||
add_test(NAME national_friendly_actions_tests COMMAND national_friendly_actions_tests)
|
||||
|
||||
add_executable(edition_startup_app_tests tests/edition_startup_app_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(edition_startup_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
bmh_add_data_test(NAME edition_startup_app_tests COMMAND edition_startup_app_tests "${BMH_DATA}")
|
||||
|
||||
add_executable(manager_join_app_tests tests/manager_join_app_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(manager_join_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
if(MSVC)
|
||||
@@ -940,6 +964,8 @@ bmh_add_data_test(NAME league_views_data_tests COMMAND league_views_data_tests "
|
||||
# FLTD is translated by launch_check/the launcher first. Do not point these
|
||||
# tests at the raw DOS directory: the shared UI consumes the prepared image.
|
||||
set(BMH_ENGLISH_DATA "" CACHE PATH "Prepared Football Limited game-data directory")
|
||||
bmh_add_data_test(NAME english_environment_controller_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND app_controller_tests "${BMH_ENGLISH_DATA}" --environment-only)
|
||||
bmh_add_data_test(NAME english_edition_startup_app_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND edition_startup_app_tests "${BMH_ENGLISH_DATA}")
|
||||
bmh_add_data_test(NAME english_pairings_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_pairings_data_tests "${BMH_ENGLISH_DATA}")
|
||||
bmh_add_data_test(NAME english_desktop_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND desktop_data_tests "${BMH_ENGLISH_DATA}" --english)
|
||||
bmh_add_data_test(NAME english_league_views_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_views_data_tests "${BMH_ENGLISH_DATA}")
|
||||
@@ -1124,6 +1150,9 @@ foreach(dependency IN ITEMS SDL2 miniz lzma_sdk nfd)
|
||||
endforeach()
|
||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/package-dependencies.json" CONTENT "${package_dependencies}\n")
|
||||
|
||||
add_executable(environment_profile_tests tests/environment_profile_tests.cpp)
|
||||
target_link_libraries(environment_profile_tests PRIVATE bmhcore)
|
||||
add_test(NAME environment_profile_tests COMMAND environment_profile_tests)
|
||||
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)
|
||||
@@ -1157,40 +1186,38 @@ add_executable(desktop_feedback_tests tests/desktop_feedback_tests.cpp)
|
||||
target_link_libraries(desktop_feedback_tests PRIVATE bmhui)
|
||||
bmh_add_data_test(NAME desktop_feedback_tests COMMAND desktop_feedback_tests "${BMH_DATA}")
|
||||
|
||||
add_executable(data_profile_tests tests/data_profile_tests.cpp)
|
||||
target_link_libraries(data_profile_tests PRIVATE bmhcore)
|
||||
add_test(NAME data_profile_tests COMMAND data_profile_tests)
|
||||
add_executable(daily_interest_unit_tests tests/daily_interest_unit_tests.cpp)
|
||||
target_link_libraries(daily_interest_unit_tests PRIVATE bmhcore)
|
||||
add_test(NAME daily_interest_unit_tests COMMAND daily_interest_unit_tests)
|
||||
add_executable(transfer_seller_actions_tests tests/transfer_seller_actions_tests.cpp)
|
||||
target_link_libraries(transfer_seller_actions_tests PRIVATE bmhcore)
|
||||
add_test(NAME transfer_seller_actions_tests COMMAND transfer_seller_actions_tests)
|
||||
|
||||
# Offline private package preparation; never installs Original data.
|
||||
add_executable(export_community_runtime tools/poc/export_runtime.cpp)
|
||||
target_link_libraries(export_community_runtime PRIVATE bmhcore)
|
||||
add_executable(resource_bundle_tests tests/resource_bundle_tests.cpp)
|
||||
target_link_libraries(resource_bundle_tests PRIVATE bmhcore bmh_miniz)
|
||||
add_test(NAME resource_bundle_tests COMMAND resource_bundle_tests)
|
||||
add_executable(transfer_seller_app_tests tests/transfer_seller_app_tests.cpp ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(transfer_seller_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
set(BMH_TEST_TRANSFER_SELLER_APP_SAVE "" CACHE FILEPATH "External career for seller-offer integration; not distributed")
|
||||
bmh_add_data_test(NAME transfer_seller_app_tests REQUIRED_OPTIONS BMH_TEST_TRANSFER_SELLER_APP_SAVE
|
||||
COMMAND transfer_seller_app_tests "${BMH_DATA}" "${BMH_TEST_TRANSFER_SELLER_APP_SAVE}")
|
||||
|
||||
# Small native OBD editor. Its model is tested on every platform; UI is Win32 only.
|
||||
add_library(obdeddi_hash STATIC ${BMH_LZMA_C}/Sha256.c ${BMH_LZMA_C}/Sha256Opt.c)
|
||||
target_include_directories(obdeddi_hash PUBLIC ${BMH_LZMA_C})
|
||||
target_link_libraries(obdeddi_hash PRIVATE bmh_7z)
|
||||
add_library(obdeddi_model STATIC src/obdeddi/document.cpp src/cli/json.cpp)
|
||||
target_include_directories(obdeddi_model PUBLIC src)
|
||||
target_link_libraries(obdeddi_model PUBLIC bmhcore PRIVATE bmh_miniz obdeddi_hash)
|
||||
if(WIN32)
|
||||
add_executable(obdeddi WIN32 src/obdeddi/main_win32.cpp src/obdeddi/logo_win32.cpp src/obdeddi/logo_transform_win32.cpp)
|
||||
target_link_libraries(obdeddi PRIVATE obdeddi_model comctl32 comdlg32 user32 gdi32 shell32 gdiplus)
|
||||
if(MSVC)
|
||||
target_compile_options(obdeddi PRIVATE /utf-8)
|
||||
target_compile_options(obdeddi_model PRIVATE /utf-8)
|
||||
endif()
|
||||
install(TARGETS obdeddi RUNTIME DESTINATION . COMPONENT Editor)
|
||||
endif()
|
||||
add_executable(obdeddi_tests tests/obdeddi_tests.cpp)
|
||||
target_link_libraries(obdeddi_tests PRIVATE obdeddi_model bmh_miniz)
|
||||
add_test(NAME obdeddi_tests COMMAND obdeddi_tests)
|
||||
add_executable(wide_number_unit_tests tests/wide_number_unit_tests.cpp)
|
||||
target_link_libraries(wide_number_unit_tests PRIVATE bmhcore)
|
||||
add_test(NAME wide_number_unit_tests COMMAND wide_number_unit_tests)
|
||||
add_executable(long_career_tests tests/long_career_tests.cpp)
|
||||
target_link_libraries(long_career_tests PRIVATE bmhcore)
|
||||
add_test(NAME long_career_tests COMMAND long_career_tests)
|
||||
|
||||
if(WIN32)
|
||||
add_executable(obdeddi_logo_tests tests/obdeddi_logo_tests.cpp src/obdeddi/logo_transform_win32.cpp)
|
||||
target_include_directories(obdeddi_logo_tests PRIVATE src)
|
||||
target_link_libraries(obdeddi_logo_tests PRIVATE gdiplus)
|
||||
add_test(NAME obdeddi_logo_tests COMMAND obdeddi_logo_tests)
|
||||
endif()
|
||||
add_executable(bank_robbery_month_tests tests/bank_robbery_month_tests.cpp)
|
||||
target_link_libraries(bank_robbery_month_tests PRIVATE bmhcore)
|
||||
add_test(NAME bank_robbery_month_tests COMMAND bank_robbery_month_tests)
|
||||
add_executable(monthly_dividend_tests tests/monthly_dividend_tests.cpp)
|
||||
target_link_libraries(monthly_dividend_tests PRIVATE bmhui)
|
||||
add_test(NAME monthly_dividend_tests COMMAND monthly_dividend_tests)
|
||||
|
||||
add_executable(native_save_version_tests tests/native_save_version_tests.cpp)
|
||||
target_link_libraries(native_save_version_tests PRIVATE bmhcore)
|
||||
add_test(NAME native_save_version_tests COMMAND native_save_version_tests)
|
||||
add_executable(native_save_import_tests tests/native_save_import_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(native_save_import_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
set(BMH_TEST_NATIVE_SAVE_IMPORT_INPUT "" CACHE FILEPATH "External native save for import compatibility; not distributed")
|
||||
bmh_add_data_test(NAME native_save_import_tests REQUIRED_OPTIONS BMH_TEST_NATIVE_SAVE_IMPORT_INPUT
|
||||
COMMAND native_save_import_tests "${BMH_DATA}" "${BMH_TEST_NATIVE_SAVE_IMPORT_INPUT}")
|
||||
@@ -1,6 +1,9 @@
|
||||
# OpenBMH
|
||||
|
||||
This is the **1.1 community development branch**. A prepared community package starts directly from `COMMUNITY.OBD`, without BMH.exe or a DOS installation. Original loose Classic installations remain supported. The stable 1.0 line stays on main. See [standalone community data](docs/poc-1.1/STANDALONE.md).
|
||||
**Classic-Version: 1.0.7.** Die originalgetreue Linie bleibt in diesem Repository.
|
||||
Erweiterte Ligen, die gemeinsame deutsche/englische Karriere und der Dateneditor
|
||||
werden separat als **[OpenBMH-Extended 1.0 Beta](https://github.com/Weyoune/OpenBMH-extended)** entwickelt.
|
||||
|
||||
|
||||
A faithful, standalone community reconstruction of *Bundesliga Manager Hattrick*, using the player's original installation and SDL2 interface.
|
||||
|
||||
@@ -25,7 +28,9 @@ From a terminal in the extracted package on Linux or macOS:
|
||||
|
||||
In Windows PowerShell, use `.\OpenBMH.exe` and `.\openbmh_cli.exe` instead.
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0/RELEASE_NOTES.md).
|
||||
To report a problem, start the game with `-debug`. It then writes `openbmh-debug.log` (timestamped events, errors and refused actions) and `openbmh-stderr.log` into the `debug` sub folder of the save directory, and saves the game there after every match day (`DBG00001.FBM`, `DBG00002.FBM`, ...). Attach the log and the last save to the report.
|
||||
|
||||
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.7/RELEASE_NOTES.md).
|
||||
|
||||
## Features and direction
|
||||
|
||||
@@ -108,3 +113,5 @@ OpenBMH's own code and documentation are licensed under **GNU GPL version 3 only
|
||||
Every published binary release identifies its matching source tag and provides a corresponding source archive. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
|
||||
|
||||
Bundled components retain their own licenses, including Nuked OPL3 under LGPL-2.1-or-later. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and [ACKNOWLEDGEMENTS.md](ACKNOWLEDGEMENTS.md).
|
||||
|
||||
The supplied project start artwork is embedded at native resolution; see [start-screen artwork](docs/START_SCREEN.md). It replaces the original title image while the game continues to use your own original data and assets.
|
||||
@@ -4,6 +4,7 @@ OpenBMH's own code and documentation use GPL-3.0-only. This does not replace the
|
||||
|
||||
| Component | Version used by the build | License | Included notice |
|
||||
|---|---|---|---|
|
||||
| [stb_image](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h) | 2.30, vendored header; JPEG decoder only | MIT or public-domain alternative | [stb_image.txt](docs/licenses/stb_image.txt) |
|
||||
| [SDL2](https://github.com/libsdl-org/SDL/tree/release-2.32.10) | 2.32.10, or an explicitly selected system SDL2 | zlib license | [SDL2.txt](docs/licenses/SDL2.txt) |
|
||||
| SDL2 HIDAPI code | Included with SDL2 | BSD-3-Clause option; upstream also offers GPL-3.0 and its original license | [license options](docs/licenses/SDL2-HIDAPI-options.txt), [BSD text](docs/licenses/SDL2-HIDAPI-BSD.txt), [original text](docs/licenses/SDL2-HIDAPI-original.txt) |
|
||||
| SDL2 yuv2rgb code | Included with SDL2 | BSD-3-Clause | [SDL2-yuv2rgb.txt](docs/licenses/SDL2-yuv2rgb.txt) |
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# OpenBMH Classic start artwork
|
||||
|
||||
The project maintainer supplied this new start-screen artwork for use and
|
||||
repository distribution with this application. It is not extracted game content.
|
||||
The repository license applies to project artwork; original game assets remain
|
||||
external. The unmodified upstream decoder has its separate documented license.
|
||||
|
||||
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
|
||||
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
|
||||
without EXIF or other input metadata. It occupies 587,410 bytes.
|
||||
The application embeds it at build time and decodes it once at startup, so
|
||||
installed applications need no image sidecar or original title-screen VGA.
|
||||
|
||||
The SDL renderer uses the actual image dimensions while showing the title,
|
||||
including high-DPI output and aspect-preserving side bars, then restores the
|
||||
320 × 240 game/input canvas. A complete left or right mouse click continues;
|
||||
there is no loading-ball animation. Changing the artwork also requires an
|
||||
explicit review/update of its SHA256 in the public-source guard.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 574 KiB |
@@ -0,0 +1,4 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
file(READ "${INPUT}" artwork HEX)
|
||||
string(REGEX REPLACE "(..)" "0x\\1," artwork "${artwork}")
|
||||
file(WRITE "${OUTPUT}" "// Generated from the repository-owned compressed start screen.\n#include \"app/start_screen_data.hpp\"\nnamespace bmh::app {\nconst unsigned char start_screen_jpeg[] = {${artwork}};\nconst std::size_t start_screen_jpeg_size=sizeof(start_screen_jpeg);\n}\n")
|
||||
@@ -139,6 +139,8 @@ This index includes registered and reserved names. `ListOptions` and `Help` from
|
||||
| `SetSquadSheet` | sheet:enum(A,B) | Set Squad Sheet. See current Help for behaviour and bounds. |
|
||||
| `SetMarketVisible` | on:bool | Set Market Visible. See current Help for behaviour and bounds. |
|
||||
| `ShowPlayer` | player:Player | Show Player. See current Help for behaviour and bounds. |
|
||||
| `ShowOffers` | player:Player | existing bids for an owned listing; raw bid slots 0..3 |
|
||||
| `AcceptOffer` | player:Player, bid:int(0..3) | accept an existing bid before weekly expiry |
|
||||
| `SellPlayer` | player:Player | VER-KAUFEN: put an own player on the list |
|
||||
| `LoanOutPlayer` | player:Player, months:int(12\|24) | VER-LEIHEN: offer an own player for loan |
|
||||
| `BuyPlayer` | player:Player | VER-KAUFEN on a market player: the offer editor |
|
||||
|
||||
+136
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
OpenBMH aims to preserve the familiar game while handling malformed input and unsafe edge cases explicitly. A reconstruction can remain faithful without reproducing a crash or pretending to implement an unknown path.
|
||||
|
||||
- Content such as names, text, graphics and edition-specific tables is loaded from the user's installation. The loaded program retains its own rule-table values; loading no longer applies the former shared replacement profile.
|
||||
- Names, text, graphics and compatible data tables come from the user's installation. The common gameplay implementation follows the documented Diamond 3.7 engine policy; original programme instructions are not executed or selected as separate engines.
|
||||
- Safety checks reject transactions that would exhaust required return capacity, use stale identities or lose a valid state. Unsupported operations report their limitation rather than inventing an outcome.
|
||||
- Calendar progression handles boundary days and seasonal transitions without relying on unsafe fixed-day assumptions.
|
||||
- Saves are written from the committed session state. Saving does not deliberately replay unrelated game actions.
|
||||
@@ -23,14 +23,33 @@ 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
|
||||
## Common engine and source data
|
||||
|
||||
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.
|
||||
The common engine uses the Diamond 3.7 six-budget monthly environment model for every supported source-data edition, including Diamond 3.6 and Football Limited. Original programme instruction fingerprints do not select another engine or block compatible data. The six numeric budget increments are read from the supplied table and installed together only when all are present and nonzero; malformed layouts remain rejected. Existing saved lump-sum academy contracts retain their established accounting until edited. English translation supplies the actual English geometry, steps and suffixes for this common model. The old floppy executable remains unsupported, and Football Limited remains experimental.
|
||||
|
||||
Football Limited's data distinguishes five internal domestic slots from four
|
||||
player-visible levels. Fresh manager selection cycles those four levels and
|
||||
hides the internal fifth picker group; confirmation rejects hidden targets and
|
||||
clubs before changing options or consuming RNG. Additional club pages remain
|
||||
separate. Internal sizes, squads, rankings and fixtures are retained, and saved
|
||||
internal league values do not cause a general load rejection.
|
||||
|
||||
Release acceptance of individual editions is recorded separately from their recognition. Source compatibility and automated tests do not establish full original-game or platform validation.
|
||||
|
||||
OpenBMH deviates from the original: graphical startup shows the supplied static
|
||||
137.VGA title with its embedded palette, without the DOS loading animation.
|
||||
It waits for a complete left or right mouse click before the game options.
|
||||
The title does not advance on a timer; its confirming press and release are
|
||||
consumed so they cannot also change a setup option.
|
||||
|
||||
Setup restores ordinary scene-backed manager dialogs before a career is created
|
||||
or loaded. The executable's boot-only black dialog mode is process state and is
|
||||
not restored from native save files. Football Limited's translated data includes
|
||||
its own verified calendar year and weekday operands; German epochs are not used
|
||||
as a substitute for the English edition.
|
||||
|
||||
## Diamond 3.7 foreign crests
|
||||
|
||||
The supplied edition controls whether foreign league clubs use individual
|
||||
@@ -41,3 +60,117 @@ Older drawing gates retain their own behaviour; no external crest pack is needed
|
||||
The automatic lineup installs the supplied foreign-player rule switch alongside the career tables. Where enabled, it restores the original three/two-player limit, reserve swaps with board-coordinate preservation and the short-lineup outcome when domestic reserves are unavailable. This does not consume additional random draws.
|
||||
|
||||
New careers correct the original all-zero EM qualification placeholders to the original national-team placeholders. Supplied nonzero seeds and restored savegame state are not rewritten by this initialization.
|
||||
|
||||
## Stadium extension in1.0.3
|
||||
|
||||
The user-requested stadium extension raises standard A–H maxima to14/24/14/20/
|
||||
14/24/14/20thousand places (144,000total), keeping larger supplied custom limits
|
||||
where the saved byte fields can represent them. Original unit prices remain
|
||||
edition-owned. Each stand's base build period is at least two weeks per1,000
|
||||
places of its expanded maximum and never shorter than the edition's original
|
||||
period. Contractor shortening remains unchanged.
|
||||
|
||||
The original Diamond3.6/3.7 table's14k stands really used25weeks versus30weeks
|
||||
for8k and37weeks for18k. That was original data, not a mistaken timer. Expanded
|
||||
limits/time policy is an intentional improvement. The UI now validates quotes
|
||||
against the actual edition and this shared policy rather than hardcoded Diamond
|
||||
prices and sizes. Existing eight capacity/construction bytes and saves are retained.
|
||||
## Daily interest at large native balances
|
||||
|
||||
OpenBMH deviates from the original: daily debt and deposit interest uses 64-bit
|
||||
intermediate arithmetic before the original integer divisions. The balance-plan
|
||||
preview uses the same calculation. Original rates, division order and random
|
||||
consumption remain unchanged. Account balances and accumulated statistics retain
|
||||
the native 32-bit save representation; this change does not add unlimited account
|
||||
balances or change the original high-cash deduction policy.
|
||||
OpenBMH deviates from the original: the legacy transfer market allows an owned
|
||||
listing to open incoming offers before its weekly expiry. Select the player and
|
||||
use the sale action (or Enter). Cancel keeps the listing and offers unchanged;
|
||||
acceptance uses the existing buyer eligibility, player salary qualification and
|
||||
transaction rules. Human-buyer loans still require their separate consent and
|
||||
allocator context and are unavailable in this early review. Viewing/canceling
|
||||
consumes no RNG. The weekly auction remains unchanged.
|
||||
|
||||
The transfer overview processes one selected player per action and renders action
|
||||
feedback in its footer. A cleared unsuccessful listing can be listed again
|
||||
immediately; there is no additional cooldown. The manager listing action refuses a full ordinary market
|
||||
without allocating a reserved special-offer row. These are explicit
|
||||
application outcomes instead of the Original's destructive overflow/dialog paths.
|
||||
|
||||
OpenBMH deviates from the original: a newly initialized squad board entry clears
|
||||
retirement, refused-negotiation and month-processing flags left by its previous
|
||||
occupant. The Original leaves that byte intact when reusing the row, so purchases
|
||||
and academy arrivals can inherit a refusal to renew. Existing players' genuine
|
||||
retirement/refusal flags remain effective. The initial academy contract remains
|
||||
two years; a young arrival can immediately negotiate any supported renewal term.
|
||||
This corrects the reused-row mechanism; it does not establish a fixed 200–300
|
||||
season threshold or repair ambiguous refusal flags in existing saved careers.
|
||||
|
||||
Bank finance-overview totals and gains use 64-bit read-only projections and
|
||||
currency formatting, including values beyond a signed native account word.
|
||||
Saved cash, deposits, loan fields and holdings retain their original widths.
|
||||
This prevents a positive combined portfolio from appearing negative; it does
|
||||
not recover amounts that have already overflowed inside a native saved field.
|
||||
|
||||
Live ball, set-piece and shot animations retain
|
||||
visible scoreboard digits at the chance-preview value until the result view.
|
||||
The simulation still commits goals, statistics and random draws at their existing
|
||||
boundaries. Post-match overview dismissal owns its full mouse gesture, including
|
||||
release after pointer movement, before the following calendar decision can open.
|
||||
The pitch uses each edition's original position-distance tables, atlas swatches
|
||||
and pointer bitmap for placement feedback; this display state is not serialized.
|
||||
OpenBMH deviates from the original: cumulative human-club appearances, goals and
|
||||
assists have optional 64-bit counters. Original byte/word fields keep their
|
||||
modulo representation for gameplay/layout compatibility; roster projections use
|
||||
the wider values. Tracking begins with the surviving legacy values, so high bits
|
||||
already lost in an imported save cannot be recovered. A new arrival clears the
|
||||
previous squad occupant's totals. Club promotion remaps counter ownership.
|
||||
|
||||
Title-holder and cup-winner lists retain all observed seasons in the same optional
|
||||
OpenBMH save extension. The Original nine-by-fifty table remains a rolling window.
|
||||
The archive captures that window before it shifts, and the title list can page
|
||||
through the archived rows. Late legacy imports start with their surviving fifty
|
||||
seasons; earlier winners are unknown and are not fabricated. Stored winner names
|
||||
are historical snapshots, so later renaming and promotion cannot change them.
|
||||
The separate manager-achievements graph retains its Original fifty-season view.
|
||||
|
||||
These records use a versioned `OBMHEXT1` extension after the Original name pools;
|
||||
see [save format](formats/LONG_CAREER.md). Original programs and older OpenBMH
|
||||
writers do not preserve this archive. Keep an OpenBMH backup when exchanging
|
||||
careers with those writers. The native calendar still has its existing signed
|
||||
16-bit season limit; this patch does not claim an unlimited calendar.
|
||||
## Monthly high-cash loss limit
|
||||
|
||||
OpenBMH deviates from the original: the high-cash bank robbery can occur at most
|
||||
once per manager and calendar month. The original threshold above 100 million
|
||||
and random loss of 10–20 million remain. A blocked repeat consumes no random
|
||||
draw. Month boundaries follow the same source calendar used by daily processing,
|
||||
and the guard is stored in the optional BRM1 section of OBMHEXT1 saves.
|
||||
|
||||
An older save has no record of past robberies. Its first qualifying high-cash month
|
||||
receives a grace period without a loss or random draw; subsequent saves retain
|
||||
that guard. The next calendar month can trigger the ordinary loss. Import cannot
|
||||
infer whether an event already occurred before this feature. Fresh histories
|
||||
receive the same initial grace month.
|
||||
|
||||
|
||||
OpenBMH deviates from the original: monthly fund/property dividends multiply
|
||||
unit price by the dividend factor in 64 bits before the existing integer division.
|
||||
The monthly and annual previews and weekly offers use the same widened product.
|
||||
Per-unit rounding and the selected legacy/typed recipient policy are unchanged.
|
||||
This corrects intermediate overflow for representable dividends; account,
|
||||
deposit, property book value and monthly totals still use their native 32-bit
|
||||
storage and can overflow. It is not a complete large-balance finance fix.
|
||||
|
||||
|
||||
Release-driven incoming-transfer presenters require a matching press observed
|
||||
inside that modal. An orphan or repeated release from the preceding result table
|
||||
cannot decline an offer or dismiss its confirmation. Repeated presses while a
|
||||
button is held still form one gesture; fresh left/right clicks keep their actions.
|
||||
|
||||
## Host file overwrite confirmation
|
||||
|
||||
The file picker reuses the Original overwrite question and Ja/Nein button
|
||||
layout. A separate Yes click or Enter confirms; repeated double-clicks do not.
|
||||
OpenBMH deviates from the original: host file operations use the shared dialog's
|
||||
system identity because the picker does not own a live manager portrait projection.
|
||||
@@ -6,27 +6,40 @@ See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These en
|
||||
describe deliberate changes; they are not a list of every known compatibility limit.
|
||||
|
||||
- [src/app/career_session.cpp](../src/app/career_session.cpp): supports designated set-piece record initialization and validation.
|
||||
- [src/app/main.cpp](../src/app/main.cpp): display the repository-owned title at its native resolution until a complete left/right click, without loading balls.
|
||||
- [src/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
|
||||
- [src/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
||||
- [src/game/career.hpp](../src/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
- [src/game/desk_actions.cpp](../src/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): supports designated set-piece records and the supported transfer-editor rules.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): a seller may accept an existing bid before expiry.
|
||||
- [src/game/environment.cpp](../src/game/environment.cpp): the common Diamond 3.7 monthly environment model applies to every supported source-data edition.
|
||||
- [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image.
|
||||
- [src/game/lineup.hpp](../src/game/lineup.hpp): supports owner-bound designated set-piece selection.
|
||||
- [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules.
|
||||
- [src/game/match_engine.cpp](../src/game/match_engine.cpp): supports designated set-piece takers, the enhanced injury tables, and the extended suspension fields.
|
||||
- [src/game/month.cpp](../src/game/month.cpp): keep the price product in 64 bits until division, retaining per-unit truncation and recipient policy.
|
||||
- [src/game/national.cpp](../src/game/national.cpp): a new arrival must not inherit the previous occupant's retirement/refusal/month-processing flags.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): age/retire each player once, even when a temporary offer row references his club slot or regeneration moves him to a later free-agent slot.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): includes transfer-market players in retirement so the five-bit age cannot wrap to 16.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): initializes the empty EM qualifier seeds with national teams, preventing club zero from entering the EM.
|
||||
- [src/game/season.hpp](../src/game/season.hpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/stadium_blocks.cpp](../src/game/stadium_blocks.cpp): allow 144,000 standard places and size-aware construction times while retaining edition-owned unit prices.
|
||||
- [src/game/state.hpp](../src/game/state.hpp): retains designated set-piece selections in the supported manager-record extension.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): widen products before annual-rate division so valid native account amounts do not overflow intermediate sums.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): an unknown history receives a grace month; later losses occur at most once per source month.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): uses the enhanced training rules: focus strength is at least five below its target, and completed skills rotate to another focus.
|
||||
- [src/game/week.hpp](../src/game/week.hpp): uses the enhanced assistant-training rules, retaining the selected skill until it reaches its maximum.
|
||||
- [src/game/weekly.cpp](../src/game/weekly.cpp): uses the supported weekly-event configuration, with its rule switch disabled.
|
||||
- [src/game/weekly.hpp](../src/game/weekly.hpp): uses the supported weekly processing and transfer rule profile.
|
||||
- [src/ui/bank.cpp](../src/ui/bank.cpp): read-only totals use wide arithmetic; individual saved account, price, holding and paid fields are unchanged.
|
||||
- [src/ui/desk_state.cpp](../src/ui/desk_state.cpp): the desk shows the opponent's badge whenever the data has one.
|
||||
- [src/ui/league_pairings.cpp](../src/ui/league_pairings.cpp): the computer tip is ignored silently once a visible result is known, instead of raising an engine error.
|
||||
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
|
||||
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): omits DOS drive and delete buttons in the directory-confined save/load view.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): the host file picker uses the shared dialog's system identity without a live manager portrait projection.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): permits cancelling host file dialogs with the right mouse button.
|
||||
- [src/ui/settings.cpp](../src/ui/settings.cpp): the settings page names the product and its build version instead of the original's version text.
|
||||
@@ -0,0 +1,18 @@
|
||||
# OpenBMH Classic start artwork
|
||||
|
||||
The project maintainer supplied this new start-screen artwork for use and
|
||||
repository distribution with this application. It is not extracted game content.
|
||||
The repository license applies to project artwork; original game assets remain
|
||||
external. The unmodified upstream decoder has its separate documented license.
|
||||
|
||||
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
|
||||
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
|
||||
without EXIF or other input metadata. It occupies 587,410 bytes.
|
||||
The application embeds it at build time and decodes it once at startup, so
|
||||
installed applications need no image sidecar or original title-screen VGA.
|
||||
|
||||
The SDL renderer uses the actual image dimensions while showing the title,
|
||||
including high-DPI output and aspect-preserving side bars, then restores the
|
||||
320 × 240 game/input canvas. A complete left or right mouse click continues;
|
||||
there is no loading-ball animation. Changing the artwork also requires an
|
||||
explicit review/update of its SHA256 in the public-source guard.
|
||||
@@ -0,0 +1,51 @@
|
||||
# Desktop and advertising mouse input fixes
|
||||
|
||||
The optional desktop frame bit controls decoration, not whether the visible
|
||||
widget contents accept input. The corrections reuse the Original renderer,
|
||||
coordinates, layout records and action dispatchers.
|
||||
|
||||
- The date widget activates the same owned advance action as Anstoß, with or
|
||||
without a frame. In a multiplayer turn this first hands control to the next
|
||||
manager. The separate calendar/rescheduling menu keeps its own behavior.
|
||||
- Stored icons remain clickable and draggable from unframed folders. Extraction
|
||||
restores the actual icon record to the visible chain; the folder stays put.
|
||||
Hidden or unlinked owners remain invalid. Removal corners keep their separate
|
||||
transaction and mouse-release barrier. The same frame-origin correction also
|
||||
covers the existing admission scale and five automation controls.
|
||||
- A true double-click on an existing save opens the shared Original-style
|
||||
overwrite question. A separate single click on Ja confirms, Nein returns to
|
||||
the picker, and repeated double-click releases cannot write. Enter and cancel
|
||||
paths remain. FBM, EIN and MEN use the same confirmation boundary.
|
||||
- Advertising follows all nineteen original hit rectangles with palette0x27
|
||||
outlines and the installed edition's detail/help text. Motion alone does not
|
||||
change the career, revision or either random stream. Offers/calculators retain
|
||||
their input owner; returning from them reevaluates the actual pointer, avoiding
|
||||
a stale highlight without requiring another mouse movement.
|
||||
|
||||
## Validation
|
||||
|
||||
The focused configured-data tests are `app_desktop_input_tests`,
|
||||
`app_advertising_input_tests`, `ui_desktop_input_tests`, `ui_save_load_tests` and
|
||||
`ui_advertising_tests`. They cover frame variants, exact field boundaries,
|
||||
canonical actions, stale/hidden-owner refusal, cancellation, input release,
|
||||
overwrite confirmation and unchanged game/random state for presentation-only
|
||||
input. The desktop input test isolates these checks from unrelated private
|
||||
text/badge inventories; the existing full test retains its additional checks.
|
||||
|
||||
Private Linux SDL before/after captures and actual saved games are maintained in
|
||||
`bmh_4k_ui/docs/qa/classic-extended-ui-input`. The fixtures use actual club/player
|
||||
data with a controlled desktop layout. No results are fabricated. A successful
|
||||
compile or CI run alone is not native Windows/macOS UI verification.
|
||||
|
||||
Tracked reports: [#51](https://github.com/Weyoune/openbmh/issues/51), [#52](https://github.com/Weyoune/openbmh/issues/52), [#53](https://github.com/Weyoune/openbmh/issues/53), [#54](https://github.com/Weyoune/openbmh/issues/54).
|
||||
|
||||
The primary regression run uses the supplied Diamond 3.7 installation. Unrelated
|
||||
historical rendering fixtures retain their declared reference requirements.
|
||||
Two existing Classic test fixtures were aligned with the already implemented
|
||||
stadium-capacity policy and verified edition-specific crest gate; product
|
||||
validation was not relaxed to satisfy those tests.
|
||||
|
||||
The overwrite prompt also maps the actual Football Limited English pointer.
|
||||
The translation copies exactly that four-byte pointer and preserves adjacent
|
||||
empty slots. The launcher translation-cache revision is advanced, so an existing
|
||||
cached English installation receives the newly supported prompt as well.
|
||||
@@ -783,7 +783,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishLayoutTranslation157` | `0x6e094` | English image adapter |
|
||||
| `EnglishLayoutTranslation158` | `0x6e0b8` | English image adapter |
|
||||
| `EnglishLayoutTranslation159` | `0x6e0bb` | English image adapter |
|
||||
| `EnglishLayoutTranslation16` | `0x6be4f` | English image adapter |
|
||||
| `EnglishLayoutTranslation16` | `0x6be50` | English image adapter |
|
||||
| `EnglishLayoutTranslation160` | `0x6e0d8` | English image adapter |
|
||||
| `EnglishLayoutTranslation161` | `0x6e110` | English image adapter |
|
||||
| `EnglishLayoutTranslation162` | `0x6e11c` | English image adapter |
|
||||
@@ -1005,7 +1005,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishLayoutTranslation70` | `0x6d270` | English image adapter |
|
||||
| `EnglishLayoutTranslation71` | `0x6d272` | English image adapter |
|
||||
| `EnglishLayoutTranslation72` | `0x6d274` | English image adapter |
|
||||
| `EnglishLayoutTranslation73` | `0x6d29c` | English image adapter |
|
||||
| `EnglishLayoutTranslation73` | `0x6d29d` | English image adapter |
|
||||
| `EnglishLayoutTranslation74` | `0x6d3b4` | English image adapter |
|
||||
| `EnglishLayoutTranslation75` | `0x6d404` | English image adapter |
|
||||
| `EnglishLayoutTranslation76` | `0x6d408` | English image adapter |
|
||||
@@ -1495,6 +1495,14 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `Pitch_Render_TextPointer3` | `0xae0f0` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer4` | `0xae0f4` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer5` | `0xae0f8` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceDepthBases` | `0xa3cc3` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceRed` | `0xa3cc7` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceGreen` | `0xa3cd1` | German-compatible image / runtime field |
|
||||
| `OriginalPointerPixels` | `0xa45b4` | German-compatible image / runtime field |
|
||||
| `EnglishPitchPreferenceDepthBases` | `0x6e230` | English image adapter |
|
||||
| `EnglishPitchPreferenceRed` | `0x6e234` | English image adapter |
|
||||
| `EnglishPitchPreferenceGreen` | `0x6e240` | English image adapter |
|
||||
| `EnglishOriginalPointerPixels` | `0x70554` | English image adapter |
|
||||
| `PitchOrderPositionPointers` | `0xa2a37` | German-compatible image / runtime field |
|
||||
| `PitchOrderZoneMasks` | `0xa2a4b` | German-compatible image / runtime field |
|
||||
| `PitchOrderZoneTextPointers` | `0xae818` | German-compatible image / runtime field |
|
||||
@@ -1570,6 +1578,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `SaveLoad_Render_RuntimeField` | `0xa2334` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_RuntimeField2` | `0xa233f` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_RuntimeField3` | `0xa234a` | German-compatible image / runtime field |
|
||||
| `SaveLoad_OverwriteQuestionPointer` | `0xa21c4` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_TextPointer` | `0xa1512` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_TextPointer2` | `0xae5f0` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_TextPointer3` | `0xae620` | German-compatible image / runtime field |
|
||||
@@ -1991,13 +2000,11 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishSixTeamFixtureTable` | `0x6eed4` | English image adapter |
|
||||
| `EnglishTwelveTeamFixtureTable` | `0x6f0bc` | English image adapter |
|
||||
| `EnglishTwentyTeamFixtureTable` | `0x6ee40` | English image adapter |
|
||||
|
||||
## 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.
|
||||
| `EnglishDesktopBinSourceX` | `0x6e180` | English image adapter |
|
||||
| `EnglishDesktopBinSourceY` | `0x6e182` | English image adapter |
|
||||
| `EnglishDesktopSocketSourceX` | `0x6e184` | English image adapter |
|
||||
| `EnvironmentBudgetSteps` | `0xa50ff` | German-compatible image / runtime field |
|
||||
| `EnvironmentVerifiedCodeBegin` | `0x6c000` | English image adapter |
|
||||
| `EnvironmentVerifiedCodeEnd` | `0x6cb40` | English image adapter |
|
||||
| `EnvironmentVerifiedHookBegin` | `0x7af65` | English image adapter |
|
||||
| `EnvironmentVerifiedHookEnd` | `0x7b020` | English image adapter |
|
||||
+37
-1
@@ -9,7 +9,7 @@
|
||||
| Plain header | Variable | Manager/date information for the load list |
|
||||
| Signature area | 10 bytes | Eight-byte `KRON_FBM` signature and two following bytes |
|
||||
| First ID | u32 | Container identifier |
|
||||
| Version | 6 bytes | NUL-terminated version field, normally `V2.24` for the supported state layout |
|
||||
| Version | 6 bytes | NUL-terminated version field, `V2.24` or the verified Diamond `V3.7` marker for this state layout |
|
||||
| Second ID | u32 | Save identifier |
|
||||
| Random byte | u8 | Header value |
|
||||
| Initial key | u8 | Rolling-cipher seed |
|
||||
@@ -26,8 +26,44 @@ The supported layout contains a fixed ordered block table, followed by four name
|
||||
|
||||
Each name pool has a u16 byte length followed by that many bytes, in club, player, referee and stadium order. These pools preserve renamed entities. The splitter rejects missing/truncated blocks or pools and requires exact stream consumption. See [STATE](STATE.md) for interpreted records and [M3D](M3D.md) for pool references.
|
||||
|
||||
## Optional OpenBMH state
|
||||
|
||||
After the four name pools, OpenBMH can append `OBMHEXT1`, a u16 block count,
|
||||
then each block as a u32 identifier, u32 byte length and payload. There is at
|
||||
most one such container and the decoder requires exact consumption of it.
|
||||
Original saves have no container. The entire extension is included in the outer
|
||||
rolling cipher and checksum.
|
||||
|
||||
Known OpenBMH-owned sections include:
|
||||
|
||||
| Identifier | Payload | Purpose |
|
||||
|---|---|---|
|
||||
| `OBLC` (`0x4f424c43`) | Versioned variable-length archive | [Long-career player counters and title winners](LONG_CAREER.md) |
|
||||
| `BRM1` (`0x314d5242`) | Four little-endian u32 month-start keys (16 bytes) | Per-manager monthly high-cash robbery guard |
|
||||
|
||||
A robbery key is the absolute first day of the last blocked source-calendar
|
||||
month. `UINT32_MAX` means unknown. An unknown high-cash history receives a
|
||||
first qualifying grace month; later deductions can occur at most once per
|
||||
calendar month. Managers have independent keys. A truncated or duplicate BRM1
|
||||
section is rejected before game state is published.
|
||||
|
||||
These identifiers describe OpenBMH-owned payloads, not original executable
|
||||
addresses. The container can also hold explicitly supported compatibility blocks,
|
||||
such as edition-specific cup state. Unrecognized payloads are not a general
|
||||
persistence API. Original programs and older OpenBMH writers may reject or
|
||||
discard optional information: keep a backup before opening a new save with them.
|
||||
|
||||
## Edition compatibility
|
||||
|
||||
Diamond 3.7 uses the `V3.7` container label with the verified German V2.24 state
|
||||
layout. Career loading, saved-desktop/preparation import and browser information
|
||||
accept that exact label as well as `V2.24`. The checksum, full block/pool structure
|
||||
and installed edition's database dimensions are still required. An accepted
|
||||
version label cannot make a malformed or mismatched state valid. Ordinary
|
||||
OpenBMH native saves continue to use the canonical `V2.24` output marker.
|
||||
Unknown labels are rejected separately from checksum failures.
|
||||
|
||||
|
||||
Original Football Limited V2.20 saves use a different state block list despite sharing the signature and rolling cipher. They are not interchangeable with the V2.24 layout. Reading an English installation and importing its original saves are separate features; do not edit a version string to bypass the distinction. OpenBMH's own English careers use the session's supported save representation.
|
||||
|
||||
Keep a backup before using a save with another engine version. Unknown bytes retained for compatibility are not safe targets for direct client manipulation.
|
||||
@@ -0,0 +1,34 @@
|
||||
# Optional long-career statistics and title archive
|
||||
|
||||
The existing `OBMHEXT1` container can contain block `0x4f424c43` (OpenBMH-owned,
|
||||
not a guest memory address). Original state blocks and all four name pools retain
|
||||
their sizes and ordering. No extension is emitted until an archive is needed.
|
||||
Payload integers use little-endian encoding:
|
||||
|
||||
| Field | Encoding |
|
||||
|---|---|
|
||||
| Payload version | u32, currently 1 |
|
||||
| Player/club record count | u32 |
|
||||
| Known season record count | u32 |
|
||||
| Each player/club record | u32 key, then six u64 counters |
|
||||
| Each season record | u32 absolute zero-based season, then nine names |
|
||||
| Each name | u16 byte length followed by Original-encoding bytes |
|
||||
|
||||
The player key is `(runtime_club << 12) | player_id`. The six counters are league,
|
||||
national-cup and European-cup appearances, total appearances, goals and assists.
|
||||
Club swaps remap keys; fresh squad entry initialization resets the new player's
|
||||
club record. The Original byte/word fields continue to update normally.
|
||||
|
||||
Season names follow the nine Original title categories. An empty name is a known
|
||||
season with no holder for that category. Missing season records are unknown,
|
||||
not an assertion that no competition was held. Names are owned snapshots at the
|
||||
award/capture time, independent of future club-number and name-pool changes.
|
||||
A legacy import contributes only its surviving window; no earlier information
|
||||
is inferred. The title list uses the earliest known absolute season when paging
|
||||
and compensates for the native rolling-window year offset.
|
||||
|
||||
The decoder rejects unknown versions, truncated payloads, invalid/duplicate
|
||||
identities and seasons, duplicate blocks and trailing bytes before publishing
|
||||
archive state. Season records remain within the native signed 16-bit calendar
|
||||
range. The surrounding FBM checksum covers the extension. Older writers may
|
||||
discard extensions; Original-game roundtrip preservation is not promised.
|
||||
@@ -12,3 +12,5 @@ These files preserve upstream license and attribution wording. They are not a gr
|
||||
- [LGPL version 2.1](LGPL-2.1.txt): full license supplied with Nuked OPL3. Its source notices permit version 2.1 or any later version.
|
||||
|
||||
[THIRD_PARTY_NOTICES.md](../../THIRD_PARTY_NOTICES.md) identifies the upstream versions and distribution requirements. Include this directory, that notice file and the root LICENSE with release packages. Preserve upstream attribution within these verbatim texts.
|
||||
|
||||
- [stb_image](stb_image.txt): complete upstream dual-license text from the vendored 2.30 header. JPEG-only decoding is used for the supplied project start screen.
|
||||
@@ -0,0 +1,38 @@
|
||||
This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
@@ -1,28 +0,0 @@
|
||||
# obdeddi 0.1.0
|
||||
|
||||
A small native Windows data editor for the standalone OpenBMH 1.1 COMMUNITY.OBD format. It uses Win32/common controls, not SDL, RmlUI or a browser. The model and archive-writing tests build on all supported platforms; the graphical editor is Windows x64 only.
|
||||
|
||||
## Use
|
||||
|
||||
Extract the separate editor package and start `obdeddi.exe`. Open a COMMUNITY.OBD with the Open button or Ctrl+O. A file path may also be passed on the command line. Search and sortable virtual lists cover players and clubs; the club filter applies to players. Artwork is decoded only on demand in the separate club-logo dialog.
|
||||
|
||||
Player fields include names, position, nationality, age, form/technique/condition, bonus and the seven Classic skills. Displayed strength is derived, not a second independent field. Club fields include names, the stored short-name span and existing kit selectors. League sizes and record counts stay fixed. Country rows and rules are not editable. Club logos can be imported from PNG/JPEG/BMP, cropped by source-pixel coordinates, freely rotated and mirrored. The before/after preview uses the actual 38×38 Original palette and bright background; shared crest cells are cloned into a free cell. Other artwork is not editable. League players can move between squads or swap places; temporary/reserve-table players cannot be reassigned as if they were ordinary roster members.
|
||||
|
||||
Classic new-career generation is deliberately retained: many stored player values are randomized/recalculated when a career starts. Editing the database does not modify an existing saved game. This limitation is visible in the player form.
|
||||
|
||||
Apply commits the current form to the in-memory document. Changing selection also validates the draft form. Ctrl+S writes the document to its original OBD after verification and backup. Closing or opening another file asks about unsaved changes.
|
||||
|
||||
## Save safety
|
||||
|
||||
- ZIP/resource limits and supplied hashes are checked on open. Original database order, IDs, unknown player bits and non-database resource bytes are preserved.
|
||||
- The M3D writer validates a decode/encode roundtrip. Unsupported characters and full 16-bit string pools are rejected rather than silently replaced.
|
||||
- Save serializes a temporary sibling archive and reopens it for validation. A cooperating editor lock prevents overlapping saves.
|
||||
- The complete prior archive is copied to `backups/` and read back for verification. External modifications are checked before the transaction and again before replacement.
|
||||
- Only then does the OS atomically replace the original. A failed backup, validation or replacement leaves the original intact; a temporary file is cleaned up. Successful saves update resource hashes and append an editor-history record.
|
||||
- Saving an unchanged document is a no-op. Backups are independent OBD bytes and can be copied back while the application is closed.
|
||||
|
||||
## Performance and delivery
|
||||
|
||||
Owner-data lists request only visible cell text. Search is debounced, forms update on selection/change, and the native message loop does not render continuously while idle. Assets are retained as bytes for integrity and save roundtrips, without image/font/audio decoding.
|
||||
|
||||
The editor has its own ZIP/release. It is not inserted into the small Windows community game package. Corresponding full sources are offered separately. OpenBMH 1.1 Beta keeps a fixed `OpenBMH 1.1` window caption, fits 18/20-team strengths views above the controls and uses a 25% longer default scene-frame delay (at least 16 ms). Explicit frame-delay overrides remain available; simulation clocks and random streams are not changed.
|
||||
@@ -1,64 +0,0 @@
|
||||
# Classic-plus-1 profile
|
||||
|
||||
This opt-in experimental profile keeps the Classic competition types and indexed artwork formats. It is not a DOS patch. The original executable is read only; verified dimension data and the expanded calendar are prepared in memory. Unmarked installations retain Classic dimensions and save identity.
|
||||
|
||||
## Discovery and dimensions
|
||||
|
||||
`OBMHPROF.INI` contains exactly:
|
||||
|
||||
```ini
|
||||
[OpenBMH]
|
||||
profile=classic-plus-1
|
||||
```
|
||||
|
||||
Unknown keys/profiles are rejected. The German executable and calendar are required.
|
||||
|
||||
| Table | Classic | Classic-plus-1 |
|
||||
| --- | ---: | ---: |
|
||||
| League sizes, German divisions | 18/18/18/18/18 | 18/18/18/18/18 |
|
||||
| Spain/England/France/Italy | 12/12/12/12 | 18/20/18/18 |
|
||||
| League clubs | 138 | 164 |
|
||||
| Cup-only clubs | 30 | 30 |
|
||||
| League and cup records | 168 | 194 |
|
||||
| Other foreign clubs | 189 | 189 |
|
||||
| National teams | 62 | 62 |
|
||||
| All club/country entries | 419 | 445 |
|
||||
| Players | 2,574 | 3,334 |
|
||||
| Clubs with 24 roster slots | 90 | 164 |
|
||||
| First market slot | 2,928 | 3,936 |
|
||||
| First national roster slot | 3,072 | 4,080 |
|
||||
| First extra-player slot | 3,096 | 4,104 |
|
||||
| Total runtime slots | 3,150 | 4,158 |
|
||||
|
||||
Player identifiers still use twelve bits, with 4,095 reserved for empty. **An absolute roster slot is not a player identifier**: extended auxiliary slots exceed 4,095 and must not be masked. Club identifiers fit existing packed club fields and crest selectors fit nine bits.
|
||||
|
||||
## Master database and artwork
|
||||
|
||||
The M3D table order and encoding remain unchanged. Kit selectors scale with all club/country entries; short-name offsets and auxiliary words scale with league-plus-cup entries. The squad master has four fewer rows than runtime, because temporary transfer rows are inserted during career initialization. String pools retain unsigned 16-bit offsets. Imported names use ISO 646-DE, with explicit transliteration of unsupported letters.
|
||||
|
||||
The preparation script keeps original player words and original IDs, appends supplemental players and records the source-to-runtime club mapping. Existing twelve-club foreign cores are retained; additional clubs are ranked by donor mean player strength. Missing-person data are not silently fetched or invented. Every supplied provenance/fictional-field note is retained in the private import report.
|
||||
|
||||
Crests are fitted into 38-by-38 cells of 304-by-38 VGA sheets, using the supplied VGA palette. No PNG/SVG decoder is needed at runtime. Transparency is index zero for these generated crest cells. Existing protected crest cells remain intact. Repeated Original placeholder images are rejected rather than counted as real club crests. Missing crests use explicitly fictional vector monograms, and dark monochrome logos can use a light contrast variant; both are recorded per club. Asset source and rights notes remain separate from the application's GPL license.
|
||||
|
||||
The offline preparation utility accepts local paths:
|
||||
|
||||
```sh
|
||||
python3 -m venv asset-tools
|
||||
asset-tools/bin/pip install Pillow CairoSVG
|
||||
asset-tools/bin/python tools/poc/prepare_international.py \
|
||||
--source /path/to/supplied/german-game \
|
||||
--supplement /path/to/supplied/season.obw \
|
||||
--output /path/to/new/private-data
|
||||
```
|
||||
|
||||
The destination must not exist. Inputs are never overwritten. Original content and private import reports must stay outside public source trees, issues and CI artifacts.
|
||||
|
||||
## Save and memory boundaries
|
||||
|
||||
Classic containers retain `V2.24`. Extended containers use `O1.1`, checked against the selected installation before state decoding. The table sequence remains familiar, with count-derived sizes for club records, manager/opponent histories, crests, kits and short-name offsets. Extended typed tables must not grow into adjacent globals in the guest-memory compatibility representation.
|
||||
|
||||
The result store already reserves nine leagues with 38 rounds and ten matches per round. Expanded scheduling uses each league's own fixture size. The shared foreign calendar supplies 38 dates; each league stops at its own 34 or 38 rounds. Domestic/cup/national flags are preserved. Dates are an experimental calendar policy, not a claim about real-world fixtures.
|
||||
|
||||
## Distribution
|
||||
|
||||
Public artifacts contain the implementation, build information and corresponding sources. The community data ZIP is prepared privately and separately; existing content provenance and rights are unchanged. The stable 1.0 release line is not replaced by this POC.
|
||||
@@ -1,21 +0,0 @@
|
||||
# Standalone community data
|
||||
|
||||
The 1.1 community edition can start from `COMMUNITY.OBD` without an installed DOS game. The stable main line and loose Classic installation support remain separate.
|
||||
|
||||
`COMMUNITY.OBD` is a compressed read-only resource bundle. It contains the master database, text, palette, formations, desktop layout, fonts, indexed pictures/crests and audio containers required by OpenBMH. These are game content, not application code. Saves, highscores and user layouts remain normal writable files outside the bundle.
|
||||
|
||||
The bundle's `RUNTIME.DAT` uses the `OBMHDAT1` schema: data-segment base/length, calendar epoch, resolved badge/environment policies, data-segment bytes and explicitly named auxiliary labels. The exporter discards the DOS header, DOS/4GW loader and machine-code objects. Calendar and verified edition policies are values, rather than retained code fingerprints. This is not a renamed or embedded BMH executable.
|
||||
|
||||
The Classic address-view adapter still supplies the existing engine/UI table readers. It reads resource entries directly from the compressed bundle, without unpacking original executables or a cached DOS installation. Bundle paths are case-insensitive and reject duplicate/path-traversal entries; compressed/uncompressed limits bound allocations. Original loose installations retain their loading path.
|
||||
|
||||
Offline preparation from privately supplied resources:
|
||||
|
||||
```sh
|
||||
cmake --build build --target export_community_runtime
|
||||
python3 tools/poc/bundle_community.py --source /path/to/prepared-data \
|
||||
--exporter /path/to/build/export_community_runtime --out /path/to/new/community-data
|
||||
```
|
||||
|
||||
Only required resource types are included. DOS programs, installers, editor executables, original saves, backup directories, manuals and unused picture formats are excluded. Import provenance stays in `IMPORT-REPORT.json`; `PACKAGE.json` records the hashes of the bundled resources. A bundled `OBMHPROF.INI` selects the expanded league profile, so no additional loose Original files are needed.
|
||||
|
||||
Generated foreign crests now use the supplied Original domestic crest background texture. Transparent edges are composited onto that bright texture before palette reduction; actual black logo details remain black. The previous black rectangles and the light-on-dark monochrome workaround are removed.
|
||||
@@ -1,22 +0,0 @@
|
||||
# International-league POC
|
||||
|
||||
Working branch: `poc/1.1-international`, based on `v1.0.2`. Stable main remains separate.
|
||||
|
||||
Implemented:
|
||||
|
||||
- Explicit `OBMHPROF.INI` metadata; unmarked installations retain Classic dimensions.
|
||||
- Five German divisions unchanged; international sizes 18/20/18/18, 164 league clubs.
|
||||
- Twenty starting players and 24 slots per league club; 4,158 runtime roster/auxiliary slots.
|
||||
- Profile-aware master-database and executable-data views, preserving executable bytes on disk.
|
||||
- Count-derived club records, opponent histories, kit/short-name and fair-play tables.
|
||||
- Per-league fixtures and 38 foreign calendar dates, with smaller leagues stopping at 34 rounds.
|
||||
- Extended save identity `O1.1`; Classic retains `V2.24` and its existing dimensions.
|
||||
- Offline private data preparation, provenance, crest fitting and Original-format VGA output.
|
||||
|
||||
Local integration evidence so far: the expanded career completed 180 turns with seed 1 (three season ends), and another 180 with seed 11 (two season ends). No simulator invariant violations or contract-policy errors were reported. These are automated manager-policy runs, not claims of complete human gameplay QA or validation of all editions/platforms.
|
||||
|
||||
The prepared private dataset has 445 club/country entries, 3,334 players and 263 individual foreign club crests. Original German rosters and all 2,574 Original player word records are preserved by assertions during preparation. The visual review identified 175 usable supplied foreign crests and 88 missing/shared Original placeholders. Those 88 now have explicit fictional club-specific monograms instead of the computer symbol; the updated crest preparation uses the bright Original background texture and preserves black logo details. Donor fields retain their real/fictional provenance. No original game content is committed here.
|
||||
|
||||
Validation: 37 configured synthetic tests executed successfully, with 158 external-input tests explicitly skipped; four offline preparation tests passed. Extended save/reload and both cross-profile rejection paths passed. Two separate season-end snapshots each contain every fixture in all nine leagues. A Classic 80-turn run produces a byte-identical save to stable 1.0.2. Screenshots and saves are archived privately. Native platform CI also builds and tests Windows x64, macOS ARM64 and Linux x64; release QA receipts identify the exact successful revision. See [FORMAT.md](FORMAT.md) for dimensions, preparation and distribution boundaries. A development commit is not a completed release claim.
|
||||
|
||||
The next community package uses a data-only `COMMUNITY.OBD` bundle and no DOS executables. See [STANDALONE.md](STANDALONE.md). The Windows community ZIP omits source archives and loose PNG/JPEG studies; corresponding sources remain available separately.
|
||||
@@ -0,0 +1,71 @@
|
||||
# OpenBMH 1.0.3
|
||||
|
||||
This Classic maintenance release fixes startup, dialog and match presentation,
|
||||
transfer handling and several long-career limits. It uses the player's own
|
||||
supported game installation. Extended development lives separately in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes
|
||||
|
||||
- Football Limited startup reads its own calendar epoch and prepared-image
|
||||
tables. Original CD assets are located without assuming filename case.
|
||||
- Original Diamond 3.7 saves with the verified `V3.7` container marker load in
|
||||
the career, browser information and preparation paths. Unknown versions and
|
||||
checksum failures are reported separately; layout checks remain strict.
|
||||
- The original title remains visible until a complete left or right mouse click,
|
||||
without loading balls or automatic advancement.
|
||||
- Career dialogs retain their scene background instead of inheriting the
|
||||
executable's black boot-dialog mode.
|
||||
- Goal scenes retain the previous visible score until the result is revealed.
|
||||
- Closing a table or pairings overview owns the complete right-button gesture.
|
||||
- Pitch placement again uses the edition's preferred-position colors and
|
||||
original colored cursor.
|
||||
- Select an owned transfer listing and use the sale action or Enter to inspect
|
||||
existing offers before expiry. Cancel preserves the listing. Cleared listings
|
||||
can be offered again; refusals receive visible feedback.
|
||||
- A fresh squad arrival clears negotiation flags left by the previous occupant
|
||||
of its row. This prevents inherited refusal of contract renewal.
|
||||
- Optional saved archives preserve cumulative player counters and observed
|
||||
title winners beyond the original byte/word and fifty-season windows.
|
||||
- Daily interest and property/fund dividend products use wider intermediate
|
||||
arithmetic; Bank portfolio totals use wide display values.
|
||||
- The high-cash bank robbery remains, at most once per manager and calendar
|
||||
month. Saving and loading preserves the limit. An older save with unknown
|
||||
history receives a first qualifying month of grace.
|
||||
- Standard stadium blocks now allow 144,000 places in total. Unit prices come
|
||||
from the loaded edition; build periods increase with expanded block size.
|
||||
|
||||
## Validation
|
||||
|
||||
The release workflow requires successful builds, configured synthetic tests and
|
||||
package checks for Windows x64, macOS ARM64 and Linux x64 at the tagged revision.
|
||||
Reports and checksums accompany the downloads. Missing external-data tests are
|
||||
reported as skipped, rather than counted as successful game tests.
|
||||
|
||||
Additional private Linux checks use Original CD, Diamond and Football Limited
|
||||
assets for startup and setup, scene-backed dialogs, calendar/rescheduling,
|
||||
transfer decisions, preferred-position feedback and score reveal. A 144,000-place
|
||||
stadium was rendered after encrypted native save/load. These checks do not
|
||||
constitute manual gameplay validation on Windows or macOS, or a full
|
||||
200–300-season simulation.
|
||||
|
||||
## Known limits
|
||||
|
||||
- Individual native cash, deposit and financial-history fields remain 32-bit and
|
||||
can still overflow. Wider calculations and aggregate display do not solve
|
||||
multi-billion single-account storage; that issue remains open.
|
||||
- Calendar and rescheduling opened in the checked Classic datasets; the reported
|
||||
failure remains open because it could not be reproduced.
|
||||
- Football Limited remains experimental. Its original V2.20 save layout is
|
||||
different and is not enabled by the Diamond 3.7 import correction.
|
||||
- Already lost counters and earlier title winners cannot be reconstructed. The
|
||||
separate manager-achievements graph retains its original fifty-season window.
|
||||
Original programs and older OpenBMH writers can discard optional archive and
|
||||
monthly-robbery extensions; keep backups before exchanging saves.
|
||||
- The row-initialization correction does not clear genuine retirement/refusal
|
||||
flags in an existing career or establish a fixed 200–300-season threshold.
|
||||
- Early acceptance of a human-buyer loan still needs its separate consent flow
|
||||
and is unavailable from the early offer preview.
|
||||
|
||||
The public downloads contain implementation, corresponding source and notices;
|
||||
original game content is not included.
|
||||
@@ -0,0 +1,57 @@
|
||||
# OpenBMH Classic 1.0.4
|
||||
|
||||
This Classic patch release includes the desktop, save and advertising fixes
|
||||
added after 1.0.3. It requires the player's own supported game installation.
|
||||
Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.3
|
||||
|
||||
- The supplied Classic start artwork is embedded at its native resolution and
|
||||
displayed with correct proportions, including high-DPI output. A complete
|
||||
left or right mouse click continues into the game.
|
||||
- An unframed desktop calendar/date control now starts the next turn correctly.
|
||||
Unframed admission-price and automation controls use their correct origins;
|
||||
hidden controls and national-team restrictions remain enforced.
|
||||
- Dragging an icon out of a stored desktop folder moves the selected icon while
|
||||
keeping the folder in place. Folder-corner removal uses the original input
|
||||
geometry.
|
||||
- Double-clicking an occupied save slot opens the original overwrite question.
|
||||
Its Yes/No buttons work entirely with the mouse. No preserves the existing
|
||||
file; Yes writes the selected slot.
|
||||
- Advertising choices use the original hover outlines and help areas. Returning
|
||||
from a dialog refreshes the pointer state and removes stale highlighting.
|
||||
- Malformed saved formation automation is rejected before desktop projection,
|
||||
without changing the career state or random streams.
|
||||
- Football Limited retains its original overwrite question during English-data
|
||||
translation. The launcher rebuilds older translated caches automatically.
|
||||
|
||||
## Validation
|
||||
|
||||
The release workflow requires successful builds, configured tests, version and
|
||||
package checks for Windows x64, macOS ARM64 and Linux x64 at the exact tagged
|
||||
revision. Downloads include checksums, a platform test report and corresponding
|
||||
source with pinned open-source dependencies.
|
||||
|
||||
Additional private Linux validation of the fixes used Diamond 3.7 data and real
|
||||
mouse input. The 211-test configured suite executed 116 passing tests, skipped
|
||||
95 checks needing other private fixtures, and reported no failures. Focused
|
||||
save, desktop and advertising input checks executed. Native before/after checks
|
||||
verified mouse-only overwrite refusal/acceptance, folder extraction and a real
|
||||
two-manager calendar handoff, with saved-state verification. An original
|
||||
Football Limited data probe verified the translated overwrite question.
|
||||
|
||||
These checks do not establish manual gameplay acceptance on Windows or macOS.
|
||||
Issues [#51](https://github.com/Weyoune/openbmh/issues/51),
|
||||
[#52](https://github.com/Weyoune/openbmh/issues/52),
|
||||
[#53](https://github.com/Weyoune/openbmh/issues/53) and
|
||||
[#54](https://github.com/Weyoune/openbmh/issues/54) remain open for human QA.
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
|
||||
No original executables, databases, saves, graphics or audio are included.
|
||||
@@ -0,0 +1,52 @@
|
||||
# OpenBMH Classic 1.0.5
|
||||
|
||||
This patch fixes environment access with compatible older DIAMOND data and
|
||||
English contract labels. It requires the player's own game installation.
|
||||
Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.4
|
||||
|
||||
- Environment management uses the common Diamond 3.7 monthly model for supported
|
||||
source-data editions. Different original programme instructions no longer
|
||||
block compatible numeric data. Six budget steps are validated and installed
|
||||
together; malformed layouts and artwork bounds remain guarded. Existing
|
||||
saved lump-sum academy budgets retain their accounting until edited.
|
||||
- Football Limited translation supplies its actual environment geometry,
|
||||
numeric steps and suffixes. Selecting the original English installation
|
||||
rebuilds older translated caches automatically.
|
||||
- Contract tabs use the installation's original text and font path, including
|
||||
English data, salary and team-bonus captions.
|
||||
- English manager selection exposes the Original four starting levels. The
|
||||
fifth internal data league remains in the model, squads, rankings and fixture
|
||||
data. Hidden targets/clubs are rejected before fresh-manager mutation or RNG;
|
||||
existing saved league values are not generally rejected.
|
||||
|
||||
## Validation and human QA
|
||||
|
||||
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
|
||||
builds, configured tests, product-version checks and package/source verification
|
||||
for the exact tagged revision. Downloads include checksums, a platform test
|
||||
report and corresponding source with pinned open-source dependencies.
|
||||
|
||||
Local checks use an older primary DIAMOND installation, separately identified
|
||||
Diamond 3.6 and 3.7 data, German CD data and translated Football Limited data.
|
||||
They cover all six environment controls, transaction ownership and unchanged RNG,
|
||||
source-language contract glyphs, valid manager selection and hidden-level refusal.
|
||||
Native Linux before/after checks reproduce the older DIAMOND menu block and
|
||||
verify the corrected environment screen and English contract captions. The older
|
||||
package's precise edition name remains unconfirmed; the separately supplied
|
||||
3.6 installation also passed the original controller check.
|
||||
|
||||
Issues [#55](https://github.com/Weyoune/openbmh/issues/55) and
|
||||
[#56](https://github.com/Weyoune/openbmh/issues/56) remain open for human QA.
|
||||
Native Windows/macOS gameplay acceptance is not established by CI builds.
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
|
||||
No original executables, databases, saves, graphics or audio are included.
|
||||
@@ -0,0 +1,54 @@
|
||||
# OpenBMH Classic 1.0.6
|
||||
|
||||
This patch fixes bugs reported by Windows and macOS testers and adds a `-debug`
|
||||
mode. It requires the player's own game installation. Extended development
|
||||
remains separate in [OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.5
|
||||
|
||||
- **Debug mode.** `-debug` writes a log and the redirected error output to a
|
||||
`debug` folder inside the save directory and stores a savegame after every
|
||||
kick-off, so a failing session can be reproduced from the files.
|
||||
- **Settings.** Every unlocked switch of the settings screen is stored; only
|
||||
locked rows stay fixed.
|
||||
- **Training.** The skill bars per player and the hovered row are drawn.
|
||||
- **Line-up.** Set-piece takers can be picked and players placed in the shooter
|
||||
editor. The live line-up now also opens at the national-team desk.
|
||||
- **Mouse pointer.** The original game pointer is used, at the correct size on
|
||||
high-DPI displays (macOS).
|
||||
- **Calendar.** The calendar works after a kick-off and at the end of the
|
||||
season, shows the original colour gradient and uses the live season values.
|
||||
- **Running matchday.** Table, Strengths and the results page no longer hang or
|
||||
reject clicks while a matchday is running.
|
||||
- **National-team desk.** Save loading, Table, Strengths, Other Games, Top
|
||||
Scorers and the live line-up work for the national coach; the club badges on
|
||||
the desk follow the opponent of the day.
|
||||
- **Joined managers.** A manager who joins a running career sees his next
|
||||
opponent instead of "no match".
|
||||
- **Club information.** The Radio/Video setting of the club information screen
|
||||
persists, so an AI match set to Video appears live.
|
||||
- **Stadium.** The yellow hover frame appears over seat blocks, investments and
|
||||
buildings; the panorama view is not framed.
|
||||
- **Advertising.** ANNEHMEN is hidden when the offer cannot be accepted, as in
|
||||
the original. Settings screen shows the product name and version.
|
||||
- **Table calculator.** The right mouse button closes the From/To calculator.
|
||||
|
||||
## Validation and human QA
|
||||
|
||||
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
|
||||
builds, configured tests, product-version checks and package/source verification
|
||||
for the exact tagged revision. Downloads include checksums, a platform test
|
||||
report and corresponding source with pinned open-source dependencies.
|
||||
|
||||
Several fixes were reproduced on testers' savegames and checked with test
|
||||
programmes; native Windows/macOS gameplay acceptance is not established by CI
|
||||
builds. Open points: the "player card: original atlas bounds" error (#77),
|
||||
KI-Tipp after a match (#69), sporadic double clicks (#58) and the macOS match
|
||||
scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,35 @@
|
||||
# OpenBMH Classic 1.0.7
|
||||
|
||||
This patch fixes national-team desk screens and two small interface details
|
||||
reported by testers. It requires the player's own game installation. Extended
|
||||
development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.6
|
||||
|
||||
- **National-team desk.** Other Games and Top Scorers open again; both screens
|
||||
are identified by the home club, so the desk is no longer rejected as stale
|
||||
or as a mismatched acknowledgement.
|
||||
- **Computer tip.** After the results of a round are known the button is only
|
||||
pressed and released, as in the original, instead of raising an engine error.
|
||||
- **Manager selection.** JA of the confirmation question is shown pushed in
|
||||
briefly after it is clicked.
|
||||
|
||||
## Validation and human QA
|
||||
|
||||
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
|
||||
builds, configured tests, product-version checks and package/source verification
|
||||
for the exact tagged revision. Downloads include checksums, a platform test
|
||||
report and corresponding source with pinned open-source dependencies.
|
||||
|
||||
The fixes were checked with the desktop, controller and manager tests; native
|
||||
Windows/macOS gameplay acceptance is not established by CI builds. Open points
|
||||
from 1.0.6 remain: the "player card: original atlas bounds" error (#77),
|
||||
sporadic double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
+123
-110
@@ -1,9 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/data_profile.hpp"
|
||||
#include "app/career_session.hpp"
|
||||
#include "formats/league_visibility.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <system_error>
|
||||
@@ -72,7 +73,7 @@ int national_opportunities_rank(const GameState& game,int team,std::array<uint8_
|
||||
ranks.fill(1);
|
||||
const int rounds=game.league_rounds.empty()?0:int8_t(game.league_rounds.at(0));
|
||||
if(rounds<2||rounds>=league_matchdays(0))return 0;
|
||||
return team>=runtime_dimensions.league_teams?9:0;
|
||||
return team>=138?9:0;
|
||||
}
|
||||
|
||||
uint8_t source_runtime_byte(const GameState& state,const std::map<uint32_t,uint8_t>& runtime,
|
||||
@@ -373,8 +374,15 @@ void restore_saved_turn_cursor(TurnDriver& driver, GameState& state, const Datab
|
||||
const int manager_count = int(state.manager_teams.size());
|
||||
if (manager_count > 4 || !state.memory.has(::bmh::layout::ActiveManager) || !state.memory.has(::bmh::layout::DeskPosition))
|
||||
throw std::runtime_error("saved turn cursor: manager continuation fields are missing");
|
||||
const int position = int(state.memory.u8(::bmh::layout::DeskPosition));
|
||||
int position = int(state.memory.u8(::bmh::layout::DeskPosition));
|
||||
const int active = int(state.memory.u8(::bmh::layout::ActiveManager));
|
||||
// A completed manager loop leaves DeskPosition == ManagerCount (the day's desks are done). A desk
|
||||
// that was saved in that state is the first desk again for a single manager: nothing else can
|
||||
// follow it. Reading the byte as 0 lets the day go on instead of refusing the whole save.
|
||||
if (manager_count == 1 && position == 1 && active == 0) {
|
||||
position = 0;
|
||||
state.memory.set8(::bmh::layout::DeskPosition, 0);
|
||||
}
|
||||
if (position < 0 || position >= manager_count)
|
||||
throw std::runtime_error("saved turn cursor: manager position is outside the saved roster");
|
||||
if (manager_count == 1) {
|
||||
@@ -549,15 +557,10 @@ static void install_league_sizes(const LeImage& exe) {
|
||||
install_calendar_rules(exe);
|
||||
}
|
||||
|
||||
static std::filesystem::path install_session_profile(const std::filesystem::path& data) {
|
||||
install_runtime_profile(load_data_profile(data));
|
||||
return data;
|
||||
}
|
||||
|
||||
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed)
|
||||
: data_directory_(install_session_profile(data)), exe_(load_le(data / "BMH.exe")),
|
||||
db_(load_database(data / "M3D.MAN")),
|
||||
texts_(load_textd(data / "TEXTD.BLK")),
|
||||
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))),
|
||||
db_(load_database(ui::asset_path(data, "M3D.MAN"))),
|
||||
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))),
|
||||
rand_(watcom_seed) {
|
||||
install_league_sizes(exe_);
|
||||
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
|
||||
@@ -566,7 +569,7 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
? TransferAllocatorContext::zero : TransferAllocatorContext::blocked;
|
||||
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
|
||||
initialize_club_modal_runtime();
|
||||
g_ = startup_state(exe_, db_, read_file(data / "M3.MEN"), read_file(data / "M3.DAT"));
|
||||
g_ = startup_state(exe_, db_, read_file(ui::asset_path(data, "M3.MEN")), read_file(ui::asset_path(data, "M3.DAT")));
|
||||
g_.texts = &texts_;
|
||||
g_.currency_suffix = exe_.cstring(::bmh::layout::CurrencySuffixText); // CurrencySuffixText
|
||||
configure_training_camp_data(g_, exe_);
|
||||
@@ -582,8 +585,8 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
|
||||
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed,
|
||||
const std::filesystem::path& save_path)
|
||||
: data_directory_(install_session_profile(data)), exe_(load_le(data / "BMH.exe")), db_(load_database(data / "M3D.MAN")),
|
||||
texts_(load_textd(data / "TEXTD.BLK")), rand_(watcom_seed) {
|
||||
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))), db_(load_database(ui::asset_path(data, "M3D.MAN"))),
|
||||
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))), rand_(watcom_seed) {
|
||||
install_league_sizes(exe_);
|
||||
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
|
||||
turn_driver_.disable_match_events = exe_.u8(::bmh::layout::MatchEventsDisabled) != 0;
|
||||
@@ -592,8 +595,8 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
|
||||
initialize_club_modal_runtime();
|
||||
const Savegame file = load_savegame(save_path);
|
||||
if (!file.checksum_ok || file.version != (runtime_dimensions.expanded ? "O1.1" : "V2.24")) throw std::runtime_error("savegame: unsupported or damaged FBM");
|
||||
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), db_.counts.league_teams, db_.counts.cup_teams};
|
||||
require_native_savegame(file);
|
||||
const DbCounts counts{exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
const SaveState save(file.stream, counts);
|
||||
g_ = GameState::from_save(save, counts);
|
||||
// CompetitionPointers2, after DeskDate2: these are process statics, not FBM fields.
|
||||
@@ -733,6 +736,9 @@ bool CareerSession::confirm_manager_join(const ui::ManagerChoice& choice, std::s
|
||||
selected.name = choice.name; selected.team = runtime_club(draft.state, choice.master_club);
|
||||
selected.league = choice.start_league; selected.strength = choice.strength; selected.portrait = choice.portrait;
|
||||
if (selected.team < 0) throw FormatError("join: club not found");
|
||||
const auto visible=player_league_count(exe_);
|
||||
const auto club_league=team_league(selected.team);
|
||||
if(selected.league>=visible||(club_league>=visible&&club_league<5))throw FormatError("join: league is not available for human management");
|
||||
MinuteReport report;
|
||||
if (!career_add_manager(draft.state, exe_, choice.slot, selected, true, draft.game, draft.rand, report))
|
||||
throw FormatError(report.reason);
|
||||
@@ -762,6 +768,9 @@ bool CareerSession::commit_manager_join(ui::CareerInitializationResult& result,
|
||||
// ConfirmManager retains the current desk/cursor. Weiter performs the later handoff.
|
||||
const auto next_revision = revision + 1;
|
||||
turn_driver_.revision = next_revision;
|
||||
// The next opponent of every manager is captured per day for the manager count of that day;
|
||||
// the joined manager has only the default ("no game") until it is captured again.
|
||||
capture_source_desk_callargs();
|
||||
ui::CareerInitializationResult next;
|
||||
next.desktop = desktop_projection(next_revision); next.managers = managers_;
|
||||
next.preparation = preparation_projection(next_revision);
|
||||
@@ -812,6 +821,12 @@ void CareerSession::apply_options(const ui::SetupOptions& o) {
|
||||
bool CareerSession::confirm_manager(const ui::SetupOptions& options, const ui::ManagerChoice& choice, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return false; }
|
||||
const auto visible=player_league_count(exe_);
|
||||
const auto selected_team=runtime_club(choice.master_club);
|
||||
const auto selected_league=selected_team>=0?team_league(selected_team):-1;
|
||||
if(choice.start_league<0||choice.start_league>=visible||(selected_league>=visible&&selected_league<5)) {
|
||||
error="league is not available for human management";return false;
|
||||
}
|
||||
if (!options_applied_) apply_options(options);
|
||||
const int m = int(managers_.size());
|
||||
if (m >= options.managers) {
|
||||
@@ -932,6 +947,9 @@ std::optional<PendingOfferResult> CareerSession::dispatch_club_player_pending_of
|
||||
}
|
||||
|
||||
void CareerSession::initialize_club_modal_runtime() {
|
||||
// Setup clears the boot-only dialog mode before either creating or loading
|
||||
// a career. This process flag is deliberately absent from native saves.
|
||||
club_modal_runtime_.emplace(layout::CompactDialogFrame, 0);
|
||||
// LE object4 has bb cdd/de/e1 in its zero-initialized virtual tail;
|
||||
// CareerSession_InitializeClubModalRuntime_ExecutableField is file-backed zero. These are explicit process-start values,
|
||||
// carried by this runtime owner across modal entry/return, not FBM bytes.
|
||||
@@ -1284,7 +1302,7 @@ std::optional<ui::StrengthsIdentity> CareerSession::begin_friendly_opponent_tabl
|
||||
uint64_t revision,std::string& error) {
|
||||
error.clear();
|
||||
const auto request=strengths_open_request(revision);
|
||||
if(!request||request->identity.runtime_club>=runtime_dimensions.record_teams||request->identity.source_param2||
|
||||
if(!request||request->identity.runtime_club>=168||request->identity.source_param2||
|
||||
league_family_owner_||strengths_owner_||league_pairings_draft_) {
|
||||
error="friendly table: unavailable club entry";return {};
|
||||
}
|
||||
@@ -1332,7 +1350,7 @@ std::optional<int> CareerSession::resolve_friendly_table_opponent(
|
||||
if(visible.runtime_team_id!=request.runtime_team||visible.club_identity_key!=request.expected_club_identity||
|
||||
visible.runtime_team_id<0||size_t(visible.runtime_team_id)>=g_.club_ids.size()||
|
||||
visible.club_identity_key!=int(g_.club_ids[size_t(visible.runtime_team_id)])||
|
||||
normal.rank!=row+1||normal.runtime_team_id<0||normal.runtime_team_id>=runtime_dimensions.record_teams||
|
||||
normal.rank!=row+1||normal.runtime_team_id<0||normal.runtime_team_id>=168||
|
||||
size_t(normal.runtime_team_id)>=g_.club_ids.size()||
|
||||
normal.club_identity_key!=int(g_.club_ids[size_t(normal.runtime_team_id)])) {
|
||||
error="friendly table: opponent row identity changed";return {};
|
||||
@@ -1789,13 +1807,13 @@ std::optional<CareerSession::LiveOverviewProjection> CareerSession::open_running
|
||||
// CupGroupOverviewEffects resolves this exact active descriptor through FindCup(selector, ordinal).
|
||||
const int competition_id = int16_t(g_.memory.u16(cup_entry_address(entry_index)+0x18));
|
||||
int stable_team = request.runtime_team;
|
||||
if (stable_team > (kNoTeam - 1)) {
|
||||
if (stable_team > 0x164) {
|
||||
const size_t backup = 4 * 0xb0c + 0x290;
|
||||
if (request.manager_slot != 0 || backup + 2 > g_.manager_records.size())
|
||||
throw FormatError("live overview: unsupported national cup owner");
|
||||
stable_team = int(uint16_t(g_.manager_records[backup] | uint16_t(g_.manager_records[backup+1])<<8));
|
||||
}
|
||||
if (stable_team < 0 || stable_team >= runtime_dimensions.league_teams || size_t(stable_team) >= g_.club_ids.size())
|
||||
if (stable_team < 0 || stable_team >= 138 || size_t(stable_team) >= g_.club_ids.size())
|
||||
throw FormatError("live overview: missing stable cup owner identity");
|
||||
ui::OtherGamesIdentity identity;
|
||||
identity.manager_slot=request.manager_slot; identity.runtime_team=request.runtime_team;
|
||||
@@ -2249,7 +2267,10 @@ std::optional<ui::StrengthsIdentity> CareerSession::dispatch_family_table_team_i
|
||||
before.family==after.family&&before.next_family_id==after.next_family_id&&
|
||||
before.next_strengths_scope==after.next_strengths_scope&&
|
||||
!before.strengths&&!after.strengths&&!before.pairings&&!after.pairings;
|
||||
if(!live_unchanged||!accepted||(poach_selection?entry_calls<1:entry_calls!=1))
|
||||
// The club information enters the club again on every redraw (view toggle, statistics, player
|
||||
// card), so one entry is the minimum; requiring exactly one threw away the whole visit, also the
|
||||
// Nein/Radio/Video setting made in it.
|
||||
if(!live_unchanged||!accepted||entry_calls<1)
|
||||
throw FormatError("league family: TeamInfo presenter changed owner or did not enter the selected club");
|
||||
const size_t record=size_t(id.manager)*0xb0c;
|
||||
if(next.date!=g_.date||next.manager_teams!=g_.manager_teams||
|
||||
@@ -2265,7 +2286,7 @@ std::optional<ui::StrengthsIdentity> CareerSession::dispatch_family_table_team_i
|
||||
if(poach_selection && *poach_selection) {
|
||||
const auto chosen=club_player_detail_context(next,**poach_selection);
|
||||
if(chosen.selection.runtime_team!=selected_team || chosen.source_slot<0 ||
|
||||
chosen.source_slot>=runtime_dimensions.pool_first || chosen.human_loan)
|
||||
chosen.source_slot>=0xb70 || chosen.human_loan)
|
||||
throw FormatError("poach: card returned a different ordinary squad player");
|
||||
refreshed.expected_family_word=next.memory.u16(family_word_at);
|
||||
// A successful param1=1 selection leaves50775 here. Its common
|
||||
@@ -2337,13 +2358,17 @@ std::optional<CareerSession::StrengthsDispatch> CareerSession::dispatch_strength
|
||||
const ui::StrengthsRequest& request,uint64_t& revision,std::string& error,
|
||||
const TransferOfferTeamInfoPresenter& team_info,bool family_transition) {
|
||||
error.clear();const auto& id=request.identity;const bool opening=request.kind==ui::StrengthsAction::open;
|
||||
// The turn driver marks the claimed turn as Failed until it completes (a guard against replaying
|
||||
// a half-played turn), so inside the running matchday the stage is not a desk. The Stärken page
|
||||
// of the live overview (G key, results page after a phase) belongs to that running turn.
|
||||
const bool running_turn=live_overview_owner_.has_value()&&turn_driver_.stage==TurnDriver::Stage::Failed;
|
||||
if(league_family_teaminfo_active_||strengths_dispatch_active_||revision==UINT64_MAX||id.revision!=revision||id.sequence==UINT64_MAX||
|
||||
id.manager<0||id.manager>3||!g_.memory.has(::bmh::layout::ActiveManager)||g_.memory.u8(::bmh::layout::ActiveManager)!=id.manager||
|
||||
size_t(id.manager)>=g_.manager_teams.size()||id.runtime_club!=g_.manager_teams[size_t(id.manager)]||
|
||||
id.runtime_club<0||size_t(id.runtime_club)>=g_.club_ids.size()||
|
||||
id.club_identity!=int(g_.club_ids[size_t(id.runtime_club)])||id.day_counter!=g_.date||
|
||||
id.league<0||id.league>8||career_complete()||
|
||||
(turn_driver_.stage!=TurnDriver::Stage::MatchdayDesks&&turn_driver_.stage!=TurnDriver::Stage::SeasonEndDesk)||
|
||||
(turn_driver_.stage!=TurnDriver::Stage::MatchdayDesks&&turn_driver_.stage!=TurnDriver::Stage::SeasonEndDesk&&!running_turn)||
|
||||
pending_offer_dispatch_active_||market_dispatch_active_||calendar_advance_active_||league_pairings_draft_||
|
||||
league_pairings_dispatch_active_||transfer_offer_editor_||manager_join_||contract_quote_||
|
||||
stadium_.investment||stadium_.tip||stadium_.periphery_quote||top_scorers_owner_||top_scorers_dispatch_active_ || stadium_.block_expansion||other_games_owner_||other_games_dispatch_active_) {
|
||||
@@ -2581,12 +2606,12 @@ std::optional<ui::TopScorersState> CareerSession::open_top_scorers(
|
||||
throw FormatError("top scorers: unsupported national-coach owner");
|
||||
stable_team = int(uint16_t(g_.manager_records[backup] |
|
||||
uint16_t(g_.manager_records[backup + 1]) << 8));
|
||||
} else if (team < 0 || team >= runtime_dimensions.league_teams) {
|
||||
} else if (team < 0 || team >= 138) {
|
||||
throw FormatError("top scorers: manager team is outside Source league scope");
|
||||
}
|
||||
if (stable_team < 0 || stable_team >= runtime_dimensions.league_teams || size_t(stable_team) >= g_.club_ids.size())
|
||||
if (stable_team < 0 || stable_team >= 138 || size_t(stable_team) >= g_.club_ids.size())
|
||||
throw FormatError("top scorers: missing stable club identity");
|
||||
const int league = team > (kNoTeam - 1) ? 0 : team_league(team);
|
||||
const int league = team > 0x164 ? 0 : team_league(team);
|
||||
if (league < 0 || league > 8)
|
||||
throw FormatError("top scorers: manager has no supported Source league");
|
||||
|
||||
@@ -2651,7 +2676,7 @@ std::optional<CareerSession::TopScorersDispatch> CareerSession::dispatch_top_sco
|
||||
(backup + 2 <= g_.manager_records.size() ?
|
||||
int(uint16_t(g_.manager_records[backup] |
|
||||
uint16_t(g_.manager_records[backup + 1]) << 8)) : -1) : identity.runtime_team;
|
||||
if (identity_team < 0 || identity_team >= runtime_dimensions.league_teams ||
|
||||
if (identity_team < 0 || identity_team >= 138 ||
|
||||
size_t(identity_team) >= g_.club_ids.size() ||
|
||||
int(g_.club_ids[size_t(identity_team)]) != identity.club_identity)
|
||||
throw FormatError("top scorers: stable club identity changed");
|
||||
@@ -2754,9 +2779,9 @@ std::optional<ui::OpportunitiesState> CareerSession::open_opportunities(
|
||||
const int manager=request.manager_slot,team=g_.manager_teams[size_t(manager)];
|
||||
const int league=national_source_case?0:team_league(team);
|
||||
if(national_source_case) {
|
||||
if(team!=kNoTeam||league!=0)throw FormatError("opportunities: invalid national menu-6 owner");
|
||||
if(team!=0x165||league!=0)throw FormatError("opportunities: invalid national menu-6 owner");
|
||||
if(stable_identity<0)throw FormatError("opportunities: missing national Desk identity");
|
||||
} else if(team<0||team>=runtime_dimensions.league_teams||size_t(team)>=g_.club_ids.size()||league<0||league>=9)
|
||||
} else if(team<0||team>=138||size_t(team)>=g_.club_ids.size()||league<0||league>=9)
|
||||
throw FormatError("opportunities: unsupported team/league");
|
||||
if(underlay.width!=320||underlay.height!=240)throw FormatError("opportunities: expected captured 320x240 desktop");
|
||||
const uint32_t choice_at=::bmh::layout::CareerSession_FormatError_ExecutableField+uint32_t(manager)*2;
|
||||
@@ -2793,7 +2818,7 @@ std::optional<CareerSession::OpportunitiesDispatch> CareerSession::dispatch_oppo
|
||||
uint32_t(g_.date)!=current.identity.day_counter||
|
||||
size_t(current.identity.runtime_team)>=g_.club_ids.size()||
|
||||
(!national_source_case&&int(g_.club_ids[size_t(current.identity.runtime_team)])!=current.identity.stable_club_identity)||
|
||||
(national_source_case&&(current.identity.runtime_team!=kNoTeam||
|
||||
(national_source_case&&(current.identity.runtime_team!=0x165||
|
||||
current.identity.stable_club_identity<0)))
|
||||
throw FormatError("opportunities: desk owner changed");
|
||||
OpportunitiesDispatch result;result.page=current;
|
||||
@@ -2873,14 +2898,14 @@ std::optional<ui::OtherGamesState> CareerSession::open_other_games(
|
||||
uint16_t(next.manager_records[record + 0x291]) << 8) != uint16_t(team))
|
||||
throw FormatError("other games: manager record does not own the active team");
|
||||
int stable_team = team;
|
||||
if (team > (kNoTeam - 1)) {
|
||||
if (team > 0x164) {
|
||||
const size_t backup = 4 * 0xb0c + 0x290;
|
||||
if (manager != 0 || backup + 2 > next.manager_records.size())
|
||||
throw FormatError("other games: unsupported national-coach owner");
|
||||
stable_team = int(uint16_t(next.manager_records[backup] |
|
||||
uint16_t(next.manager_records[backup + 1]) << 8));
|
||||
}
|
||||
if (stable_team < 0 || stable_team >= runtime_dimensions.league_teams || size_t(stable_team) >= next.club_ids.size())
|
||||
if (stable_team < 0 || stable_team >= 138 || size_t(stable_team) >= next.club_ids.size())
|
||||
throw FormatError("other games: missing stable manager club identity");
|
||||
|
||||
const uint8_t source_view = next.memory.u8(::bmh::layout::CareerSession_DispatchOtherGames_RuntimeField + uint32_t(manager));
|
||||
@@ -2971,13 +2996,13 @@ std::optional<CareerSession::OtherGamesDispatch> CareerSession::dispatch_other_g
|
||||
uint16_t(id.runtime_team))
|
||||
throw FormatError("other games: manager record changed");
|
||||
int stable_team = id.runtime_team;
|
||||
if (id.runtime_team > (kNoTeam - 1)) {
|
||||
if (id.runtime_team > 0x164) {
|
||||
const size_t backup = 4 * 0xb0c + 0x290;
|
||||
if (id.manager_slot != 0 || backup + 2 > g_.manager_records.size())
|
||||
throw FormatError("other games: unsupported national owner");
|
||||
stable_team = int(uint16_t(g_.manager_records[backup] | uint16_t(g_.manager_records[backup + 1]) << 8));
|
||||
}
|
||||
if (stable_team < 0 || stable_team >= runtime_dimensions.league_teams || size_t(stable_team) >= g_.club_ids.size() ||
|
||||
if (stable_team < 0 || stable_team >= 138 || size_t(stable_team) >= g_.club_ids.size() ||
|
||||
int(g_.club_ids[size_t(stable_team)]) != id.club_identity)
|
||||
throw FormatError("other games: stable club identity changed");
|
||||
if (request.action == ui::OtherGamesAction::team_info) {
|
||||
@@ -3026,10 +3051,10 @@ std::optional<CareerSession::OtherGamesDispatch> CareerSession::dispatch_other_g
|
||||
uint16_t(next.manager_records[active_record+0x290]|
|
||||
uint16_t(next.manager_records[active_record+0x291])<<8)!=uint16_t(id.runtime_team))
|
||||
throw FormatError("other games: TeamInfo changed the active manager record");
|
||||
const int retained_team=id.runtime_team>(kNoTeam - 1)
|
||||
const int retained_team=id.runtime_team>0x164
|
||||
? int(uint16_t(next.manager_records[4*0xb0c+0x290]|
|
||||
uint16_t(next.manager_records[4*0xb0c+0x291])<<8)) : id.runtime_team;
|
||||
if(retained_team<0||retained_team>=runtime_dimensions.league_teams||size_t(retained_team)>=next.club_ids.size()||
|
||||
if(retained_team<0||retained_team>=138||size_t(retained_team)>=next.club_ids.size()||
|
||||
int(next.club_ids[size_t(retained_team)])!=id.club_identity)
|
||||
throw FormatError("other games: TeamInfo changed the stable desk club identity");
|
||||
|
||||
@@ -3582,7 +3607,7 @@ std::optional<CareerSession::TransferOfferEditorDispatch> CareerSession::open_tr
|
||||
!g_.memory.has(::bmh::layout::ActiveManager) || g_.memory.u8(::bmh::layout::ActiveManager) != request.manager_slot ||
|
||||
request.runtime_club != g_.manager_teams[size_t(request.manager_slot)] ||
|
||||
request.bid.manager != request.manager_slot || request.bid.list_entry < 0 || request.bid.list_entry >= 40 ||
|
||||
request.bid.source_slot != runtime_dimensions.pool_first + request.bid.list_entry || request.selected_players.size() > 1) {
|
||||
request.bid.source_slot != 2928 + request.bid.list_entry || request.selected_players.size() > 1) {
|
||||
error = "transfer offer: stale, nested or unsupported marked opening";
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -3644,7 +3669,7 @@ std::optional<CareerSession::PoachDispatch> CareerSession::open_poach(
|
||||
result.start = start_poach(next_state, manager_slot, squad_slot, next_rand);
|
||||
if (result.start.status == PoachStatus::ready) {
|
||||
const int row = 0x28 + result.start.offer_row;
|
||||
const TransferOfferEditorRequest input{manager_slot, g_.manager_teams[size_t(manager_slot)], row, runtime_dimensions.pool_first + row,
|
||||
const TransferOfferEditorRequest input{manager_slot, g_.manager_teams[size_t(manager_slot)], row, 2928 + row,
|
||||
result.start.player, next_state.memory.u16(::bmh::layout::EditorList + uint32_t(row) * 0x58 + 8), 0, false, true};
|
||||
auto owner = open_transfer_offer_editor_source(next_state, input, next_game, next_rand);
|
||||
if (!owner.supported) { error = owner.reason; return std::nullopt; }
|
||||
@@ -3767,7 +3792,7 @@ bool CareerSession::dispatch_poach_ui(const ui::TransferMarketRequest& request,
|
||||
throw FormatError("poach: selection is not an ordinary squad row");
|
||||
const auto player=club_player_detail_context(next,*selection);
|
||||
slot=player.source_slot;
|
||||
if(slot<0 || slot>=runtime_dimensions.pool_first || slot_team(slot)!=selection->runtime_team ||
|
||||
if(slot<0 || slot>=0xb70 || slot_team(slot)!=selection->runtime_team ||
|
||||
(next.squad_slots.at(size_t(slot))&0xfff)!=selection->player_id)
|
||||
throw FormatError("poach: stale player selection");
|
||||
}
|
||||
@@ -3932,7 +3957,7 @@ std::optional<CareerSession::TransferMarketPreviewDispatch> CareerSession::previ
|
||||
if (request.preview_snapshot_index != -1 || request.squad_row != -1 || request.bid.manager != request.manager_slot ||
|
||||
request.bid.list_entry < 0 || request.bid.list_entry >= 40 ||
|
||||
request.bid.source_slot != request.preview_source_slot ||
|
||||
request.preview_source_slot != runtime_dimensions.pool_first + request.bid.list_entry ||
|
||||
request.preview_source_slot != 0xb70 + request.bid.list_entry ||
|
||||
request.bid.player != request.expected_player) {
|
||||
error = "transfer market: mismatched preview listing identity";
|
||||
return std::nullopt;
|
||||
@@ -3988,7 +4013,8 @@ std::optional<CareerSession::TransferMarketPreviewDispatch> CareerSession::previ
|
||||
|
||||
std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& presenters,
|
||||
uint64_t& revision, std::string& error) {
|
||||
uint64_t& revision, std::string& error,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
@@ -4001,7 +4027,18 @@ std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
error = "transfer market: stale or nested request";
|
||||
return std::nullopt;
|
||||
}
|
||||
if (request.kind == ui::TransferMarketRequestKind::submit_bid) {
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
if (!review || request.bid.manager != request.manager_slot || request.bid.list_entry < 0 ||
|
||||
request.bid.list_entry >= 40 || request.bid.source_slot != 0xb70 + request.bid.list_entry ||
|
||||
request.squad_row != -1 || !request.selected_players.empty()) {
|
||||
error = "transfer market: invalid offer review"; return std::nullopt;
|
||||
}
|
||||
const auto view = project_transfer_offer_list(g_, request.bid.list_entry);
|
||||
if (!view.valid || view.player != request.bid.player || view.seller != request.runtime_club ||
|
||||
view.seller_manager != request.manager_slot) {
|
||||
error = "transfer market: stale seller listing"; return std::nullopt;
|
||||
}
|
||||
} else if (request.kind == ui::TransferMarketRequestKind::submit_bid) {
|
||||
if (request.bid.manager != request.manager_slot || request.squad_row != -1 ||
|
||||
request.expected_player != -1 ||
|
||||
std::any_of(request.bid.bonuses.begin(), request.bid.bonuses.end(),
|
||||
@@ -4067,7 +4104,21 @@ std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
try {
|
||||
const auto before = save_stream(g_);
|
||||
TransferActionResult result;
|
||||
if (request.kind == ui::TransferMarketRequestKind::list_player)
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
const auto view = project_transfer_offer_list(next_state, request.bid.list_entry);
|
||||
const int selected = view.offer_count ? review(next_state, view) : -1;
|
||||
result.player = view.player; result.list_entry = view.list_entry;
|
||||
result.status = TransferActionStatus::pending;
|
||||
if (selected != -1) {
|
||||
auto allocator = TransferAllocatorContext::unsupported;
|
||||
if (turn_driver_.transfer_allocator_context == PendingOfferAllocatorGate::zero)
|
||||
allocator = TransferAllocatorContext::zero;
|
||||
else if (turn_driver_.transfer_allocator_context == PendingOfferAllocatorGate::blocked)
|
||||
allocator = TransferAllocatorContext::blocked;
|
||||
result = accept_manager_transfer_offer(next_state, request.manager_slot,
|
||||
view.list_entry, view.player, selected, next_rand, report, allocator);
|
||||
}
|
||||
} else if (request.kind == ui::TransferMarketRequestKind::list_player)
|
||||
result = list_manager_player(next_state, request.manager_slot, request.squad_row, next_rand, report);
|
||||
else
|
||||
result = submit_transfer_bid_source_human_buyer(next_state, request.bid, next_rand, hooks, report);
|
||||
@@ -4505,42 +4556,11 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
|
||||
const uint8_t old = raw_value;
|
||||
uint8_t next = old;
|
||||
if (request.operation == ui::SettingsEdit::toggle_binary) {
|
||||
// Inventory of actual current consumers: direct match-engine buttons,
|
||||
// matchday/season flags and the live-scene switch. Other cells are not
|
||||
// made writable merely because the Original UI displayed a cell.
|
||||
// Tie the write whitelist to the concrete consumer ranges. League
|
||||
// remapping reads rows 0..4, columns 0..3; matchday display kinds 1/2
|
||||
// map to columns 0..2 and rows 0..4 or 17..19.
|
||||
const bool consumed = (sound_cell && sound_capabilities_.has_value()) ||
|
||||
(request.row == 0 && request.column == 4) || // A5: match/Sportschau sound
|
||||
((request.row <= 4 && request.column <= 3) ||
|
||||
((request.row <= 4 || request.row >= 17) && request.column <= 2)) ||
|
||||
((request.row == 5 || (request.row >= 9 && request.row <= 12)) && request.column == 0) ||
|
||||
(request.row == 1 && request.column == 4) || // B5 live-scene option
|
||||
(request.row == 2 && request.column == 4) || // C5: Reality player numbers (RealityMatch_FormatError_ExecutableField)
|
||||
(request.row == 5 && request.column == 5) || // F6: Source manager-match desk gate (MatchdaySetup_MatchdayNeedsManagerDesks_RuntimeField)
|
||||
(request.row == 6 && request.column == 5) || // G6: transfer confirmation wait (OutcomeDelayDisabled)
|
||||
(request.row == 16 && request.column == 6) || // Q7: own-club Sportschau preference (MatchdaySetup_ConsiderSportschauFixture_RuntimeField)
|
||||
(request.row == 13 && request.column == 6) || // N7: Source kickoff competition list (SportschauAwards_MatchdayIntroView_RuntimeField)
|
||||
(request.row == 1 && request.column == 6) || // B7: SportschauIntro intro gate (Controller_FormatError_RuntimeField)
|
||||
(request.row == 2 && request.column == 6) || // C7: SportschauIntro intro-animation gate (Controller_FormatError_RuntimeField2)
|
||||
(request.row == 3 && request.column == 6) || // D7: selected report progression (ReplayProgressionMode)
|
||||
(request.row == 4 && request.column == 6) || // E7: Source-owned Sportschau scenes (ReplayChanceMode)
|
||||
(request.row == 5 && request.column == 6) || // F7: SportschauIntro fixture-report gate (Controller_FormatError_RuntimeField3)
|
||||
(request.row == 6 && request.column == 6) || // G7: MatchdayIntro player/award rating (SportschauAwards_FinishSportschauAwards_RuntimeField)
|
||||
(request.row == 7 && request.column == 6) || // H7: SportschauTeamInfo competition totals (SportschauAwards_SportschauTeamInfoView_RuntimeField)
|
||||
(request.row == 2 && request.column == 5) || // C6 drawer-handle behavior (CareerSession_DispatchDesktopLayout_RuntimeField)
|
||||
(request.row == 3 && request.column == 5) || // D6 native desktop drag raster (CareerSession_DispatchDesktopLayout_RuntimeField2)
|
||||
(request.row == 4 && request.column == 5) || // E6 always-visible shortcut bar (DeskState_FormatError_RuntimeField3)
|
||||
(request.row == 7 && request.column == 5) || // H6 transfer option
|
||||
(request.row == 8 && (request.column == 5 || request.column == 6)) || // I6/I7
|
||||
(request.row >= 10 && request.row <= 13 && request.column == 4) || // K5:N5 match buttons
|
||||
(request.row >= 10 && request.row <= 12 && request.column == 6) || // K7:M7 presentation
|
||||
(request.row == 9 && request.column == 6) || // J7 season-entrant visibility (SeasonEntrants_SeasonEntrantsFromGame_TextPointer)
|
||||
(request.row == 15 && request.column == 4) || // P5
|
||||
(request.row == 16 && request.column == 4) || // Q5
|
||||
(request.row == 17 && request.column == 4); // R5: secondary leagues (CalendarState_FormatError_RuntimeField2)
|
||||
if (!consumed || (old != 0 && old != 1)) {
|
||||
// The original edits every unlocked switch: the page only stores the value and each
|
||||
// consumer reads it where it needs it. A switch without a consumer in OpenBMH yet is still
|
||||
// stored (and saved) and never refused. Locks (bit 7 of the entry-time availability) and
|
||||
// values other than 0/1 are refused above and below.
|
||||
if (old != 0 && old != 1) {
|
||||
error = "Diese Einstellung ist noch nicht verfügbar.";
|
||||
return false;
|
||||
}
|
||||
@@ -4559,17 +4579,8 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
|
||||
}
|
||||
next = old ^ 1;
|
||||
} else {
|
||||
// Column8: existing presentation speeds B8:F8, H8 process budget,
|
||||
// J8 postponed limit and K8 autosave. Column9 only exposes values
|
||||
// already read by Main's Source live presenters or CupDrawScreen.
|
||||
const bool consumed = (request.column == 7 &&
|
||||
((request.row <= 6) || request.row == 7 || request.row == 9 || request.row == 10 ||
|
||||
(scoped_settings && request.row == 8))) ||
|
||||
// A9 match minutes; B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
|
||||
// I9 cup draw; K9 Reality report; M9 preview/shootout; P9 shot.
|
||||
(request.column == 8 && ((request.row >= 0 && request.row <= 6) ||
|
||||
request.row == 7 || request.row == 8 || request.row == 10 || request.row == 12 || request.row == 15));
|
||||
if (!consumed || old >= 200) {
|
||||
// The numeric columns are stored the same way; values from 200 up are blank cells.
|
||||
if (old >= 200) {
|
||||
error = "Diese Einstellung ist noch nicht verfügbar.";
|
||||
return false;
|
||||
}
|
||||
@@ -5602,15 +5613,20 @@ bool CareerSession::dispatch_desk_widget(const ui::DeskRequest& request, uint64_
|
||||
identity.stable_club_identity = int(g_.club_ids[size_t(identity.runtime_club)]);
|
||||
}
|
||||
if (!validate_desk_setting_owner(identity, revision, error, false)) return false;
|
||||
// Refuse malformed saved formation state before projecting widget ownership.
|
||||
// The desktop renderer cannot project indices outside the stored 0..8 range.
|
||||
if (g_.manager_options[size_t(active) * 5] > 8) {
|
||||
error = "invalid_saved_formation_automation"; return false;
|
||||
}
|
||||
const bool price = request.kind == ui::DeskRequestKind::change_ticket_price;
|
||||
if (!price && request.kind != ui::DeskRequestKind::change_option) {
|
||||
error = "unsupported_desk_widget"; return false;
|
||||
}
|
||||
// Keep SDL requests bound to a visible, open and enabled MEN drawer/item.
|
||||
// Keep SDL requests bound to a visible and enabled MEN drawer/item; the frame bit is optional.
|
||||
const auto desk = desktop_projection(revision);
|
||||
const int expected_kind = price ? 55 : 64;
|
||||
const auto item = std::find_if(desk.items.begin(), desk.items.end(), [&](const ui::DeskItem& item) {
|
||||
return item.id == request.item_id && item.kind == expected_kind && item.open && !item.disabled;
|
||||
return item.id == request.item_id && item.kind == expected_kind && !item.disabled;
|
||||
});
|
||||
if (request.menu_kind != expected_kind || item == desk.items.end()) {
|
||||
error = "stale_or_closed_desk_widget"; return false;
|
||||
@@ -5720,19 +5736,20 @@ bool CareerSession::dispatch_desktop_layout(const ui::DeskRequest& request, uint
|
||||
(expected[at+13]&0x7f)!=folder||expected[at+12]>=50) {
|
||||
error="invalid_desk_folder_child_return"; return false;
|
||||
}
|
||||
bool owner_open=false;
|
||||
bool owner_visible=false;
|
||||
for(size_t item=1;item<kItems;++item) {
|
||||
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+13]&0x80)==0) continue;
|
||||
// The frame bit does not hide folder contents; require a visible linked owner.
|
||||
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+1]&0x10)!=0) continue;
|
||||
int cursor=0;size_t visited=0;
|
||||
while(++visited<kItems) {
|
||||
const int next=expected[size_t(cursor)*kStride+5];
|
||||
if(next==int(item)) { owner_open=true;break; }
|
||||
if(next==int(item)) { owner_visible=true;break; }
|
||||
if(next<=0||next>=int(kItems)) break;
|
||||
cursor=next;
|
||||
}
|
||||
if(owner_open) break;
|
||||
if(owner_visible) break;
|
||||
}
|
||||
if(!owner_open) { error="desk_folder_child_owner_closed"; return false; }
|
||||
if(!owner_visible) { error="desk_folder_child_owner_hidden"; return false; }
|
||||
const int max_x=std::max(1,319-int(expected[at+3])),max_y=std::max(1,239-int(expected[at+4]));
|
||||
const int source_x=int(moved_x&0xefff);
|
||||
const bool snap=g_.memory.has(::bmh::layout::CareerSession_DispatchDesktopLayout_RuntimeField2)&&g_.memory.u8(::bmh::layout::CareerSession_DispatchDesktopLayout_RuntimeField2)==0;
|
||||
@@ -5773,19 +5790,20 @@ bool CareerSession::dispatch_desktop_layout(const ui::DeskRequest& request, uint
|
||||
(expected[at+13]&0x7f)!=folder||expected[at+12]>=50) {
|
||||
error="invalid_desk_bin_restore";return false;
|
||||
}
|
||||
bool owner_open=false;
|
||||
bool owner_visible=false;
|
||||
for(size_t item=1;item<kItems;++item) {
|
||||
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+13]&0x80)==0) continue;
|
||||
// The frame bit does not hide folder contents; require a visible linked owner.
|
||||
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+1]&0x10)!=0) continue;
|
||||
int cursor=0;size_t visited=0;
|
||||
while(++visited<kItems) {
|
||||
const int next=expected[size_t(cursor)*kStride+5];
|
||||
if(next==int(item)) { owner_open=true;break; }
|
||||
if(next==int(item)) { owner_visible=true;break; }
|
||||
if(next<=0||next>=int(kItems)) break;
|
||||
cursor=next;
|
||||
}
|
||||
if(owner_open)break;
|
||||
if(owner_visible)break;
|
||||
}
|
||||
if(!owner_open) { error="desk_bin_restore_folder_closed";return false; }
|
||||
if(!owner_visible) { error="desk_bin_restore_folder_hidden";return false; }
|
||||
int tail=0;size_t guard=0;
|
||||
while(expected[size_t(tail)*kStride+5]!=0) {
|
||||
if(++guard>=kItems) { error="invalid_desk_layout_chain";return false; }
|
||||
@@ -7209,7 +7227,7 @@ ui::PreparationState CareerSession::preparation_projection(const GameState& stat
|
||||
uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * 0xb0c + 0x2ad)) << 8;
|
||||
const int source_team = int16_t(uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * 0xb0c + 0x290)) |
|
||||
uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * 0xb0c + 0x291)) << 8);
|
||||
const int source_league = source_team > (kNoTeam - 1) ? 0 : team_league(source_team);
|
||||
const int source_league = source_team > 0x164 ? 0 : team_league(source_team);
|
||||
if (source_league < 0 || size_t(source_league) >= state.league_rounds.size())
|
||||
throw FormatError("stadium source league is outside the live league table");
|
||||
stadium.live_league_round = state.league_rounds.at(size_t(source_league));
|
||||
@@ -7953,7 +7971,7 @@ bool CareerSession::dispatch_stadium(const ui::StadiumRequest& supplied_request,
|
||||
}
|
||||
if (request.manager_slot != active || active < 0 || active > 3 ||
|
||||
size_t(active) >= g_.manager_teams.size() || request.runtime_club != g_.manager_teams[size_t(active)] ||
|
||||
request.runtime_club < 0 || request.runtime_club >= kNoTeam ||
|
||||
request.runtime_club < 0 || request.runtime_club >= 357 ||
|
||||
size_t(request.runtime_club) >= g_.club_ids.size() ||
|
||||
request.stable_club_identity != std::optional<int>(int(g_.club_ids[size_t(request.runtime_club)])) ||
|
||||
request.revision != revision || revision == UINT64_MAX || !g_.memory.has(::bmh::layout::GameMode)) {
|
||||
@@ -8108,12 +8126,7 @@ bool CareerSession::dispatch_stadium(const ui::StadiumRequest& supplied_request,
|
||||
if (request.object != -1 || request.option != -1 || request.price != 0 ||
|
||||
(request.kind != ui::StadiumRequestKind::expansion_answer_tip && request.accept_tip))
|
||||
return invalid("invalid_block_expansion_envelope");
|
||||
StadiumBlockExpansionConstants block_constants;
|
||||
for (unsigned i = 0; i < 8; ++i) {
|
||||
block_constants.price_per_1000[i] = exe_.u32(::bmh::layout::CareerSession_DispatchStadium_RuntimeField + (i + 8) * 4);
|
||||
block_constants.weeks[i] = exe_.u8(::bmh::layout::CareerSession_DispatchStadium_RuntimeField2 + (i + 22) * 5);
|
||||
block_constants.max_places[i] = uint32_t(exe_.u8(::bmh::layout::CareerSession_Invalid_RuntimeField + i)) * 1000;
|
||||
}
|
||||
const auto block_constants=stadium_block_expansion_constants(exe_);
|
||||
const auto quote_block = [&](StadiumBlockSlot slot, uint32_t total, uint8_t features) {
|
||||
return quote_stadium_block_expansion(g_, active, slot, total, features,
|
||||
stadium_.price_percent, block_constants);
|
||||
|
||||
@@ -175,7 +175,8 @@ public:
|
||||
// result with valid dependent projections becomes the live state.
|
||||
std::optional<TransferActionResult> dispatch_transfer_market(
|
||||
const ui::TransferMarketRequest&, const HumanBuyerSaleHooks&,
|
||||
uint64_t& revision, std::string& error);
|
||||
uint64_t& revision, std::string& error,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
|
||||
|
||||
struct TransferMarketPreviewDispatch {
|
||||
ui::PreparationState preparation;
|
||||
|
||||
+54
-24
@@ -2,6 +2,7 @@
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/controller.hpp"
|
||||
#include "app/debug_log.hpp"
|
||||
#include "app/window_actions.hpp"
|
||||
#include "app/desktop_actions.hpp"
|
||||
#include "app/audio.hpp"
|
||||
@@ -145,12 +146,12 @@ void serve_friendly_action(ui::StartupFlow& flow, CareerSession& session,
|
||||
const auto& national=*request.national_booking;
|
||||
const auto expected=FriendlyActions::national_owner(request);
|
||||
if(request.kind!=ui::FriendlyRequestKind::book||!request.quote_id||
|
||||
request.runtime_team!=kNoTeam||request.opponent<(kNoTeam + 1)||request.opponent>(kNoTeam + 61)||
|
||||
request.runtime_team!=0x165||request.opponent<0x166||request.opponent>0x1a2||
|
||||
request.season_day<0||request.season_day>365||request.planner_count<0||
|
||||
request.planner_count>253||request.revision!=revision||
|
||||
national.owner!=expected||national.quote.owner!=expected||
|
||||
national.season_day!=request.season_day||national.quote.terms.manager!=manager||
|
||||
national.quote.terms.manager_team!=kNoTeam||national.quote.terms.opponent!=request.opponent||
|
||||
national.quote.terms.manager_team!=0x165||national.quote.terms.opponent!=request.opponent||
|
||||
national.quote.terms.planner_count!=request.planner_count||
|
||||
national.quote.terms.home_team!=request.home_team||national.quote.terms.away_team!=request.away_team||
|
||||
national.quote.terms.payer_manager!=request.payer_manager||
|
||||
@@ -232,7 +233,7 @@ void serve_friendly_action(ui::StartupFlow& flow, CareerSession& session,
|
||||
|
||||
if (request.kind != ui::FriendlyRequestKind::book || request.quote_id == 0 ||
|
||||
request.season_day < 0 || request.season_day > 365 || request.opponent < 0 ||
|
||||
request.opponent >= runtime_dimensions.record_teams || request.cost < 0 || request.planner_count > 253) {
|
||||
request.opponent >= 168 || request.cost < 0 || request.planner_count > 253) {
|
||||
flow.reject_friendly_action("Die Angaben zum Spieltermin sind ungültig.");
|
||||
return;
|
||||
}
|
||||
@@ -257,13 +258,13 @@ bool valid_national_friendly_family(const ui::StartupFlow& flow,const GameState&
|
||||
const auto* origin=flow.national_friendly_desk_owner();
|
||||
const auto* menu=flow.statistics_menu();
|
||||
const auto* desk=flow.desktop();
|
||||
if(!owner||!origin||!menu||!desk||owner->desk_menu!=6||owner->runtime_team!=kNoTeam||
|
||||
if(!owner||!origin||!menu||!desk||owner->desk_menu!=6||owner->runtime_team!=0x165||
|
||||
owner->manager<0||owner->revision!=revision||origin->kind!=ui::DeskRequestKind::open_menu||
|
||||
origin->menu_kind!=6||origin->manager_slot!=owner->manager||origin->revision!=revision||
|
||||
desk->state().revision!=revision||desk->state().manager_slot!=owner->manager||
|
||||
menu->state().owner.kind!=ui::DeskRequestKind::open_menu||menu->state().owner.menu_kind!=23||
|
||||
menu->state().owner.manager_slot!=owner->manager||menu->state().owner.revision!=revision||
|
||||
size_t(owner->manager)>=game.manager_teams.size()||game.manager_teams[size_t(owner->manager)]!=kNoTeam||
|
||||
size_t(owner->manager)>=game.manager_teams.size()||game.manager_teams[size_t(owner->manager)]!=0x165||
|
||||
!game.memory.has(::bmh::layout::ActiveManager)||int(game.memory.u8(::bmh::layout::ActiveManager))!=owner->manager)return false;
|
||||
return true;
|
||||
}
|
||||
@@ -278,17 +279,17 @@ void serve_national_friendly_selection(ui::StartupFlow& flow,CareerSession& sess
|
||||
const auto& game=session.state();
|
||||
const auto& desk=flow.desktop()->state();
|
||||
const int manager=owner->manager;
|
||||
if(owner->desk_menu!=6||owner->runtime_team!=kNoTeam||owner->revision!=revision||
|
||||
if(owner->desk_menu!=6||owner->runtime_team!=0x165||owner->revision!=revision||
|
||||
desk_request->kind!=ui::DeskRequestKind::open_menu||desk_request->menu_kind!=6||
|
||||
desk_request->revision!=revision||desk_request->manager_slot!=manager||
|
||||
desk.revision!=revision||desk.manager_slot!=manager||manager<0||
|
||||
size_t(manager)>=game.manager_teams.size()||game.manager_teams[size_t(manager)]!=kNoTeam||
|
||||
int(game.memory.u8(::bmh::layout::ActiveManager))!=manager||selected_team<(kNoTeam + 1)||selected_team>(kNoTeam + 61)) {
|
||||
size_t(manager)>=game.manager_teams.size()||game.manager_teams[size_t(manager)]!=0x165||
|
||||
int(game.memory.u8(::bmh::layout::ActiveManager))!=manager||selected_team<0x166||selected_team>0x1a2) {
|
||||
flow.close_national_friendly_picker();
|
||||
return;
|
||||
}
|
||||
if(!presenter) { flow.close_national_friendly_picker(); return; }
|
||||
ui::NationalFriendlyUi dialog_flow(*owner,national_friendly_identity(game,manager,kNoTeam));
|
||||
ui::NationalFriendlyUi dialog_flow(*owner,national_friendly_identity(game,manager,0x165));
|
||||
auto venue=dialog_flow.select_opponent(game,selected_team);
|
||||
if(venue.kind!=ui::NationalFriendlyUiActionKind::show_question||!venue.question) {
|
||||
flow.close_national_friendly_picker();return;
|
||||
@@ -321,7 +322,7 @@ void serve_national_friendly_selection(ui::StartupFlow& flow,CareerSession& sess
|
||||
}
|
||||
ui::FriendlyQuoteProjection projection;
|
||||
projection.request_id=quote_request.engine_owner->request_id;
|
||||
projection.revision=revision;projection.manager_slot=manager;projection.runtime_team=kNoTeam;
|
||||
projection.revision=revision;projection.manager_slot=manager;projection.runtime_team=0x165;
|
||||
projection.opponent=selected_team;projection.opponent_manager=quote.terms.opponent_manager;
|
||||
projection.payer_manager=quote.terms.payer_manager;projection.home_team=quote.terms.home_team;
|
||||
projection.away_team=quote.terms.away_team;projection.cost=quote.terms.cost;
|
||||
@@ -336,7 +337,7 @@ void serve_national_friendly_selection(ui::StartupFlow& flow,CareerSession& sess
|
||||
projection.dates.push_back({day,mark});
|
||||
}
|
||||
ui::FriendlyMatchState calendar;
|
||||
calendar.revision=revision;calendar.manager_slot=manager;calendar.runtime_team=kNoTeam;
|
||||
calendar.revision=revision;calendar.manager_slot=manager;calendar.runtime_team=0x165;
|
||||
calendar.current_day=game.season_day();calendar.planner_count=quote.terms.planner_count;
|
||||
calendar.season_start_counter=game.season_start;calendar.mode_three=desk.options.mode==3;
|
||||
calendar.national_team=true;calendar.manager_name=ui::original_to_utf8(desk.manager_name);
|
||||
@@ -370,9 +371,11 @@ std::string transfer_status_message(TransferActionStatus status, ui::TransferMar
|
||||
case TransferActionStatus::accepted:
|
||||
return kind == ui::TransferMarketRequestKind::list_player
|
||||
? "Der Spieler steht jetzt auf der Transferliste." : "Der Spieler hat das Angebot angenommen.";
|
||||
case TransferActionStatus::pending: return "Der Spieler entscheidet sich nächste Woche.";
|
||||
case TransferActionStatus::pending: return kind == ui::TransferMarketRequestKind::list_player
|
||||
? "Der Spieler steht bereits auf der Transferliste." : "Der Spieler entscheidet sich nächste Woche.";
|
||||
case TransferActionStatus::offer_too_low: return "Das Angebot ist zu niedrig.";
|
||||
case TransferActionStatus::blocked_by_board: return "Der Vorstand genehmigt diesen Transfer nicht.";
|
||||
case TransferActionStatus::blocked_by_board: return kind == ui::TransferMarketRequestKind::list_player
|
||||
? "Transferliste voll oder Spieler nicht verfügbar." : "Der Vorstand genehmigt diesen Transfer nicht.";
|
||||
case TransferActionStatus::insufficient_funds: return "Das Geld reicht für diesen Transfer nicht aus.";
|
||||
case TransferActionStatus::no_squad_room: return "Im Kader ist kein Platz für diesen Spieler.";
|
||||
case TransferActionStatus::rejected: return "Der Spieler hat das Angebot abgelehnt.";
|
||||
@@ -384,7 +387,8 @@ void serve_transfer_action(ui::StartupFlow& flow, CareerSession& session,
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision,
|
||||
const HumanBuyerSaleHooks& presenters,
|
||||
HumanBuyerMarketEntryPolicy entry_policy,
|
||||
const CareerSession::PoachPlayerSelector& poach_selector, const PoachNoticePresenter& poach_notice) {
|
||||
const CareerSession::PoachPlayerSelector& poach_selector, const PoachNoticePresenter& poach_notice,
|
||||
const TransferOfferPresenter& review) {
|
||||
const auto* pending = flow.pending_transfer_market();
|
||||
// JSON covers every offer field except its redundant nested manager identity.
|
||||
// Check that identity too, before an engine helper can consume a random draw.
|
||||
@@ -473,13 +477,22 @@ void serve_transfer_action(ui::StartupFlow& flow, CareerSession& session,
|
||||
const auto outcome = TransferActions(session).market(request, hooks, revision, error, entry_policy,
|
||||
[&](const TransferActions::MarketDispatch& applied) {
|
||||
// Preserve the Source caller's existing notice/ACK sequence.
|
||||
const bool source_finished = entry_policy == HumanBuyerMarketEntryPolicy::normal_interactive &&
|
||||
(source_notice_presented || applied.action.status == TransferActionStatus::pending);
|
||||
const bool source_finished = request.kind != ui::TransferMarketRequestKind::review_offers &&
|
||||
entry_policy == HumanBuyerMarketEntryPolicy::normal_interactive &&
|
||||
(source_notice_presented || (request.kind == ui::TransferMarketRequestKind::submit_bid &&
|
||||
applied.action.status == TransferActionStatus::pending));
|
||||
auto notice = source_finished ? std::string{} : transfer_status_message(applied.action.status, request.kind);
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
notice = applied.action.status == TransferActionStatus::accepted
|
||||
? "Das Angebot wurde angenommen."
|
||||
: applied.action.status == TransferActionStatus::pending
|
||||
? "Spieler bleibt auf der Transferliste."
|
||||
: "Angebot abgelehnt; Transferliste unverändert.";
|
||||
}
|
||||
if (!applied.changed && source_finished) flow.acknowledge_unchanged_transfer_market();
|
||||
else if (!applied.changed) flow.reject_preparation_action(std::move(notice));
|
||||
else flow.acknowledge_preparation(session.preparation_projection(revision), std::move(notice));
|
||||
});
|
||||
}, review);
|
||||
if (!outcome) throw FormatError(error);
|
||||
} catch (const std::exception&) {
|
||||
flow.reject_preparation_action("Diese Transferaktion konnte nicht übernommen werden.");
|
||||
@@ -566,6 +579,8 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
opened.identity.runtime_team!=desk.runtime_club||
|
||||
opened.identity.day_counter!=desk.day_counter||desk.manager_slot<0||
|
||||
size_t(desk.manager_slot)>=desk.managers.size()||
|
||||
// The session identifies the national-coach desk by the home club
|
||||
// (stable team behind the desk), not by the desk's own runtime club.
|
||||
opened.identity.club_identity!=desk.managers[size_t(desk.manager_slot)].club_identity_key)
|
||||
throw FormatError("other games: stale desktop identity");
|
||||
flow.show_other_games(std::move(opened),session->preparation_projection(revision),result.desk_action);
|
||||
@@ -809,14 +824,14 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
const bool national_source_case=flow.national_friendly_family_active();
|
||||
const int stable_identity=national_source_case&&flow.desktop()&&
|
||||
owner.manager_slot>=0&&size_t(owner.manager_slot)<flow.desktop()->state().managers.size()?
|
||||
flow.desktop()->state().managers[size_t(owner.manager_slot)].club_identity_key:-1;
|
||||
flow.desktop()->state().session_identity_key(size_t(owner.manager_slot)):-1;
|
||||
auto page=OpportunitiesActions(*session).open(owner,revision,underlay,error,
|
||||
national_source_case,stable_identity,[&](ui::OpportunitiesState& opened) {
|
||||
const auto& desk=flow.desktop()->state();
|
||||
if(opened.identity.manager_slot!=desk.manager_slot||opened.identity.runtime_team!=desk.runtime_club||
|
||||
opened.identity.day_counter!=desk.day_counter||desk.manager_slot<0||
|
||||
size_t(desk.manager_slot)>=desk.managers.size()||
|
||||
opened.identity.stable_club_identity!=int(desk.managers[size_t(desk.manager_slot)].club_identity_key))
|
||||
opened.identity.stable_club_identity!=int(desk.session_identity_key(size_t(desk.manager_slot))))
|
||||
throw FormatError("opportunities: stale desktop identity");
|
||||
flow.show_opportunities(std::move(opened),session->preparation_projection(revision),owner);
|
||||
});
|
||||
@@ -926,6 +941,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
opened.identity.day_counter!=desk.day_counter||
|
||||
desk.manager_slot<0||
|
||||
size_t(desk.manager_slot)>=desk.managers.size()||
|
||||
// Same home-club identity as the session builds for the national desk.
|
||||
opened.identity.club_identity!=desk.managers[size_t(desk.manager_slot)].club_identity_key)
|
||||
throw FormatError("top scorers: stale desktop identity");
|
||||
flow.show_top_scorers(std::move(opened),session->preparation_projection(revision),result.desk_action);
|
||||
@@ -957,7 +973,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
const int team=game.manager_teams[size_t(manager)];
|
||||
if(team!=kNoTeam&&(team<0||size_t(team)>=game.team_flags.size()))
|
||||
throw FormatError("fair play: active manager has no Source roster");
|
||||
const int league=team>(kNoTeam - 1)?0:team_league(team);
|
||||
const int league=team>0x164?0:team_league(team);
|
||||
page=ui::fair_play_state_from_game(game,league,underlay,manager);
|
||||
} else {
|
||||
page.kind=ui::DeskRecordKind::highscore;
|
||||
@@ -1308,7 +1324,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
const auto& desk=flow.desktop()->state();
|
||||
if(!semantic||semantic->identity.manager!=desk.manager_slot||semantic->identity.runtime_club!=desk.runtime_club||
|
||||
semantic->identity.day_counter!=desk.day_counter||desk.manager_slot<0||size_t(desk.manager_slot)>=desk.managers.size()||
|
||||
semantic->identity.club_identity!=desk.managers[size_t(desk.manager_slot)].club_identity_key)
|
||||
semantic->identity.club_identity!=desk.session_identity_key(size_t(desk.manager_slot)))
|
||||
throw FormatError("strengths: stale desktop identity");
|
||||
const auto applied=session->dispatch_strengths(*semantic,revision,error);
|
||||
if(!applied)throw FormatError(error.empty()?"league family Strengths entry rejected":error);
|
||||
@@ -1533,7 +1549,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
} else if (result.request == ui::FlowRequest::submenu_action && session &&
|
||||
std::holds_alternative<ui::TransferMarketRequest>(result.submenu_action)) {
|
||||
serve_transfer_action(flow, *session, std::get<ui::TransferMarketRequest>(result.submenu_action), revision,
|
||||
market_sale_presenter, market_entry_policy, poach_player_selector, poach_notice_presenter);
|
||||
market_sale_presenter, market_entry_policy, poach_player_selector, poach_notice_presenter, transfer_presenter);
|
||||
} else if (result.request == ui::FlowRequest::submenu_action && session &&
|
||||
std::holds_alternative<ui::OutgoingTransferRequest>(result.submenu_action)) {
|
||||
serve_transfer_offer(flow, *session, std::get<ui::OutgoingTransferRequest>(result.submenu_action), revision,
|
||||
@@ -1854,6 +1870,20 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
});
|
||||
const auto advanced = session->dispatch_kickoff(result.desk_action, revision, error);
|
||||
start_original_desk_audio(playback, session->state(), music_enabled);
|
||||
if (app::debug::enabled()) {
|
||||
// -debug: one savegame after every match day, in the debug folder (DBG00001.FBM, ...).
|
||||
app::debug::log("kickoff handled: " + std::string(advanced.kind == TurnDeskKind::Failed ? "failed" : "ok") +
|
||||
", date counter " + std::to_string(session->state().date) + ", revision " + std::to_string(revision) +
|
||||
(error.empty() ? std::string() : ", error " + error));
|
||||
if (advanced.kind != TurnDeskKind::Failed) {
|
||||
const auto path = app::debug::next_save_path();
|
||||
std::string save_error;
|
||||
const int slot = int(session->state().memory.u8(::bmh::layout::ActiveManager));
|
||||
const bool saved = session->save_game(path, slot, true, save_error);
|
||||
app::debug::log(saved ? "debug savegame " + path.filename().string()
|
||||
: "debug savegame failed: " + save_error);
|
||||
}
|
||||
}
|
||||
if (advanced.kind == TurnDeskKind::Failed || advanced.kind == TurnDeskKind::WaitingAtDesk) {
|
||||
flow.reject_desk_action(error.empty() ? advanced.reason : error);
|
||||
return {};
|
||||
@@ -2110,11 +2140,11 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
const auto& desk = flow.desktop()->state();
|
||||
const int manager=request.manager_slot;
|
||||
if(manager>=0&&size_t(manager)<game.manager_teams.size()&&
|
||||
game.manager_teams[size_t(manager)]==kNoTeam) {
|
||||
game.manager_teams[size_t(manager)]==0x165) {
|
||||
const auto projection=ui::world_cup_statistics_from_game(game,
|
||||
load_le(ui::asset_path(data,"BMH.exe")),
|
||||
ui::WorldCupStatisticsOwner::friendly_match_nation_picker);
|
||||
flow.show_national_friendly_picker(projection,request,kNoTeam);
|
||||
flow.show_national_friendly_picker(projection,request,0x165);
|
||||
return {};
|
||||
}
|
||||
LeagueFamilyActions(*session).apply(revision, [&] {
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace bmh::app::debug {
|
||||
|
||||
// The debug mode (command line -debug): a log with timestamps next to everything the game prints
|
||||
// to stderr, and a savegame after every played match day, both in one sub folder of the save
|
||||
// directory. Off by default; every function is a no-op until init() has run.
|
||||
struct State {
|
||||
bool enabled = false;
|
||||
std::filesystem::path directory;
|
||||
unsigned saves = 0;
|
||||
std::mutex mutex;
|
||||
};
|
||||
inline State& state() { static State s; return s; }
|
||||
|
||||
inline bool enabled() { return state().enabled; }
|
||||
inline const std::filesystem::path& directory() { return state().directory; }
|
||||
|
||||
inline std::string timestamp() {
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
const std::time_t t = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm parts{};
|
||||
#ifdef _WIN32
|
||||
localtime_s(&parts, &t);
|
||||
#else
|
||||
localtime_r(&t, &parts);
|
||||
#endif
|
||||
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count() % 1000;
|
||||
char text[40];
|
||||
std::snprintf(text, sizeof text, "%04d-%02d-%02d %02d:%02d:%02d.%03d", parts.tm_year + 1900, parts.tm_mon + 1,
|
||||
parts.tm_mday, parts.tm_hour, parts.tm_min, parts.tm_sec, int(ms));
|
||||
return text;
|
||||
}
|
||||
|
||||
// One line, flushed at once so that a crash or a hang loses nothing.
|
||||
inline void log(const std::string& line) {
|
||||
auto& s = state();
|
||||
if (!s.enabled) return;
|
||||
std::lock_guard<std::mutex> lock(s.mutex);
|
||||
std::ofstream out(s.directory / "openbmh-debug.log", std::ios::app);
|
||||
if (out) out << timestamp() << " " << line << '\n';
|
||||
}
|
||||
|
||||
// Creates the folder and redirects stderr into the same folder, so the messages the game
|
||||
// prints on its own (for example the live overview errors) are kept as well.
|
||||
inline bool init(const std::filesystem::path& directory) {
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(directory, ec);
|
||||
if (ec || !std::filesystem::is_directory(directory)) return false;
|
||||
auto& s = state();
|
||||
s.directory = directory;
|
||||
s.enabled = true;
|
||||
const auto errors = (directory / "openbmh-stderr.log").string();
|
||||
if (std::FILE* redirected = std::freopen(errors.c_str(), "a", stderr)) std::setvbuf(redirected, nullptr, _IONBF, 0);
|
||||
log("debug mode on, folder " + directory.string());
|
||||
return true;
|
||||
}
|
||||
|
||||
// The file name of the next automatic savegame: DBG00001.FBM, DBG00002.FBM, ... (8.3 like the original).
|
||||
inline std::filesystem::path next_save_path() {
|
||||
auto& s = state();
|
||||
char name[16];
|
||||
std::snprintf(name, sizeof name, "DBG%05u.FBM", ++s.saves);
|
||||
return s.directory / name;
|
||||
}
|
||||
|
||||
} // namespace bmh::app::debug
|
||||
+158
-71
@@ -1,9 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/scene_timing.hpp"
|
||||
#include "formats/data_profile.hpp"
|
||||
#include "game/profile_runtime.hpp"
|
||||
#include "app/start_screen.hpp"
|
||||
#include "ui/live_timing.hpp"
|
||||
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
|
||||
// career initialised by the engine (app/career_session.hpp) and its desk.
|
||||
@@ -36,6 +34,8 @@
|
||||
#include "version.hpp"
|
||||
#include "app/video_session.hpp"
|
||||
#include "app/live_matchday_events.hpp"
|
||||
#include "app/debug_log.hpp"
|
||||
#include "app/pitch_pointer.hpp"
|
||||
#include "audio/playback.hpp"
|
||||
#include "app/audio.hpp"
|
||||
#include "formats/palette.hpp"
|
||||
@@ -116,7 +116,7 @@ int main(int argc, char** argv) {
|
||||
const std::vector<std::string> args = launch::utf8_arguments(argc, argv); // (file names beyond the code page)
|
||||
fs::path data, save_directory;
|
||||
uint32_t seed = uint32_t(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
bool muted = false, music_enabled = true;
|
||||
bool muted = false, music_enabled = true, debug_mode = false;
|
||||
int live_frame_ms = 0;
|
||||
bool live_frame_ms_explicit = false;
|
||||
if (const char* configured = std::getenv("BMH_LIVE_FRAME_MS")) {
|
||||
@@ -140,6 +140,8 @@ int main(int argc, char** argv) {
|
||||
data = launch::path_from_utf8(args[++i]);
|
||||
} else if (is("--seed") && value) {
|
||||
seed = uint32_t(std::strtoul(args[++i].c_str(), nullptr, 0));
|
||||
} else if (is("-debug") || is("--debug")) {
|
||||
debug_mode = true;
|
||||
} else if (is("--save-directory") && value) {
|
||||
save_directory = launch::path_from_utf8(args[++i]);
|
||||
} else if (is("--volume") && value) {
|
||||
@@ -149,7 +151,7 @@ int main(int argc, char** argv) {
|
||||
return 0;
|
||||
} else if (is("--help") || is("-h")) {
|
||||
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>] [-debug]\n");
|
||||
return 0;
|
||||
} else if (args[i].rfind("--", 0) != 0 && data.empty()) {
|
||||
data = launch::path_from_utf8(args[i]);
|
||||
@@ -196,8 +198,14 @@ int main(int argc, char** argv) {
|
||||
data = game.check.directory;
|
||||
}
|
||||
if (save_directory.empty()) save_directory = data;
|
||||
if (debug_mode) {
|
||||
// -debug: log in <saves>/debug, with a savegame after every match day (app/debug_log.hpp).
|
||||
if (!app::debug::init(save_directory / "debug")) std::fprintf(stderr, "debug folder cannot be created\n");
|
||||
app::debug::log(std::string("OpenBMH ") + bmh::kOpenBmhVersion + ", data " + data.string() + ", saves " + save_directory.string() + ", seed " + std::to_string(seed));
|
||||
SDL_version linked; SDL_GetVersion(&linked);
|
||||
app::debug::log("SDL " + std::to_string(linked.major) + "." + std::to_string(linked.minor) + "." + std::to_string(linked.patch) + ", platform " + SDL_GetPlatform());
|
||||
}
|
||||
try {
|
||||
install_runtime_profile(load_data_profile(data));
|
||||
const Palette palette = load_palette(ui::asset_path(data, "M3PC.COL"));
|
||||
ui::StartupFlow flow(data, save_directory);
|
||||
std::unique_ptr<app::CareerSession> session;
|
||||
@@ -209,8 +217,9 @@ int main(int argc, char** argv) {
|
||||
playback.set_volume(volume);
|
||||
std::optional<uint64_t> audio_session;
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
|
||||
const std::string window_title = "OpenBMH 1.1";
|
||||
SDL_Window* window = SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 720, SDL_WINDOW_RESIZABLE);
|
||||
const std::string window_title = std::string("OpenBMH ") + bmh::kOpenBmhVersion +
|
||||
(english_game ? " - Football Limited (experimental)" : "");
|
||||
SDL_Window* window = SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 720, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
if (!window) throw FormatError(SDL_GetError());
|
||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
|
||||
if (!renderer) renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
|
||||
@@ -218,6 +227,7 @@ int main(int argc, char** argv) {
|
||||
SDL_RenderSetLogicalSize(renderer, 320, 240);
|
||||
SDL_Texture* texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 320, 240);
|
||||
if (!texture) throw FormatError(SDL_GetError());
|
||||
app::PitchPointer pitch_pointer;
|
||||
std::vector<uint32_t> pixels(320 * 240);
|
||||
ui::LiveMatchdayScreen live_screen(data);
|
||||
ui::RealityReporterPanel reality_reporter(data);
|
||||
@@ -226,8 +236,21 @@ int main(int argc, char** argv) {
|
||||
ui::SportschauEleven sportschau_eleven(data);
|
||||
ui::SportschauTeamInfo sportschau_team_info(data);
|
||||
ui::CompetitionWinnerScreen competition_winner(data);
|
||||
ui::set_settings_product_version(bmh::kOpenBmhVersion);
|
||||
const auto season_exe = load_le(ui::asset_path(data, "BMH.exe"));
|
||||
english_game = english_game || season_exe.u8(layout::LeagueSizes) == 20;
|
||||
{
|
||||
// The pointer of the original is its default 11x11 bitmap (index 0 transparent, hot spot
|
||||
// top left, set when a window object is created); the pitch page draws the same bitmap
|
||||
// with its own fill colour. The edition's own bitmap is used for the English version.
|
||||
std::array<uint32_t, 121> bitmap{};
|
||||
for (uint32_t i = 0; i < bitmap.size(); ++i) {
|
||||
const auto index = season_exe.u8(layout::OriginalPointerPixels + i);
|
||||
bitmap[i] = index == 0 ? 0 : palette.argb[index];
|
||||
}
|
||||
pitch_pointer.set_default(bitmap);
|
||||
pitch_pointer.show({}, renderer);
|
||||
}
|
||||
app::QuitConfirmation quit_confirmation(window, english_game);
|
||||
try {
|
||||
if (!playback.initialize_original(app::original_audio_assets(data, season_exe), audio_error))
|
||||
@@ -331,7 +354,7 @@ int main(int argc, char** argv) {
|
||||
std::optional<Image> season_backdrop;
|
||||
auto present_season = [&](const Image& image, const char* title,
|
||||
const Palette* palette_override = nullptr) {
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, title);
|
||||
season_backdrop = image;
|
||||
const Palette& frame_palette = palette_override ? *palette_override : palette;
|
||||
const Image painted = process_timer_image(image);
|
||||
@@ -598,7 +621,7 @@ int main(int argc, char** argv) {
|
||||
"_" + std::to_string(fixture.fixture) + "_" + std::to_string(sportschau_step_index++);
|
||||
present_season(sportschau_replay_screen->render_report(step), title.c_str());
|
||||
const int raw = state.memory.has(::bmh::layout::Main_FormatError_RuntimeField4) ? state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField4) : 0;
|
||||
if (step.minute_wait) source_tick_wait(unsigned((app::scene_frame_delay((raw < 6 ? raw / 2 : raw)*20)+19)/20));
|
||||
if (step.minute_wait) source_tick_wait(unsigned(raw < 6 ? raw / 2 : raw));
|
||||
if (step.chance_wait) source_tick_wait(50);
|
||||
return skip;
|
||||
};
|
||||
@@ -619,7 +642,7 @@ int main(int argc, char** argv) {
|
||||
const auto delay = [&](int row) {
|
||||
const uint32_t address = ::bmh::layout::Main_FormatError_ExecutableFieldUnsigned + uint32_t(row * 9);
|
||||
const int raw = state.memory.has(address) ? state.memory.u8(address) : 0;
|
||||
source_tick_wait(unsigned((app::scene_frame_delay((raw < 6 ? raw / 2 : raw)*20)+19)/20));
|
||||
source_tick_wait(unsigned(raw < 6 ? raw / 2 : raw));
|
||||
};
|
||||
present_season(backdrop, ("OpenBMH - sportschau_scene_header_" + id).c_str(), &colors);
|
||||
delay(12); // AdvanceStep(12), header preview in ShotAnimation
|
||||
@@ -630,7 +653,7 @@ int main(int argc, char** argv) {
|
||||
std::to_string(i)).c_str(), &colors);
|
||||
const unsigned retraces = i == 0 ? 40u :
|
||||
(state.memory.has(::bmh::layout::Main_FormatError_RuntimeField2) ? state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField2) : 0u);
|
||||
SDL_Delay(Uint32(live_frame_ms_explicit?live_frame_ms:app::scene_frame_delay(int(retraces)*1000/70))); // FirstThen: first40, then F8
|
||||
wait_source_retraces(retraces); // FirstThen: first40, then F8
|
||||
}
|
||||
}
|
||||
const auto frames = live_screen.render_shot(frame, scene.shot, &backdrop);
|
||||
@@ -638,7 +661,7 @@ int main(int argc, char** argv) {
|
||||
present_season(frames[i], ("OpenBMH - sportschau_shot_" + id + "_" +
|
||||
std::to_string(i)).c_str(), &colors);
|
||||
const int speed = state.memory.has(::bmh::layout::Main_FormatError_RuntimeField) ? int(int8_t(state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField))) : 0;
|
||||
SDL_Delay(Uint32(live_frame_ms_explicit?live_frame_ms:app::scene_frame_delay(std::max(0,speed)*1000/70)));
|
||||
wait_source_retraces(unsigned(std::max(0, speed)));
|
||||
}
|
||||
source_tick_wait(10); // LiveMatchdayFrame's final ten ticks
|
||||
if (!running) return;
|
||||
@@ -948,7 +971,7 @@ int main(int argc, char** argv) {
|
||||
int manager, int source_slot, int list_entry,
|
||||
const HumanBuyerSaleHooks& sale_hooks) -> int {
|
||||
if (!running || manager < 0 || manager >= 4 || list_entry < 40 || list_entry >= 44 ||
|
||||
source_slot != runtime_dimensions.pool_first + list_entry || !staged.memory.has(::bmh::layout::EditorList + uint32_t(list_entry) * 0x58 + 0x57))
|
||||
source_slot != 2928 + list_entry || !staged.memory.has(::bmh::layout::EditorList + uint32_t(list_entry) * 0x58 + 0x57))
|
||||
return -1;
|
||||
const uint32_t row = ::bmh::layout::EditorList + uint32_t(list_entry) * 0x58;
|
||||
const int player = staged.squad_slots.at(size_t(source_slot)) & 0x0fff;
|
||||
@@ -1361,7 +1384,7 @@ int main(int argc, char** argv) {
|
||||
auto page=staged.current_league_table_dispatch(error);
|
||||
if(!page)throw FormatError(error);
|
||||
const auto present=[&](const Image& frame,const std::string& title) {
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");season_backdrop=frame;
|
||||
SDL_SetWindowTitle(window,title.c_str());season_backdrop=frame;
|
||||
const auto painted=process_timer_image(frame);
|
||||
for(size_t i=0;i<pixels.size();++i)pixels[i]=palette.argb[painted.pixels[i]];
|
||||
if(SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4)!=0 ||
|
||||
@@ -1705,6 +1728,7 @@ int main(int argc, char** argv) {
|
||||
std::optional<Uint64> timed_notice_presented_at;
|
||||
std::optional<Uint8> timed_notice_release;
|
||||
auto handle = [&](const ui::FlowResult& r) {
|
||||
pitch_pointer.show({}, renderer);
|
||||
if (r.request == ui::FlowRequest::end_session && !quit_confirmation.confirm()) {
|
||||
flow.reject_desk_action(english_game ? "Quit cancelled." : "Beenden abgebrochen.");
|
||||
dirty = true;
|
||||
@@ -1750,7 +1774,7 @@ int main(int argc, char** argv) {
|
||||
"OpenBMH - live_substitution_notice") == PendingOfferAnswer::unsupported)
|
||||
throw FormatError("live substitution notice presenter stopped");
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, parent_title);
|
||||
};
|
||||
bool completed = false;
|
||||
const int selected_manager = selected_team >= 0 ? state.manager_of(selected_team) : -1;
|
||||
@@ -1780,10 +1804,11 @@ int main(int argc, char** argv) {
|
||||
return (screen.extras().native_display_word & 8)
|
||||
? "OpenBMH - live_pitch" : "OpenBMH - live_lineup";
|
||||
};
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, live_title());
|
||||
bool closed = false;
|
||||
const auto apply_live_pitch = [&](const ui::PitchRequest& action) {
|
||||
if (action.kind == ui::PitchRequestKind::none) return;
|
||||
pitch_pointer.show({}, renderer);
|
||||
if (action.kind == ui::PitchRequestKind::open_player_info) {
|
||||
try {
|
||||
if (action.row < 0 || size_t(action.row) >= screen.state().players.size() ||
|
||||
@@ -1819,10 +1844,11 @@ int main(int argc, char** argv) {
|
||||
? "Der Spielerwechsel ist nicht freigegeben." : result.error);
|
||||
}
|
||||
}
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, live_title());
|
||||
};
|
||||
bool left_held = false, left_release_consumed = false, right_held = false;
|
||||
while (running && !closed) {
|
||||
pitch_pointer.show(screen.pointer_cursor(palette), renderer);
|
||||
const Image image = screen.render();
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
pixels[i] = palette.argb[image.pixels[i]];
|
||||
@@ -1883,8 +1909,10 @@ int main(int argc, char** argv) {
|
||||
scope_finished = true;
|
||||
completed = true;
|
||||
}
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
pitch_pointer.show({}, renderer);
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_matchday");
|
||||
} catch (const std::exception& e) {
|
||||
pitch_pointer.show({}, renderer);
|
||||
if (scope_started && !scope_finished)
|
||||
dispatch_scope(app::LiveInterventionBoundary::abort, 2,
|
||||
selected_manager, selected_team, scope_error);
|
||||
@@ -1967,7 +1995,7 @@ int main(int argc, char** argv) {
|
||||
const Image image = table_screen ? table_screen->render()
|
||||
: pairings_screen ? pairings_screen->render()
|
||||
: strengths_screen ? strengths_screen->render() : cup_screen->render();
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, overview_title().c_str());
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
pixels[i] = palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
@@ -1989,7 +2017,7 @@ int main(int argc, char** argv) {
|
||||
std::optional<ui::TableRangeDialogOutcome> outcome;
|
||||
const auto show_dialog = [&] {
|
||||
const Image image = dialog.render();
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_table_range");
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
pixels[i] = palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
@@ -2099,11 +2127,16 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
};
|
||||
SDL_FlushEvent(SDL_KEYUP);
|
||||
while (running && !closed) {
|
||||
while (running && (!closed || down)) {
|
||||
SDL_Event input;
|
||||
bool redrawn = false;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; break; }
|
||||
if (closed) {
|
||||
if (input.type == SDL_MOUSEBUTTONUP && down &&
|
||||
input.button.button == down->button) { down.reset(); break; }
|
||||
continue;
|
||||
}
|
||||
if (input.type == SDL_MOUSEMOTION) {
|
||||
const bool changed = table_screen ? table_screen->move(input.motion.x, input.motion.y)
|
||||
: pairings_screen ? pairings_screen->move(input.motion.x, input.motion.y)
|
||||
@@ -2122,8 +2155,7 @@ int main(int argc, char** argv) {
|
||||
else cup_screen->pointer_down(input.button.x, input.button.y,
|
||||
input.button.button == SDL_BUTTON_RIGHT);
|
||||
} else if (input.type == SDL_MOUSEBUTTONUP && down &&
|
||||
input.button.button == down->button && input.button.x == down->x &&
|
||||
input.button.y == down->y) {
|
||||
input.button.button == down->button) {
|
||||
down.reset();
|
||||
if (table_screen) table_screen->click(input.button.x, input.button.y,
|
||||
input.button.button == SDL_BUTTON_RIGHT);
|
||||
@@ -2144,19 +2176,21 @@ int main(int argc, char** argv) {
|
||||
else if (cup_screen && cup_screen->pending())
|
||||
action = *cup_screen->pending();
|
||||
if (action) { dispatch_action(*action); redrawn = true; }
|
||||
if (closed || !running) break;
|
||||
if ((closed && !down) || !running) break;
|
||||
}
|
||||
if (!running || closed) break;
|
||||
if (!running || (closed && !down)) break;
|
||||
if (closed) { SDL_Delay(8); continue; }
|
||||
if (pairings_screen && pairings_screen->tick_source_seconds(overview_source_seconds())) {
|
||||
if (pairings_screen->pending())
|
||||
dispatch_action(app::CareerSession::LiveOverviewAction{*pairings_screen->pending()});
|
||||
redrawn = true;
|
||||
}
|
||||
if (closed || !running) break;
|
||||
if ((closed && !down) || !running) break;
|
||||
if (!redrawn) SDL_Delay(8);
|
||||
}
|
||||
return running && closed;
|
||||
};
|
||||
ui::LiveScoreReveal live_score_reveal;
|
||||
std::optional<ui::LiveChanceProjection> live_chance_context;
|
||||
std::unique_ptr<ui::RealityFieldScreen> reality_field;
|
||||
ui::RealityReporterLayoutState reality_layout;
|
||||
@@ -2170,7 +2204,7 @@ int main(int argc, char** argv) {
|
||||
if (!live_skipped) {
|
||||
const auto frame = ui::live_matchday_frame(minute, groups, state);
|
||||
if (!frame.matches.empty()) {
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_matchday");
|
||||
const Image live_image = live_screen.render(frame);
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[live_image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
@@ -2191,7 +2225,7 @@ int main(int argc, char** argv) {
|
||||
ui::IncomingTransferScreen offer_screen(data,
|
||||
ui::incoming_transfer_decision_from_game(state, view),
|
||||
state.memory.u8(::bmh::layout::TextGradientDisabled) == 0);
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - incoming_transfer");
|
||||
const Uint32 notice_started = SDL_GetTicks();
|
||||
bool offer_dirty = true;
|
||||
// Keep the original synchronous decision stack suspended here.
|
||||
@@ -2215,10 +2249,13 @@ int main(int argc, char** argv) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return -1; }
|
||||
std::optional<int> answer;
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
answer = offer_screen.click(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT);
|
||||
offer_screen.pointer_down(event.button.button == SDL_BUTTON_RIGHT);
|
||||
} else if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
answer = offer_screen.pointer_up(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT);
|
||||
offer_dirty = true;
|
||||
} else if (event.type == SDL_KEYDOWN) {
|
||||
if (offer_screen.notice_active()) {
|
||||
@@ -2260,7 +2297,7 @@ int main(int argc, char** argv) {
|
||||
decision_screen.begin_outcome(decision.offers.offer_count,
|
||||
decision.accepted ? decision.selected_bid_index : -1, state.memory.u8(::bmh::layout::OutcomeDelayDisabled));
|
||||
}
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, confirmation ? "OpenBMH - transfer_confirmation" : "OpenBMH - transfer_evaluation");
|
||||
const Uint32 started = SDL_GetTicks();
|
||||
uint64_t rendered_phase = UINT64_MAX;
|
||||
// The observer only presents the engine's settled decision. Keep
|
||||
@@ -2283,9 +2320,12 @@ int main(int argc, char** argv) {
|
||||
SDL_Event event;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))
|
||||
(void)decision_screen.click(event.button.x, event.button.y,
|
||||
decision_screen.pointer_down(event.button.button == SDL_BUTTON_RIGHT);
|
||||
else if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))
|
||||
(void)decision_screen.pointer_up(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT, elapsed);
|
||||
}
|
||||
if (confirmation ? decision_screen.confirmation_dismissed() : decision_screen.outcome_dismissed()) return;
|
||||
@@ -2299,7 +2339,7 @@ int main(int argc, char** argv) {
|
||||
// Other season animations remain separate implementation work.
|
||||
for (auto view : ui::season_entrants_from_game(state, season_exe, season_texts)) {
|
||||
ui::SeasonEntrantsScreen entrants_screen(data, std::move(view));
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - season_entrants");
|
||||
const Image image = entrants_screen.render();
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
@@ -2423,7 +2463,7 @@ int main(int argc, char** argv) {
|
||||
// SDLFlushEvents3 is a timed Source notice. Do not let its release
|
||||
// event become another click in the resumed parent screen.
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, parent_title);
|
||||
};
|
||||
const auto open_live_tactics = [&](int side, int y) {
|
||||
const auto frame = ui::live_matchday_frame(minute, groups, state);
|
||||
@@ -2449,7 +2489,7 @@ int main(int argc, char** argv) {
|
||||
tactics_game.memory.set8(::bmh::layout::ActiveManager, uint8_t(selected_manager));
|
||||
ui::TacticsScreen screen(data,
|
||||
ui::tactics_from_game(tactics_game, season_exe, live_revision));
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_tactics");
|
||||
bool closed = false;
|
||||
std::optional<SDL_MouseButtonEvent> tactics_down;
|
||||
bool source_completed = false;
|
||||
@@ -2503,7 +2543,7 @@ int main(int argc, char** argv) {
|
||||
selected_manager, selected_team, scope_error);
|
||||
scope_active = false;
|
||||
}
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_matchday");
|
||||
} catch (const std::exception& e) {
|
||||
if (scope_active)
|
||||
dispatch_scope(app::LiveInterventionBoundary::abort, 8,
|
||||
@@ -2522,7 +2562,7 @@ int main(int argc, char** argv) {
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, nullptr, nullptr);
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_paused");
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
bool resumed = false;
|
||||
@@ -2541,12 +2581,12 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
if (!resumed && running) SDL_Delay(8);
|
||||
}
|
||||
if (running) SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
if (running) SDL_SetWindowTitle(window, "OpenBMH - live_matchday");
|
||||
};
|
||||
const auto restore_live_frame = [&] {
|
||||
if (!running) return;
|
||||
const Image image = live_screen.render(ui::live_matchday_frame(minute, groups, state));
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_matchday");
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
pixels[i] = palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
@@ -2611,7 +2651,7 @@ int main(int argc, char** argv) {
|
||||
std::unique_ptr<ui::SettingsReadmeScreen> readme;
|
||||
const auto render_settings = [&] {
|
||||
const Image image = readme ? readme->render() : screen.render();
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, readme ? "OpenBMH - settings_readme" : "OpenBMH - live_settings");
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
pixels[i] = palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
@@ -2632,7 +2672,7 @@ int main(int argc, char** argv) {
|
||||
ui::SaveLoadFileKind::settings, menu_request.origin_item_id);
|
||||
const auto render_file = [&] {
|
||||
const Image image = file_screen.render();
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_settings_file");
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
pixels[i] = palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
@@ -2653,7 +2693,8 @@ int main(int argc, char** argv) {
|
||||
file_input.button.button == SDL_BUTTON_RIGHT)) {
|
||||
file_changed |= file_screen.click(file_input.button.x,
|
||||
file_input.button.y,
|
||||
file_input.button.button == SDL_BUTTON_RIGHT);
|
||||
file_input.button.button == SDL_BUTTON_RIGHT,
|
||||
file_input.button.clicks >= 2);
|
||||
} else if (file_input.type == SDL_KEYDOWN && !file_input.key.repeat) {
|
||||
std::string_view key;
|
||||
switch (file_input.key.keysym.sym) {
|
||||
@@ -2778,7 +2819,7 @@ int main(int argc, char** argv) {
|
||||
screen.consume_release();
|
||||
settings_down.reset();
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_settings");
|
||||
} else {
|
||||
screen.reject(error.empty() ? "Diese Einstellung wurde nicht übernommen." : error);
|
||||
std::fprintf(stderr, "live settings: %s\n", error.c_str());
|
||||
@@ -2914,7 +2955,7 @@ int main(int argc, char** argv) {
|
||||
}, [&](const LiveBallEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
const auto frame = live_score_reveal.project(ui::live_matchday_frame(event.minute, groups, state));
|
||||
if (frame.matches.empty()) return;
|
||||
const auto present = [&](const Image& image) {
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]];
|
||||
@@ -2933,7 +2974,7 @@ int main(int argc, char** argv) {
|
||||
const std::string title = "OpenBMH - live_ball_" + std::to_string(event.minute) + "_" +
|
||||
std::to_string(event.group) + "_" + std::to_string(event.match) + "_" +
|
||||
std::to_string(event.displacement) + "_" + std::to_string(index);
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, title.c_str());
|
||||
const auto* chance = live_chance_context &&
|
||||
live_chance_context->minute == event.minute &&
|
||||
live_chance_context->group == event.group &&
|
||||
@@ -2948,19 +2989,20 @@ int main(int argc, char** argv) {
|
||||
// AdvanceStep(5) reads a252c; DecodeTaxAnimationScript2 uses 20ms ticks.
|
||||
// Retain key/mouse events for the live-minute input boundary.
|
||||
const int delay = live_frame_ms_explicit ? live_frame_ms :
|
||||
app::scene_frame_delay(source_delay(5));
|
||||
source_delay(5);
|
||||
if (delay > 0) SDL_Delay(Uint32(delay));
|
||||
}
|
||||
if (running) {
|
||||
const int final_delay = live_frame_ms_explicit ? live_frame_ms : app::scene_frame_delay(source_delay(6));
|
||||
const int final_delay = live_frame_ms_explicit ? live_frame_ms : source_delay(6);
|
||||
if (final_delay > 0) SDL_Delay(Uint32(final_delay));
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_matchday");
|
||||
present(live_screen.render(frame));
|
||||
}
|
||||
}, [&](const LiveChanceEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
live_score_reveal.observe(event.stage, frame);
|
||||
if (frame.matches.empty()) return;
|
||||
const auto chance = ui::live_chance_projection(event, groups, state, season_exe);
|
||||
if (event.stage == LiveChanceStage::preview) live_chance_context = chance;
|
||||
@@ -2969,7 +3011,7 @@ int main(int argc, char** argv) {
|
||||
std::to_string(event.minute) + "_" + std::to_string(event.group) + "_" +
|
||||
std::to_string(event.match) + "_" + std::to_string(event.side) + "_" +
|
||||
std::to_string(event.kind) + "_" + std::to_string(int(event.goal));
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, title.c_str());
|
||||
const Image image = live_screen.render_chance(frame, chance);
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
@@ -2987,13 +3029,13 @@ int main(int argc, char** argv) {
|
||||
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 delay = live_frame_ms_explicit ? live_frame_ms :
|
||||
app::scene_frame_delay((saved < 6 ? saved / 2 : saved) * 20);
|
||||
(saved < 6 ? saved / 2 : saved) * 20;
|
||||
if (delay > 0) SDL_Delay(Uint32(delay));
|
||||
if (event.stage == LiveChanceStage::result) live_chance_context.reset();
|
||||
}, [&](const LiveShotEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
const auto frame = live_score_reveal.project(ui::live_matchday_frame(event.minute, groups, state));
|
||||
if (frame.matches.empty()) return;
|
||||
const auto frames = live_screen.render_shot(frame, event);
|
||||
const auto shot_colors = live_screen.shot_palette(palette, event, groups, state);
|
||||
@@ -3002,7 +3044,7 @@ int main(int argc, char** argv) {
|
||||
std::to_string(event.acting_side) + "_" + std::to_string(int(event.miss));
|
||||
for (size_t index = 0; index < frames.size() && running; ++index) {
|
||||
const std::string title = "OpenBMH - live_shot_" + identity + "_" + std::to_string(index);
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, title.c_str());
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = shot_colors.argb[frames[index].pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
SDL_RenderClear(renderer);
|
||||
@@ -3017,7 +3059,7 @@ int main(int argc, char** argv) {
|
||||
// Source waits Main_FormatError_RuntimeField vertical retraces after each frame (70 Hz).
|
||||
const int retraces = state.memory.has(::bmh::layout::Main_FormatError_RuntimeField) ?
|
||||
std::max(0, int(int8_t(state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField)))) : 0;
|
||||
const int delay = live_frame_ms_explicit ? live_frame_ms : app::scene_frame_delay(retraces * 1000 / 70);
|
||||
const int delay = live_frame_ms_explicit ? live_frame_ms : retraces * 1000 / 70;
|
||||
if (delay > 0) SDL_Delay(Uint32(delay));
|
||||
}
|
||||
if (!running) return;
|
||||
@@ -3027,7 +3069,7 @@ int main(int argc, char** argv) {
|
||||
if (state.memory.has(::bmh::layout::Main_FormatError_RuntimeField5) && state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField5) == 0) {
|
||||
// SDLFlushEvents2 accepts a fresh left/right press, not a keyboard skip.
|
||||
const std::string title = "OpenBMH - live_shot_wait_" + identity;
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, title.c_str());
|
||||
SDL_FlushEvents(SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP);
|
||||
SDL_Event input;
|
||||
bool acknowledged = false;
|
||||
@@ -3045,13 +3087,13 @@ int main(int argc, char** argv) {
|
||||
} else {
|
||||
// AdvanceStep(15): the ordinary saved pause instead of a click.
|
||||
const int saved = state.memory.has(::bmh::layout::Main_FormatError_RuntimeField7) ? state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField7) : 0;
|
||||
const int delay = live_frame_ms_explicit ? live_frame_ms : app::scene_frame_delay((saved < 6 ? saved / 2 : saved) * 20);
|
||||
const int delay = live_frame_ms_explicit ? live_frame_ms : (saved < 6 ? saved / 2 : saved) * 20;
|
||||
if (delay > 0) SDL_Delay(Uint32(delay));
|
||||
}
|
||||
}, [&](const LiveSetPieceEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame=ui::live_matchday_frame(event.minute,groups,state);
|
||||
const auto frame=live_score_reveal.project(ui::live_matchday_frame(event.minute,groups,state));
|
||||
if (frame.matches.empty()) return;
|
||||
const auto images=live_screen.render_set_piece(frame,event);
|
||||
LiveShotEvent palette_event;
|
||||
@@ -3062,7 +3104,7 @@ int main(int argc, char** argv) {
|
||||
std::to_string(event.group)+"_"+std::to_string(event.match)+"_"+
|
||||
std::to_string(event.source_side)+"_"+std::to_string(event.kind)+"_"+
|
||||
std::to_string(index)+"_"+std::to_string(images.size());
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window,title.c_str());
|
||||
for (size_t i=0;i<pixels.size();++i) pixels[i]=colors.argb[images[index].pixels[i]];
|
||||
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
||||
SDL_RenderClear(renderer);SDL_RenderCopy(renderer,texture,nullptr,nullptr);SDL_RenderPresent(renderer);
|
||||
@@ -3071,7 +3113,7 @@ int main(int argc, char** argv) {
|
||||
// FirstThen holds the first frame for 40 retraces; later frames
|
||||
// use saved Main_FormatError_RuntimeField2. Keyboard/mouse input remains for the minute hook.
|
||||
const int retraces=index==0?40:(state.memory.has(::bmh::layout::Main_FormatError_RuntimeField2)?state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField2):0);
|
||||
const int delay=live_frame_ms_explicit?live_frame_ms:app::scene_frame_delay(retraces*1000/70);
|
||||
const int delay=live_frame_ms_explicit?live_frame_ms:retraces*1000/70;
|
||||
if (delay>0) SDL_Delay(Uint32(delay));
|
||||
}
|
||||
if (running && !live_frame_ms_explicit) SDL_Delay(200); // LiveMatchdayFrame
|
||||
@@ -3089,7 +3131,7 @@ int main(int argc, char** argv) {
|
||||
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
||||
SDL_RenderClear(renderer);SDL_RenderCopy(renderer,texture,nullptr,nullptr);SDL_RenderPresent(renderer);
|
||||
};
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");present(live_screen.render_booking(frame,booking));
|
||||
SDL_SetWindowTitle(window,title.c_str());present(live_screen.render_booking(frame,booking));
|
||||
if (event.kind != 2 && app::match_sound_enabled(state))
|
||||
app::original_audio_command(playback, 17); // EventImpl/SDLPumpEvents, no injury whistle.
|
||||
SDL_PumpEvents();SDL_Event input;
|
||||
@@ -3097,10 +3139,10 @@ int main(int argc, char** argv) {
|
||||
const int pause=event.kind==0?3:4;
|
||||
const uint32_t address=::bmh::layout::Main_FormatError_ExecutableFieldUnsigned+uint32_t(pause*9);
|
||||
const int saved=state.memory.has(address)?state.memory.u8(address):0;
|
||||
const int delay=live_frame_ms_explicit?live_frame_ms:app::scene_frame_delay((saved<6?saved/2:saved)*20);
|
||||
const int delay=live_frame_ms_explicit?live_frame_ms:(saved<6?saved/2:saved)*20;
|
||||
if (delay>0) SDL_Delay(Uint32(delay));
|
||||
// EventImpl clears the box after its pause; no Source click wait here.
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");present(live_screen.render(frame));
|
||||
SDL_SetWindowTitle(window,"OpenBMH - live_matchday");present(live_screen.render(frame));
|
||||
}, [&](const LiveShootoutEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
@@ -3111,7 +3153,7 @@ int main(int argc, char** argv) {
|
||||
std::to_string(event.group)+"_"+std::to_string(event.match)+"_"+
|
||||
std::to_string(event.side)+"_"+std::to_string(event.round)+"_"+
|
||||
std::to_string(event.of)+"_"+std::to_string(event.player);
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window,title.c_str());
|
||||
const auto image=live_screen.render_shootout(frame,projection);
|
||||
for (size_t i=0;i<pixels.size();++i) pixels[i]=palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
||||
@@ -3120,21 +3162,21 @@ int main(int argc, char** argv) {
|
||||
if (quit_confirmation.peep(&input,1,SDL_GETEVENT,SDL_QUIT,SDL_QUIT)>0) { running=false;return; }
|
||||
const int repeats=event.stage==LiveShootoutStage::preview?4:2;
|
||||
const int saved=state.memory.has(::bmh::layout::Main_FormatError_RuntimeField6)?state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField6):0;
|
||||
const int delay=live_frame_ms_explicit?live_frame_ms:app::scene_frame_delay((saved<6?saved/2:saved)*20);
|
||||
const int delay=live_frame_ms_explicit?live_frame_ms:(saved<6?saved/2:saved)*20;
|
||||
for (int i=0;i<repeats && running;++i) if (delay>0) SDL_Delay(Uint32(delay));
|
||||
}, [&](const LiveRealityEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) -> bool {
|
||||
if (!running || live_skipped) return false;
|
||||
const auto frame = ui::live_matchday_frame(event.minute,groups,state);
|
||||
const auto present = [&](const Image& image,const Palette& colors,const std::string& title) {
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window,title.c_str());
|
||||
for (size_t i=0;i<pixels.size();++i) pixels[i]=colors.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
||||
SDL_RenderClear(renderer);SDL_RenderCopy(renderer,texture,nullptr,nullptr);SDL_RenderPresent(renderer);
|
||||
};
|
||||
const auto delay = [&](uint32_t address) {
|
||||
const int saved=state.memory.has(address)?state.memory.u8(address):0;
|
||||
const int ms=live_frame_ms_explicit?live_frame_ms:app::scene_frame_delay((saved<6?saved/2:saved)*20);
|
||||
const int ms=live_frame_ms_explicit?live_frame_ms:(saved<6?saved/2:saved)*20;
|
||||
if (ms>0) SDL_Delay(Uint32(ms));
|
||||
};
|
||||
const std::string identity=std::to_string(event.minute)+"_"+std::to_string(event.group)+"_"+
|
||||
@@ -3154,7 +3196,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
if (event.stage==LiveRealityStage::settling) {
|
||||
reality_field.reset();
|
||||
const int ms=live_frame_ms_explicit?live_frame_ms:app::scene_frame_delay(200); // DecodeTaxAnimationScript2(10)
|
||||
const int ms=live_frame_ms_explicit?live_frame_ms:200; // DecodeTaxAnimationScript2(10)
|
||||
if (ms>0) SDL_Delay(Uint32(ms));
|
||||
return false;
|
||||
}
|
||||
@@ -3207,6 +3249,7 @@ int main(int argc, char** argv) {
|
||||
}, &request);
|
||||
if (!closed) throw FormatError("phase results: viewer stopped before Source ACK");
|
||||
}, true);
|
||||
if (app::debug::enabled()) app::debug::log("request " + std::to_string(int(r.request)) + (message.empty() ? std::string(" ok") : " -> " + message));
|
||||
if (message == "career_complete") { running = false; return; }
|
||||
if (!message.empty()) std::fprintf(stderr, "engine: %s\n", message.c_str());
|
||||
if (session) {
|
||||
@@ -3229,7 +3272,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
if(!flow.timed_notice_open())timed_notice_presented_at.reset();
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, ("OpenBMH - " + flow.screen_name()).c_str());
|
||||
};
|
||||
const auto present_formation_save_feedback = [&] {
|
||||
for (bool restored : {false, true}) {
|
||||
@@ -3602,6 +3645,42 @@ int main(int argc, char** argv) {
|
||||
if (expired.request != ui::FlowRequest::none || expired.changed) handle(expired);
|
||||
}
|
||||
};
|
||||
// OpenBMH deviates from the original: display the repository-owned title
|
||||
// at its native resolution until a complete left/right click, without loading balls.
|
||||
{
|
||||
app::StartScreen title_screen(renderer);
|
||||
title_screen.present();
|
||||
bool opening_confirmed = false;
|
||||
std::optional<Uint8> opening_press;
|
||||
while (running && !opening_confirmed) {
|
||||
SDL_Event opening_event;
|
||||
while (quit_confirmation.poll(&opening_event)) {
|
||||
if (opening_event.type == SDL_QUIT) running = false;
|
||||
if (opening_event.type == SDL_KEYDOWN && opening_event.key.keysym.sym == SDLK_ESCAPE &&
|
||||
quit_confirmation.confirm()) running = false;
|
||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||
(opening_event.window.event == SDL_WINDOWEVENT_EXPOSED ||
|
||||
opening_event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED))
|
||||
title_screen.present();
|
||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||
opening_event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
opening_press.reset();
|
||||
if (opening_event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(opening_event.button.button == SDL_BUTTON_LEFT ||
|
||||
opening_event.button.button == SDL_BUTTON_RIGHT))
|
||||
opening_press = opening_event.button.button;
|
||||
if (opening_event.type == SDL_MOUSEBUTTONUP && opening_press &&
|
||||
opening_event.button.button == *opening_press)
|
||||
opening_confirmed = true;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
} // Restore the indexed game canvas and its logical input mapping.
|
||||
// Opening input must not also change an option on the first setup frame.
|
||||
SDL_FlushEvents(SDL_KEYDOWN, SDL_KEYUP);
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
season_backdrop.reset();
|
||||
dirty = true;
|
||||
SDL_StartTextInput();
|
||||
bool filename_input_active = false;
|
||||
std::array<bool, 2> setup_button_down{};
|
||||
@@ -3731,7 +3810,7 @@ int main(int argc, char** argv) {
|
||||
} else if (flow.desktop() && flow.desktop()->socket_confirmation_armed()) {
|
||||
// SDLSetWindowTitle paints its pressed socket sprite before
|
||||
// DeskDate waits for the physical release.
|
||||
SDL_SetWindowTitle(window, "OpenBMH 1.1");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - desktop");
|
||||
const auto image=process_timer_image(flow.render());
|
||||
for(size_t i=0;i<pixels.size();++i)pixels[i]=palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4);
|
||||
@@ -3790,6 +3869,12 @@ int main(int argc, char** argv) {
|
||||
const auto released = held ? flow.hold(e.button.x, e.button.y, 2000)
|
||||
: flow.click(e.button.x, e.button.y, e.button.button == SDL_BUTTON_RIGHT, e.button.clicks >= 2);
|
||||
present_formation_save_feedback();
|
||||
// JA of the manager confirmation is shown pushed in briefly before the
|
||||
// (possibly slow) next step starts, as in the original.
|
||||
if (flow.screen_name() == "manager_accepted") {
|
||||
present_season(flow.render(), "OpenBMH - manager_accepted");
|
||||
SDL_Delay(150);
|
||||
}
|
||||
handle(released);
|
||||
present_desk_record_points();
|
||||
press.reset();
|
||||
@@ -3880,6 +3965,7 @@ int main(int argc, char** argv) {
|
||||
throw std::runtime_error(std::string("Source modal texture: ") + SDL_GetError());
|
||||
dirty = false;
|
||||
}
|
||||
pitch_pointer.show(flow.pitch_pointer_cursor(palette), renderer);
|
||||
const int cleared = SDL_RenderClear(renderer);
|
||||
const int copied = SDL_RenderCopy(renderer, texture, nullptr, nullptr);
|
||||
if (source_modal_redraw && (cleared != 0 || copied != 0))
|
||||
@@ -3904,6 +3990,7 @@ int main(int argc, char** argv) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
SDL_StopTextInput();
|
||||
pitch_pointer.clear();
|
||||
SDL_DestroyTexture(texture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
// SDL owns pointer position; the UI supplies only the original bitmap/colors. Everywhere but on the
|
||||
// pitch page the pointer is the original's default 11x11 bitmap (set_default); the pitch page
|
||||
// passes the same bitmap with its position-colour fill.
|
||||
class PitchPointer {
|
||||
public:
|
||||
~PitchPointer() { clear(); }
|
||||
void clear() {
|
||||
if (cursor_) {
|
||||
SDL_SetCursor(SDL_GetDefaultCursor());
|
||||
SDL_FreeCursor(cursor_);
|
||||
cursor_ = nullptr;
|
||||
}
|
||||
pixels_.reset();
|
||||
}
|
||||
void set_default(const std::optional<std::array<uint32_t,121>>& pixels) { default_ = pixels; }
|
||||
void show(const std::optional<std::array<uint32_t,121>>& requested, SDL_Renderer* renderer) {
|
||||
const auto& pixels = requested ? requested : default_;
|
||||
if (!pixels) { SDL_SetCursor(SDL_GetDefaultCursor()); return; }
|
||||
// Cursor bitmaps are sized in window points, not in pixels: on a high-DPI display (macOS
|
||||
// Retina) the renderer's output is larger than the window, and a bitmap scaled to it would
|
||||
// show twice as large. SDL_GetWindowSize gives the points.
|
||||
int width = 320, height = 240;
|
||||
if (SDL_Window* window = SDL_RenderGetWindow(renderer)) SDL_GetWindowSize(window, &width, &height);
|
||||
else SDL_GetRendererOutputSize(renderer, &width, &height);
|
||||
const int scale = std::max(1, std::min(width / 320, height / 240));
|
||||
if (!cursor_ || pixels != pixels_ || scale != scale_) {
|
||||
std::vector<uint32_t> enlarged(size_t(11 * scale) * size_t(11 * scale));
|
||||
for (int y = 0; y < 11 * scale; ++y) for (int x = 0; x < 11 * scale; ++x)
|
||||
enlarged[size_t(y) * size_t(11 * scale) + size_t(x)] =
|
||||
pixels->at(size_t(y / scale) * 11 + size_t(x / scale));
|
||||
SDL_Surface* surface = SDL_CreateRGBSurfaceWithFormatFrom(enlarged.data(),
|
||||
11 * scale, 11 * scale, 32, 11 * scale * 4, SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_Cursor* next = surface ? SDL_CreateColorCursor(surface, 0, 0) : nullptr;
|
||||
if (surface) SDL_FreeSurface(surface);
|
||||
if (!next) return; // A headless SDL driver may not support host cursors.
|
||||
clear(); cursor_ = next; pixels_ = pixels; scale_ = scale;
|
||||
}
|
||||
SDL_SetCursor(cursor_);
|
||||
}
|
||||
private:
|
||||
SDL_Cursor* cursor_ = nullptr;
|
||||
std::optional<std::array<uint32_t,121>> pixels_, default_;
|
||||
int scale_ = 1;
|
||||
};
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -1,7 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
namespace bmh::app {
|
||||
// Presentation only: 25% more time per scene frame, without gameplay/RNG changes.
|
||||
constexpr int scene_frame_delay(int milliseconds) { return std::max(16,(milliseconds*5+3)/4); }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "app/start_screen.hpp"
|
||||
#include "app/start_screen_data.hpp"
|
||||
#include <SDL.h>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#define STBI_ONLY_JPEG
|
||||
#define STBI_NO_STDIO
|
||||
#define STBI_NO_HDR
|
||||
#define STBI_NO_LINEAR
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "app/third_party/stb_image.h"
|
||||
namespace bmh::app {
|
||||
StartScreen::StartScreen(SDL_Renderer* renderer):renderer_(renderer) {
|
||||
if(!renderer_)throw std::runtime_error("Start screen: missing renderer");
|
||||
SDL_RenderGetLogicalSize(renderer_,&previous_width_,&previous_height_);
|
||||
int channels=0;
|
||||
const std::unique_ptr<unsigned char,decltype(&stbi_image_free)> pixels(
|
||||
stbi_load_from_memory(start_screen_jpeg,int(start_screen_jpeg_size),&width_,&height_,&channels,3),stbi_image_free);
|
||||
if(!pixels)throw std::runtime_error("Start screen: embedded artwork could not be decoded");
|
||||
texture_=SDL_CreateTexture(renderer_,SDL_PIXELFORMAT_RGB24,SDL_TEXTUREACCESS_STATIC,width_,height_);
|
||||
if(!texture_)throw std::runtime_error(SDL_GetError());
|
||||
if(SDL_UpdateTexture(texture_,nullptr,pixels.get(),width_*3)!=0||SDL_SetTextureScaleMode(texture_,SDL_ScaleModeLinear)!=0) {
|
||||
const std::string error=SDL_GetError();SDL_DestroyTexture(texture_);texture_=nullptr;throw std::runtime_error(error);
|
||||
}
|
||||
}
|
||||
StartScreen::~StartScreen() {
|
||||
SDL_DestroyTexture(texture_);
|
||||
SDL_RenderSetLogicalSize(renderer_,previous_width_,previous_height_);
|
||||
}
|
||||
void StartScreen::present() {
|
||||
if(SDL_RenderSetLogicalSize(renderer_,width_,height_)!=0)throw std::runtime_error(SDL_GetError());
|
||||
Uint8 r=0,g=0,b=0,a=0;SDL_GetRenderDrawColor(renderer_,&r,&g,&b,&a);
|
||||
SDL_SetRenderDrawColor(renderer_,0,0,0,255);
|
||||
const int cleared=SDL_RenderClear(renderer_);SDL_SetRenderDrawColor(renderer_,r,g,b,a);
|
||||
if(cleared!=0||SDL_RenderCopy(renderer_,texture_,nullptr,nullptr)!=0)throw std::runtime_error(SDL_GetError());
|
||||
SDL_RenderPresent(renderer_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
struct SDL_Renderer;
|
||||
struct SDL_Texture;
|
||||
namespace bmh::app {
|
||||
// Owned, embedded artwork, rendered independently of the indexed game canvas.
|
||||
// Destruction restores the caller's logical size and therefore its input mapping.
|
||||
class StartScreen {
|
||||
public:
|
||||
explicit StartScreen(SDL_Renderer*);
|
||||
~StartScreen();
|
||||
StartScreen(const StartScreen&)=delete;
|
||||
StartScreen& operator=(const StartScreen&)=delete;
|
||||
void present();
|
||||
int width()const{return width_;}
|
||||
int height()const{return height_;}
|
||||
private:
|
||||
SDL_Renderer* renderer_;
|
||||
SDL_Texture* texture_=nullptr;
|
||||
int width_=0,height_=0,previous_width_=0,previous_height_=0;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
namespace bmh::app {
|
||||
extern const unsigned char start_screen_jpeg[];
|
||||
extern const std::size_t start_screen_jpeg_size;
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
# stb_image
|
||||
|
||||
Unmodified upstream stb_image 2.30 header, commit `013ac3beddff3dbffafd5177e7972067cd2b5083`.
|
||||
Source: [013ac3beddff3dbffafd5177e7972067cd2b5083](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h).
|
||||
SHA256: `594c2fe35d49488b4382dbfaec8f98366defca819d916ac95becf3e75f4200b3`.
|
||||
|
||||
Only JPEG decoding is compiled. The complete dual MIT/public-domain license
|
||||
is retained in the header and in `docs/licenses/stb_image.txt`.
|
||||
Vendored
+7988
File diff suppressed because it is too large.
Load diff
@@ -108,12 +108,13 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
|
||||
std::optional<TransferActions::MarketDispatch> TransferActions::market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, HumanBuyerMarketEntryPolicy policy,
|
||||
const MarketAccept& acknowledge) {
|
||||
const MarketAccept& acknowledge,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
|
||||
std::optional<MarketDispatch> result;
|
||||
apply(revision, [&] {
|
||||
const auto old_revision = revision;
|
||||
if (policy == HumanBuyerMarketEntryPolicy::normal_interactive) {
|
||||
const auto action = session_.dispatch_transfer_market(request, hooks, revision, error);
|
||||
const auto action = session_.dispatch_transfer_market(request, hooks, revision, error, review);
|
||||
if (!action) return false;
|
||||
result = MarketDispatch{*action, revision != old_revision};
|
||||
} else {
|
||||
@@ -174,7 +175,8 @@ std::string TransferActions::rejection(const ui::TransferMarketRequest& request,
|
||||
return "Dieser Spieler gehört nicht mehr zur gewählten Kaderposition.";
|
||||
} else if (request.kind != ui::TransferMarketRequestKind::open_offer &&
|
||||
request.kind != ui::TransferMarketRequestKind::preview_quote &&
|
||||
request.kind != ui::TransferMarketRequestKind::open_poach)
|
||||
request.kind != ui::TransferMarketRequestKind::open_poach &&
|
||||
request.kind != ui::TransferMarketRequestKind::review_offers)
|
||||
return "Diese Transferaktion ist nicht verfügbar.";
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ public:
|
||||
std::optional<MarketDispatch> market(const ui::TransferMarketRequest&, const HumanBuyerSaleHooks&,
|
||||
uint64_t& revision, std::string& error,
|
||||
HumanBuyerMarketEntryPolicy = HumanBuyerMarketEntryPolicy::normal_interactive,
|
||||
const MarketAccept& = {});
|
||||
const MarketAccept& = {},
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> open_offer(const ui::TransferMarketRequest&,
|
||||
uint64_t& revision, std::string& error, const OfferAccept& = {});
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> preview(const ui::TransferMarketRequest&,
|
||||
|
||||
@@ -160,6 +160,8 @@ void Console::register_transfer_commands() {
|
||||
require_engine(false, "transfer", error);
|
||||
}
|
||||
flush_notices();
|
||||
if (outcome->action.status != TransferActionStatus::accepted)
|
||||
fail("E_RULE", "Der Spieler konnte nicht auf die Transferliste gesetzt werden.");
|
||||
emit('+', utf8(item.name) + (loan
|
||||
? " steht auf der Transferliste; der Entleiher wählt 12 oder 24 Monate im Angebot"
|
||||
: " is on the transfer list"));
|
||||
@@ -175,6 +177,42 @@ void Console::register_transfer_commands() {
|
||||
list_player(v.text("player"), true);
|
||||
});
|
||||
|
||||
add({"Transfer", "ShowOffers", {player}, "incoming offers for an own listed player", false},
|
||||
[this, market_item](const Values& v) {
|
||||
const auto item = market_item(v.text("player"));
|
||||
if (!item.own_listing) fail("E_RULE", "the listing belongs to another club");
|
||||
const auto offers = project_transfer_offer_list(session_->state(), item.list_entry);
|
||||
std::vector<std::vector<std::string>> rows;
|
||||
for (const auto& offer : offers.offers) {
|
||||
if (!offer.present) continue;
|
||||
rows.push_back({std::to_string(offer.bid_index), utf8(session_->state().club_name(offer.buyer)),
|
||||
money(offer.fee), money(offer.monthly_salary), std::to_string(offer.contract_months),
|
||||
offer.loan ? "loan" : "sale",
|
||||
offer.eligible && offer.loan_permitted && offer.transaction_supported ? "yes" : "no"});
|
||||
}
|
||||
emit_table({"Bid", "Club", "Fee", "Monthly salary", "Months", "Type", "Available"}, rows);
|
||||
if (rows.empty()) emit('i', "Noch keine Angebote für diesen Spieler.");
|
||||
});
|
||||
add({"Transfer", "AcceptOffer", {player, integer("bid", 0, 3)}, "accept an existing bid before weekly expiry", true},
|
||||
[this, market, market_item, hooks, flush_notices](const Values& v) {
|
||||
const auto observed = market();
|
||||
const auto item = market_item(v.text("player"));
|
||||
if (!item.own_listing) fail("E_RULE", "the listing belongs to another club");
|
||||
auto request = app::TransferActions::opening(observed, item, false);
|
||||
request.kind = ui::TransferMarketRequestKind::review_offers;
|
||||
request.selected_players.clear();
|
||||
const int bid = int(v.integer("bid"));
|
||||
std::string error;
|
||||
const auto outcome = app::TransferActions(*session_).market(request, hooks(), revision_, error,
|
||||
app::HumanBuyerMarketEntryPolicy::normal_interactive, {},
|
||||
[bid](const GameState&, const TransferOfferListView&) { return bid; });
|
||||
if (!outcome) require_engine(false, "transfer", error);
|
||||
flush_notices();
|
||||
if (outcome->action.status != TransferActionStatus::accepted)
|
||||
fail("E_RULE", "Dieses Angebot kann nicht angenommen werden; die Transferliste bleibt unverändert.");
|
||||
emit('+', "Das Angebot wurde angenommen.");
|
||||
});
|
||||
|
||||
// --- Transfer.Negotiate: the offer editor (06-verein 5.2) -----------------------------
|
||||
auto show_offer = [this] {
|
||||
if (!offer_editor_) fail("E_INTERNAL", "no offer editor");
|
||||
@@ -420,7 +458,7 @@ void Console::register_transfer_commands() {
|
||||
Arg a;
|
||||
a.text = number;
|
||||
const auto id = to_int(a);
|
||||
if (!id || *id < 0 || *id >= runtime_dimensions.league_teams) fail("E_BAD_ARGUMENT", "club is club:<n> (ListPoachClubs)");
|
||||
if (!id || *id < 0 || *id >= 138) fail("E_BAD_ARGUMENT", "club is club:<n> (ListPoachClubs)");
|
||||
return int(*id);
|
||||
};
|
||||
Param club = detail::text("club");
|
||||
|
||||
@@ -9,10 +9,8 @@ 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 bool expanded_badges = false;
|
||||
|
||||
inline int original_badge_gate(const LeImage& exe) {
|
||||
if(const auto* policy=exe.runtime_policy())return int(policy->badge_end);
|
||||
constexpr auto instruction = layout::ForeignBadgeGateInstruction;
|
||||
if (exe.contains(instruction) && exe.contains(instruction + 6) &&
|
||||
exe.u8(instruction) == 0x66 && exe.u8(instruction + 1) == 0x81 &&
|
||||
@@ -27,12 +25,10 @@ inline int original_badge_gate(const LeImage& exe) {
|
||||
|
||||
inline void install_original_badge_policy(const LeImage& exe) {
|
||||
original_foreign_badge_end = original_badge_gate(exe);
|
||||
expanded_badges = exe.expanded_profile();
|
||||
}
|
||||
|
||||
inline bool original_badge_fallback(int token, const LeImage* exe = nullptr) {
|
||||
const int team = token & 0xfff;
|
||||
if (exe ? exe->expanded_profile() : expanded_badges) return team == 0xfff;
|
||||
const int end = exe ? original_badge_gate(*exe) : original_foreign_badge_end;
|
||||
return team == 0xfff || (team >= 90 && team < end) || (team >= 168 && team < 357);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/binary.hpp"
|
||||
#include "formats/resource_bundle.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
@@ -8,8 +7,6 @@
|
||||
namespace bmh {
|
||||
|
||||
Bytes read_file(const std::filesystem::path& path) {
|
||||
if (!std::filesystem::exists(path))
|
||||
if (auto bytes=bundled_resource(path)) return std::move(*bytes);
|
||||
std::ifstream in(path, std::ios::binary);
|
||||
if (!in) throw FormatError("cannot open " + path.string());
|
||||
return Bytes(std::istreambuf_iterator<char>(in), {});
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/data_profile.hpp"
|
||||
#include "formats/resource_bundle.hpp"
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
namespace bmh {
|
||||
DataProfile DataProfile::international_11() {
|
||||
DataProfile p;
|
||||
p.id="classic-plus-1";
|
||||
p.leagues={18,18,18,18,18,18,20,18,18};
|
||||
p.counts={445,3334,194,4104,164,30};
|
||||
p.big_squad_teams=164;
|
||||
p.national_first=383;
|
||||
return p;
|
||||
}
|
||||
void DataProfile::validate() const {
|
||||
const auto total=std::accumulate(leagues.begin(),leagues.end(),uint32_t(0));
|
||||
if(total!=counts.league_teams || big_squad_teams>total || counts.n42!=total+counts.cup_teams ||
|
||||
counts.n66!=extra_slots_first() || counts.clubs!=national_first+62 ||
|
||||
national_first!=total+counts.cup_teams+189 || counts.clubs>512 || counts.players>=4095 || total_slots()>65535)
|
||||
throw FormatError("profile: inconsistent counts or packed identifier overflow");
|
||||
for(auto size:leagues)if(size!=12 && size!=18 && size!=20)throw FormatError("profile: unsupported league size");
|
||||
}
|
||||
DataProfile load_data_profile(const std::filesystem::path& directory) {
|
||||
const auto file=directory/"OBMHPROF.INI";
|
||||
if(!resource_exists(file))return {};
|
||||
return decode_data_profile(read_file(file));
|
||||
}
|
||||
DataProfile decode_data_profile(const Bytes& raw) {
|
||||
std::istringstream input(std::string(raw.begin(),raw.end()));
|
||||
std::string line,id;bool section=false,seen=false;
|
||||
while(std::getline(input,line)) {
|
||||
if(!line.empty()&&line.back()=='\r')line.pop_back();
|
||||
const auto first=line.find_first_not_of(" \t");if(first==std::string::npos||line[first]==';'||line[first]=='#')continue;
|
||||
const auto last=line.find_last_not_of(" \t");line=line.substr(first,last-first+1);
|
||||
if(line=="[OpenBMH]"){if(section)throw FormatError("profile: duplicate section");section=true;continue;}
|
||||
if(!section||line.rfind("profile=",0)!=0||seen)throw FormatError("profile: unknown or duplicate metadata key");
|
||||
id=line.substr(8);seen=true;
|
||||
}
|
||||
if(id!="classic-plus-1")throw FormatError("profile: unsupported data profile");
|
||||
auto p=DataProfile::international_11();p.validate();return p;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include "formats/m3d.hpp"
|
||||
namespace bmh {
|
||||
// Installation metadata; original files retain their implicit Classic profile.
|
||||
struct DataProfile {
|
||||
std::string id = "classic";
|
||||
std::array<uint8_t,9> leagues{18,18,18,18,18,12,12,12,12};
|
||||
DbCounts counts{};
|
||||
uint32_t big_squad_teams = 90;
|
||||
uint32_t national_first = 357;
|
||||
uint32_t pool_first() const { return big_squad_teams*24+(counts.league_teams-big_squad_teams)*16; }
|
||||
uint32_t national_slots_first() const { return pool_first()+144; }
|
||||
uint32_t extra_slots_first() const { return national_slots_first()+24; }
|
||||
uint32_t total_slots() const { return extra_slots_first()+54; }
|
||||
bool extended() const { return id != "classic"; }
|
||||
void validate() const;
|
||||
static DataProfile international_11();
|
||||
};
|
||||
DataProfile decode_data_profile(const Bytes&);
|
||||
DataProfile load_data_profile(const std::filesystem::path& directory);
|
||||
}
|
||||
@@ -874,6 +874,13 @@ inline constexpr auto EnglishLayoutTranslation255 = 0x6f0ec;
|
||||
inline constexpr auto EnglishLayoutTranslation256 = 0x6f2ae;
|
||||
inline constexpr auto EnglishLayoutTranslation257 = 0x6f2d4;
|
||||
inline constexpr auto EnglishLayoutTranslation258 = 0x6f2e0;
|
||||
// English six-budget environment data used by the common monthly model.
|
||||
inline constexpr auto EnglishEnvironmentTileX = 0x6d230;
|
||||
inline constexpr auto EnglishEnvironmentTileY = 0x6d238;
|
||||
inline constexpr auto EnglishEnvironmentYouthColors = 0x6d240;
|
||||
inline constexpr auto EnglishEnvironmentBudgetSteps = 0x6d244;
|
||||
inline constexpr auto EnglishEnvironmentYouthPositionSuffix = 0x6d24a;
|
||||
inline constexpr auto EnglishEnvironmentCostSuffix = 0x6d24f;
|
||||
inline constexpr auto EnglishLayoutTranslation259 = 0x6f2fc;
|
||||
inline constexpr auto EnglishLayoutTranslation26 = 0x6bf2c;
|
||||
inline constexpr auto EnglishLayoutTranslation260 = 0x6f300;
|
||||
@@ -1412,13 +1419,7 @@ inline constexpr auto NationalFriendlyPayerPrefixText = 0xa000f;
|
||||
inline constexpr auto NextDeskManager = 0xbd6cc;
|
||||
inline constexpr auto NoClubText = 0xaec74;
|
||||
inline constexpr auto NoPlayerText = 0xaec78;
|
||||
// Legacy symbol name: this is the league+cup team count, NOT a squad slot offset.
|
||||
inline constexpr auto NoTeamSquadStart = 0xa2c38;
|
||||
inline constexpr auto ProfileSmallSquadClubs = 0xa2c32;
|
||||
inline constexpr auto ProfilePoolFirst = 0xa2c56;
|
||||
inline constexpr auto ProfileFreeFirst = 0xa2c5a;
|
||||
inline constexpr auto ProfileForeignFreeFirst = 0xa2c5e;
|
||||
inline constexpr auto ProfileNationalSlotsFirst = 0xa2c62;
|
||||
inline constexpr auto OfferSlots = 0xbb844;
|
||||
inline constexpr auto Opportunities_FormatError_RuntimeField = 0xa3a6e;
|
||||
inline constexpr auto Opportunities_FormatError_RuntimeField2 = 0xa3a80;
|
||||
@@ -1482,6 +1483,14 @@ inline constexpr auto Pitch_Render_TextPointer2 = 0xae0ec;
|
||||
inline constexpr auto Pitch_Render_TextPointer3 = 0xae0f0;
|
||||
inline constexpr auto Pitch_Render_TextPointer4 = 0xae0f4;
|
||||
inline constexpr auto Pitch_Render_TextPointer5 = 0xae0f8;
|
||||
inline constexpr auto PitchPreferenceDepthBases = 0xa3cc3;
|
||||
inline constexpr auto PitchPreferenceRed = 0xa3cc7;
|
||||
inline constexpr auto PitchPreferenceGreen = 0xa3cd1;
|
||||
inline constexpr auto OriginalPointerPixels = 0xa45b4;
|
||||
inline constexpr auto EnglishPitchPreferenceDepthBases = 0x6e230;
|
||||
inline constexpr auto EnglishPitchPreferenceRed = 0x6e234;
|
||||
inline constexpr auto EnglishPitchPreferenceGreen = 0x6e240;
|
||||
inline constexpr auto EnglishOriginalPointerPixels = 0x70554;
|
||||
inline constexpr auto PitchOrderPositionPointers = 0xa2a37;
|
||||
inline constexpr auto PitchOrderZoneMasks = 0xa2a4b;
|
||||
inline constexpr auto PitchOrderZoneTextPointers = 0xae818;
|
||||
@@ -1557,6 +1566,7 @@ inline constexpr auto SaveLoad_Render_ExecutableField = 0xa148f;
|
||||
inline constexpr auto SaveLoad_Render_RuntimeField = 0xa2334;
|
||||
inline constexpr auto SaveLoad_Render_RuntimeField2 = 0xa233f;
|
||||
inline constexpr auto SaveLoad_Render_RuntimeField3 = 0xa234a;
|
||||
inline constexpr auto SaveLoad_OverwriteQuestionPointer = 0xa21c4;
|
||||
inline constexpr auto SaveLoad_Render_TextPointer = 0xa1512;
|
||||
inline constexpr auto SaveLoad_Render_TextPointer2 = 0xae5f0;
|
||||
inline constexpr auto SaveLoad_Render_TextPointer3 = 0xae620;
|
||||
|
||||
+2
-97
@@ -1,7 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/data_profile.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
@@ -18,10 +16,6 @@ struct Object {
|
||||
} // namespace
|
||||
|
||||
std::string LeImage::cstring(uint32_t address) const {
|
||||
if (runtime_policy_) {
|
||||
const auto label=runtime_policy_->labels.find(address);
|
||||
if(label!=runtime_policy_->labels.end())return label->second;
|
||||
}
|
||||
std::string s;
|
||||
while (contains(address) && u8(address) != 0) s.push_back(char(u8(address++)));
|
||||
return s;
|
||||
@@ -41,103 +35,14 @@ void save_image(const LeImage& image, const std::filesystem::path& path) {
|
||||
if (!file) throw FormatError("cannot write the OpenBMH image");
|
||||
}
|
||||
|
||||
void save_runtime_image(const LeImage& image, const RuntimePolicy& policy, const std::filesystem::path& path) {
|
||||
constexpr uint32_t start=layout::GermanDataSegmentBegin;
|
||||
if(!image.contains(start) || policy.year<1600 || policy.year>9999 || policy.weekday>6 ||
|
||||
(policy.badge_end!=90 && policy.badge_end!=138) || policy.environment_verified>1 || policy.labels.size()>16)
|
||||
throw FormatError("runtime data: unsupported source policies");
|
||||
const uint32_t size=image.base()+image.size()-start;
|
||||
if(size>1024*1024)throw FormatError("runtime data: data segment too large");
|
||||
Bytes out{'O','B','M','H','D','A','T','1'};
|
||||
const auto put=[&](uint32_t value){for(int b=0;b<4;++b)out.push_back(uint8_t(value>>(8*b)));};
|
||||
for(uint32_t value:{start,size,policy.year,policy.weekday,policy.badge_end,policy.environment_verified,uint32_t(policy.labels.size())})put(value);
|
||||
out.insert(out.end(),image.data(start),image.data(start)+size);
|
||||
for(const auto& [address,text]:policy.labels) {
|
||||
if(text.size()>1024)throw FormatError("runtime data: label too long");
|
||||
put(address);put(uint32_t(text.size()));out.insert(out.end(),text.begin(),text.end());
|
||||
}
|
||||
std::ofstream file(path,std::ios::binary|std::ios::trunc);file.write(reinterpret_cast<const char*>(out.data()),std::streamsize(out.size()));
|
||||
if(!file)throw FormatError("cannot write runtime data");
|
||||
}
|
||||
|
||||
LeImage load_le(const std::filesystem::path& path) {
|
||||
const auto profile = load_data_profile(path.parent_path());
|
||||
const auto apply_profile = [&](LeImage img) {
|
||||
if (!profile.extended()) return img;
|
||||
const auto put = [&](uint32_t address, uint32_t value, int width) {
|
||||
if (!img.contains(address) || !img.contains(address + uint32_t(width - 1)))
|
||||
throw FormatError("profile: executable lacks verified data dimensions");
|
||||
for (int b = 0; b < width; ++b) img.bytes_.at(address - img.base_ + uint32_t(b)) = uint8_t(value >> (8 * b));
|
||||
};
|
||||
if (img.u8(layout::LeagueSizes) != 18)
|
||||
throw FormatError("profile: classic-plus-1 requires a German installation");
|
||||
put(layout::CareerSession_DataDirectory_RuntimeField, profile.counts.clubs, 4);
|
||||
put(layout::CareerSession_DataDirectory_RuntimeField3, profile.counts.players, 4);
|
||||
put(layout::CareerSession_DataDirectory_RuntimeField2, profile.counts.n42, 4);
|
||||
put(layout::CareerSession_DataDirectory_RuntimeField4, profile.counts.n66, 4);
|
||||
put(layout::CareerSession_DispatchLineup_RuntimeField, profile.counts.league_teams, 2);
|
||||
put(layout::TeamsWithSquads, profile.big_squad_teams, 2);
|
||||
put(layout::NoTeamSquadStart, profile.counts.n42, 2);
|
||||
put(layout::ProfileSmallSquadClubs, profile.counts.league_teams - profile.big_squad_teams, 2);
|
||||
put(layout::ClubPlayerDetail_ClubPlayerDetailRedraw_RuntimeField, profile.counts.players, 4);
|
||||
put(layout::ProfilePoolFirst, profile.pool_first(), 4);
|
||||
put(layout::ProfileFreeFirst, profile.pool_first() + 44, 4);
|
||||
put(layout::ProfileForeignFreeFirst, profile.pool_first() + 124, 4);
|
||||
put(layout::ProfileNationalSlotsFirst, profile.national_slots_first(), 4);
|
||||
for (size_t league = 0; league < profile.leagues.size(); ++league)
|
||||
put(layout::LeagueSizes + uint32_t(league), profile.leagues[league], 1);
|
||||
std::vector<int> foreign_days;
|
||||
for (int day = 0; day < 365; ++day) {
|
||||
const auto at = layout::CompetitionCalendar + uint32_t(day * 2);
|
||||
const uint16_t flags = img.u16(at);
|
||||
if ((flags & 0x4001) == 1 && day + 1 < 365) foreign_days.push_back(day + 1);
|
||||
put(at, flags & ~0x10u, 2);
|
||||
}
|
||||
if (foreign_days.size() != 34) throw FormatError("profile: unsupported domestic calendar");
|
||||
for (int target : {60, 110, 250, 290}) {
|
||||
int chosen = -1;
|
||||
for (int delta = 0; delta < 7 && chosen < 0; ++delta) {
|
||||
const int day = target + delta;
|
||||
if (img.u16(layout::CompetitionCalendar + uint32_t(day * 2)) == 0 &&
|
||||
std::find(foreign_days.begin(), foreign_days.end(), day) == foreign_days.end()) chosen = day;
|
||||
}
|
||||
if (chosen < 0) throw FormatError("profile: no calendar space for extra English fixtures");
|
||||
foreign_days.push_back(chosen);
|
||||
}
|
||||
for (int day : foreign_days) {
|
||||
const auto at = layout::CompetitionCalendar + uint32_t(day * 2);
|
||||
put(at, img.u16(at) | 0x10, 2);
|
||||
}
|
||||
img.expanded_profile_ = true;
|
||||
return img;
|
||||
};
|
||||
const Bytes raw = read_file(path);
|
||||
if(raw.size()>=8 && std::string(raw.begin(),raw.begin()+8)=="OBMHDAT1") {
|
||||
if(raw.size()<36)throw FormatError("runtime data: truncated header");
|
||||
const uint32_t base=le32(raw,8),size=le32(raw,12),labels=le32(raw,32);
|
||||
RuntimePolicy policy{le32(raw,16),le32(raw,20),le32(raw,24),le32(raw,28),{}};
|
||||
if(base!=layout::GermanDataSegmentBegin || size>1024*1024 || size_t(size)+36>raw.size() || labels>16 ||
|
||||
policy.year<1600 || policy.year>9999 || policy.weekday>6 || (policy.badge_end!=90 && policy.badge_end!=138) || policy.environment_verified>1)
|
||||
throw FormatError("runtime data: invalid dimensions or policies");
|
||||
auto image=LeImage::from_bytes(base,Bytes(raw.begin()+36,raw.begin()+36+size));
|
||||
size_t at=36+size;
|
||||
for(uint32_t i=0;i<labels;++i) {
|
||||
if(at+8>raw.size())throw FormatError("runtime data: truncated label");
|
||||
const auto address=le32(raw,at),length=le32(raw,at+4);at+=8;
|
||||
if(length>1024 || at+length>raw.size() || !policy.labels.emplace(address,std::string(raw.begin()+at,raw.begin()+at+length)).second)
|
||||
throw FormatError("runtime data: invalid label");
|
||||
at+=length;
|
||||
}
|
||||
if(at!=raw.size())throw FormatError("runtime data: trailing bytes");
|
||||
image.runtime_policy_=std::move(policy);
|
||||
return apply_profile(std::move(image));
|
||||
}
|
||||
if (raw.size() >= sizeof kImageMagic + 8 && std::equal(kImageMagic, kImageMagic + sizeof kImageMagic, raw.begin())) {
|
||||
const auto word = [&](size_t at) { return uint32_t(raw[at] | raw[at + 1] << 8 | raw[at + 2] << 16) | uint32_t(raw[at + 3]) << 24; };
|
||||
const uint32_t base = word(sizeof kImageMagic), size = word(sizeof kImageMagic + 4);
|
||||
if (raw.size() != sizeof kImageMagic + 8 + size_t(size)) throw FormatError("OpenBMH image: wrong size");
|
||||
LeImage img = LeImage::from_bytes(base, Bytes(raw.begin() + sizeof kImageMagic + 8, raw.end()));
|
||||
return apply_profile(std::move(img));
|
||||
return img;
|
||||
}
|
||||
auto u8 = [&](size_t o) -> uint32_t {
|
||||
if (o >= raw.size()) throw FormatError("LE: read beyond the file");
|
||||
@@ -226,7 +131,7 @@ LeImage load_le(const std::filesystem::path& path) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return apply_profile(std::move(img));
|
||||
return img;
|
||||
}
|
||||
|
||||
} // namespace bmh
|
||||
@@ -11,18 +11,11 @@
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
// Resolved edition policies, not copied machine instructions.
|
||||
struct RuntimePolicy {
|
||||
uint32_t year=0, weekday=0, badge_end=0, environment_verified=0;
|
||||
std::map<uint32_t,std::string> labels;
|
||||
};
|
||||
class LeImage {
|
||||
public:
|
||||
uint32_t base() const { return base_; }
|
||||
@@ -50,14 +43,10 @@ public:
|
||||
return img;
|
||||
}
|
||||
const Bytes& bytes() const { return bytes_; }
|
||||
bool expanded_profile() const { return expanded_profile_; }
|
||||
const RuntimePolicy* runtime_policy() const { return runtime_policy_ ? &*runtime_policy_ : nullptr; }
|
||||
|
||||
friend LeImage load_le(const std::filesystem::path& path);
|
||||
|
||||
private:
|
||||
std::optional<RuntimePolicy> runtime_policy_;
|
||||
bool expanded_profile_ = false;
|
||||
uint32_t base_ = 0;
|
||||
Bytes bytes_;
|
||||
};
|
||||
@@ -69,7 +58,5 @@ LeImage load_le(const std::filesystem::path& path);
|
||||
// The OpenBMH image format: "OPENBMH-IMAGE" NUL, u32 base, u32 size, the bytes. load_le()
|
||||
// reads it as well, so a translated image can stand in for BMH.exe in a data directory.
|
||||
void save_image(const LeImage& image, const std::filesystem::path& path);
|
||||
// Exports only the data segment and resolved policy values, never DOS/LE/code objects.
|
||||
void save_runtime_image(const LeImage&, const RuntimePolicy&, const std::filesystem::path&);
|
||||
|
||||
} // namespace bmh
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include <stdexcept>
|
||||
namespace bmh {
|
||||
// Original data separates internal domestic slots from player-visible levels.
|
||||
inline int player_league_count(const LeImage& image) {
|
||||
const auto address=layout::LeaguePairings_LeaguePairingsConstants_RuntimeField;
|
||||
if(!image.contains(address+1)||image.u8(address)!=5||image.u8(address+1)<1||image.u8(address+1)>5)
|
||||
throw std::invalid_argument("invalid player-facing league count");
|
||||
return image.u8(address+1);
|
||||
}
|
||||
}
|
||||
+4
-25
@@ -1,6 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/m3d.hpp"
|
||||
#include "formats/data_profile.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -35,20 +34,13 @@ std::string pool_string(const Bytes& pool, size_t offset) {
|
||||
|
||||
} // namespace
|
||||
|
||||
Database load_database(const std::filesystem::path& path) {
|
||||
return load_database(path, load_data_profile(path.parent_path()).counts);
|
||||
}
|
||||
|
||||
Database load_database(const std::filesystem::path& path, const DbCounts& c) {
|
||||
return decode_database(read_file(path),c);
|
||||
}
|
||||
|
||||
Database decode_database(const Bytes& d,const DbCounts& c) {
|
||||
Bytes d = read_file(path);
|
||||
Reader r{d};
|
||||
Bytes lens = r.take(8);
|
||||
size_t len_clubs = le16(lens, 0), len_players = le16(lens, 2), len_refs = le16(lens, 4), len_stadiums = le16(lens, 6);
|
||||
|
||||
Database db; db.counts=c;
|
||||
Database db;
|
||||
db.raw_player_bonus_values = r.take(c.n66 + 0x32);
|
||||
Bytes club_pool = r.take(len_clubs);
|
||||
Bytes player_pool = r.take(len_players);
|
||||
@@ -65,8 +57,8 @@ Database decode_database(const Bytes& d,const DbCounts& c) {
|
||||
db.raw_foreign_club_strength = r.take(0xFB);
|
||||
db.raw_league_auxiliary_bytes = r.take(0xBD);
|
||||
db.raw_referee_properties = r.take(0x32);
|
||||
db.raw_club_kit_selectors = r.take(c.clubs);
|
||||
db.raw_club_short_name_offsets = r.take(c.n42);
|
||||
db.raw_club_kit_selectors = r.take(0x1A3);
|
||||
db.raw_club_short_name_offsets = r.take(0xA8);
|
||||
db.squad_list = r.take((c.n66 - 4) * 2 + 0x6C);
|
||||
Bytes w35c = r.take(c.players * 4), w368 = r.take(c.players * 4), w364 = r.take(c.players * 4);
|
||||
if (r.pos != d.size()) throw FormatError("M3D: trailing data, table sizes do not match");
|
||||
@@ -77,17 +69,4 @@ Database decode_database(const Bytes& d,const DbCounts& c) {
|
||||
return db;
|
||||
}
|
||||
|
||||
Bytes encode_database(const Database& db) {
|
||||
Bytes out;
|
||||
const auto put=[&](uint32_t value,int width){for(int i=0;i<width;++i)out.push_back(uint8_t(value>>(8*i)));};
|
||||
const auto append=[&](const Bytes& bytes){out.insert(out.end(),bytes.begin(),bytes.end());};
|
||||
for(const auto& pool:db.pools){if(pool.size()>65535)throw FormatError("M3D: string pool exceeds 16-bit offsets");put(uint32_t(pool.size()),2);}
|
||||
append(db.raw_player_bonus_values);for(const auto& pool:db.pools)append(pool);
|
||||
for(const auto* bytes:{&db.raw_club_name_offsets,&db.raw_player_name_offsets,&db.raw_database_metadata,&db.raw_club_auxiliary_words,
|
||||
&db.raw_club_badge_selectors,&db.raw_foreign_club_strength,&db.raw_league_auxiliary_bytes,&db.raw_referee_properties,&db.raw_club_kit_selectors,&db.raw_club_short_name_offsets,&db.squad_list})append(*bytes);
|
||||
for(int word=0;word<3;++word)for(const auto& player:db.players)put(word==0?player.w35c:word==1?player.w368:player.w364,4);
|
||||
(void)decode_database(out,db.counts);
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace bmh
|
||||
+1
-7
@@ -16,8 +16,6 @@ struct DbCounts {
|
||||
uint32_t players = 2574;
|
||||
uint32_t n42 = 168;
|
||||
uint32_t n66 = 3096;
|
||||
uint32_t league_teams = 138;
|
||||
uint32_t cup_teams = 30;
|
||||
};
|
||||
|
||||
// A player as stored in the three parallel u32 tables of the database/savegame
|
||||
@@ -63,7 +61,6 @@ struct Player {
|
||||
};
|
||||
|
||||
struct Database {
|
||||
DbCounts counts{};
|
||||
std::vector<std::string> club_names;
|
||||
std::vector<std::string> referees;
|
||||
std::vector<std::string> stadiums;
|
||||
@@ -76,9 +73,6 @@ struct Database {
|
||||
Bytes raw_player_bonus_values, raw_database_metadata, raw_club_auxiliary_words, raw_club_badge_selectors, raw_foreign_club_strength, raw_league_auxiliary_bytes, raw_referee_properties, raw_club_kit_selectors, raw_club_short_name_offsets;
|
||||
};
|
||||
|
||||
Database load_database(const std::filesystem::path& path, const DbCounts& counts);
|
||||
Database load_database(const std::filesystem::path& path);
|
||||
Database decode_database(const Bytes&, const DbCounts&);
|
||||
Bytes encode_database(const Database&);
|
||||
Database load_database(const std::filesystem::path& path, const DbCounts& counts = {});
|
||||
|
||||
} // namespace bmh
|
||||
@@ -0,0 +1,20 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "formats/fbm.hpp"
|
||||
#include <string_view>
|
||||
|
||||
namespace bmh {
|
||||
// Verified German V2.24 state layout: the supplied Diamond 3.7 changes its
|
||||
// container label, while retaining the same block order and database counts.
|
||||
// Expanded careers have their own layout and must not accept these markers.
|
||||
inline bool supported_native_save_version(std::string_view version, bool expanded = false) {
|
||||
return expanded ? version == "O1.1" : version == "V2.24" || version == "V3.7";
|
||||
}
|
||||
inline void require_native_savegame(const Savegame& save, bool expanded = false) {
|
||||
if (!save.checksum_ok) throw FormatError("savegame: FBM checksum mismatch");
|
||||
if (!supported_native_save_version(save.version, expanded))
|
||||
throw FormatError("savegame: unsupported FBM version " + save.version);
|
||||
// Callers still parse the complete state using the installed edition's
|
||||
// exact DbCounts; a recognized marker never bypasses layout validation.
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,24 @@ Palette load_palette(const std::filesystem::path& path) {
|
||||
return p;
|
||||
}
|
||||
|
||||
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path) {
|
||||
const Bytes bytes = read_file(path);
|
||||
if (bytes.size() < 8) throw FormatError("VGA palette source is truncated");
|
||||
const size_t rle_end = 8 + size_t(le32(bytes, 4));
|
||||
if (rle_end > bytes.size()) throw FormatError("VGA RLE length exceeds palette source");
|
||||
const size_t trailing = bytes.size() - rle_end;
|
||||
if (trailing == 0) return std::nullopt;
|
||||
if (trailing < 768) throw FormatError("truncated embedded VGA palette");
|
||||
Palette palette;
|
||||
for (size_t i = 0; i < palette.argb.size(); ++i) {
|
||||
const auto channel = [&](size_t component) {
|
||||
return uint32_t(vga_dac_rgb8(bytes[rle_end + i * 3 + component]));
|
||||
};
|
||||
palette.argb[i] = 0xff000000u | channel(0) << 16 | channel(1) << 8 | channel(2);
|
||||
}
|
||||
return palette;
|
||||
}
|
||||
|
||||
uint8_t Palette::nearest(uint8_t r, uint8_t g, uint8_t b) const {
|
||||
int best = 0, best_dist = INT32_MAX;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -21,5 +22,7 @@ constexpr uint8_t vga_dac_rgb8(uint8_t channel) {
|
||||
}
|
||||
|
||||
Palette load_palette(const std::filesystem::path& path);
|
||||
// Some full-screen VGA pictures carry their own DAC palette after the RLE data.
|
||||
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path);
|
||||
|
||||
} // namespace bmh
|
||||
@@ -1,92 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/resource_bundle.hpp"
|
||||
#include "miniz.h"
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
namespace bmh {
|
||||
namespace {
|
||||
std::string folded(std::string name) {
|
||||
std::transform(name.begin(),name.end(),name.begin(),[](unsigned char ch){return char(std::toupper(ch));});
|
||||
return name;
|
||||
}
|
||||
struct Bundle {
|
||||
Bytes file;
|
||||
mz_zip_archive zip{};
|
||||
std::map<std::string,mz_uint> entries;
|
||||
explicit Bundle(const std::filesystem::path& path) {
|
||||
const auto size=std::filesystem::file_size(path);
|
||||
if(size>64*1024*1024)throw FormatError("community bundle exceeds size limit");
|
||||
std::ifstream input(path,std::ios::binary);
|
||||
file.assign(std::istreambuf_iterator<char>(input),{});
|
||||
if(!input.is_open() || file.size()!=size || !mz_zip_reader_init_mem(&zip,file.data(),file.size(),0))
|
||||
throw FormatError("cannot read community bundle");
|
||||
try {
|
||||
uint64_t total=0;
|
||||
const auto count=mz_zip_reader_get_num_files(&zip);
|
||||
if(count>4096)throw FormatError("community bundle has too many entries");
|
||||
for(mz_uint i=0;i<count;++i) {
|
||||
mz_zip_archive_file_stat st{};
|
||||
if(!mz_zip_reader_file_stat(&zip,i,&st))throw FormatError("invalid community directory");
|
||||
if(st.m_is_directory)continue;
|
||||
const std::string name=st.m_filename;
|
||||
const std::filesystem::path relative(name);
|
||||
if(name.empty()||name.find('\\')!=std::string::npos||name.find(':')!=std::string::npos||relative.is_absolute())
|
||||
throw FormatError("unsafe community resource name");
|
||||
for(const auto& part:relative)if(part==".."||part==".")throw FormatError("unsafe community resource path");
|
||||
total+=st.m_uncomp_size;
|
||||
if(st.m_uncomp_size>32*1024*1024 || total>128*1024*1024 ||
|
||||
!entries.emplace(folded(name),i).second)throw FormatError("ambiguous or oversized community resources");
|
||||
}
|
||||
}catch(...){mz_zip_reader_end(&zip);throw;}
|
||||
}
|
||||
~Bundle(){mz_zip_reader_end(&zip);}
|
||||
};
|
||||
std::mutex bundle_mutex;
|
||||
struct Cached { std::filesystem::file_time_type modified; uintmax_t size; std::shared_ptr<Bundle> bundle; };
|
||||
std::map<std::filesystem::path,Cached> cache;
|
||||
std::pair<std::shared_ptr<Bundle>,std::string> locate(const std::filesystem::path& requested) {
|
||||
auto path=std::filesystem::absolute(requested).lexically_normal();
|
||||
auto root=path.parent_path();
|
||||
for(int depth=0;depth<4 && !root.empty();++depth) {
|
||||
const auto archive=root/kCommunityBundle;
|
||||
std::error_code ec;
|
||||
if(std::filesystem::is_regular_file(archive,ec)) {
|
||||
const auto modified=std::filesystem::last_write_time(archive);
|
||||
const auto size=std::filesystem::file_size(archive);
|
||||
auto found=cache.find(archive);
|
||||
if(found==cache.end()||found->second.modified!=modified||found->second.size!=size) {
|
||||
auto bundle=std::make_shared<Bundle>(archive);
|
||||
if(cache.size()>=4)cache.clear();
|
||||
found=cache.insert_or_assign(archive,Cached{modified,size,std::move(bundle)}).first;
|
||||
}
|
||||
auto name=folded(path.lexically_relative(root).generic_string());
|
||||
// Compatibility address-view API; the archive contains no EXE image.
|
||||
if(name=="BMH.EXE")name="RUNTIME.DAT";
|
||||
return {found->second.bundle,std::move(name)};
|
||||
}
|
||||
const auto parent=root.parent_path();if(parent==root)break;root=parent;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
std::optional<Bytes> bundled_resource(const std::filesystem::path& path) {
|
||||
std::lock_guard lock(bundle_mutex);
|
||||
auto [bundle,name]=locate(path);if(!bundle)return std::nullopt;
|
||||
const auto found=bundle->entries.find(name);if(found==bundle->entries.end())return std::nullopt;
|
||||
mz_zip_archive_file_stat st{};mz_zip_reader_file_stat(&bundle->zip,found->second,&st);
|
||||
Bytes result(size_t(st.m_uncomp_size));
|
||||
if(!mz_zip_reader_extract_to_mem(&bundle->zip,found->second,result.data(),result.size(),0))
|
||||
throw FormatError("damaged community resource: "+name);
|
||||
return result;
|
||||
}
|
||||
bool resource_exists(const std::filesystem::path& path) {
|
||||
std::error_code ec;if(std::filesystem::is_regular_file(path,ec))return true;
|
||||
std::lock_guard lock(bundle_mutex);auto [bundle,name]=locate(path);
|
||||
return bundle && bundle->entries.count(name)!=0;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "formats/binary.hpp"
|
||||
#include <optional>
|
||||
namespace bmh {
|
||||
inline constexpr const char* kCommunityBundle = "COMMUNITY.OBD";
|
||||
// Read-only package lookup. Loose user saves always remain outside the bundle.
|
||||
std::optional<Bytes> bundled_resource(const std::filesystem::path& path);
|
||||
bool resource_exists(const std::filesystem::path& path);
|
||||
}
|
||||
@@ -31,7 +31,7 @@ constexpr BlockDef kBlocks[] = {
|
||||
{::bmh::layout::Cup_AdvanceCup_RuntimeField3, false, 1, Count::None, 0, false}, {::bmh::layout::LiveMatchday_FormatError_RuntimeField14, false, 6, Count::None, 0, false},
|
||||
{::bmh::layout::ManagerRecords, false, 0x373c, Count::None, 0, false}, // 5 manager records of 0xB0C bytes
|
||||
{::bmh::layout::Loans, false, 0x1e0, Count::None, 0, false},
|
||||
{::bmh::layout::ManagerMatchHistory, false, 0, Count::N42, 50, false}, // form history: 5 managers x 168 teams x 10
|
||||
{::bmh::layout::ManagerMatchHistory, false, 0x20d0, Count::None, 0, false}, // form history: 5 managers x 168 teams x 10
|
||||
{::bmh::layout::MatchdayGroupDescriptors, false, 0x4e0, Count::None, 0, false}, {::bmh::layout::ManagerAutomation, false, 0x14, Count::None, 0, false},
|
||||
{::bmh::layout::Desktops, false, 0x10e0, Count::None, 0, false}, // desktop layouts (.MEN), 5 x 0x360
|
||||
{::bmh::layout::CareerSession_DispatchToto_RuntimeField, false, 1, Count::None, 0, false}, {::bmh::layout::Cup_AdvanceCup_RuntimeField4, false, 1, Count::None, 0, false},
|
||||
@@ -43,7 +43,7 @@ constexpr BlockDef kBlocks[] = {
|
||||
{::bmh::layout::Placements, false, 0x50, Count::None, 0, false}, {::bmh::layout::ActiveSelectors, false, 8, Count::None, 0, false},
|
||||
{::bmh::layout::Career_CareerAddManager_RuntimeField2, false, 0x90, Count::None, 0, false}, {::bmh::layout::DeskActions_SubmitPoolsCoupon_RuntimeField, false, 0x2c, Count::None, 0, false},
|
||||
{::bmh::layout::NextDeskManager, false, 8, Count::None, 0, false}, {::bmh::layout::Savestate_Layout_ExecutableField8, false, 10, Count::None, 0, false},
|
||||
{::bmh::layout::DeskPosition, false, 1, Count::None, 0, false}, {::bmh::layout::DeskRecords_Teams_RuntimeField, false, 0, Count::Teams, 2, false},
|
||||
{::bmh::layout::DeskPosition, false, 1, Count::None, 0, false}, {::bmh::layout::DeskRecords_Teams_RuntimeField, false, 0x114, Count::None, 0, false},
|
||||
{::bmh::layout::CareerSession_FormatError_RuntimeField7, false, 2, Count::None, 0, false}, {::bmh::layout::Cup_AdvanceCup_RuntimeField6, false, 6, Count::None, 0, false},
|
||||
{::bmh::layout::CurrentMatchday, false, 4, Count::None, 0, false}, // seed of the game RNG (GameRandom)
|
||||
{::bmh::layout::ClubPlayerDetail_InvalidArgument_RuntimeField3, false, 1, Count::None, 0, false}, {::bmh::layout::CoachActive, false, 1, Count::None, 0, false},
|
||||
@@ -51,12 +51,12 @@ constexpr BlockDef kBlocks[] = {
|
||||
{::bmh::layout::CareerDuration, false, 1, Count::None, 0, false}, {::bmh::layout::GameMode, false, 1, Count::None, 0, false},
|
||||
{::bmh::layout::CompetitionSelection, false, 4, Count::None, 0, false}, {::bmh::layout::ManagerCount, false, 1, Count::None, 0, false}, // number of managers
|
||||
{::bmh::layout::SavedCompetition, false, 4, Count::None, 0, false}, {::bmh::layout::Difficulty, false, 1, Count::None, 0, false},
|
||||
{::bmh::layout::StockExchange, false, 0x450, Count::None, 0, false}, {::bmh::layout::FundBlock, false, 0, Count::N42, 1, false},
|
||||
{::bmh::layout::StockExchange, false, 0x450, Count::None, 0, false}, {::bmh::layout::FundBlock, false, 0xa8, Count::None, 0, false},
|
||||
{::bmh::layout::Coupon, false, 100, Count::None, 0, false}, {::bmh::layout::Savestate_Layout_ExecutableField2, false, 3, Count::None, 0, false},
|
||||
{::bmh::layout::Savestate_Layout_ExecutableField, false, 1, Count::None, 0, false}, {::bmh::layout::AdGroupId, false, 1, Count::None, 0, false},
|
||||
{::bmh::layout::OfferSlots, false, 0x10, Count::None, 0, false}, {::bmh::layout::ForeignClubStrength, false, 0xfb, Count::None, 0, false},
|
||||
{::bmh::layout::Career_Put_ExecutableField3, false, 0xbd, Count::None, 0, false}, {::bmh::layout::ClubShortNameOffsets, false, 0, Count::N42, 1, false},
|
||||
{::bmh::layout::ClubKitSelectors, false, 0, Count::Clubs, 1, false}, {::bmh::layout::Savestate_Layout_ExecutableField7, false, 0x18, Count::None, 0, false},
|
||||
{::bmh::layout::Career_Put_ExecutableField3, false, 0xbd, Count::None, 0, false}, {::bmh::layout::ClubShortNameOffsets, false, 0xa8, Count::None, 0, false},
|
||||
{::bmh::layout::ClubKitSelectors, false, 0x1a3, Count::None, 0, false}, {::bmh::layout::Savestate_Layout_ExecutableField7, false, 0x18, Count::None, 0, false},
|
||||
{::bmh::layout::ClubInfo_FormatError_RuntimeField, false, 0x420, Count::None, 0, false}, {::bmh::layout::Career_CareerManagersEnd_RuntimeField, false, 0x18, Count::None, 0, false},
|
||||
{::bmh::layout::ClubInfo_FormatError_RuntimeField2, false, 0xc, Count::None, 0, false}, {::bmh::layout::DeskActions_Unsupported_RuntimeField, false, 4, Count::None, 0, false},
|
||||
{::bmh::layout::Career_RemoveJoinLoans_RuntimeField, false, 800, Count::None, 0, false}, {::bmh::layout::ClubPlayerDetail_InvalidArgument_RuntimeField, false, 200, Count::None, 0, false},
|
||||
@@ -98,7 +98,7 @@ constexpr BlockDef kBlocks[] = {
|
||||
{::bmh::layout::Career_EuropeanClub_ExecutableField, false, 1, Count::None, 0, false}, {::bmh::layout::Career_EuropeanClub_ExecutableField2, false, 1, Count::None, 0, false},
|
||||
{::bmh::layout::Career_EuropeanClub_ExecutableField3, false, 1, Count::None, 0, false}, {::bmh::layout::Career_CompetitionPointersEnglish_ExecutableField24, false, 0x28, Count::None, 0, false},
|
||||
{::bmh::layout::Career_CompetitionPointersEnglish_ExecutableField29, false, 0x14, Count::None, 0, false}, {::bmh::layout::ClubSeasonRecords, false, 4, Count::None, 0, false},
|
||||
{::bmh::layout::ClubSeasonRecords, true, 0, Count::N42, 74, true}, // club records (168 x 74), only if pointer != 0
|
||||
{::bmh::layout::ClubSeasonRecords, true, 0x3090, Count::None, 0, true}, // club records (168 x 74), only if pointer != 0
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -106,7 +106,7 @@ constexpr BlockDef kBlocks[] = {
|
||||
SaveState::SaveState(const Bytes& stream, const DbCounts& c) : stream_(stream) {
|
||||
// Teams in league play and cup-only teams are not part of DbCounts yet;
|
||||
// these are the V2.24 values (CareerSession_DispatchLineup_RuntimeField, CareerSession_InstallLeagueSizes_RuntimeField6).
|
||||
const uint32_t kTeams = c.league_teams, kCupTeams = c.cup_teams;
|
||||
constexpr uint32_t kTeams = 138, kCupTeams = 30;
|
||||
size_t pos = 0;
|
||||
uint32_t last_pointer = 0;
|
||||
for (const BlockDef& d : kBlocks) {
|
||||
@@ -177,7 +177,7 @@ const SaveBlock& SaveState::block(uint32_t address) const {
|
||||
namespace bmh {
|
||||
|
||||
std::vector<SaveBlock> save_layout(const DbCounts& c, bool club_records) {
|
||||
const uint32_t kTeams = c.league_teams, kCupTeams = c.cup_teams;
|
||||
constexpr uint32_t kTeams = 138, kCupTeams = 30;
|
||||
std::vector<SaveBlock> out;
|
||||
size_t pos = 0;
|
||||
for (const BlockDef& d : kBlocks) {
|
||||
|
||||
@@ -56,19 +56,9 @@ uint32_t facility_level(const GameState& g, int m, int k) {
|
||||
// (balance 1 %, fixed deposit 2 % a year), positive an expense (overdraft 12 %, beyond the
|
||||
// credit line 18 %). The divisor is -36500.
|
||||
int32_t daily_interest_preview(const GameState& g, int m) {
|
||||
constexpr int32_t kAnnual = -0x8e94;
|
||||
const int32_t balance = rec32(g, m, 0x314), deposit = rec32(g, m, 0x318), credit = rec32(g, m, 0x31c);
|
||||
int32_t result = 0;
|
||||
if (balance < 0) {
|
||||
const int32_t with_credit = wrap(int64_t(balance) + credit);
|
||||
if (with_credit < 0) result = wrap(int64_t(with_credit) * 0x12) / kAnnual;
|
||||
int32_t below = wrap(-int64_t(credit));
|
||||
if (below < balance) below = balance;
|
||||
result = wrap(int64_t(result) + wrap(int64_t(below) * 0xc) / kAnnual);
|
||||
} else {
|
||||
result = balance / kAnnual;
|
||||
}
|
||||
return wrap(int64_t(result) + wrap(int64_t(deposit / 10000) * 20000) / kAnnual);
|
||||
const auto interest = daily_interest_amounts(balance, deposit, credit);
|
||||
return interest.borrowing + interest.cash_and_deposit;
|
||||
}
|
||||
|
||||
// SharesAndLoans(manager, flags, months): flags 1 the dividends of the manager's funds and
|
||||
@@ -78,7 +68,7 @@ int32_t shares_and_loans(const GameState& g, int m, int flags, int months) {
|
||||
int32_t sum = 0;
|
||||
if (flags & 1) {
|
||||
for (int k = 0; k < 6; k++) {
|
||||
const uint32_t unit = g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c) * uint32_t(kShareUnits[k]) / 10000;
|
||||
const uint32_t unit = uint32_t((uint64_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c)) * uint32_t(kShareUnits[k])) / 10000);
|
||||
sum = wrap(int64_t(sum) + int64_t(unit * g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c)));
|
||||
}
|
||||
if (flags & 4) sum = wrap(int64_t(sum) * months);
|
||||
@@ -261,7 +251,7 @@ int32_t stadium_required_attendance(const GameState& source, int manager) {
|
||||
if (manager < 0 || manager > 4) throw FormatError("stadium attendance: invalid manager");
|
||||
GameState g = source;
|
||||
const int team = g.manager_teams.at(size_t(manager));
|
||||
const int league = team > (kNoTeam - 1) ? 0 : team_league(team);
|
||||
const int league = team > 0x164 ? 0 : team_league(team);
|
||||
if (league < 0 || league >= kLeagueCount)
|
||||
throw FormatError("stadium attendance: manager has no Source league");
|
||||
const int home_games = league_matchdays(league) / 2;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "game/state.hpp"
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
|
||||
namespace bmh {
|
||||
// OpenBMH-owned OBMHEXT1 section BRM1: four little-endian blocked month-start keys.
|
||||
// Unknown histories use UINT32_MAX; original save fields are not repurposed.
|
||||
inline constexpr uint32_t kBankRobberyMonthExtension = 0x314d5242;
|
||||
inline constexpr uint32_t kUnknownBankRobberyMonth = std::numeric_limits<uint32_t>::max();
|
||||
inline constexpr uint32_t kBankRobberyMonthBytes = 16;
|
||||
|
||||
inline std::optional<uint32_t> bank_robbery_guard_month(const GameState& state, int manager) {
|
||||
if (manager < 0 || manager > 3) throw FormatError("bank robbery: invalid manager");
|
||||
if (!state.memory.has(kBankRobberyMonthExtension)) return {};
|
||||
if (!state.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
|
||||
throw FormatError("bank robbery: truncated monthly guard");
|
||||
const auto key = state.memory.u32(kBankRobberyMonthExtension + uint32_t(manager) * 4);
|
||||
return key == kUnknownBankRobberyMonth ? std::nullopt : std::optional<uint32_t>{key};
|
||||
}
|
||||
inline void set_bank_robbery_guard_month(GameState& state, int manager, std::optional<uint32_t> key) {
|
||||
if (manager < 0 || manager > 3) throw FormatError("bank robbery: invalid manager");
|
||||
if (!state.memory.has(kBankRobberyMonthExtension)) {
|
||||
state.memory.add_block(kBankRobberyMonthExtension, kBankRobberyMonthBytes);
|
||||
for (uint32_t slot = 0; slot < 4; ++slot)
|
||||
state.memory.set32(kBankRobberyMonthExtension + slot * 4, kUnknownBankRobberyMonth);
|
||||
}
|
||||
if (!state.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
|
||||
throw FormatError("bank robbery: truncated monthly guard");
|
||||
state.memory.set32(kBankRobberyMonthExtension + uint32_t(manager) * 4, key.value_or(kUnknownBankRobberyMonth));
|
||||
}
|
||||
// The first absolute day of the source calendar month, distinct across years.
|
||||
uint32_t bank_robbery_month_key(uint32_t date);
|
||||
}
|
||||
+12
-1
@@ -5,12 +5,23 @@
|
||||
namespace bmh {
|
||||
namespace { CalendarEpoch installed_epoch{2026, 2}; }
|
||||
CalendarEpoch calendar_epoch_from_executable(const LeImage& exe) {
|
||||
if(const auto* policy=exe.runtime_policy())return {int(policy->year),int(policy->weekday)};
|
||||
constexpr auto setup = layout::CalendarDateSetup;
|
||||
constexpr uint8_t weekday_prefix[] = {0xc6,0x44,0x24,0x04};
|
||||
constexpr uint8_t month_and_year_prefix[] = {0xc6,0x44,0x24,0x0c,0x07,0xc7,0x04,0x24};
|
||||
if (!exe.contains(setup) || !exe.contains(setup + 16))
|
||||
throw FormatError("calendar: missing original date setup");
|
||||
constexpr uint8_t english_prefix[] = {0xc6,0x45,0xf6};
|
||||
constexpr uint8_t english_month_and_year[] = {0xc6,0x45,0xf7,0x07,0x66,0xc7,0x45,0xf8};
|
||||
bool english = true;
|
||||
for (uint32_t i=0;i<sizeof english_prefix;++i)
|
||||
english = english && exe.u8(setup+i)==english_prefix[i];
|
||||
for (uint32_t i=0;i<sizeof english_month_and_year;++i)
|
||||
english = english && exe.u8(setup+4+i)==english_month_and_year[i];
|
||||
if (english) {
|
||||
const auto year=exe.u16(setup+12); const int weekday=exe.u8(setup+3);
|
||||
if(year<1600||year>9999||weekday>6)throw FormatError("calendar: invalid original English epoch");
|
||||
return {int(year),weekday};
|
||||
}
|
||||
for (uint32_t i=0;i<sizeof weekday_prefix;++i)
|
||||
if(exe.u8(setup+i)!=weekday_prefix[i])throw FormatError("calendar: unverified weekday setup");
|
||||
for (uint32_t i=0;i<sizeof month_and_year_prefix;++i)
|
||||
|
||||
+23
-19
@@ -12,12 +12,12 @@ namespace bmh {
|
||||
|
||||
namespace {
|
||||
|
||||
const int& kPoolSlots = runtime_dimensions.pool_first; // CareerRuntimeField: the clubs' squads end here
|
||||
const int& kTailFrom = runtime_dimensions.market_special_first;
|
||||
const int& kTailTo = runtime_dimensions.free_first; // CareerRuntimeField2
|
||||
const int& kExtraSlots = runtime_dimensions.extra_slots_first; // CareerSession_DataDirectory_RuntimeField4: 54 extra players from here
|
||||
const int& kSquadSlots = runtime_dimensions.total_slots;
|
||||
const int& kLeagueTeams = runtime_dimensions.league_teams; // CareerSession_DispatchLineup_RuntimeField
|
||||
constexpr size_t kPoolSlots = 2928; // CareerRuntimeField: the clubs' squads end here
|
||||
constexpr size_t kTailFrom = 2928 + 40;
|
||||
constexpr size_t kTailTo = 2972; // CareerRuntimeField2
|
||||
constexpr size_t kExtraSlots = 3096; // CareerSession_DataDirectory_RuntimeField4: 54 extra players from here
|
||||
constexpr size_t kSquadSlots = 3096 + 54;
|
||||
constexpr int kLeagueTeams = 138; // CareerSession_DispatchLineup_RuntimeField
|
||||
|
||||
// LeagueSizes: clubs per league; LeagueStrengthRanges: (minimum, maximum) strength per league.
|
||||
// (the clubs per league are kLeagueSizes, schedule.hpp)
|
||||
@@ -101,7 +101,7 @@ void startup_players(GameState& g, GameRandom& game, WatcomRandom& rand) {
|
||||
namespace bmh {
|
||||
|
||||
GameState startup_state(const LeImage& exe, const Database& db, const Bytes& m3_men, const Bytes& m3_dat) {
|
||||
const DbCounts counts=db.counts;
|
||||
const DbCounts counts;
|
||||
const std::vector<SaveBlock> layout = save_layout(counts, true);
|
||||
Bytes stream;
|
||||
for (const SaveBlock& b : layout) {
|
||||
@@ -154,7 +154,7 @@ GameState startup_state(const LeImage& exe, const Database& db, const Bytes& m3_
|
||||
if (b.heap) {
|
||||
for (size_t i = 0; i < db.players.size() && 4 * i + 3 < data.size(); i++) {
|
||||
uint32_t w = b.address == ::bmh::layout::PlayerConditionTechniqueForm ? db.players[i].w35c : b.address == ::bmh::layout::PlayerSkillWords ? db.players[i].w368 : db.players[i].w364;
|
||||
if (b.address == ::bmh::layout::PlayerSkillWords && !runtime_dimensions.expanded && i + 32 >= db.players.size())
|
||||
if (b.address == ::bmh::layout::PlayerSkillWords && i + 32 >= db.players.size())
|
||||
w = (w & 0x07ffffffu) | uint32_t(exe.u8(::bmh::layout::Career_BuildStadium_RuntimeField4 - uint32_t(db.players.size() - i))) << 27;
|
||||
for (int k = 0; k < 4; k++) data[4 * i + size_t(k)] = uint8_t(w >> (8 * k));
|
||||
}
|
||||
@@ -171,6 +171,10 @@ GameState startup_state(const LeImage& exe, const Database& db, const Bytes& m3_
|
||||
}
|
||||
const SaveState save(stream, counts);
|
||||
GameState g = GameState::from_save(save, counts);
|
||||
// The original options entry restores ordinary dialogs before any manager
|
||||
// confirmation. The executable's initial value belongs to its boot screens.
|
||||
g.memory.add_block(layout::CompactDialogFrame, 1);
|
||||
g.memory.set8(layout::CompactDialogFrame, 0);
|
||||
competition_pointers(g.memory, exe); // CompetitionPointers
|
||||
return g;
|
||||
}
|
||||
@@ -213,14 +217,14 @@ void new_career_markets_and_moods(GameState& g, GameRandom& game, WatcomRandom&
|
||||
}
|
||||
|
||||
bool new_career_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteReport& report) {
|
||||
for (size_t slot = 0; slot < runtime_dimensions.pool_first; slot++) {
|
||||
for (size_t slot = 0; slot < 2928; slot++) {
|
||||
const int id = g.squad_slots.at(slot) & 0x0fff;
|
||||
if (id == 0x0fff) continue;
|
||||
Player& p = g.players.at(size_t(id));
|
||||
p.w364 |= uint32_t(rand.range(4, 0x10)) << 21;
|
||||
p.w368 = (p.w368 & 0xffffc000u) + uint32_t(rand.range(0, 0x3fff));
|
||||
}
|
||||
for (int slot = runtime_dimensions.extra_slots_first; slot < runtime_dimensions.extra_slots_first + 0x36; slot++)
|
||||
for (int slot = 3096; slot < 3096 + 0x36; slot++)
|
||||
if (!release_player(g, slot, game, rand, report)) return false;
|
||||
return !report.unsupported;
|
||||
}
|
||||
@@ -258,7 +262,7 @@ bool human_club(const GameState& g, int team) {
|
||||
const int managers = g.memory.u8(::bmh::layout::ManagerCount);
|
||||
for (int m = 0; m < managers; m++)
|
||||
if (team_of(g, m) == uint16_t(team)) return true;
|
||||
return team_of(g, 0) == kNoTeam && team_of(g, 4) == uint16_t(team);
|
||||
return team_of(g, 0) == 0x165 && team_of(g, 4) == uint16_t(team);
|
||||
}
|
||||
|
||||
// OpenBMH deviates from the original: skips reserved calendar positions when assigning a joining manager to a club.
|
||||
@@ -431,17 +435,17 @@ bool career_add_manager(GameState& g, const LeImage& exe, int m, const CareerMan
|
||||
if (!g.memory.has(::bmh::layout::ManagerCount) || m < 0 || m >= 4 ||
|
||||
g.memory.u8(::bmh::layout::ManagerCount) > 4 || m >= g.memory.u8(::bmh::layout::ManagerCount) ||
|
||||
size_t(m) >= g.manager_teams.size() || g.manager_records.size() < 5 * kRecord ||
|
||||
choice.team < 0 || choice.team >= runtime_dimensions.record_teams || size_t(choice.team) >= g.club_ids.size() ||
|
||||
choice.team < 0 || choice.team >= 168 || size_t(choice.team) >= g.club_ids.size() ||
|
||||
choice.league < 0 || choice.league > 4 || choice.strength < 0 || choice.strength > 2 ||
|
||||
choice.portrait < 0 || choice.portrait > 11 || choice.name.size() > 24 ||
|
||||
g.tactics.size() < size_t(m + 1) * 0x840 ||
|
||||
g.manager_ratings.size() < size_t(m + 1) * 0x3c ||
|
||||
g.manager_results.size() < g.manager_teams.size() * (runtime_dimensions.record_teams * 10) ||
|
||||
g.squad_slots.size() < kSquadSlots || g.club_ids.size() < runtime_dimensions.record_teams ||
|
||||
g.team_morale.size() < runtime_dimensions.record_teams || g.team_flags.size() < runtime_dimensions.record_teams ||
|
||||
g.club_heap_bc.size() < runtime_dimensions.record_teams * 2 || g.club_heap_78.size() < runtime_dimensions.record_teams * 2 ||
|
||||
g.club_heap_b8.size() < runtime_dimensions.record_teams || g.position_history.size() < runtime_dimensions.league_teams * 0x1a ||
|
||||
(!g.club_table.empty() && g.club_table.size() < runtime_dimensions.record_teams * 0x4a) ||
|
||||
g.manager_results.size() < g.manager_teams.size() * 0x690 ||
|
||||
g.squad_slots.size() < kSquadSlots || g.club_ids.size() < 168 ||
|
||||
g.team_morale.size() < 168 || g.team_flags.size() < 168 ||
|
||||
g.club_heap_bc.size() < 168 * 2 || g.club_heap_78.size() < 168 * 2 ||
|
||||
g.club_heap_b8.size() < 168 || g.position_history.size() < 138 * 0x1a ||
|
||||
(!g.club_table.empty() && g.club_table.size() < 168 * 0x4a) ||
|
||||
g.player_bonus.size() < g.players.size() || g.player_cards.size() < g.players.size() ||
|
||||
!exe.contains(::bmh::layout::Career_CareerAddManager_ExecutableField) || !exe.contains(::bmh::layout::Career_BuildStadium_RuntimeField3 + 0x15 * 5) ||
|
||||
!exe.contains(::bmh::layout::Career_BuildStadium_RuntimeField + 4 * 0x17 + 0x15)) {
|
||||
@@ -554,7 +558,7 @@ bool career_add_manager(GameState& g, const LeImage& exe, int m, const CareerMan
|
||||
new_board_entry(g, m, int(i), int(slot), rand);
|
||||
g.tactics.at(size_t(m) * 0x840 + i * 0x58 + 0xd) = 100;
|
||||
}
|
||||
for (size_t i = 0; i < (runtime_dimensions.record_teams * 10); i++) g.manager_results.at(size_t(m) * (runtime_dimensions.record_teams * 10) + i) = 0xff;
|
||||
for (size_t i = 0; i < 0x690; i++) g.manager_results.at(size_t(m) * 0x690 + i) = 0xff;
|
||||
const uint8_t level = mem.u8(::bmh::layout::Difficulty);
|
||||
const uint32_t money = level == 0 ? 50000000u : 4000000u - level * 200000u;
|
||||
put32(r, rec + 0x314, money);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <stdexcept>
|
||||
namespace bmh {
|
||||
ClubInfoEntry prepare_club_info_entry(GameState& g, int team) {
|
||||
if (team < 0 || (team >= runtime_dimensions.league_teams && team != kNoTeam))
|
||||
if (team < 0 || (team >= 138 && team != kNoTeam))
|
||||
throw std::invalid_argument("club info: team has no squad");
|
||||
const SquadRange range = squad_range(team);
|
||||
if (range.first > g.squad_slots.size() || range.count > g.squad_slots.size() - range.first)
|
||||
|
||||
@@ -31,9 +31,9 @@ int source_manager(const GameState& g, int club) {
|
||||
|
||||
int club_of_slot(int slot) {
|
||||
if (slot < 0) return -1;
|
||||
if (slot < runtime_dimensions.big_squad_teams * 24) return slot / 24;
|
||||
if (slot < runtime_dimensions.pool_first) return (slot - runtime_dimensions.big_squad_teams * 8) / 16;
|
||||
if (slot >= runtime_dimensions.national_slots_first && slot < runtime_dimensions.extra_slots_first) return kNoTeam;
|
||||
if (slot < 90 * 24) return slot / 24;
|
||||
if (slot < 90 * 24 + 48 * 16) return (slot - 90 * 8) / 16;
|
||||
if (slot >= 3072 && slot < 3096) return kNoTeam;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ ClubPlayerDetailContext club_player_detail_context(const GameState& g, const Clu
|
||||
out.primary_club = -1;
|
||||
} else {
|
||||
if (s.rendered_row < 0 || s.rendered_row >= 24 || s.runtime_team < 0 ||
|
||||
(s.runtime_team >= runtime_dimensions.league_teams && s.runtime_team != kNoTeam))
|
||||
(s.runtime_team >= 138 && s.runtime_team != kNoTeam))
|
||||
throw std::invalid_argument("player detail: invalid runtime club");
|
||||
const auto range = squad_range(s.runtime_team);
|
||||
if (range.first + range.count > g.squad_slots.size()) throw std::invalid_argument("player detail: truncated squad");
|
||||
|
||||
@@ -53,7 +53,7 @@ struct ClubPlayerDetailContext {
|
||||
|
||||
// OpenTransferEditor passes actual slots CareerRuntimeField + entry (0..39) for ordinary
|
||||
// transfer-market pool cards. It never turns the entry into a squad row.
|
||||
inline const int& kClubPlayerDetailMarketPoolFirst = runtime_dimensions.pool_first;
|
||||
constexpr int kClubPlayerDetailMarketPoolFirst = 0xb70;
|
||||
constexpr int kClubPlayerDetailMarketPoolCount = 40;
|
||||
|
||||
// Resolves runtime club, explicit row and Source loan/national ownership without
|
||||
|
||||
+3
-3
@@ -482,7 +482,7 @@ void order_national_cup_ties(GameState& g, int teams, int offset) {
|
||||
for (int i = 0; i < teams; i += 2) {
|
||||
if (lower <= team(i + 1) && team(i) < lower)
|
||||
swap16(mem, list + uint32_t(i) * 2, list + uint32_t(i + 1) * 2);
|
||||
auto league = [](int t) { return t > (kNoTeam - 1) ? 0 : team_league(t); };
|
||||
auto league = [](int t) { return t > 0x164 ? 0 : team_league(t); };
|
||||
const int la = league(team(i)), lb = league(team(i + 1));
|
||||
weights.push_back(uint8_t(kWeight[la < 10 ? la : 9] + kWeight[lb < 10 ? lb : 9]));
|
||||
}
|
||||
@@ -622,7 +622,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
|
||||
g.manager_records.at(at) = uint8_t(n + 1), g.manager_records.at(at + 1) = uint8_t((n + 1) >> 8);
|
||||
}
|
||||
// ListTitleHoldersAf(winner, title): the list of title holders (Titles)
|
||||
mem.set16(::bmh::layout::Titles + uint32_t(title) * 100 + uint32_t(std::min<int>(g.season, 0x31)) * 2, winners[0]);
|
||||
record_title_holder(g, title, winners[0]);
|
||||
}
|
||||
if (type == 0 && !winners.empty()) {
|
||||
// the national cup: winner (Cup_AdvanceCup_RuntimeField5) and the previous holder
|
||||
@@ -654,7 +654,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
|
||||
if (mem.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && winner_display)
|
||||
winner_display(g, {7, winner});
|
||||
if (mem.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && mem.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2)) mem.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2, 0);
|
||||
mem.set16(::bmh::layout::Titles + 7 * 100 + uint32_t(std::min<int>(g.season, 0x31)) * 2, winner);
|
||||
record_title_holder(g, 7, winner);
|
||||
if (mem.has(::bmh::layout::Cup_AdvanceCup_RuntimeField7)) mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField7, winner);
|
||||
const int manager = g.manager_of(winner);
|
||||
if (manager >= 0) {
|
||||
|
||||
+19
-12
@@ -69,7 +69,7 @@ FriendlyBookingQuote make_friendly_quote(const GameState& g, int manager, int op
|
||||
return out;
|
||||
}
|
||||
const int own_team = g.manager_teams[size_t(manager)];
|
||||
if (own_team < 0 || own_team >= runtime_dimensions.record_teams || opponent < 0 || opponent >= runtime_dimensions.record_teams || opponent == own_team) {
|
||||
if (own_team < 0 || own_team >= 168 || opponent < 0 || opponent >= 168 || opponent == own_team) {
|
||||
out.status = FriendlyQuoteStatus::invalid_opponent;
|
||||
return out;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ NationalFriendlyQuote make_national_friendly_quote(const GameState& g,
|
||||
return out;
|
||||
}
|
||||
// Page 4 cannot return Germany (0); the engine boundary repeats that gate.
|
||||
if (opponent <= kNoTeam || opponent > (kNoTeam + 61) || opponent == kNoTeam) {
|
||||
if (opponent <= kNoTeam || opponent > 0x1a2 || opponent == kNoTeam) {
|
||||
out.terms.status = FriendlyQuoteStatus::invalid_opponent;
|
||||
return out;
|
||||
}
|
||||
@@ -538,6 +538,13 @@ TransferActionResult list_manager_player(GameState& g, int manager, int squad_ro
|
||||
out.status = TransferActionStatus::invalid_player;
|
||||
return out;
|
||||
}
|
||||
bool free_entry = false;
|
||||
for (size_t entry = 0; entry < 40; ++entry) {
|
||||
const int listed = g.squad_slots.at(0xb70 + entry) & 0xfff;
|
||||
if (listed == player) { out.status = TransferActionStatus::pending; out.player = player; out.list_entry = int(entry); return out; }
|
||||
free_entry = free_entry || listed == 0xfff;
|
||||
}
|
||||
if (!free_entry) { out.status = TransferActionStatus::blocked_by_board; return out; }
|
||||
if (!list_transfer_player(g, slot, rand, report)) {
|
||||
out.status = report.unsupported ? TransferActionStatus::invalid_request : TransferActionStatus::blocked_by_board;
|
||||
return out;
|
||||
@@ -624,7 +631,7 @@ TransferActionResult submit_transfer_bid_impl(GameState& g, const TransferBidReq
|
||||
const bool source_direct_candidate = source_hooks && seller_manager < 0 &&
|
||||
fee_pct >= 110 && salary_pct >= g.memory.u8(entry + 0x55);
|
||||
if (source_direct_candidate) {
|
||||
if (request.list_entry >= 40 || seller < 0 || (seller >= runtime_dimensions.league_teams && seller != 0x0fff) || seller == buyer ||
|
||||
if (request.list_entry >= 40 || seller < 0 || (seller >= 0x8a && seller != 0x0fff) || seller == buyer ||
|
||||
request.manager < 0 || size_t(request.manager) >= g.manager_teams.size() ||
|
||||
!g.memory.has(::bmh::layout::ActiveManager) || g.memory.u8(::bmh::layout::ActiveManager) != request.manager ||
|
||||
source_hooks->direct_mode != HumanBuyerSaleDirectMode::ordinary_ai_purchase ||
|
||||
@@ -790,7 +797,7 @@ TransferActionResult submit_transfer_bid_source_impl(GameState& g, const Transfe
|
||||
// ordinary settlement already removes players using that actual range.
|
||||
// Higher club IDs have no ordinary squad; do not invent their settlement
|
||||
// or let ReleasePlayer reach its missing-player/internal-error21 boundary.
|
||||
if (seller != 0x0fff && seller >= runtime_dimensions.league_teams) {
|
||||
if (seller != 0x0fff && seller >= 138) {
|
||||
report.fail(kOrdinarySellerBoundary);
|
||||
out.status = TransferActionStatus::unsupported;
|
||||
out.player = player; out.list_entry = request.list_entry;
|
||||
@@ -1009,7 +1016,7 @@ TransferActionResult submit_transfer_bid_source_impl(GameState& g, const Transfe
|
||||
std::optional<TransferMarketSnapshotPreview> transfer_market_snapshot_preview(
|
||||
const GameState& g,int manager,int runtime_club,int index) {
|
||||
if(manager<0||manager>=4||size_t(manager)>=g.manager_teams.size()||
|
||||
g.manager_teams[size_t(manager)]!=runtime_club||runtime_club<0||runtime_club>=runtime_dimensions.league_teams||index<0||index>=12)
|
||||
g.manager_teams[size_t(manager)]!=runtime_club||runtime_club<0||runtime_club>=138||index<0||index>=12)
|
||||
return std::nullopt;
|
||||
const auto owner=squad_range(runtime_club);
|
||||
int count=0,ordinal=-1;
|
||||
@@ -1036,7 +1043,7 @@ std::optional<TransferMarketSnapshotPreview> transfer_market_snapshot_preview(
|
||||
// Require exactly one genuine ledger and its authenticated owner.
|
||||
if(borrower!=-1||int(loan>>12&0x3ff)!=runtime_club)return std::nullopt;
|
||||
borrower=int(loan>>22&0x3ff);
|
||||
if(borrower<0||borrower>=runtime_dimensions.league_teams||borrower==runtime_club)return std::nullopt;
|
||||
if(borrower<0||borrower>=138||borrower==runtime_club)return std::nullopt;
|
||||
}
|
||||
if(borrower<0)return std::nullopt;
|
||||
const auto range=squad_range(borrower);
|
||||
@@ -1072,9 +1079,9 @@ TransferMarketPreviewResult quote_transfer_market_preview_source(
|
||||
return unsupported("market preview: stale Source player/slot");
|
||||
if(request.purchase) {
|
||||
if(request.snapshot_index!=-1)return unsupported("market preview: snapshot is not a purchase row");
|
||||
if(request.source_slot<runtime_dimensions.pool_first||request.source_slot>=runtime_dimensions.pool_first+40)
|
||||
if(request.source_slot<2928||request.source_slot>=2928+40)
|
||||
return unsupported("market preview: purchase is not an ordinary market row");
|
||||
const uint32_t seller_at=::bmh::layout::EditorList+uint32_t(request.source_slot-runtime_dimensions.pool_first)*0x58+8;
|
||||
const uint32_t seller_at=::bmh::layout::EditorList+uint32_t(request.source_slot-2928)*0x58+8;
|
||||
if(!g.memory.has(seller_at)||!g.memory.has(seller_at+1))
|
||||
return unsupported("market preview: missing Source seller word");
|
||||
const uint16_t raw=g.memory.u16(seller_at);
|
||||
@@ -1091,7 +1098,7 @@ TransferMarketPreviewResult quote_transfer_market_preview_source(
|
||||
// with the unchanged42307 formula; do not synthesize a Native slot.
|
||||
} else {
|
||||
if(request.snapshot_index!=-1)return unsupported("market preview: invalid snapshot index");
|
||||
if(request.seller!=request.runtime_club||request.runtime_club>=runtime_dimensions.league_teams)
|
||||
if(request.seller!=request.runtime_club||request.runtime_club>=138)
|
||||
return unsupported("market preview: outgoing club is not an ordinary owned squad");
|
||||
const auto range=squad_range(request.runtime_club);
|
||||
if(range.count==0||range.first+range.count>g.squad_slots.size()||
|
||||
@@ -1133,7 +1140,7 @@ int editor_slot(const GameState& g,const TransferOfferEditorRequest& r) {
|
||||
std::string editor_identity(const GameState& g,const TransferOfferEditorRequest& r) {
|
||||
if(r.manager<0||r.manager>=4||size_t(r.manager)>=g.manager_teams.size()||
|
||||
!g.memory.has(::bmh::layout::ActiveManager)||g.memory.u8(::bmh::layout::ActiveManager)!=r.manager||
|
||||
g.manager_teams[size_t(r.manager)]!=r.runtime_club||r.runtime_club<0||r.runtime_club>=runtime_dimensions.league_teams)
|
||||
g.manager_teams[size_t(r.manager)]!=r.runtime_club||r.runtime_club<0||r.runtime_club>=138)
|
||||
return "OpenTransferEditor: stale ordinary manager/team";
|
||||
const size_t record=size_t(r.manager)*kRecordSize;
|
||||
if(record+kRecordSize>g.manager_records.size()||
|
||||
@@ -1143,7 +1150,7 @@ std::string editor_identity(const GameState& g,const TransferOfferEditorRequest&
|
||||
const bool ordinary_entry = r.list_entry >= 0 && r.list_entry < 40 && !r.poach && !r.loan_return_entry;
|
||||
const bool poach_entry = r.list_entry >= 40 && r.list_entry < 44 && r.poach && !r.loan_return_entry;
|
||||
const bool return_entry = r.list_entry >= 40 && r.list_entry < 44 && r.loan_return_entry && !r.poach;
|
||||
if((!ordinary_entry&&!poach_entry&&!return_entry)||r.source_slot!=runtime_dimensions.pool_first+r.list_entry||
|
||||
if((!ordinary_entry&&!poach_entry&&!return_entry)||r.source_slot!=2928+r.list_entry||
|
||||
size_t(r.source_slot)>=g.squad_slots.size()||r.expected_player<0||r.expected_player>=0x0fff||
|
||||
size_t(r.expected_player)>=g.players.size()||
|
||||
int(g.squad_slots[size_t(r.source_slot)]&0x0fff)!=r.expected_player)
|
||||
@@ -1159,7 +1166,7 @@ std::string editor_identity(const GameState& g,const TransferOfferEditorRequest&
|
||||
const int seller=int(r.expected_seller_word&0x7fff);
|
||||
if(r.expected_seller_word==0xffff||seller==r.runtime_club)
|
||||
return "OpenTransferEditor: targeted/invalid seller is outside ordinary editor";
|
||||
if(seller!=0x0fff&&seller>=runtime_dimensions.league_teams)return kOrdinarySellerBoundary;
|
||||
if(seller!=0x0fff&&seller>=138)return kOrdinarySellerBoundary;
|
||||
// OpenTransferEditor: the original refuses a loan from a free agent (seller 0x0fff) with the message
|
||||
// DeskActionsRuntimeField6 (SDLFlushEvents3) - a rule of the game, not a gap: the code names it
|
||||
if(r.loan&&r.expected_seller_word==0x0fff)return "free_agent_loan_refused";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "game/transfer_allocator.hpp"
|
||||
// OpenBMH deviates from the original: supports designated set-piece records and the supported transfer-editor rules.
|
||||
// Actions a human manager can take at his desk that change the game state and draw random
|
||||
// numbers (BMH.exe V2.24 + supported rule profile patch). The screens themselves belong to the UI; these
|
||||
@@ -272,6 +273,12 @@ struct TransferOfferEditorSubmitResult {
|
||||
TransferOfferEditorSubmitResult submit_transfer_offer_editor_source(GameState&,
|
||||
const TransferOfferEditorState&,WatcomRandom&,const HumanBuyerSaleHooks&,MinuteReport&);
|
||||
|
||||
// OpenBMH deviates from the original: a seller may accept an existing bid before expiry.
|
||||
// The caller stages state/RNG; cancellation is handled before invoking this action.
|
||||
TransferActionResult accept_manager_transfer_offer(GameState&, int manager, int list_entry,
|
||||
int expected_player, int bid_index, WatcomRandom&, MinuteReport&,
|
||||
TransferAllocatorContext = TransferAllocatorContext::unsupported);
|
||||
|
||||
// Submit a manager bid on an existing list entry. A full-value fee and salary meeting
|
||||
// the demand complete an immediate agreement; lower viable offers persist for weekly review.
|
||||
TransferActionResult submit_transfer_bid(GameState& g, const TransferBidRequest& request, WatcomRandom& rand);
|
||||
|
||||
+10
-13
@@ -33,19 +33,16 @@ uint32_t academy_paid(const GameState& g, int manager) {
|
||||
}
|
||||
}
|
||||
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;
|
||||
// OpenBMH deviates from the original: the common Diamond 3.7 monthly
|
||||
// environment model applies to every supported source-data edition.
|
||||
// Numeric steps are data; an edition's original instructions are not run.
|
||||
auto steps=kEnvironmentStep;
|
||||
for(size_t i=0;i<steps.size();++i) {
|
||||
const auto at=layout::EnvironmentBudgetSteps+uint32_t(i);
|
||||
if(!exe.contains(at)||exe.u8(at)==0){supported_environment=false;return;}
|
||||
steps[i]=int32_t(exe.u8(at))*1000;
|
||||
}
|
||||
if(const auto* policy=exe.runtime_policy()) { supported_environment=policy->environment_verified!=0;return; }
|
||||
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;
|
||||
kEnvironmentStep=steps;supported_environment=true;
|
||||
}
|
||||
bool environment_rules_supported() { return supported_environment; }
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
|
||||
@@ -58,7 +55,7 @@ bool environment_academy_active(const GameState& g, int manager) {
|
||||
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
|
||||
}
|
||||
EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
if (!supported_environment) throw FormatError("environment: this original program variant is not verified");
|
||||
if (!supported_environment) throw FormatError("environment: monthly budget steps are missing or invalid");
|
||||
validate_manager(g, manager);
|
||||
EnvironmentState result;
|
||||
for (int i = 0; i < kEnvironmentItems; ++i) {
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
#include "game/state.hpp"
|
||||
|
||||
namespace bmh {
|
||||
// Verified original-program capability; unknown environment variants are not guessed.
|
||||
// Install validated numeric steps for the common Diamond 3.7 monthly model.
|
||||
void install_environment_rules(const LeImage&);
|
||||
bool environment_rules_supported();
|
||||
constexpr int kEnvironmentItems = 6;
|
||||
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
|
||||
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
|
||||
// Monthly environment model verified in the supported CD and Diamond 3.6/3.7 programs.
|
||||
// Canonical monthly environment model; source editions supply compatible data.
|
||||
inline std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
struct EnvironmentState {
|
||||
std::array<int32_t, kEnvironmentItems> monthly{};
|
||||
|
||||
@@ -108,7 +108,7 @@ void validate(const GameState& g,const LeaguePairingsOwner& o) {
|
||||
require(o.supported&&!o.closed&&o.manager>=0&&o.manager<4&&
|
||||
size_t(o.manager)<g.manager_teams.size()&&g.memory.has(::bmh::layout::ActiveManager)&&
|
||||
g.memory.u8(::bmh::layout::ActiveManager)==o.manager&&g.manager_teams[size_t(o.manager)]==o.runtime_club&&
|
||||
(national||(o.runtime_club>=0&&o.runtime_club<runtime_dimensions.league_teams))&&
|
||||
(national||(o.runtime_club>=0&&o.runtime_club<138))&&
|
||||
size_t(o.runtime_club)<g.club_ids.size()&&
|
||||
g.club_ids[size_t(o.runtime_club)]==o.club_identity,
|
||||
"pairings: stale or unsupported manager identity");
|
||||
@@ -124,12 +124,12 @@ void validate(const GameState& g,const LeaguePairingsOwner& o) {
|
||||
(g.memory.u8(::bmh::layout::CareerSession_CloseLeagueFamily_ExecutableField+uint32_t(o.manager))&0x0f)==8)&&
|
||||
g.memory.has(::bmh::layout::LeagueTableDisplayModes+uint32_t(o.manager)*2+1),
|
||||
"pairings: missing preferences or unsupported saved list mode");
|
||||
require(g.results.size()>=kResultsSize&&g.club_ids.size()>=runtime_dimensions.league_teams&&g.league_rounds.size()>=9&&
|
||||
require(g.results.size()>=kResultsSize&&g.club_ids.size()>=138&&g.league_rounds.size()>=9&&
|
||||
g.memory.has(::bmh::layout::Postponed+0xef)&&g.memory.has(::bmh::layout::CompetitionCalendar+365*2+1),
|
||||
"pairings: incomplete Native schedule");
|
||||
const auto selection_valid=[&](int team,int identity) {
|
||||
return team<0 ? team>=-2&&identity==-1 :
|
||||
team<runtime_dimensions.league_teams&&team_league(team)==o.league&&g.club_ids.at(size_t(team))==identity;
|
||||
team<138&&team_league(team)==o.league&&g.club_ids.at(size_t(team))==identity;
|
||||
};
|
||||
require(selection_valid(o.search_first,o.search_first_identity)&&
|
||||
selection_valid(o.search_second,o.search_second_identity)&&
|
||||
@@ -181,7 +181,7 @@ void validate(const GameState& g,const LeaguePairingsOwner& o) {
|
||||
o.filter_offset>=0&&o.filter_offset%10==0&&o.filter_team>=-2,
|
||||
"pairings: invalid Source club-filter mode");
|
||||
if(o.filter_team>=0) {
|
||||
require(o.filter_team<runtime_dimensions.league_teams&&team_league(o.filter_team)==o.league&&
|
||||
require(o.filter_team<138&&team_league(o.filter_team)==o.league&&
|
||||
g.club_ids.at(size_t(o.filter_team))==o.filter_identity&&
|
||||
(o.filter_offset==0||o.filter_offset<filtered_fixture_count(o.league,o.filter_team)),
|
||||
"pairings: stale or out-of-range filtered club");
|
||||
@@ -315,7 +315,7 @@ LeaguePairingsOwner open_league_pairings_source(GameState& g,int manager,const L
|
||||
require(manager>=0&&manager<4&&size_t(manager)<g.manager_teams.size(),"pairings: unsupported manager");
|
||||
LeaguePairingsOwner out;out.manager=manager;out.runtime_club=g.manager_teams[size_t(manager)];
|
||||
const bool national=out.runtime_club==kNoTeam;
|
||||
require((national||(out.runtime_club>=0&&out.runtime_club<runtime_dimensions.league_teams))&&
|
||||
require((national||(out.runtime_club>=0&&out.runtime_club<138))&&
|
||||
size_t(out.runtime_club)<g.club_ids.size(),"pairings: unsupported or unowned manager");
|
||||
out.club_identity=g.club_ids[size_t(out.runtime_club)];
|
||||
// TeamLeague2 maps the Original national runtime team 0x165 to league 0.
|
||||
|
||||
+4
-4
@@ -37,7 +37,7 @@ uint8_t formation_byte(const GameState& g, size_t index) {
|
||||
}
|
||||
|
||||
bool pitch_context_valid(const GameState& g, int manager, int team) {
|
||||
if (manager < 0 || manager > 3 || team < 0 || team >= runtime_dimensions.league_teams || g.lineups_frozen ||
|
||||
if (manager < 0 || manager > 3 || team < 0 || team >= 138 || g.lineups_frozen ||
|
||||
!g.memory.has(::bmh::layout::ActiveManager) || !g.memory.has(::bmh::layout::GameMode) ||
|
||||
g.memory.u8(::bmh::layout::ActiveManager) != manager || g.memory.u8(::bmh::layout::GameMode) < 1 || g.memory.u8(::bmh::layout::GameMode) > 3 ||
|
||||
size_t(manager) >= g.manager_teams.size() || g.manager_teams[size_t(manager)] != team ||
|
||||
@@ -326,7 +326,7 @@ void install_lineup_rules(const LeImage& exe) {
|
||||
}
|
||||
|
||||
static void auto_lineup_impl(GameState& g, int team, int mode, int manager) {
|
||||
if (team >= runtime_dimensions.league_teams && team != kNoTeam) return; // teams without squads
|
||||
if (team >= 138 && team != kNoTeam) return; // teams without squads
|
||||
if (g.lineups_frozen) return; // LineupRuntimeField (the season change)
|
||||
const bool improve_from_reserves = (mode & 0x80) != 0;
|
||||
mode &= 0x7F;
|
||||
@@ -646,7 +646,7 @@ void auto_lineup(GameState& g, int team, int mode) {
|
||||
|
||||
void auto_lineup_parked_club_source(GameState& g, int team, int mode) {
|
||||
constexpr size_t record = 4*0xb0c+0x290;
|
||||
if (team<0 || team>=runtime_dimensions.league_teams || g.manager_teams.size()!=1 || g.manager_teams[0]!=kNoTeam ||
|
||||
if (team<0 || team>=138 || g.manager_teams.size()!=1 || g.manager_teams[0]!=kNoTeam ||
|
||||
!g.memory.has(::bmh::layout::CoachActive) || g.memory.u8(::bmh::layout::CoachActive)==0 ||
|
||||
!g.memory.has(::bmh::layout::ManagerCount) || g.memory.u8(::bmh::layout::ManagerCount)!=1 ||
|
||||
!g.memory.has(::bmh::layout::OriginalManagerCount) || g.memory.u8(::bmh::layout::OriginalManagerCount)<1 || g.memory.u8(::bmh::layout::OriginalManagerCount)>4 ||
|
||||
@@ -682,7 +682,7 @@ void quicksort_by_key(int16_t* items, uint32_t* keys, int count, bool ascending)
|
||||
}
|
||||
|
||||
bool substitute(GameState& g, int team, int off, int mode, WatcomRandom& rand) {
|
||||
if (!(team < runtime_dimensions.league_teams || team == kNoTeam)) return false;
|
||||
if (!(team < 138 || team == kNoTeam)) return false;
|
||||
const int manager = g.manager_of(team);
|
||||
int used = g.team_flags.at(team) >> 5 & 7; // substitutions so far
|
||||
if (mode == 10) {
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/long_career.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace bmh {
|
||||
namespace {
|
||||
uint32_t key(int team, int player) {
|
||||
if (team < 0 || team > 0xfff || player < 0 || player >= 0xfff)
|
||||
throw FormatError("long career: invalid player/club identity");
|
||||
return uint32_t(team) << 12 | uint32_t(player);
|
||||
}
|
||||
int manager_team(const GameState& g, int manager) {
|
||||
if (manager >= 0 && size_t(manager) < g.manager_teams.size()) return g.manager_teams[size_t(manager)];
|
||||
const size_t at = size_t(manager) * 0xb0c + 0x290;
|
||||
if (manager < 0 || manager > 4 || at + 1 >= g.manager_records.size())
|
||||
throw FormatError("long career: invalid manager");
|
||||
return int(g.manager_records[at] | uint16_t(g.manager_records[at + 1]) << 8);
|
||||
}
|
||||
PlayerClubStatistics legacy(const std::array<uint8_t, 0x58>& b) {
|
||||
auto word = [&](size_t at) { return uint64_t(b[at] | uint16_t(b[at + 1]) << 8); };
|
||||
return {{b[7], b[8], b[9]}, word(0x48), word(0x4a), word(0x4c)};
|
||||
}
|
||||
void increment(uint64_t& n) {
|
||||
if (n == std::numeric_limits<uint64_t>::max()) throw FormatError("long career: statistics counter exhausted");
|
||||
++n;
|
||||
}
|
||||
void put(Bytes& b, uint64_t n, int width) { for (int i = 0; i < width; ++i) b.push_back(uint8_t(n >> (i * 8))); }
|
||||
struct Reader {
|
||||
const Bytes& bytes; size_t pos = 0;
|
||||
uint64_t get(int width) {
|
||||
if (size_t(width) > bytes.size() - pos) throw FormatError("long career: truncated extension");
|
||||
uint64_t n = 0; for (int i = 0; i < width; ++i) n |= uint64_t(bytes[pos++]) << (i * 8); return n;
|
||||
}
|
||||
std::string string() {
|
||||
const size_t size = size_t(get(2));
|
||||
if (size > bytes.size() - pos) throw FormatError("long career: truncated title name");
|
||||
std::string s(bytes.begin() + pos, bytes.begin() + pos + size); pos += size; return s;
|
||||
}
|
||||
};
|
||||
}
|
||||
PlayerClubStatistics player_club_statistics(const GameState& g, int team, int player,
|
||||
const std::array<uint8_t, 0x58>& board) {
|
||||
const auto found = g.player_statistics.find(key(team, player));
|
||||
return found == g.player_statistics.end() ? legacy(board) : found->second;
|
||||
}
|
||||
void record_player_statistics(GameState& g, int manager, int row, int player, int cls, int kind) {
|
||||
const size_t at = size_t(manager) * 0x840 + size_t(row) * 0x58;
|
||||
if (manager < 0 || row < 0 || row >= 24 || at + 0x58 > g.tactics.size() || cls < 0 || cls > 3 || kind < 0 || kind > 2)
|
||||
throw FormatError("long career: invalid statistics row/event");
|
||||
std::array<uint8_t, 0x58> board; std::copy_n(g.tactics.begin() + at, board.size(), board.begin());
|
||||
const auto identity = key(manager_team(g, manager), player);
|
||||
auto [found, inserted] = g.player_statistics.try_emplace(identity, legacy(board));
|
||||
auto next = found->second;
|
||||
if (kind == 0) { if (cls < 3) increment(next.appearances[size_t(cls)]); increment(next.total); }
|
||||
else if (kind == 1) increment(next.goals);
|
||||
else increment(next.assists);
|
||||
found->second = next;
|
||||
}
|
||||
void reset_player_statistics(GameState& g, int manager, int player) {
|
||||
g.player_statistics.erase(key(manager_team(g, manager), player));
|
||||
}
|
||||
void swap_statistics_clubs(GameState& g, int first, int second) {
|
||||
PlayerStatisticsArchive next;
|
||||
for (const auto& [identity, value] : g.player_statistics) {
|
||||
const int club = int(identity >> 12), player = int(identity & 0xfff);
|
||||
next.emplace(key(club == first ? second : club == second ? first : club, player), value);
|
||||
}
|
||||
g.player_statistics = std::move(next);
|
||||
}
|
||||
TitleHistoryArchive title_history_rows(const GameState& g) {
|
||||
if (g.season < 0) throw FormatError("long career: negative season index");
|
||||
auto rows = g.title_history;
|
||||
if (!g.memory.has(layout::Titles + 899)) return rows;
|
||||
const int first = std::max(0, g.season - 49);
|
||||
for (int slot = 0; slot < 50 && first + slot <= g.season; ++slot) {
|
||||
const auto season = uint32_t(first + slot);
|
||||
if (rows.contains(season)) continue;
|
||||
std::array<std::string, 9> winners;
|
||||
for (size_t category = 0; category < 9; ++category) {
|
||||
const auto team = g.memory.u16(layout::Titles + uint32_t(category) * 100 + uint32_t(slot) * 2);
|
||||
if (team != 0xffff) winners[category] = g.club_name(team);
|
||||
}
|
||||
rows.emplace(season, std::move(winners));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
void capture_title_history(GameState& g) { g.title_history = title_history_rows(g); }
|
||||
void record_title_holder(GameState& g, int category, uint16_t winner) {
|
||||
if (category < 0 || category >= 9 || g.season < 0 || winner >= g.club_ids.size())
|
||||
throw FormatError("long career: invalid title award");
|
||||
capture_title_history(g);
|
||||
const auto name = g.club_name(winner);
|
||||
g.memory.set16(layout::Titles + uint32_t(category) * 100 + uint32_t(std::min(g.season, 49)) * 2, winner);
|
||||
g.title_history[uint32_t(g.season)][size_t(category)] = name;
|
||||
}
|
||||
void shift_legacy_title_history(GameState& g) {
|
||||
if (g.season <= 49) return;
|
||||
for (uint32_t category = 0; category < 9; ++category) {
|
||||
for (uint32_t i = 0; i < 98; ++i)
|
||||
g.memory.set8(layout::Titles + category * 100 + i,
|
||||
g.memory.u8(layout::Season_SeasonEndSteps_RuntimeField + category * 100 + i));
|
||||
g.memory.set16(layout::Season_SeasonEndSteps_RuntimeField2 + category * 100, 0xffff);
|
||||
}
|
||||
}
|
||||
Bytes encode_long_career(const GameState& g) {
|
||||
if (g.player_statistics.empty() && g.title_history.empty()) return {};
|
||||
Bytes b; put(b, 1, 4); put(b, g.player_statistics.size(), 4); put(b, g.title_history.size(), 4);
|
||||
for (const auto& [identity, s] : g.player_statistics) {
|
||||
put(b, identity, 4); for (const auto n : s.appearances) put(b, n, 8);
|
||||
for (const auto n : {s.total, s.goals, s.assists}) put(b, n, 8);
|
||||
}
|
||||
for (const auto& [season, names] : g.title_history) {
|
||||
if (season > 32767) throw FormatError("long career: archived season exceeds native calendar range");
|
||||
put(b, season, 4);
|
||||
for (const auto& name : names) {
|
||||
if (name.size() > UINT16_MAX) throw FormatError("long career: title name too long");
|
||||
put(b, name.size(), 2); b.insert(b.end(), name.begin(), name.end());
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
void decode_long_career(GameState& g, const Bytes& bytes) {
|
||||
Reader r{bytes};
|
||||
if (r.get(4) != 1) throw FormatError("long career: unsupported extension version");
|
||||
const auto players = r.get(4), seasons = r.get(4);
|
||||
if (players > (bytes.size() - r.pos) / 52 || seasons > 32768)
|
||||
throw FormatError("long career: invalid extension counts");
|
||||
PlayerStatisticsArchive stats; TitleHistoryArchive history;
|
||||
for (uint64_t i = 0; i < players; ++i) {
|
||||
const auto identity = uint32_t(r.get(4));
|
||||
if (identity > 0xffffff || (identity & 0xfff) == 0xfff) throw FormatError("long career: invalid archived identity");
|
||||
PlayerClubStatistics s; for (auto& n : s.appearances) n = r.get(8);
|
||||
s.total = r.get(8); s.goals = r.get(8); s.assists = r.get(8);
|
||||
if (!stats.emplace(identity, s).second) throw FormatError("long career: duplicate archived identity");
|
||||
}
|
||||
for (uint64_t i = 0; i < seasons; ++i) {
|
||||
const auto season = uint32_t(r.get(4));
|
||||
if (season > 32767) throw FormatError("long career: invalid archived season");
|
||||
std::array<std::string, 9> names; for (auto& name : names) name = r.string();
|
||||
if (!history.emplace(season, std::move(names)).second) throw FormatError("long career: duplicate archived season");
|
||||
}
|
||||
if (r.pos != bytes.size()) throw FormatError("long career: trailing extension bytes");
|
||||
g.player_statistics = std::move(stats); g.title_history = std::move(history);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "formats/binary.hpp"
|
||||
|
||||
namespace bmh {
|
||||
struct GameState;
|
||||
struct PlayerClubStatistics {
|
||||
std::array<uint64_t, 3> appearances{};
|
||||
uint64_t total = 0, goals = 0, assists = 0;
|
||||
bool operator==(const PlayerClubStatistics&) const = default;
|
||||
};
|
||||
// Optional OBMHEXT1 block, outside the Original guest address space. Payload v1.
|
||||
inline constexpr uint32_t kLongCareerExtension = 0x4f424c43;
|
||||
using PlayerStatisticsArchive = std::map<uint32_t, PlayerClubStatistics>;
|
||||
using TitleHistoryArchive = std::map<uint32_t, std::array<std::string, 9>>;
|
||||
PlayerClubStatistics player_club_statistics(const GameState&, int team, int player,
|
||||
const std::array<uint8_t, 0x58>& board);
|
||||
void record_player_statistics(GameState&, int manager, int row, int player, int competition_class, int kind);
|
||||
void reset_player_statistics(GameState&, int manager, int player);
|
||||
void swap_statistics_clubs(GameState&, int first, int second);
|
||||
TitleHistoryArchive title_history_rows(const GameState&);
|
||||
void capture_title_history(GameState&);
|
||||
void record_title_holder(GameState&, int category, uint16_t winner);
|
||||
void shift_legacy_title_history(GameState&);
|
||||
Bytes encode_long_career(const GameState&);
|
||||
void decode_long_career(GameState&, const Bytes&);
|
||||
}
|
||||
+1
-1
@@ -103,7 +103,7 @@ void rate_side(GameState& g, const MatchSetup& m, int side, int previous6, Watco
|
||||
}
|
||||
}
|
||||
if (side == 0) {
|
||||
int league = team > (kNoTeam - 1) ? 0 : team_league(team); // TeamLeague2
|
||||
int league = team > 0x164 ? 0 : team_league(team); // TeamLeague2
|
||||
int base = kLeagueCrowd[league < 10 ? league : 9] * 1000;
|
||||
if (unsigned(rand.range(base + 3000, base + 6000)) < unsigned(m.spectators)) {
|
||||
// a human manager's side with record +0x289 set suffers more from a full house
|
||||
|
||||
@@ -78,7 +78,7 @@ MinuteReport MatchEngine::minute(int minute, int last_minute, int stoppage) {
|
||||
// Human teams use the places on their tactics board, also for the player's value.
|
||||
int MatchEngine::pick_player(int team, int mode, int exclude, MinuteReport& report, int preset) {
|
||||
mode &= 0x7F; // 0x80 = reuse the squad of the previous call, same team here
|
||||
if (team >= runtime_dimensions.league_teams && team != kNoTeam) return 0xFFF; // clubs without squad: nobody, no draws
|
||||
if (team >= 138 && team != kNoTeam) return 0xFFF; // clubs without squad: nobody, no draws
|
||||
SquadRange range = squad_range(team);
|
||||
if (range.count == 0) return 0xFFF;
|
||||
RatingContext ctx{state.chance_rain, state.chance_temperature};
|
||||
@@ -522,8 +522,8 @@ ForcedMatchEvent MatchEngine::event_impl(MatchGroup& g, int m, int s, int minute
|
||||
// Small-squad teams (id >= 90) only half of the time; teams without squads never. The
|
||||
// national team (0x165, squad nominated on the national team days) only while manager
|
||||
// slot 0 holds it (CupDraw_FormatError_RuntimeField2 == 0x165: a Bundestrainer's match).
|
||||
if (!(team < runtime_dimensions.big_squad_teams || rand.range(0, 1) == 0)) return result;
|
||||
if (!(team < runtime_dimensions.league_teams || team == kNoTeam)) return result;
|
||||
if (!(team < 90 || rand.range(0, 1) == 0)) return result;
|
||||
if (!(team < 138 || team == kNoTeam)) return result;
|
||||
if (team == kNoTeam && (state.manager_teams.empty() || state.manager_teams[0] != kNoTeam)) return result;
|
||||
const int manager = state.manager_of(team); // FindManagerForClub, local_6c
|
||||
const bool human = manager >= 0;
|
||||
@@ -944,7 +944,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
|
||||
}
|
||||
|
||||
// Goalkeeper of the opponent: the player in squad slot 0 if the formation puts it in goal.
|
||||
if (!reality_played && (opp_team < runtime_dimensions.record_teams || opp_team == kNoTeam)) {
|
||||
if (!reality_played && (opp_team < 168 || opp_team == kNoTeam)) {
|
||||
int x = 0, y = 0;
|
||||
state.formation_position(opp_team, 0, x, y);
|
||||
if (x == 0 && y == 4) keeper = state.squad_slots.at(squad_range(opp_team).first) & 0x0FFF;
|
||||
@@ -979,7 +979,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
|
||||
deflected = game.range(0, 5) == 0;
|
||||
}
|
||||
if (kind == 0) {
|
||||
if (team >= runtime_dimensions.record_teams && team != kNoTeam) {
|
||||
if (team >= 168 && team != kNoTeam) {
|
||||
// clubs without squad: the attack rating (TeamRating, profile 3), drawn
|
||||
RatingContext drawn;
|
||||
drawn.rand = &rand;
|
||||
@@ -989,7 +989,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
|
||||
}
|
||||
}
|
||||
if (keeper == 0xFFF) {
|
||||
if (opp_team >= runtime_dimensions.record_teams && opp_team != kNoTeam) {
|
||||
if (opp_team >= 168 && opp_team != kNoTeam) {
|
||||
// clubs without squad: the goalkeeping rating (profile 0), drawn
|
||||
RatingContext drawn;
|
||||
drawn.rand = &rand;
|
||||
@@ -1196,7 +1196,7 @@ void MatchEngine::penalty_shootout(MatchGroup& g, int m, MinuteReport& report) {
|
||||
const int side = order[k];
|
||||
const int team = pair[side];
|
||||
int player = 0xFFF;
|
||||
if (team < runtime_dimensions.league_teams || team == kNoTeam) {
|
||||
if (team < 138 || team == kNoTeam) {
|
||||
// a player who has not taken a penalty yet (after 100 tries the list restarts)
|
||||
int tries = 0;
|
||||
bool fresh;
|
||||
|
||||
+15
-11
@@ -46,7 +46,7 @@ int competition_class(int type) { return type >= 0 && type < 24 ? kCompetitionCl
|
||||
|
||||
// TeamLeague2: league (0-8) of a club id, 9 for clubs outside the leagues.
|
||||
int league_of(int team) {
|
||||
if (team > (kNoTeam - 1)) return 0;
|
||||
if (team > 0x164) return 0;
|
||||
int end = 0;
|
||||
for (int l = 0; l < 9; l++) {
|
||||
end += kLeagueSizes[l];
|
||||
@@ -129,10 +129,10 @@ SportschauFixtureView sportschau_fixture_view(const GameState& state, const Matc
|
||||
if (team >= 0 && size_t(team) * 2 + 1 < state.club_heap_78.size())
|
||||
badge_word = uint16_t(state.club_heap_78[size_t(team) * 2] |
|
||||
uint16_t(state.club_heap_78[size_t(team) * 2 + 1]) << 8);
|
||||
if (team >= 0 && team < runtime_dimensions.record_teams) {
|
||||
if (team >= 0 && team < 0xa8) {
|
||||
requires_font_fit = true;
|
||||
if (state.memory.has(::bmh::layout::ClubShortNameOffsets + uint32_t(team))) {
|
||||
const uint8_t source = state.club_short_offset(team);
|
||||
const uint8_t source = state.memory.u8(::bmh::layout::ClubShortNameOffsets + uint32_t(team));
|
||||
const size_t offset = source >> 4;
|
||||
const size_t length = (source & 0x0f) + 1;
|
||||
if (offset <= full.size()) {
|
||||
@@ -242,6 +242,7 @@ void player_statistic(GameState& g, int type, int player, int manager, int slot,
|
||||
if (cls == 3 && (g.player_bonus.at(player) & 0x7F) < 0x7F) g.player_bonus.at(player)++;
|
||||
if (manager >= 0) {
|
||||
pay_bonus(g, manager, slot, 2, true);
|
||||
record_player_statistics(g, manager, slot, player, cls, kind);
|
||||
if (cls < 3) g.tactics.at(board + 7 + cls)++;
|
||||
wr16(g.tactics, board + 0x48, uint16_t(rd16(g.tactics, board + 0x48) + 1));
|
||||
}
|
||||
@@ -249,13 +250,17 @@ void player_statistic(GameState& g, int type, int player, int manager, int slot,
|
||||
} else if (kind == 1) { // goal
|
||||
if (manager >= 0) {
|
||||
pay_bonus(g, manager, slot, 0, true);
|
||||
record_player_statistics(g, manager, slot, player, cls, kind);
|
||||
wr16(g.tactics, board + 0x4a, uint16_t(rd16(g.tactics, board + 0x4a) + 1));
|
||||
if (cls == 0) g.manager_records.at(size_t(manager) * kManagerRecord + 0x1ae + std::min(minute, 89) / 5)++;
|
||||
}
|
||||
// league goals in bits 2-7 (a 64th goal carries into bit 8, as in the original)
|
||||
if (cls == 0) p.w364 = (w364 & 0xFFFFFF03u) | ((((w364 >> 2) & 0x3F) << 2) + 4);
|
||||
} else if (kind == 2) { // assist
|
||||
if (manager >= 0) wr16(g.tactics, board + 0x4c, uint16_t(rd16(g.tactics, board + 0x4c) + 1));
|
||||
if (manager >= 0) {
|
||||
record_player_statistics(g, manager, slot, player, cls, kind);
|
||||
wr16(g.tactics, board + 0x4c, uint16_t(rd16(g.tactics, board + 0x4c) + 1));
|
||||
}
|
||||
if (cls == 0) p.w368 = (p.w368 & 0xFF03FFFFu) | ((((p.w368 >> 18) & 0x3F) + 1) << 18);
|
||||
}
|
||||
}
|
||||
@@ -302,7 +307,7 @@ void update_club_table(GameState& g, int home, int away, int hg, int ag) {
|
||||
auto add16 = [&](size_t o, int v) { wr16(g.club_table, o, uint16_t(rd16(g.club_table, o) + v)); };
|
||||
// Only the first league and the regional leagues keep points in this table (the
|
||||
// condition tests the home club only).
|
||||
const bool league = home < kLeagueSizes[0] || (home >= 90 && home < runtime_dimensions.league_teams);
|
||||
const bool league = home < kLeagueSizes[0] || (home >= 90 && home < 138);
|
||||
const int win_points = kThreePoints[league_of(home)] ? 3 : 2;
|
||||
if (league) {
|
||||
add16(H + 0x20, hg);
|
||||
@@ -404,7 +409,7 @@ void develop_players(GameState& g, const MatchGroup& grp, int m, GameRandom& gam
|
||||
const int type = grp.desc.at(0);
|
||||
for (int side = 0; side < 2; side++) {
|
||||
const int team = grp.fixtures.at(m * 2 + side);
|
||||
if (!(team < runtime_dimensions.record_teams || team == kNoTeam)) continue;
|
||||
if (!(team < 168 || team == kNoTeam)) continue;
|
||||
const uint8_t cls = (type == 0xb && team == kNoTeam) ? 3 : uint8_t(competition_class(type));
|
||||
const int manager = g.manager_of(team);
|
||||
const SquadRange range = squad_range(team);
|
||||
@@ -586,7 +591,7 @@ bool league_screen_shown(const std::vector<uint8_t>& buttons, int param_1, int p
|
||||
|
||||
|
||||
int table_position(const GameState& g, int team) {
|
||||
if (team >= runtime_dimensions.league_teams) return 2;
|
||||
if (team >= 138) return 2;
|
||||
int league = league_of(team);
|
||||
int rounds = league < int(g.league_rounds.size()) ? g.league_rounds[league] : 0;
|
||||
if (rounds == 0) return -1;
|
||||
@@ -667,8 +672,8 @@ void manager_match_record(GameState& g, const MatchGroup& grp, int m, int home_g
|
||||
rating = std::clamp(int16_t(rating), int16_t(0), int16_t(200));
|
||||
rate_manager(g, int(k), rating, 0);
|
||||
}
|
||||
if (opp < runtime_dimensions.record_teams) {
|
||||
size_t at = k * (runtime_dimensions.record_teams * 10) + size_t(opp) * 10 + (side == 1 ? 5 : 0);
|
||||
if (opp < 0xa8) {
|
||||
size_t at = k * 0x690 + size_t(opp) * 10 + (side == 1 ? 5 : 0);
|
||||
std::copy_backward(g.manager_results.begin() + at, g.manager_results.begin() + at + 4,
|
||||
g.manager_results.begin() + at + 5);
|
||||
g.manager_results.at(at) = uint8_t(own + (against << 4));
|
||||
@@ -717,7 +722,6 @@ void advance_league_rounds(GameState& g, uint32_t competitions, WatcomRandom& ra
|
||||
const int end = bit < 4 ? bit + 1 : 8;
|
||||
for (int c = bit; c < end; c++) {
|
||||
for (int league = kFirst[c]; league < kFirst[c] + kCount[c]; league++) {
|
||||
if (runtime_dimensions.expanded && g.league_rounds.at(size_t(league)) >= 2 * (kLeagueSizes[league] - 1)) continue;
|
||||
if (league == 0) {
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++) {
|
||||
advance_youth_teams(g, int(m), rand);
|
||||
@@ -777,7 +781,7 @@ void advance_league_rounds(GameState& g, uint32_t competitions, WatcomRandom& ra
|
||||
if (g.memory.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && winner)
|
||||
winner(g, {0, uint16_t(champion)});
|
||||
if (g.memory.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && g.memory.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2)) g.memory.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2, 0);
|
||||
g.memory.set16(::bmh::layout::Titles + uint32_t(std::min<int>(g.season, 0x31)) * 2, uint16_t(champion));
|
||||
record_title_holder(g, 0, uint16_t(champion));
|
||||
const int manager = g.manager_of(champion);
|
||||
if (manager >= 0) {
|
||||
const size_t at = size_t(manager) * kManagerRecord + 0x8a4;
|
||||
|
||||
@@ -35,9 +35,9 @@ constexpr uint8_t kCompetitionClass[24] = {0, 1, 2, 2, 2, 3, 3, 3, 3, 255, 0, 25
|
||||
// Crowd interest per descriptor type (MatchdaySetupRuntimeField).
|
||||
constexpr uint8_t kTypeInterest[24] = {5, 5, 10, 15, 12, 10, 5, 10, 5, 10, 5, 31, 10, 10, 10, 0, 0, 1, 0, 0, 0, 12, 0, 0};
|
||||
// Number of clubs taking part in league play (CareerSession_DispatchLineup_RuntimeField).
|
||||
const int& kLeagueClubCount = runtime_dimensions.league_teams;
|
||||
constexpr int kLeagueClubCount = 0x8a;
|
||||
// Squad slots checked by the driver (CareerRuntimeField).
|
||||
const int& kSquadSlotCount = runtime_dimensions.pool_first;
|
||||
constexpr size_t kSquadSlotCount = 0xb70;
|
||||
|
||||
// The attendance tables MatchdaySetup_Attendance_ExecutableField .. MatchdaySetupRuntimeField2 as one block, because the original
|
||||
// indexes them with league classes 0-7 although they only have four entries: classes 4-7
|
||||
@@ -76,7 +76,7 @@ void wr16(Bytes& b, size_t o, uint16_t v) { b.at(o) = uint8_t(v), b.at(o + 1) =
|
||||
|
||||
// TeamLeague2: league of a club, 0 for the special ids above 0x164, 9 outside the leagues.
|
||||
int league_of(int team) {
|
||||
if (team > (kNoTeam - 1)) return 0;
|
||||
if (team > 0x164) return 0;
|
||||
return team_league(team);
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ void indoor_tournament_draw(GameState& g, GameRandom& game, WatcomRandom& rand)
|
||||
indoor_tournament_reset(g);
|
||||
uint8_t attempts = 0;
|
||||
const int guest = rand.range(0, 1);
|
||||
if (guest != 0) mem.set16(kTeams, uint16_t(rand.range(runtime_dimensions.domestic_teams, runtime_dimensions.league_teams - 1)));
|
||||
if (guest != 0) mem.set16(kTeams, uint16_t(rand.range(90, 137)));
|
||||
int count = guest != 0;
|
||||
int n = rand.range(5, 7);
|
||||
uint8_t lo = 0, hi = uint8_t(kLeagueSizes[0]);
|
||||
@@ -431,7 +431,7 @@ void indoor_tournament_draw(GameState& g, GameRandom& game, WatcomRandom& rand)
|
||||
int sum = 0; // IndoorTournamentReset
|
||||
for (uint32_t k = 0; k < 8; k++) {
|
||||
const int t = mem.u16(kTeams + k * 2);
|
||||
const int league = t > (kNoTeam - 1) ? 0 : team_league(t); // TeamLeague2
|
||||
const int league = t > 0x164 ? 0 : team_league(t); // TeamLeague2
|
||||
if (league < 2) sum += (0x26 - table_position(g, t)) - kLeagueSizes[0] * league;
|
||||
else if (league < 5) sum += 1;
|
||||
else sum += 0x19;
|
||||
@@ -563,7 +563,6 @@ std::vector<MatchGroup> setup_matchday(GameState& g, uint32_t competitions, cons
|
||||
for (int k = from; k < to; k++) {
|
||||
// FixturesFromGenerateFixtures(k)
|
||||
for (int league = kGroupLeague[k]; league < kGroupLeague[k] + kGroupLeagues[k]; league++) {
|
||||
if (runtime_dimensions.expanded && g.league_rounds.at(size_t(league)) >= 2 * (kLeagueSizes[league] - 1)) continue;
|
||||
turn_step = "setup: winter postponements";
|
||||
winter_postponements(g, ctx.season_day, league, game, rand);
|
||||
const int round = g.league_rounds.at(size_t(league));
|
||||
@@ -887,7 +886,7 @@ bool select_live_match(GameState& g, int home, int away) {
|
||||
// record +0x8ac / 16 + 40.
|
||||
void man_marking(GameState& g, int own_manager, int own, int other_manager, int other, int chance, int rate,
|
||||
WatcomRandom& rand) {
|
||||
const int kLeagueTeams = runtime_dimensions.league_teams; // CareerSession_DispatchLineup_RuntimeField
|
||||
constexpr int kLeagueTeams = 138; // CareerSession_DispatchLineup_RuntimeField
|
||||
if (g.indoor || own >= kLeagueTeams || other >= kLeagueTeams || (own_manager < 0 && other_manager < 0)) return;
|
||||
if (other_manager >= 0)
|
||||
for (size_t s = 0; s < 24; s++) {
|
||||
|
||||
+1
-10
@@ -20,7 +20,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "formats/savestate.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -35,15 +34,7 @@ public:
|
||||
explicit StaticMemory(const SaveState& save) {
|
||||
for (const SaveBlock& b : save.blocks())
|
||||
if (!b.heap && b.size != 0 && !blocks_.count(b.address))
|
||||
{
|
||||
// Expanded tails live in typed GameState vectors. Keep guest
|
||||
// memory at Original extents to avoid aliasing adjacent globals.
|
||||
size_t size = b.size;
|
||||
if (b.address == layout::ClubKitSelectors) size = std::min(size, size_t(419));
|
||||
if (b.address == layout::ClubShortNameOffsets) size = std::min(size, size_t(168));
|
||||
if (b.address == layout::ManagerMatchHistory) size = std::min(size, size_t(8400));
|
||||
blocks_[b.address].assign(save.stream().begin() + b.offset, save.stream().begin() + b.offset + size);
|
||||
}
|
||||
blocks_[b.address].assign(save.stream().begin() + b.offset, save.stream().begin() + b.offset + b.size);
|
||||
}
|
||||
|
||||
// A global the savegame does not store (e.g. a work list the original rebuilds before
|
||||
|
||||
+44
-9
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -113,13 +114,8 @@ std::string message_text_following(const GameState& g, uint32_t pointer_variable
|
||||
return text;
|
||||
}
|
||||
|
||||
std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
if (flags & 0x100) {
|
||||
// ConvertCurrency: currency conversion (1/1 unless the savegame says otherwise)
|
||||
const int32_t mul = g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1;
|
||||
const int32_t div = g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1;
|
||||
if (div != 0) value = value * mul / div;
|
||||
}
|
||||
namespace {
|
||||
std::string format_number_digits(const GameState& g, int64_t value, int flags) {
|
||||
// FormatGroupedDigits: digits from the right; with grouping (bit 0x40 clear) a dot before the
|
||||
// 4th, 8th and 12th character; padded to the width (bits 0-5), leading blanks for the
|
||||
// dots a wide field reserves
|
||||
@@ -127,12 +123,12 @@ std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
const int width = flags & 0x3F;
|
||||
int blanks = group && width > 3 ? (width - 4) / 3 + 1 : 0;
|
||||
const bool negative = value < 0;
|
||||
uint32_t v = negative ? uint32_t(-int64_t(value)) : uint32_t(value);
|
||||
uint64_t v = negative ? uint64_t(-(value + 1)) + 1 : uint64_t(value);
|
||||
std::string reversed;
|
||||
int dots = 0;
|
||||
while (v != 0) {
|
||||
const size_t n = reversed.size();
|
||||
if (group && (n == 3 || n == 7 || n == 11)) reversed.push_back('.'), blanks--, dots++;
|
||||
if (group && n % 4 == 3) reversed.push_back('.'), blanks--, dots++;
|
||||
reversed.push_back(char('0' + v % 10));
|
||||
v /= 10;
|
||||
}
|
||||
@@ -149,6 +145,45 @@ std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
if (flags & 0x100) {
|
||||
// ConvertCurrency: currency conversion (1/1 unless the savegame says otherwise)
|
||||
const int32_t mul = g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1;
|
||||
const int32_t div = g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1;
|
||||
if (div != 0) value = value * mul / div;
|
||||
}
|
||||
return format_number_digits(g, value, flags);
|
||||
}
|
||||
|
||||
std::string format_number_wide(const GameState& g, int64_t value, int flags) {
|
||||
if (flags & 0x100) {
|
||||
const int32_t mul = g.memory.has(layout::CurrencyMultiplier) ? int32_t(g.memory.u32(layout::CurrencyMultiplier)) : 1;
|
||||
const int32_t div = g.memory.has(layout::CurrencyDivisor) ? int32_t(g.memory.u32(layout::CurrencyDivisor)) : 1;
|
||||
if (div != 0) {
|
||||
const bool negative = (value < 0) != ((mul < 0) != (div < 0));
|
||||
const uint64_t magnitude = value < 0 ? uint64_t(-(value + 1)) + 1 : uint64_t(value);
|
||||
const uint64_t multiplier = mul < 0 ? uint64_t(-int64_t(mul)) : uint64_t(mul);
|
||||
const uint64_t divisor = div < 0 ? uint64_t(-int64_t(div)) : uint64_t(div);
|
||||
const uint64_t limit = uint64_t(std::numeric_limits<int64_t>::max()) + uint64_t(negative);
|
||||
// Split before multiplication, keeping exact truncation without
|
||||
// requiring nonportable 128-bit integers for currency conversion.
|
||||
const uint64_t whole = magnitude / divisor;
|
||||
if (multiplier && whole > limit / multiplier)
|
||||
throw FormatError("wide currency amount exceeds display range");
|
||||
const uint64_t base = whole * multiplier;
|
||||
const uint64_t fraction = (magnitude % divisor) * multiplier / divisor;
|
||||
if (fraction > limit - base)
|
||||
throw FormatError("wide currency amount exceeds display range");
|
||||
const uint64_t converted = base + fraction;
|
||||
value = negative ? (converted == uint64_t(std::numeric_limits<int64_t>::max()) + 1
|
||||
? std::numeric_limits<int64_t>::min() : -int64_t(converted)) : int64_t(converted);
|
||||
}
|
||||
}
|
||||
return format_number_digits(g, value, flags);
|
||||
}
|
||||
|
||||
std::string format_amount(const GameState& g, int32_t value) { return format_number(g, value, 0x101); }
|
||||
|
||||
void install_message_texts(const LeImage& exe) {
|
||||
|
||||
@@ -72,5 +72,7 @@ std::string format_amount(const GameState& g, int32_t value);
|
||||
// FormatNumber(buf, value, flags, ""): bits 0-5 the field width, bit 0x40 no dot grouping,
|
||||
// bit 0x100 an amount of money (converted, " EU" appended).
|
||||
std::string format_number(const GameState& g, int32_t value, int flags);
|
||||
// Read-only aggregates can exceed a native save word; preserve currency and padding.
|
||||
std::string format_number_wide(const GameState& g, int64_t value, int flags);
|
||||
|
||||
} // namespace bmh
|
||||
+22
-15
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <optional>
|
||||
@@ -30,12 +31,12 @@ constexpr size_t kBoard = 0x840; // tactics board of a manager
|
||||
constexpr size_t kBoardSlot = 0x58;
|
||||
constexpr uint32_t kTransferList = ::bmh::layout::EditorList;
|
||||
constexpr uint32_t kListEntry = 0x58;
|
||||
const int& kPoolFirst = runtime_dimensions.pool_first; // CareerRuntimeField: the transfer list (40 slots + 4)
|
||||
const int& kFreeAgents = runtime_dimensions.free_first; // CareerRuntimeField2: free agents (80 slots)
|
||||
const int& kForeignAgents = runtime_dimensions.foreign_free_first; // MonthRuntimeField: foreign free agents (20 slots)
|
||||
const int& kPoolEnd = runtime_dimensions.national_slots_first; // LargeSquadClubCount
|
||||
const int& kBigSquadClubs = runtime_dimensions.big_squad_teams; // TeamsWithSquads
|
||||
const int& kLeagueClubs = runtime_dimensions.league_teams; // CareerSession_DispatchLineup_RuntimeField
|
||||
constexpr int kPoolFirst = 0xb70; // CareerRuntimeField: the transfer list (40 slots + 4)
|
||||
constexpr int kFreeAgents = 0xb9c; // CareerRuntimeField2: free agents (80 slots)
|
||||
constexpr int kForeignAgents = 0xbec; // MonthRuntimeField: foreign free agents (20 slots)
|
||||
constexpr int kPoolEnd = 0xc00; // LargeSquadClubCount
|
||||
constexpr int kBigSquadClubs = 90; // TeamsWithSquads
|
||||
constexpr int kLeagueClubs = 0x8a; // CareerSession_DispatchLineup_RuntimeField
|
||||
|
||||
// MonthRuntimeField2: development steps by strength / 10; the ten bytes after it (PlayerCard_PlayerCardMarketValue_RuntimeField)
|
||||
// are the extra value above 500 points.
|
||||
@@ -162,8 +163,8 @@ bool in_pseudo_squad(const GameState& g, int slot) {
|
||||
void list_club_player(GameState& g, int first, int last, WatcomRandom& rand, MinuteReport& report) {
|
||||
const int8_t* wanted = first < kBigSquadClubs ? kWantedBig : kWantedSmall; // Attempt
|
||||
for (;;) {
|
||||
std::vector<int16_t> teams(size_t(kLeagueClubs), 0);
|
||||
std::vector<uint32_t> keys(size_t(kLeagueClubs), 0);
|
||||
int16_t teams[138];
|
||||
uint32_t keys[138];
|
||||
int n = 0; // local_14
|
||||
g.list_toggle = g.list_toggle + 1 == 2 ? 0 : g.list_toggle + 1;
|
||||
int best_line = 0; // local_1c, keeps its value between the clubs
|
||||
@@ -207,10 +208,10 @@ void list_club_player(GameState& g, int first, int last, WatcomRandom& rand, Min
|
||||
n++;
|
||||
}
|
||||
}
|
||||
int pick = runtime_dimensions.league_teams; // sVar11
|
||||
int pick = 0x8a; // sVar11
|
||||
int slot = -1; // unaff_EDI: the slot tried last
|
||||
if (n != 0) {
|
||||
quicksort_by_key(teams.data(), keys.data(), n);
|
||||
quicksort_by_key(teams, keys, n);
|
||||
for (pick = 0; pick < n; pick++) {
|
||||
const int team = teams[pick];
|
||||
const SquadRange range = squad_range(team);
|
||||
@@ -229,7 +230,7 @@ void list_club_player(GameState& g, int first, int last, WatcomRandom& rand, Min
|
||||
}
|
||||
// (when no club had a fitting player the slot tried last is listed all the same)
|
||||
}
|
||||
if (pick < runtime_dimensions.league_teams) {
|
||||
if (pick < 0x8a) {
|
||||
list_player(g, slot, rand, report);
|
||||
return;
|
||||
}
|
||||
@@ -654,7 +655,7 @@ void board_month(GameState& g, int m, WatcomRandom& rand, MinuteReport& report,
|
||||
for (int s = 0; s < 24; s++) g.tactics.at(board(s) + 0xb) &= 0x7F;
|
||||
}
|
||||
|
||||
// MonthChange2: share prices grow by 2.5 %, dividends, loans between the managers.
|
||||
// MonthChange2: share prices grow by 0.25 %, dividends, loans between the managers.
|
||||
void shares_and_loans(GameState& g) {
|
||||
StaticMemory& mem = g.memory;
|
||||
std::vector<uint8_t>& r = g.manager_records;
|
||||
@@ -665,12 +666,16 @@ void shares_and_loans(GameState& g) {
|
||||
uint32_t price = mem.u32(at);
|
||||
price += ((price / 10000) * 0x19 / 10) * 10;
|
||||
mem.set32(at, price);
|
||||
// OpenBMH deviates from the original: keep the price product in 64 bits
|
||||
// until division, retaining per-unit truncation and recipient policy.
|
||||
const uint64_t unit_dividend = (uint64_t(price) * uint32_t(kShareFactor[k])) / 10000;
|
||||
// (a bug of the original: only the last manager's dividend is kept and it is booked
|
||||
// for the manager after the last one)
|
||||
int32_t dividend = 0;
|
||||
for (int m = 0; m < managers; m++)
|
||||
dividend = int32_t(mem.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c) *
|
||||
((price * uint32_t(kShareFactor[k])) / 10000));
|
||||
dividend = std::bit_cast<int32_t>(uint32_t(
|
||||
mem.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c) *
|
||||
unit_dividend));
|
||||
book_money(g, managers, -dividend, true);
|
||||
add32(r, size_t(managers) * kRecord + 0x870, dividend);
|
||||
}
|
||||
@@ -694,6 +699,8 @@ void shares_and_loans(GameState& g) {
|
||||
|
||||
} // namespace
|
||||
|
||||
void monthly_shares_and_loans(GameState& g) { shares_and_loans(g); }
|
||||
|
||||
bool list_transfer_player(GameState& g, int slot, WatcomRandom& rand, MinuteReport& report) {
|
||||
return list_player(g, slot, rand, report);
|
||||
}
|
||||
@@ -989,7 +996,7 @@ void month_change(GameState& g, WatcomRandom& rand, MinuteReport& report, GameRa
|
||||
if (report.unsupported) return;
|
||||
// 5. shares and loans
|
||||
turn_step = "month_change: shares";
|
||||
shares_and_loans(g);
|
||||
monthly_shares_and_loans(g);
|
||||
}
|
||||
|
||||
} // namespace bmh
|
||||
@@ -28,6 +28,9 @@ namespace bmh {
|
||||
// `game` is needed when a player leaves at the end of his contract (MonthChange).
|
||||
void month_change(GameState& g, WatcomRandom& rand, MinuteReport& report, GameRandom* game = nullptr);
|
||||
|
||||
// The investment/loan phase, retaining the original dividend recipient policy.
|
||||
void monthly_shares_and_loans(GameState& g);
|
||||
|
||||
// CareerFirstSteps: new players on the transfer list (part of the month change; also at the
|
||||
// start of a season).
|
||||
void new_transfer_list_entries(GameState& g, WatcomRandom& rand, MinuteReport& report);
|
||||
|
||||
@@ -19,7 +19,7 @@ constexpr size_t kBoard = 0x840; // one manager's tactics board (24 x 0
|
||||
constexpr size_t kBoardSlot = 0x58;
|
||||
constexpr uint32_t kDesktops = ::bmh::layout::Desktops; // desktop layouts, 0x360 per manager slot
|
||||
constexpr size_t kDesktop = 0x360;
|
||||
const int& kPoolSlots = runtime_dimensions.pool_first; // CareerRuntimeField: the clubs' squads end here
|
||||
constexpr size_t kPoolSlots = 0xb70; // CareerRuntimeField: the clubs' squads end here
|
||||
constexpr uint8_t kNominated[4] = {3, 5, 7, 5}; // NationalRuntimeField: keepers, defence, midfield, attack
|
||||
|
||||
// the manager's team (record +0x290) as the port caches it
|
||||
@@ -74,6 +74,11 @@ void new_board_entry(GameState& g, int manager, int index, int slot, WatcomRando
|
||||
uint8_t* e = &g.tactics.at(size_t(manager) * kBoard + size_t(index) * kBoardSlot);
|
||||
std::memset(e + 7, 0, 3);
|
||||
std::memset(e + 0x19, 0, 0x24);
|
||||
// OpenBMH deviates from the original: a new arrival must not inherit the
|
||||
// previous occupant's retirement/refusal/month-processing flags.
|
||||
e[0xb] = 0;
|
||||
std::memset(e + 0x48, 0, 6); // Fresh arrivals do not inherit the previous player's totals.
|
||||
reset_player_statistics(g, manager, g.squad_slots.at(size_t(slot)) & 0xfff);
|
||||
e[10] = 2;
|
||||
for (int k = 0; k < 4; k++) e[2 + k] = index < 2 ? 1 : uint8_t(rand.range(2, 0x27));
|
||||
e[0x3f] = 0xff;
|
||||
|
||||
@@ -156,13 +156,13 @@ OtherGamesClubMetadata source_metadata(const GameState& game, int team) {
|
||||
uint16_t(game.manager_records[kNationalOriginalClub + 1]) << 8));
|
||||
manager_owned = original_club == team;
|
||||
}
|
||||
if (team >= runtime_dimensions.record_teams && !manager_owned) {
|
||||
const size_t at = size_t(team - runtime_dimensions.record_teams);
|
||||
if (team >= 168 && !manager_owned) {
|
||||
const size_t at = size_t(team - 168);
|
||||
if (at >= game.foreign_strength.size()) invalid("missing Source foreign-strength byte");
|
||||
out.foreign_strength = game.foreign_strength[at];
|
||||
return out;
|
||||
}
|
||||
if (team >= runtime_dimensions.record_teams && team != kNoTeam)
|
||||
if (team >= 168 && team != kNoTeam)
|
||||
invalid("manager-controlled foreign-club row needs live TeamRating W-generator context");
|
||||
constexpr std::array<uint16_t, 5> kFlags{0x0f1, 0x0f2, 0x0f4, 0x0f8, 0x0ff};
|
||||
for (size_t i = 0; i < kFlags.size(); ++i)
|
||||
|
||||
+2
-2
@@ -16,9 +16,9 @@ constexpr size_t kRecordSize = 0xb0c;
|
||||
constexpr size_t kAttempts = 0x8b6; // five player ids, 0xffff free
|
||||
constexpr uint32_t kTransferList = ::bmh::layout::EditorList; // 44 rows of 0x58 bytes
|
||||
constexpr uint32_t kListRow = 0x58;
|
||||
const int& kPoolFirst = runtime_dimensions.pool_first; // CareerRuntimeField: squad slot of list row 0
|
||||
constexpr size_t kPoolFirst = 0xb70; // CareerRuntimeField: squad slot of list row 0
|
||||
constexpr uint32_t kOfferSlots = ::bmh::layout::OfferSlots; // OfferSlots: 4 words, -1 free
|
||||
const int& kBigSquadClubs = runtime_dimensions.big_squad_teams; // TeamsWithSquads
|
||||
constexpr int kBigSquadClubs = 90; // TeamsWithSquads
|
||||
// Attempt: how many players of each position a club wants (MonthRuntimeField4 / MonthRuntimeField5)
|
||||
constexpr int8_t kWantedBig[4] = {2, 6, 7, 5}, kWantedSmall[4] = {2, 4, 5, 4};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ constexpr size_t kBoardSlot = 0x58; // one slot of the board
|
||||
// Static league tables of V2.24 (not part of the savegame):
|
||||
// (European places per league, CareerSession_InstallLeagueSizes_RuntimeField, are kLeagueEurope of the loaded game; league 0 uses 4)
|
||||
// (the relegation places per league, CareerSession_InstallLeagueSizes_RuntimeField2, are kLeagueRelegation of the loaded game)
|
||||
const int& kLeagueTeams = runtime_dimensions.league_teams; // CareerSession_DispatchLineup_RuntimeField: clubs in the league system
|
||||
constexpr int kLeagueTeams = 138; // CareerSession_DispatchLineup_RuntimeField: clubs in the league system
|
||||
|
||||
// Text of a pointer variable of the text table TextPointerTable.
|
||||
} // namespace
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/profile_runtime.hpp"
|
||||
#include "formats/data_profile.hpp"
|
||||
namespace bmh {
|
||||
void install_runtime_profile(const DataProfile& profile) {
|
||||
profile.validate();
|
||||
RuntimeDimensions next;
|
||||
next.league_teams=int(profile.counts.league_teams);
|
||||
next.cup_teams=int(profile.counts.cup_teams);
|
||||
next.big_squad_teams=int(profile.big_squad_teams);
|
||||
next.record_teams=int(profile.counts.n42);
|
||||
next.national_first=int(profile.national_first);
|
||||
next.pool_first=int(profile.pool_first());
|
||||
next.market_special_first=next.pool_first+40;
|
||||
next.free_first=next.pool_first+44;
|
||||
next.foreign_free_first=next.pool_first+124;
|
||||
next.national_slots_first=int(profile.national_slots_first());
|
||||
next.extra_slots_first=int(profile.extra_slots_first());
|
||||
next.total_slots=int(profile.total_slots());
|
||||
next.expanded=profile.extended();
|
||||
runtime_dimensions=next;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
namespace bmh {
|
||||
struct DataProfile;
|
||||
// Explicitly distinct concepts: German clubs, league clubs and large rosters.
|
||||
// One installation is active per process, like the existing fixture/rule tables.
|
||||
struct RuntimeDimensions {
|
||||
int domestic_teams=90, league_teams=138, cup_teams=30, big_squad_teams=90;
|
||||
int record_teams=168;
|
||||
int national_first=357, pool_first=2928, market_special_first=2968;
|
||||
int free_first=2972, foreign_free_first=3052, national_slots_first=3072;
|
||||
int extra_slots_first=3096, total_slots=3150;
|
||||
bool expanded=false;
|
||||
};
|
||||
inline RuntimeDimensions runtime_dimensions{};
|
||||
void install_runtime_profile(const DataProfile& profile);
|
||||
}
|
||||
+2
-2
@@ -121,7 +121,7 @@ int human_correction(GameState& g, RatingContext& ctx, int manager, int rank, in
|
||||
} // namespace
|
||||
|
||||
int team_rating(GameState& g, int team, const RatingProfile& profile, RatingContext& ctx, int* keeper) {
|
||||
if (team >= runtime_dimensions.record_teams && team != kNoTeam) {
|
||||
if (team >= 168 && team != kNoTeam) {
|
||||
// Clubs without squad: per group a random value around the level of the club
|
||||
// (ForeignClubStrength bits 5-7 -> RatingRuntimeField2), +2 if the group's strength bit is set
|
||||
// (bit 3, 3, 2, 1 for goal, defence, midfield, attack: RatingRuntimeField3) and a style
|
||||
@@ -130,7 +130,7 @@ int team_rating(GameState& g, int team, const RatingProfile& profile, RatingCont
|
||||
static const uint8_t kStrongBit[4] = {3, 3, 2, 1};
|
||||
static const int8_t kStyle[8] = {0, 6, 0, -6, 0, -6, 0, 6};
|
||||
if (!ctx.rand) throw std::invalid_argument("team_rating: a team without squad needs the Watcom generator");
|
||||
const uint8_t s = g.foreign_strength.at(size_t(team - runtime_dimensions.record_teams));
|
||||
const uint8_t s = g.foreign_strength.at(size_t(team - 168));
|
||||
int16_t total = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
const int level = kLevel[s >> 5];
|
||||
|
||||
+14
-9
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/bank_robbery.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
@@ -59,7 +60,7 @@ Bytes save_stream(const GameState& live) {
|
||||
const GameState& g = coach ? swapped : live;
|
||||
const bool records = g.memory.has(::bmh::layout::ClubSeasonRecords) && g.memory.u32(::bmh::layout::ClubSeasonRecords) != 0;
|
||||
Bytes stream;
|
||||
for (const SaveBlock& b : save_layout(g.counts, records)) {
|
||||
for (const SaveBlock& b : save_layout(DbCounts{}, records)) {
|
||||
Bytes d(b.size, 0);
|
||||
if (b.heap) {
|
||||
switch (b.address) {
|
||||
@@ -94,12 +95,6 @@ Bytes save_stream(const GameState& live) {
|
||||
// the blocks GameState keeps in typed fields
|
||||
switch (b.address) {
|
||||
case ::bmh::layout::ManagerRecords: put(d, g.manager_records); break;
|
||||
case ::bmh::layout::ClubKitSelectors:
|
||||
if (g.counts.league_teams == 164) put(d, g.club_kits);
|
||||
break;
|
||||
case ::bmh::layout::ClubShortNameOffsets:
|
||||
if (g.counts.league_teams == 164) put(d, g.club_short_offsets);
|
||||
break;
|
||||
case ::bmh::layout::ManagerMatchHistory: put(d, g.manager_results); break;
|
||||
case ::bmh::layout::ManagerRatings: put(d, g.manager_ratings); break;
|
||||
case ::bmh::layout::LeagueResults: put(d, g.results); break;
|
||||
@@ -132,6 +127,16 @@ Bytes save_stream(const GameState& live) {
|
||||
for (uint32_t i = 0; i < size; ++i) bytes[i] = g.memory.u8(at + i);
|
||||
extension.push_back({at, std::move(bytes)});
|
||||
}
|
||||
auto history = encode_long_career(g);
|
||||
if (!history.empty()) extension.push_back({kLongCareerExtension, std::move(history)});
|
||||
if (g.memory.has(kBankRobberyMonthExtension)) {
|
||||
if (!g.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
|
||||
throw FormatError("savegame: truncated bank robbery monthly guard");
|
||||
Bytes months(kBankRobberyMonthBytes);
|
||||
for (uint32_t i = 0; i < months.size(); ++i)
|
||||
months[i] = g.memory.u8(kBankRobberyMonthExtension + i);
|
||||
extension.push_back({kBankRobberyMonthExtension, std::move(months)});
|
||||
}
|
||||
append_save_extension(stream, extension);
|
||||
return stream;
|
||||
}
|
||||
@@ -146,7 +151,7 @@ Bytes save_header(const GameState& g) {
|
||||
for (int m = 0; m < managers && m < 4; m++) {
|
||||
const size_t rec = size_t(m) * 0xb0c;
|
||||
const int team = int16_t(g.manager_records.at(rec + 0x290) | g.manager_records.at(rec + 0x291) << 8);
|
||||
const bool national = team == kNoTeam;
|
||||
const bool national = team == 0x165;
|
||||
const size_t at = size_t(m) * 0x28;
|
||||
list[at] = national ? 0x1e : g.manager_records.at(rec + 0x210); // (0x1e: high byte of the loop word)
|
||||
list[at + 1] = national ? 1 : 0;
|
||||
@@ -162,7 +167,7 @@ Savegame make_savegame(const GameState& g, WatcomRandom& rand) {
|
||||
Savegame s;
|
||||
s.plain_header = save_header(g);
|
||||
s.id1 = 0;
|
||||
s.version = g.counts.league_teams == 164 ? "O1.1" : "V2.24";
|
||||
s.version = "V2.24";
|
||||
const uint32_t hi = uint32_t(rand.range(0, 0x8fff)), lo = uint32_t(rand.range(0, 0x8fff));
|
||||
s.id2 = lo + hi * 0x10000 + 1;
|
||||
s.key = uint8_t(rand.range(0, 0xff) + 'n');
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/schedule.hpp"
|
||||
#include "game/profile_runtime.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
@@ -124,16 +123,16 @@ std::vector<Fixture> generate_fixtures(int teams, int matchday, int rounds, int
|
||||
return out;
|
||||
}
|
||||
|
||||
int league_table_teams(int league) { return runtime_dimensions.expanded ? kLeagueSizes[league] : (league < 5 ? kLeagueSizes[0] : kLeagueSizes[5]); }
|
||||
int league_table_teams(int league) { return league < 5 ? kLeagueSizes[0] : kLeagueSizes[5]; }
|
||||
|
||||
void set_league_sizes(const uint8_t (&sizes)[kLeagueCount]) {
|
||||
int total = 0;
|
||||
for (int l = 0; l < kLeagueCount; l++) total += sizes[l];
|
||||
const auto has_table = [](int teams) { return teams == 20 || teams == 18 || teams == 16 || teams == 12; };
|
||||
if (total != runtime_dimensions.league_teams || !has_table(sizes[0]) || !has_table(sizes[5]))
|
||||
throw std::invalid_argument("league sizes do not match the installed profile and fixture tables");
|
||||
if (total != 138 || !has_table(sizes[0]) || !has_table(sizes[5]))
|
||||
throw std::invalid_argument("league sizes do not describe 138 league teams with fixture tables");
|
||||
for (int l = 0; l < kLeagueCount; l++)
|
||||
if (sizes[l] < 2 || (!runtime_dimensions.expanded && sizes[l] > (l < 5 ? sizes[0] : sizes[5])) || (runtime_dimensions.expanded && !has_table(sizes[l])))
|
||||
if (sizes[l] < 2 || sizes[l] > (l < 5 ? sizes[0] : sizes[5]))
|
||||
throw std::invalid_argument("a league is larger than its fixture table");
|
||||
for (int l = 0; l < kLeagueCount; l++) kLeagueSizes[l] = sizes[l];
|
||||
}
|
||||
|
||||
+30
-38
@@ -28,7 +28,7 @@ namespace {
|
||||
|
||||
constexpr uint32_t kTransferList = ::bmh::layout::EditorList; // 44 entries of 0x58 bytes
|
||||
constexpr uint32_t kListEntry = 0x58;
|
||||
const int& kPoolSlots = runtime_dimensions.pool_first; // CareerRuntimeField
|
||||
constexpr size_t kPoolSlots = 0xb70; // CareerRuntimeField
|
||||
constexpr uint32_t kOffers = ::bmh::layout::OfferSlots; // OfferSlots: 4 offers, -1 = free
|
||||
constexpr size_t kBoard = 0x840; // tactics board of a manager
|
||||
constexpr size_t kBoardSlot = 0x58;
|
||||
@@ -173,7 +173,7 @@ void club_balance(GameState& g, int team, WatcomRandom& rand) {
|
||||
namespace {
|
||||
|
||||
// TeamLeague2: the league of a club; ids above 0x164 (national teams) count as league 0
|
||||
int club_league(int team) { return team > (kNoTeam - 1) ? 0 : team_league(team); }
|
||||
int club_league(int team) { return team > 0x164 ? 0 : team_league(team); }
|
||||
|
||||
// The European entrants (Career_CompetitionPointersEnglish_ExecutableField25 UEFA Cup, Career_CompetitionPointersEnglish_RuntimeField14 Champions League,
|
||||
// Career_CompetitionPointersEnglish_ExecutableField19 Cup Winners' Cup) and their counts (Career_EuropeanClub_ExecutableField / Career_EuropeanClub_ExecutableField2 / Career_EuropeanClub_ExecutableField3).
|
||||
@@ -279,9 +279,9 @@ void observe_initial_international_groups(GameState& g, WatcomRandom& rand, int
|
||||
for(int position:{fixture.home,fixture.away}) {
|
||||
const int team=mem.u16(teams+uint32_t(position)*2);
|
||||
const bool manager_national=mem.has(::bmh::layout::CupDraw_FormatError_RuntimeField2)&&mem.has(::bmh::layout::CupDraw_FormatError_RuntimeField3)&&
|
||||
mem.u16(::bmh::layout::CupDraw_FormatError_RuntimeField2)==kNoTeam&&mem.u16(::bmh::layout::CupDraw_FormatError_RuntimeField3)==team;
|
||||
mem.u16(::bmh::layout::CupDraw_FormatError_RuntimeField2)==0x165&&mem.u16(::bmh::layout::CupDraw_FormatError_RuntimeField3)==team;
|
||||
const bool human_owned=g.manager_of(team)>=0||manager_national;
|
||||
if(team<runtime_dimensions.record_teams||team==kNoTeam||!human_owned)continue;
|
||||
if(team<168||team==kNoTeam||!human_owned)continue;
|
||||
SeasonCupDrawEvent::GroupAverageSnapshot snapshot;
|
||||
snapshot.runtime_id=uint16_t(team);
|
||||
snapshot.values={team_average(g,team,0x0f1,&rand).value,
|
||||
@@ -320,7 +320,7 @@ void european_setup(GameState& g, GameRandom& game, WatcomRandom& rand, const Se
|
||||
constexpr uint32_t kField0 = ::bmh::layout::Field0;
|
||||
if (!mem.has(kField0)) mem.add_block(kField0, 0x30);
|
||||
const int s = g.season % 4;
|
||||
const int base = 0xbd + runtime_dimensions.league_teams + 0x1e; // ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField3 + CareerSession_DispatchLineup_RuntimeField + CareerSession_InstallLeagueSizes_RuntimeField6
|
||||
const int base = 0xbd + 0x8a + 0x1e; // ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField3 + CareerSession_DispatchLineup_RuntimeField + CareerSession_InstallLeagueSizes_RuntimeField6
|
||||
int n = 1;
|
||||
std::vector<uint16_t> last;
|
||||
if (s % 2 == 0) {
|
||||
@@ -390,7 +390,7 @@ void european_setup(GameState& g, GameRandom& game, WatcomRandom& rand, const Se
|
||||
void european_fields(GameState& g, GameRandom& game, WatcomRandom& rand) {
|
||||
StaticMemory& mem = g.memory;
|
||||
Entrants en{mem};
|
||||
const int pool = runtime_dimensions.league_teams + 0x1e; // CareerSession_DispatchLineup_RuntimeField + CareerSession_InstallLeagueSizes_RuntimeField6: the first foreign club
|
||||
const int pool = 0x8a + 0x1e; // CareerSession_DispatchLineup_RuntimeField + CareerSession_InstallLeagueSizes_RuntimeField6: the first foreign club
|
||||
auto pick = [&](int from) {
|
||||
int t;
|
||||
do t = rand.range(from, from + 6); while (en.find(t) != 0);
|
||||
@@ -759,7 +759,7 @@ void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand,
|
||||
// swaps twice for them (no change), once otherwise.
|
||||
void change_places(GameState& g, int a, int b) {
|
||||
StaticMemory& mem = g.memory;
|
||||
if (a >= runtime_dimensions.league_teams + 0x1e || b >= runtime_dimensions.league_teams + 0x1e) return;
|
||||
if (a >= 0x8a + 0x1e || b >= 0x8a + 0x1e) return;
|
||||
auto swap_bytes = [](std::vector<uint8_t>& v, size_t x, size_t y, size_t n) {
|
||||
for (size_t i = 0; i < n; i++)
|
||||
if (x + i < v.size() && y + i < v.size()) std::swap(v[x + i], v[y + i]);
|
||||
@@ -776,7 +776,7 @@ void change_places(GameState& g, int a, int b) {
|
||||
else if (v == uint16_t(b)) mem.set16(at + uint32_t(i) * 2, uint16_t(a));
|
||||
}
|
||||
};
|
||||
const bool league_clubs = a < runtime_dimensions.league_teams && b < runtime_dimensions.league_teams;
|
||||
const bool league_clubs = a < 0x8a && b < 0x8a;
|
||||
if (league_clubs)
|
||||
for (uint32_t k = 0; k < 200; k++) { // loans: seller and buyer
|
||||
const uint32_t e = mem.u32(::bmh::layout::Career_RemoveJoinLoans_RuntimeField + k * 4);
|
||||
@@ -786,28 +786,22 @@ void change_places(GameState& g, int a, int b) {
|
||||
buyer = buyer == a ? b : buyer == b ? a : buyer;
|
||||
mem.set32(::bmh::layout::Career_RemoveJoinLoans_RuntimeField + k * 4, (e & 0xfff) | uint32_t(seller) << 12 | uint32_t(buyer) << 22);
|
||||
}
|
||||
if (!g.club_table.empty() && a < runtime_dimensions.record_teams && b < runtime_dimensions.record_teams) swap_bytes(g.club_table, size_t(a) * 0x4a, size_t(b) * 0x4a, 0x4a);
|
||||
if (!g.club_table.empty() && a < 0xa8 && b < 0xa8) swap_bytes(g.club_table, size_t(a) * 0x4a, size_t(b) * 0x4a, 0x4a);
|
||||
swap_statistics_clubs(g, a, b);
|
||||
std::swap(g.club_ids.at(size_t(a)), g.club_ids.at(size_t(b)));
|
||||
swap_bytes(g.club_heap_bc, size_t(a) * 2, size_t(b) * 2, 2);
|
||||
std::swap(g.team_morale.at(size_t(a)), g.team_morale.at(size_t(b)));
|
||||
if (runtime_dimensions.expanded) {
|
||||
std::swap(g.club_short_offsets.at(size_t(a)), g.club_short_offsets.at(size_t(b)));
|
||||
std::swap(g.club_kits.at(size_t(a)), g.club_kits.at(size_t(b)));
|
||||
} else {
|
||||
swap_mem8(::bmh::layout::ClubShortNameOffsets);
|
||||
swap_mem8(::bmh::layout::ClubKitSelectors);
|
||||
}
|
||||
swap_mem8(::bmh::layout::ClubShortNameOffsets);
|
||||
swap_mem8(::bmh::layout::ClubKitSelectors);
|
||||
swap_bytes(g.club_heap_78, size_t(a) * 2, size_t(b) * 2, 2);
|
||||
std::swap(g.team_flags.at(size_t(a)), g.team_flags.at(size_t(b)));
|
||||
if (league_clubs) {
|
||||
if (runtime_dimensions.expanded) std::swap(g.club_heap_b8.at(size_t(a)), g.club_heap_b8.at(size_t(b)));
|
||||
else swap_bytes(g.club_heap_b8, size_t(a) * 2, size_t(b) * 2, 2);
|
||||
swap_bytes(g.club_heap_b8, size_t(a) * 2, size_t(b) * 2, 2);
|
||||
swap_bytes(g.position_history, size_t(a) * 0x1a, size_t(b) * 0x1a, 0x1a);
|
||||
const SquadRange ra = squad_range(a), rb = squad_range(b);
|
||||
for (size_t i = 0; i < ra.count; i++) std::swap(g.squad_slots.at(ra.first + i), g.squad_slots.at(rb.first + i));
|
||||
}
|
||||
if (runtime_dimensions.expanded) std::swap(g.club_heap_b8.at(size_t(a)), g.club_heap_b8.at(size_t(b)));
|
||||
else swap_bytes(g.club_heap_b8, size_t(a) * 2, size_t(b) * 2, 2);
|
||||
swap_bytes(g.club_heap_b8, size_t(a) * 2, size_t(b) * 2, 2);
|
||||
replace(::bmh::layout::Titles, 0x1c2); // title holders
|
||||
replace(::bmh::layout::Career_CompetitionPointersEnglish_ExecutableField28, 2);
|
||||
if (!mem.has(::bmh::layout::CareerSession_FormatError_RuntimeField6) || mem.u8(::bmh::layout::CareerSession_FormatError_RuntimeField6) == 0) {
|
||||
@@ -837,7 +831,7 @@ void change_places(GameState& g, int a, int b) {
|
||||
const uint16_t w = v == uint16_t(a) ? uint16_t(b) : v == uint16_t(b) ? uint16_t(a) : v;
|
||||
g.manager_records.at(at) = uint8_t(w), g.manager_records.at(at + 1) = uint8_t(w >> 8);
|
||||
}
|
||||
swap_bytes(g.manager_results, size_t(a) * 10 + m * (runtime_dimensions.record_teams * 10), size_t(b) * 10 + m * (runtime_dimensions.record_teams * 10), 10);
|
||||
swap_bytes(g.manager_results, size_t(a) * 10 + m * 0x690, size_t(b) * 10 + m * 0x690, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1087,7 +1081,7 @@ bool release_player(GameState& g, int slot, GameRandom& game, WatcomRandom& rand
|
||||
}
|
||||
const int team = slot_team(slot);
|
||||
const bool foreign = nationality(g, player) != 0;
|
||||
const int start = foreign ? runtime_dimensions.foreign_free_first : runtime_dimensions.free_first, count = foreign ? 0x14 : 0x50; // FirstFreeSlotSquad
|
||||
const int start = foreign ? 0xbec : 0xb9c, count = foreign ? 0x14 : 0x50; // FirstFreeSlotSquad
|
||||
int free = -1;
|
||||
for (int s = start; s < start + count && free < 0; s++)
|
||||
if (g.squad_slots.at(size_t(s)) == 0x0FFF) free = s;
|
||||
@@ -1175,7 +1169,7 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
|
||||
int8_t owner = -1; // local_24: the club's human manager
|
||||
size_t board_first = 0; // local_3c
|
||||
std::vector<bool> processed(g.players.size(), false);
|
||||
for (int s = 0; s < runtime_dimensions.national_slots_first && !report.unsupported; s++) {
|
||||
for (int s = 0; s < 0xc00 && !report.unsupported; s++) {
|
||||
for (;;) {
|
||||
const int player = g.squad_slots.at(size_t(s)) & 0xFFF;
|
||||
if (player == 0xFFF) break;
|
||||
@@ -1193,7 +1187,7 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
|
||||
}
|
||||
Player& p = g.players.at(size_t(player));
|
||||
bool leaves = false;
|
||||
if (s < runtime_dimensions.pool_first && (p.w35c >> 27) == 0x1f) {
|
||||
if (s < 0xb70 && (p.w35c >> 27) == 0x1f) {
|
||||
// out for his career
|
||||
bool gone = true;
|
||||
if (owner != -1) {
|
||||
@@ -1274,8 +1268,8 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
|
||||
g.lineups_frozen = false;
|
||||
}
|
||||
for (size_t l = 0; l < g.league_rounds.size() && l < 9; l++) g.league_rounds[l] = 0;
|
||||
fill8(::bmh::layout::DeskRecords_Teams_RuntimeField, uint32_t(g.counts.league_teams * 2), 0);
|
||||
for (size_t i = 0; i < size_t(runtime_dimensions.league_teams) * 0x1a && i < g.position_history.size(); i++) g.position_history[i] = 0;
|
||||
fill8(::bmh::layout::DeskRecords_Teams_RuntimeField, 0x114, 0);
|
||||
for (size_t i = 0; i < size_t(0x8a) * 0x1a && i < g.position_history.size(); i++) g.position_history[i] = 0;
|
||||
std::fill(g.results.begin(), g.results.end(), uint8_t(0xcc));
|
||||
}
|
||||
|
||||
@@ -1291,10 +1285,7 @@ SeasonTransitionOutcome season_end_steps(GameState& g, GameRandom& game, WatcomR
|
||||
TransferAllocatorContext allocator) {
|
||||
StaticMemory& mem = g.memory;
|
||||
if (g.season > 0x31) { // SeasonEndSteps
|
||||
for (uint32_t k = 0; k < 9; k++) {
|
||||
for (uint32_t i = 0; i < 0x62; i++) mem.set8(::bmh::layout::Titles + k * 100 + i, mem.u8(::bmh::layout::Season_SeasonEndSteps_RuntimeField + k * 100 + i));
|
||||
mem.set16(::bmh::layout::Season_SeasonEndSteps_RuntimeField2 + k * 100, 0xffff);
|
||||
}
|
||||
shift_legacy_title_history(g);
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++) {
|
||||
for (size_t i = 0; i < 0x93; i++) rec8(g, int(m), 0xda + i) = rec8(g, int(m), 0xdd + i);
|
||||
const size_t at = m * 0xB0C + 0x2aa;
|
||||
@@ -1617,6 +1608,7 @@ SeasonTransitionOutcome season_transition(GameState& g, GameRandom& game, Watcom
|
||||
}
|
||||
g.memory.set8(::bmh::layout::CareerSession_RuntimeError_RuntimeField4, 0);
|
||||
if (g.memory.has(::bmh::layout::Season_SeasonTransition_RuntimeField)) g.memory.set8(::bmh::layout::Season_SeasonTransition_RuntimeField, 0);
|
||||
capture_title_history(g); // Preserve the current window before it advances/shifts.
|
||||
g.season = int16_t(g.season + 1); // SeasonIndex
|
||||
reset_club_moods(g, game, rand);
|
||||
european_setup(g, game, rand, cup_draw);
|
||||
@@ -1661,8 +1653,8 @@ void initialize_european_qualification_seed(GameState& g) {
|
||||
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, kNoTeam);
|
||||
g.memory.set16(entry + 0x24, (kNoTeam + 1));
|
||||
g.memory.set16(entry + 0x22, 357);
|
||||
g.memory.set16(entry + 0x24, 358);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1670,20 +1662,20 @@ bool career_season_setup(GameState& g, GameRandom& game, WatcomRandom& rand, Min
|
||||
const std::function<void(const char*)>& pause,
|
||||
const SeasonCupDrawHook& cup_draw) {
|
||||
StaticMemory& mem = g.memory;
|
||||
g.team_morale.at(kNoTeam) |= 0x80;
|
||||
for (int team = 0; team < runtime_dimensions.league_teams; team++) {
|
||||
g.team_morale.at(0x165) |= 0x80;
|
||||
for (int team = 0; team < 0x8a; team++) {
|
||||
club_balance(g, team, rand);
|
||||
auto_lineup(g, team, g.manager_of(team) >= 0 ? 0xe4 : 100); // (byte 100 - 0x80 for humans)
|
||||
}
|
||||
// the title holders of the cup entries (+0x22): none yet, the placeholder clubs
|
||||
const uint16_t first_small = uint16_t(league_first_team(5)); // TeamsWithSquads
|
||||
const uint16_t foreign = 189 + runtime_dimensions.league_teams + 30; // ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField3 + CareerSession_DispatchLineup_RuntimeField + CareerSession_InstallLeagueSizes_RuntimeField6 (0x165)
|
||||
const uint16_t first_small = 90; // TeamsWithSquads
|
||||
const uint16_t foreign = 189 + 138 + 30; // ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField3 + CareerSession_DispatchLineup_RuntimeField + CareerSession_InstallLeagueSizes_RuntimeField6 (0x165)
|
||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField2, foreign);
|
||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField6, uint16_t(first_small + 7));
|
||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField, 7);
|
||||
if (kEnglishCompetitions) mem.set16(::bmh::layout::CupTable + 28 * 0x28 + 0x22, 7); // (EN: the FA Cup proper, SeasonRuntimeField8)
|
||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField5, uint16_t(league_first_team(7) + 7));
|
||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField4, uint16_t(league_first_team(6) + 7));
|
||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField5, uint16_t(first_small + 0x1f));
|
||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField4, uint16_t(first_small + 0x13));
|
||||
mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField3, uint16_t(foreign + 1));
|
||||
initialize_european_qualification_seed(g);
|
||||
mem.set16(::bmh::layout::Career_CompetitionPointersEnglish_ExecutableField28, 0);
|
||||
|
||||
@@ -25,7 +25,7 @@ std::optional<MatchdayIntroView> matchday_intro_view(const GameState& state,
|
||||
if (league >= 9) throw FormatError("matchday intro: invalid Source league");
|
||||
// LeagueName with TeamStatistics_SourceLeagueName_RuntimeField=1 includes the secondary-league prefix.
|
||||
name = league < 5 ? league_name(state, int(league)) :
|
||||
message_text(state, ::bmh::layout::SportschauAwards_MatchdayIntroView_TextPointer) + state.club_name(kNoTeam + int(league) - 4);
|
||||
message_text(state, ::bmh::layout::SportschauAwards_MatchdayIntroView_TextPointer) + state.club_name(0x165 + int(league) - 4);
|
||||
} else {
|
||||
if (type > 14) throw FormatError("matchday intro: invalid Source competition type");
|
||||
name = message_text(state, ::bmh::layout::DeskState_FormatError_ExecutableField3 + uint32_t(type) * 4);
|
||||
@@ -43,7 +43,7 @@ std::string sportschau_competition_title(const GameState& state, const MatchGrou
|
||||
if (id > 20) index = state.memory.u8(id + 0x18) + 9;
|
||||
else if (index >= 9) index = std::min(index + 12, 19);
|
||||
if (index < 5) return league_name(state, index);
|
||||
if (index < 9) return state.club_name(kNoTeam + index - 4);
|
||||
if (index < 9) return state.club_name(0x165 + index - 4);
|
||||
return message_text(state, ::bmh::layout::CupDraw_FormatError_ExecutableField6 + uint32_t(index - 9) * 4);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "game/stadium_blocks.hpp"
|
||||
|
||||
#include "game/matchday.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
@@ -63,6 +64,32 @@ bool valid_resolved_offer(const StandBlockOffer& offer, const StadiumBlockExpans
|
||||
}
|
||||
} // namespace
|
||||
|
||||
StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage& image) {
|
||||
// OpenBMH deviates from the original: allow 144,000 standard places and
|
||||
// size-aware construction times while retaining edition-owned unit prices.
|
||||
static constexpr std::array<uint32_t, 8> minima{
|
||||
14000, 24000, 14000, 20000, 14000, 24000, 14000, 20000};
|
||||
StadiumBlockExpansionConstants out;
|
||||
uint32_t total = 0;
|
||||
for (size_t i = 0; i < minima.size(); ++i) {
|
||||
out.price_per_1000[i] = image.u32(
|
||||
layout::CareerSession_DispatchStadium_RuntimeField + uint32_t((i + 8) * 4));
|
||||
const auto original = uint32_t(image.u8(
|
||||
layout::CareerSession_Invalid_RuntimeField + uint32_t(i))) * 1000;
|
||||
out.max_places[i] = std::max(original, minima[i]);
|
||||
total += out.max_places[i];
|
||||
const auto source_weeks = image.u8(
|
||||
layout::CareerSession_DispatchStadium_RuntimeField2 + uint32_t((i + 22) * 5));
|
||||
const auto weeks = std::max<uint32_t>(source_weeks, 2 * (out.max_places[i] / 1000));
|
||||
if (weeks > 255)
|
||||
throw FormatError("stadium: expanded construction period exceeds saved byte");
|
||||
out.weeks[i] = uint8_t(weeks);
|
||||
}
|
||||
if (total > 255000)
|
||||
throw FormatError("stadium: combined stand limits exceed saved capacity byte");
|
||||
return out;
|
||||
}
|
||||
|
||||
std::optional<StadiumBlockExpansionQuote> quote_stadium_block_expansion(
|
||||
const GameState& g, int manager, StadiumBlockSlot slot, uint32_t total_target_places,
|
||||
uint8_t desired_features, int company_price_percent,
|
||||
|
||||
@@ -20,6 +20,10 @@ struct StadiumBlockExpansionConstants {
|
||||
std::array<uint32_t, 8> max_places{};
|
||||
};
|
||||
|
||||
// OpenBMH1.0.3 expands standard A-H limits to at least144k total. Prices
|
||||
// still come from the edition; larger blocks have at least2weeks per1000places.
|
||||
StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage&);
|
||||
|
||||
// An immutable quote binds the Source owner and every record/table value that
|
||||
// affects the quote. Commit recomputes this value before it touches money.
|
||||
struct StadiumBlockExpansionQuote {
|
||||
|
||||
+19
-16
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "game/bank_robbery.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -11,9 +12,9 @@ namespace bmh {
|
||||
namespace {
|
||||
|
||||
// Squad table layout constants of V2.24 (TeamsWithSquads, LargeSquadClubCount, NoTeamSquadStart).
|
||||
const int& kBigSquadTeams = runtime_dimensions.big_squad_teams;
|
||||
const int& kNoTeamSquadStart = runtime_dimensions.national_slots_first;
|
||||
const int& kTeamsWithSquads = runtime_dimensions.record_teams;
|
||||
constexpr int kBigSquadTeams = 90;
|
||||
constexpr size_t kNoTeamSquadStart = 3072;
|
||||
constexpr int kTeamsWithSquads = 168;
|
||||
|
||||
// C-style signed division by 8 as compiled by Watcom (rounds toward zero).
|
||||
int div8(int x) { return x / 8; }
|
||||
@@ -21,7 +22,7 @@ int div8(int x) { return x / 8; }
|
||||
} // namespace
|
||||
|
||||
GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
|
||||
GameState g; g.counts=c;
|
||||
GameState g;
|
||||
const SaveBlock& squads = save.block(::bmh::layout::SquadSlots);
|
||||
for (size_t i = 0; i + 1 < squads.size; i += 2)
|
||||
g.squad_slots.push_back(uint16_t(save.data(::bmh::layout::SquadSlots)[i] | save.data(::bmh::layout::SquadSlots)[i + 1] << 8));
|
||||
@@ -90,8 +91,6 @@ GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
|
||||
auto bytes = [&](uint32_t address) {
|
||||
return std::vector<uint8_t>(save.data(address), save.data(address) + save.block(address).size);
|
||||
};
|
||||
g.club_kits = bytes(layout::ClubKitSelectors);
|
||||
g.club_short_offsets = bytes(layout::ClubShortNameOffsets);
|
||||
g.manager_results = bytes(::bmh::layout::ManagerMatchHistory);
|
||||
g.manager_ratings = bytes(::bmh::layout::ManagerRatings);
|
||||
g.position_history = bytes(::bmh::layout::LeagueRankHistory);
|
||||
@@ -101,7 +100,16 @@ GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
|
||||
g.foreign_strength = bytes(::bmh::layout::ForeignClubStrength);
|
||||
g.memory = StaticMemory(save);
|
||||
// memory OpenBMH saves behind the trailer (the English cup blocks, career.hpp)
|
||||
for (const auto& b : save.extension()) {
|
||||
bool long_career_seen=false,robbery_months_seen=false;
|
||||
for(const auto& b:save.extension()){
|
||||
if(b.address==kLongCareerExtension){
|
||||
if(long_career_seen)throw FormatError("long career: duplicate extension block");
|
||||
decode_long_career(g,b.bytes);long_career_seen=true;continue;
|
||||
}
|
||||
if(b.address==kBankRobberyMonthExtension){
|
||||
if(robbery_months_seen||b.bytes.size()!=kBankRobberyMonthBytes)throw FormatError("savegame: invalid or duplicate bank robbery monthly guard");
|
||||
robbery_months_seen=true;
|
||||
}
|
||||
if (!g.memory.has(b.address)) g.memory.add_block(b.address, uint32_t(b.bytes.size()));
|
||||
for (size_t i = 0; i < b.bytes.size(); ++i) g.memory.set8(b.address + uint32_t(i), b.bytes[i]);
|
||||
}
|
||||
@@ -112,16 +120,11 @@ GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
|
||||
g.stadium_names = save.pool(3);
|
||||
g.player_name_offsets = words16(::bmh::layout::PlayerNameOffsets);
|
||||
g.season = int16_t(save.data(::bmh::layout::SeasonIndex)[0] | save.data(::bmh::layout::SeasonIndex)[1] << 8);
|
||||
if (!g.title_history.empty() && (g.season < 0 || g.title_history.rbegin()->first > uint32_t(g.season)))
|
||||
throw FormatError("long career: archived season is beyond the saved calendar");
|
||||
return g;
|
||||
}
|
||||
|
||||
uint8_t GameState::club_kit(int team) const {
|
||||
return counts.league_teams == 164 ? club_kits.at(size_t(team)) : memory.u8(layout::ClubKitSelectors + uint32_t(team));
|
||||
}
|
||||
uint8_t GameState::club_short_offset(int team) const {
|
||||
return counts.league_teams == 164 ? club_short_offsets.at(size_t(team)) : memory.u8(layout::ClubShortNameOffsets + uint32_t(team));
|
||||
}
|
||||
|
||||
int GameState::manager_of(int team) const {
|
||||
for (size_t m = 0; m < manager_teams.size(); m++)
|
||||
if (manager_teams[m] == team) return int(m);
|
||||
@@ -165,9 +168,9 @@ void GameState::formation_position(int team, int slot, int& x, int& y) const {
|
||||
}
|
||||
|
||||
SquadRange squad_range(int team) {
|
||||
if (team == kNoTeam) return {size_t(kNoTeamSquadStart), 24};
|
||||
if (team == kNoTeam) return {kNoTeamSquadStart, 24};
|
||||
if (team < kBigSquadTeams) return {size_t(team) * 24, 24};
|
||||
if (team < runtime_dimensions.league_teams) return {size_t(team) * 16 + kBigSquadTeams * 8, 16};
|
||||
if (team < 138) return {size_t(team) * 16 + kBigSquadTeams * 8, 16};
|
||||
return {0, 0};
|
||||
}
|
||||
|
||||
|
||||
+4
-6
@@ -16,8 +16,8 @@
|
||||
#include "formats/savestate.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
#include "game/memory.hpp"
|
||||
#include "game/profile_runtime.hpp"
|
||||
#include "game/random.hpp"
|
||||
#include "game/long_career.hpp"
|
||||
#include "game/reality_motion.hpp"
|
||||
|
||||
namespace bmh {
|
||||
@@ -27,7 +27,7 @@ struct TransferDecisionEvent;
|
||||
struct HumanBuyerSaleHooks;
|
||||
|
||||
// Special team id used by the original for "no club" / the player pool (0x165).
|
||||
inline const int& kNoTeam = runtime_dimensions.national_first;
|
||||
constexpr int kNoTeam = 0x165;
|
||||
|
||||
// Squad slot values (u16 in table *SquadSlots):
|
||||
// bits 0-11 player id, 0xFFF = empty slot
|
||||
@@ -37,10 +37,8 @@ constexpr uint16_t kEmptySlot = 0x0FFF;
|
||||
constexpr uint16_t kSlotInLineup = 0x8000;
|
||||
|
||||
struct GameState {
|
||||
DbCounts counts{};
|
||||
std::vector<uint8_t> club_kits, club_short_offsets;
|
||||
uint8_t club_kit(int team) const;
|
||||
uint8_t club_short_offset(int team) const;
|
||||
PlayerStatisticsArchive player_statistics;
|
||||
TitleHistoryArchive title_history;
|
||||
std::vector<uint16_t> squad_slots; // *SquadSlots, all squads back to back (see squad_range)
|
||||
std::vector<Player> players; // *PlayerConditionTechniqueForm / *PlayerSkillWords / *PlayerIdentityWords, names not filled
|
||||
std::vector<uint8_t> team_morale; // *TeamMorale, per team: bits 0-5 morale / 2, bits 6-7 flags
|
||||
|
||||
@@ -70,13 +70,13 @@ TopScorersProjection top_scorers_from_game(const GameState& g, int manager_slot,
|
||||
invalid("manager has no supported domestic league");
|
||||
// TeamLeague2 deliberately maps team IDs above 0x164 (including the
|
||||
// national team 0x165) to league zero; ordinary cup-only teams map to 9.
|
||||
const int league = manager_team > (kNoTeam - 1) ? 0 : team_league(manager_team);
|
||||
const int league = manager_team > 0x164 ? 0 : team_league(manager_team);
|
||||
if (league < 0 || league >= kLeagueCount)
|
||||
invalid("manager team is outside Source's nine domestic leagues");
|
||||
|
||||
const int first_team = league_first_team(league);
|
||||
const int team_count = kLeagueSizes[league];
|
||||
if (first_team < 0 || first_team + team_count > runtime_dimensions.league_teams ||
|
||||
if (first_team < 0 || first_team + team_count > 138 ||
|
||||
g.club_ids.size() < size_t(first_team + team_count) || g.club_names.empty())
|
||||
invalid("incomplete domestic club table");
|
||||
|
||||
|
||||
+46
-17
@@ -2,12 +2,14 @@
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/week.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
#include "game/bank_robbery.hpp"
|
||||
|
||||
#include "game/matchday.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -24,6 +26,23 @@ void wr32(std::vector<uint8_t>& v, size_t o, int32_t x) {
|
||||
|
||||
} // namespace
|
||||
|
||||
DailyInterestAmounts daily_interest_amounts(int32_t cash, int32_t deposit, int32_t credit) {
|
||||
// OpenBMH deviates from the original: widen products before annual-rate
|
||||
// division so valid native account amounts do not overflow intermediate sums.
|
||||
// Preserve truncation at each original division, including deposit / 10000.
|
||||
DailyInterestAmounts result;
|
||||
if (cash < 0) {
|
||||
const int64_t with_credit = int64_t(cash) + credit;
|
||||
int64_t borrowing = with_credit < 0 ? with_credit * 18 / -36500 : 0;
|
||||
borrowing += std::max(int64_t(cash), -int64_t(credit)) * 12 / -36500;
|
||||
result.borrowing = int32_t(borrowing);
|
||||
} else {
|
||||
result.cash_and_deposit = cash / -36500;
|
||||
}
|
||||
result.cash_and_deposit += int32_t(int64_t(deposit / 10000) * 20000 / -36500);
|
||||
return result;
|
||||
}
|
||||
|
||||
void daily_interest(GameState& g, WatcomRandom& rand) {
|
||||
// (DailyInterest before the day step: the training camp visits of today are over)
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++) g.manager_records.at(m * kManagerRecord + 0x21f) &= 0x7f;
|
||||
@@ -32,25 +51,29 @@ void daily_interest(GameState& g, WatcomRandom& rand) {
|
||||
const int32_t balance = rd32(g.manager_records, rec + 0x314);
|
||||
const int32_t deposit = rd32(g.manager_records, rec + 0x318);
|
||||
const int32_t credit = rd32(g.manager_records, rec + 0x31c);
|
||||
int32_t amount = 0; // positive = cost
|
||||
const auto interest = daily_interest_amounts(balance, deposit, credit);
|
||||
if (balance < 0) {
|
||||
if (balance + credit < 0) amount = ((balance + credit) * 18) / -36500;
|
||||
int32_t used = -credit < balance ? balance : -credit;
|
||||
amount += (used * 12) / -36500;
|
||||
wr32(g.manager_records, rec + 0x89c, rd32(g.manager_records, rec + 0x89c) + amount);
|
||||
book_money(g, k, amount, true);
|
||||
amount = 0;
|
||||
} else {
|
||||
amount = balance / -36500;
|
||||
const auto statistic = uint32_t(rd32(g.manager_records, rec + 0x89c)) + uint32_t(interest.borrowing);
|
||||
wr32(g.manager_records, rec + 0x89c, std::bit_cast<int32_t>(statistic));
|
||||
book_money(g, k, interest.borrowing, true);
|
||||
}
|
||||
amount += ((deposit / 10000) * 20000) / -36500;
|
||||
wr32(g.manager_records, rec + 0x870, rd32(g.manager_records, rec + 0x870) - amount);
|
||||
book_money(g, k, amount, true);
|
||||
if (rd32(g.manager_records, rec + 0x314) > 100000000) { // read again after the bookings
|
||||
int32_t extra = int32_t(rand.range(10000, 20000)) * 1000;
|
||||
// BookMoney2 with the statistics flag set: counts as an expense (+0x8a0)
|
||||
wr32(g.manager_records, rec + 0x8a0, rd32(g.manager_records, rec + 0x8a0) + extra);
|
||||
book_money(g, k, extra, true);
|
||||
const auto statistic = uint32_t(rd32(g.manager_records, rec + 0x870)) - uint32_t(interest.cash_and_deposit);
|
||||
wr32(g.manager_records, rec + 0x870, std::bit_cast<int32_t>(statistic));
|
||||
book_money(g, k, interest.cash_and_deposit, true);
|
||||
if (rd32(g.manager_records, rec + 0x314) > 100000000) {
|
||||
const auto robbery_month = bank_robbery_month_key(g.date);
|
||||
const auto guard = bank_robbery_guard_month(g, k);
|
||||
// OpenBMH deviates from the original: an unknown history receives
|
||||
// a grace month; later losses occur at most once per source month.
|
||||
if (!guard) {
|
||||
set_bank_robbery_guard_month(g, k, robbery_month);
|
||||
} else if (*guard != robbery_month) {
|
||||
const int32_t extra = int32_t(rand.range(10000, 20000)) * 1000;
|
||||
const auto expense = uint32_t(rd32(g.manager_records, rec + 0x8a0)) + uint32_t(extra);
|
||||
wr32(g.manager_records, rec + 0x8a0, std::bit_cast<int32_t>(expense));
|
||||
book_money(g, k, extra, true);
|
||||
set_bank_robbery_guard_month(g, k, robbery_month);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,6 +391,12 @@ void stock_market(GameState& g, GameRandom& game) {
|
||||
|
||||
namespace bmh {
|
||||
|
||||
uint32_t bank_robbery_month_key(uint32_t date) {
|
||||
const int month = month_code(date);
|
||||
while (date > 0 && month_code(date - 1) == month) --date;
|
||||
return date;
|
||||
}
|
||||
|
||||
int month_code(uint32_t date) {
|
||||
// DeskState_DeskDate_RuntimeField: days per month (index 1-12; February 29 in leap years)
|
||||
uint8_t days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
Loaded 100 of 227 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user