Compare commits
74
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93ca832c71 | ||
|
|
09b92c9b2a | ||
|
|
78118a6333 | ||
|
|
73ffd23dcb | ||
|
|
96d52202fc | ||
|
|
f63c0217ef | ||
|
|
73af2a657d | ||
|
|
e088704dff | ||
|
|
287b5a9251 | ||
|
|
aa6ec96305 | ||
|
|
e337c3c6b2 | ||
|
|
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
|
||||
|
||||
@@ -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.9/RELEASE_NOTES.md
|
||||
+69
-15
@@ -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.9 LANGUAGES CXX C)
|
||||
if(APPLE)
|
||||
# Enable native languages before dependencies/subdirectories inherit rules.
|
||||
enable_language(OBJC OBJCXX)
|
||||
endif()
|
||||
set(OPENBMH_PRERELEASE "poc.2" 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,13 +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}")
|
||||
|
||||
add_executable(wide_number_unit_tests tests/wide_number_unit_tests.cpp)
|
||||
target_link_libraries(wide_number_unit_tests PRIVATE bmhcore)
|
||||
add_test(NAME wide_number_unit_tests COMMAND wide_number_unit_tests)
|
||||
add_executable(long_career_tests tests/long_career_tests.cpp)
|
||||
target_link_libraries(long_career_tests PRIVATE bmhcore)
|
||||
add_test(NAME long_career_tests COMMAND long_career_tests)
|
||||
|
||||
add_executable(bank_robbery_month_tests tests/bank_robbery_month_tests.cpp)
|
||||
target_link_libraries(bank_robbery_month_tests PRIVATE bmhcore)
|
||||
add_test(NAME bank_robbery_month_tests COMMAND bank_robbery_month_tests)
|
||||
add_executable(monthly_dividend_tests tests/monthly_dividend_tests.cpp)
|
||||
target_link_libraries(monthly_dividend_tests PRIVATE bmhui)
|
||||
add_test(NAME monthly_dividend_tests COMMAND monthly_dividend_tests)
|
||||
|
||||
add_executable(native_save_version_tests tests/native_save_version_tests.cpp)
|
||||
target_link_libraries(native_save_version_tests PRIVATE bmhcore)
|
||||
add_test(NAME native_save_version_tests COMMAND native_save_version_tests)
|
||||
add_executable(native_save_import_tests tests/native_save_import_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(native_save_import_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
set(BMH_TEST_NATIVE_SAVE_IMPORT_INPUT "" CACHE FILEPATH "External native save for import compatibility; not distributed")
|
||||
bmh_add_data_test(NAME native_save_import_tests REQUIRED_OPTIONS BMH_TEST_NATIVE_SAVE_IMPORT_INPUT
|
||||
COMMAND native_save_import_tests "${BMH_DATA}" "${BMH_TEST_NATIVE_SAVE_IMPORT_INPUT}")
|
||||
@@ -1,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.9.** 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.9/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.
|
||||
+13
-3
@@ -6,27 +6,37 @@ 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/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [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): 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,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.
|
||||
@@ -0,0 +1,43 @@
|
||||
# OpenBMH Classic 1.0.8
|
||||
|
||||
This patch makes the bank credit annuity identical on every platform. 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.7
|
||||
|
||||
- **Bank credit annuity.** The original computes the monthly payment with
|
||||
x87 floating point (64-bit mantissa at every step, one final store to a
|
||||
double). The host `long double` is only 64 bits wide on Windows (MSVC) and
|
||||
on Apple silicon, so the payment differed by 1 for roughly 0.2 % of loans of
|
||||
one to sixty million. The chain is now evaluated with integer arithmetic and
|
||||
gives the original's result on every platform.
|
||||
|
||||
## 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.
|
||||
|
||||
This release follows a quality pass that ran single routines of the original
|
||||
programme in an emulator and compared them with the engine on whole savegames,
|
||||
with boundary values and a deliberately wrong result per rule that must fail.
|
||||
Compared without a difference: the random generator, market value and salary,
|
||||
the willingness of clubs to sell, the rating of transfer bids, club mood and
|
||||
flags at the end of a season, the order of national cup ties, weekly advertising
|
||||
offers, facility ageing and damage, offers to managers, weekly statistics,
|
||||
familiarity decay, squad training and daily interest. The one difference found
|
||||
is the annuity fixed above. Rules that depend on screens, dialogs or the master
|
||||
database were not part of this pass.
|
||||
|
||||
Native Windows/macOS gameplay acceptance is not established by CI builds. Open
|
||||
points from earlier releases 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.
|
||||
@@ -0,0 +1,65 @@
|
||||
# OpenBMH Classic 1.0.9
|
||||
|
||||
This release aligns the engine's hard-coded rules with BMH 2026-27 DIAMOND
|
||||
Edition 3.7. It requires the player's own game installation. Extended
|
||||
development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Why
|
||||
|
||||
The engine had been checked against an older Diamond build whose executable
|
||||
differs from 3.7 in about 2,700 bytes (50 code ranges, the Diamond patch area
|
||||
and 64 data bytes). Rules from v2.24, an older Diamond and 3.7 were therefore
|
||||
mixed. The routines of the real 3.7 executable were run in an emulator and
|
||||
compared with the engine; every difference found was ported and documented.
|
||||
|
||||
## Changes since 1.0.8
|
||||
|
||||
- **Injuries and cards.** New injury tables (thresholds and durations), the
|
||||
injury history factor 1.25, doctor and insurance caps, and the foul, booking
|
||||
and red-card chances of 3.7.
|
||||
- **Economy.** Credit limit 8,000,000, transfer fee base, DFB fee, advertising
|
||||
base, start capital, bankruptcy limit, championship and cup premiums,
|
||||
periphery prices, contract talk limit and training injury range.
|
||||
- **Weekly processing.** Retirement chance, side rating rhythm for human and
|
||||
computer managers, facility values, per-visitor income and the season
|
||||
ticket price.
|
||||
- **Youth academy.** 3.7 generation with its monthly budget gate. An age check
|
||||
was inverted in the port (older players were recycled the wrong way round);
|
||||
this is fixed.
|
||||
- **Season end.** Retirement and leave rules for the player slots.
|
||||
- **Live match statistics.** The chance counters at the bottom of the live
|
||||
matchday screen counted a chance as soon as the engine logged it, before the
|
||||
presentation started. They are now held back like the score and appear with
|
||||
the result of the chance.
|
||||
|
||||
## What was measured, what was derived
|
||||
|
||||
Compared with the 3.7 executable without any difference (boundary values and a
|
||||
deliberately wrong result per rule that must fail): random generator, market
|
||||
value, bank annuity, club mood and flags, cup tie order, advertising offers,
|
||||
bid rating, poaching, facility ageing and damage, manager offers, weekly
|
||||
statistics, familiarity decay, squad training, daily interest, youth academy,
|
||||
month change, new transfer list entries, and injuries including doctor and
|
||||
insurance (932 runs).
|
||||
|
||||
Derived from the constants of the 3.7 code but **not** measured in the
|
||||
emulator: foul and card chances in a match, and several economy numbers.
|
||||
Not covered: the complete weekly processing routine, and the amounts of newly
|
||||
created transfer bids (the original reads a stale stack value there; documented
|
||||
in the source as a known gap).
|
||||
|
||||
## Open points
|
||||
|
||||
Reported by the Diamond author and not changed here: the bug in "fetch player
|
||||
from transfer market / check offers" (exact steps still to be reproduced).
|
||||
Earlier open points 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.
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// All-or-nothing wrapper for one UI window action on a CareerSession (used by
|
||||
// desktop_actions.cpp and window_actions.cpp). It snapshots the game state, the RNG and the
|
||||
// revision counter, runs the action and, if the action returns false or throws, restores
|
||||
// all three, so a rejected action leaves no half-applied change behind.
|
||||
// apply_native() is the variant for owners that keep their state in CareerSession::state().
|
||||
// Header-only; owns no state of its own.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Glue between the original-audio engine (src/audio/playback.hpp) and the app: builds the
|
||||
// asset set from the game's sound containers and the frequency/operator tables read from the
|
||||
// executable, derives the music/click/match-sound options from the saved settings bytes of
|
||||
// the GameState, and sends sound commands only when the original sound path is ready.
|
||||
// OriginalMouseSound is an SDL event watch that plays the click sound on each real mouse
|
||||
// button press; it touches only the Playback object, never the GameState, because the
|
||||
// watch can run on SDL's event thread. Header-only.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#pragma once
|
||||
|
||||
|
||||
+725
-110
File diff suppressed because it is too large.
Load diff
@@ -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;
|
||||
|
||||
+375
-24
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The controller: the one synchronous boundary between the UI flow (ui::StartupFlow) and
|
||||
// the engine session (CareerSession). The flow turns a click or key into a ui::FlowResult
|
||||
// that carries a request; serve_flow_request() validates it against the current revision,
|
||||
// calls the session, and acknowledges the outcome back to the flow. Everything the engine
|
||||
// needs from the front end (dialogs, live match presentation, notices) is passed in as
|
||||
// std::function "presenter" hooks, so tests can drive the same code without a window.
|
||||
// Pairs with controller.cpp; the real hooks are supplied by main.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Debug mode (command line -debug): a process-wide, mutex-protected log file plus numbered
|
||||
// automatic savegames, both kept in one folder. State is a function-local static; every
|
||||
// function is a no-op until init() has succeeded, so callers may log unconditionally.
|
||||
// init() also redirects stderr into the same folder. Header-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
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the desk-level action facades declared in desktop_actions.hpp. Each
|
||||
// method checkpoints the relevant session owner, runs the request through CareerSession,
|
||||
// lets the accept callback acknowledge the result to the UI, and rolls everything back via
|
||||
// detail::apply_window if the callback returns false or throws. Errors are returned through
|
||||
// the std::string& error parameter. The request/acknowledge flow as a whole is described
|
||||
// at the top of controller.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/desktop_actions.hpp"
|
||||
#include "app/action_transaction.hpp"
|
||||
@@ -7,6 +13,8 @@
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
// Builds the desk request that opens menu `kind` for the observed manager; the item id is
|
||||
// taken from the desk item of that kind.
|
||||
ui::DeskRequest DesktopActions::menu(const ui::DeskState& observed, int kind) {
|
||||
ui::DeskRequest request;
|
||||
request.kind = ui::DeskRequestKind::open_menu;
|
||||
@@ -18,6 +26,8 @@ ui::DeskRequest DesktopActions::menu(const ui::DeskState& observed, int kind) {
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction on the desk settings owner; the checkpoint is restored
|
||||
// if the action fails.
|
||||
bool DeskSettingsActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.desk_settings_checkpoint(revision),
|
||||
[&](CareerSession::DeskSettingsCheckpoint before) {
|
||||
@@ -25,6 +35,7 @@ bool DeskSettingsActions::apply(uint64_t& revision, const std::function<bool()>&
|
||||
}, action);
|
||||
}
|
||||
|
||||
// Opens the desk settings screen; `acknowledge` receives the projection on success.
|
||||
std::optional<CareerSession::DeskSettingsProjection> DeskSettingsActions::open(
|
||||
const ui::DeskRequest& request, uint64_t& revision, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<CareerSession::DeskSettingsProjection> result;
|
||||
@@ -37,6 +48,7 @@ std::optional<CareerSession::DeskSettingsProjection> DeskSettingsActions::open(
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends any settings action (write, file, close) to the session in one transaction.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::dispatch(
|
||||
const CareerSession::DeskSettingsAction& request, uint64_t& revision, std::string& error,
|
||||
const Accept& acknowledge) {
|
||||
@@ -50,16 +62,19 @@ std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::dispatch
|
||||
return result;
|
||||
}
|
||||
|
||||
// Dispatches a settings write for the owner identified by `sequence`.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::write(uint64_t sequence,
|
||||
const ui::SettingsWriteRequest& request, uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
return dispatch(CareerSession::DeskSettingsWrite{sequence, request}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
// Dispatches a settings file (save/load) request for the owner `sequence`.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::file(uint64_t sequence,
|
||||
const ui::SaveLoadRequest& request, uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
return dispatch(CareerSession::DeskSettingsFile{sequence, request}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
// Dispatches the close of the settings owner, built from the observed desk request.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::close(uint64_t sequence,
|
||||
uint64_t owner_revision, const ui::DeskRequest& observed, uint64_t& revision, std::string& error,
|
||||
const Accept& acknowledge) {
|
||||
@@ -67,6 +82,8 @@ std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::close(ui
|
||||
return dispatch(CareerSession::DeskSettingsClose{owner}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
// Applies one edit (row, column, operation) to the settings cells; the request carries
|
||||
// the observed cells so that a stale view is detected.
|
||||
bool DeskSettingsActions::edit(const ui::SettingsState& observed, int row, int column, ui::SettingsEdit operation,
|
||||
uint64_t& revision, std::string& error) {
|
||||
ui::SettingsWriteRequest request;
|
||||
@@ -79,11 +96,13 @@ bool DeskSettingsActions::edit(const ui::SettingsState& observed, int row, int c
|
||||
return apply(revision, [&] { return session_.dispatch_settings(request, revision, error); });
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the balance checkpoint on failure.
|
||||
bool BalanceActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.balance_checkpoint(),
|
||||
[&](CareerSession::BalanceCheckpoint before) { session_.restore_balance_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the balance (finance plan) screen over `underlay`.
|
||||
std::optional<ui::BalanceState> BalanceActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::BalanceState> result;
|
||||
@@ -96,6 +115,7 @@ std::optional<ui::BalanceState> BalanceActions::open(const ui::DeskRequest& requ
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends a balance screen request to the session in one transaction.
|
||||
std::optional<CareerSession::BalanceDispatch> BalanceActions::dispatch(const ui::BalanceRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::BalanceDispatch> result;
|
||||
@@ -108,13 +128,20 @@ std::optional<CareerSession::BalanceDispatch> BalanceActions::dispatch(const ui:
|
||||
return result;
|
||||
}
|
||||
|
||||
// Draft helpers for the console balance plan (thin wrappers around the game functions):
|
||||
// open a draft for a manager,
|
||||
BalancePlanDraft BalanceActions::open_draft(int manager) const { return bmh::open_balance_plan(session_.state(), manager); }
|
||||
// switch its view,
|
||||
void BalanceActions::cycle_draft(BalancePlanDraft& draft) const { cycle_balance_view(session_.state(), draft); }
|
||||
// reset it,
|
||||
void BalanceActions::reset_draft(BalancePlanDraft& draft) const { reset_balance_plan(session_.state(), draft); }
|
||||
// and edit one row.
|
||||
BalanceEditStatus BalanceActions::edit_draft(BalancePlanDraft& draft, int row, int32_t value) const {
|
||||
return edit_balance_plan(session_.state(), draft, row, value);
|
||||
}
|
||||
|
||||
// Closes the draft inside a transaction and always increases the revision. Returns the
|
||||
// warning flag reported by the close.
|
||||
bool BalanceActions::close_draft(const BalancePlanDraft& draft, uint64_t& revision) {
|
||||
bool warning = false;
|
||||
apply(revision, [&] {
|
||||
@@ -125,11 +152,13 @@ bool BalanceActions::close_draft(const BalancePlanDraft& draft, uint64_t& revisi
|
||||
return warning;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the other-games checkpoint on failure.
|
||||
bool OtherGamesActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.other_games_checkpoint(),
|
||||
[&](CareerSession::OtherGamesCheckpoint before) { session_.restore_other_games_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the other-games screen over `underlay`.
|
||||
std::optional<ui::OtherGamesState> OtherGamesActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::OtherGamesState> result;
|
||||
@@ -142,6 +171,8 @@ std::optional<ui::OtherGamesState> OtherGamesActions::open(const ui::DeskRequest
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends an other-games request to the session; `team_info` presents club information
|
||||
// when the screen asks for it.
|
||||
std::optional<CareerSession::OtherGamesDispatch> OtherGamesActions::dispatch(const ui::OtherGamesRequest& request,
|
||||
uint64_t& revision, std::string& error, const TransferOfferTeamInfoPresenter& team_info, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::OtherGamesDispatch> result;
|
||||
@@ -154,11 +185,13 @@ std::optional<CareerSession::OtherGamesDispatch> OtherGamesActions::dispatch(con
|
||||
return result;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the top scorers checkpoint on failure.
|
||||
bool TopScorersActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.top_scorers_checkpoint(),
|
||||
[&](CareerSession::TopScorersCheckpoint before) { session_.restore_top_scorers_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the top scorers screen over `underlay`; the revision is increased on opening.
|
||||
std::optional<ui::TopScorersState> TopScorersActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::TopScorersState> result;
|
||||
@@ -172,6 +205,7 @@ std::optional<ui::TopScorersState> TopScorersActions::open(const ui::DeskRequest
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends a top scorers request to the session in one transaction.
|
||||
std::optional<CareerSession::TopScorersDispatch> TopScorersActions::dispatch(const ui::TopScorersRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::TopScorersDispatch> result;
|
||||
@@ -184,11 +218,13 @@ std::optional<CareerSession::TopScorersDispatch> TopScorersActions::dispatch(con
|
||||
return result;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the opportunities checkpoint on failure.
|
||||
bool OpportunitiesActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.opportunities_checkpoint(),
|
||||
[&](CareerSession::OpportunitiesCheckpoint before) { session_.restore_opportunities_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the opportunities screen over `underlay`; the revision is increased on opening.
|
||||
std::optional<ui::OpportunitiesState> OpportunitiesActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, bool national_source_case,
|
||||
int stable_identity, const OpenAccept& acknowledge) {
|
||||
@@ -203,6 +239,7 @@ std::optional<ui::OpportunitiesState> OpportunitiesActions::open(const ui::DeskR
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends an opportunities request to the session in one transaction.
|
||||
std::optional<CareerSession::OpportunitiesDispatch> OpportunitiesActions::dispatch(const ui::OpportunitiesRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::OpportunitiesDispatch> result;
|
||||
@@ -215,6 +252,8 @@ std::optional<CareerSession::OpportunitiesDispatch> OpportunitiesActions::dispat
|
||||
return result;
|
||||
}
|
||||
|
||||
// Stores a changed statistics display preference (expected flags to target flags) and
|
||||
// increases the revision; throws if the revision counter is exhausted.
|
||||
bool OpportunitiesActions::preference(const ui::AnalyticsRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -227,15 +266,18 @@ bool OpportunitiesActions::preference(const ui::AnalyticsRequest& request, uint6
|
||||
});
|
||||
}
|
||||
|
||||
// Builds the request that closes the observed opportunities screen.
|
||||
ui::OpportunitiesRequest OpportunitiesActions::close_request(const ui::OpportunitiesState& observed) {
|
||||
return {observed.identity, ui::OpportunitiesAction::close, observed.mode};
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the manager join checkpoint on failure.
|
||||
bool ManagerJoinActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.manager_join_checkpoint(),
|
||||
[&](CareerSession::ManagerJoinCheckpoint before) { session_.restore_manager_join_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Commits a new manager joining the career; `acknowledge` receives the initialization result.
|
||||
bool ManagerJoinActions::commit(uint64_t& revision, std::string& error,
|
||||
const std::function<void(ui::CareerInitializationResult&)>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -246,6 +288,7 @@ bool ManagerJoinActions::commit(uint64_t& revision, std::string& error,
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a mailbox action (via the native transaction wrapper) and acknowledges it.
|
||||
bool MailboxActions::dispatch(const ui::MailboxActionRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
@@ -255,6 +298,7 @@ bool MailboxActions::dispatch(const ui::MailboxActionRequest& request, uint64_t&
|
||||
});
|
||||
}
|
||||
|
||||
// Acknowledges the closing of the mailbox.
|
||||
bool MailboxActions::close(const ui::MailboxCloseRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
@@ -264,6 +308,7 @@ bool MailboxActions::close(const ui::MailboxCloseRequest& request, uint64_t& rev
|
||||
});
|
||||
}
|
||||
|
||||
// Builds a mailbox action request for the observed message (entry index and raw entry).
|
||||
ui::MailboxActionRequest MailboxActions::request(int manager, uint64_t revision,
|
||||
ui::MailboxActionKind kind, const ui::MailboxMessage& observed) {
|
||||
ui::MailboxActionRequest request;
|
||||
@@ -275,6 +320,7 @@ ui::MailboxActionRequest MailboxActions::request(int manager, uint64_t revision,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Sends a menu layout save/load request and acknowledges it.
|
||||
bool MenuLayoutActions::dispatch(const ui::SaveLoadRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
@@ -284,16 +330,22 @@ bool MenuLayoutActions::dispatch(const ui::SaveLoadRequest& request, uint64_t& r
|
||||
});
|
||||
}
|
||||
|
||||
// Sets one environment item through set_impl (normal UI path).
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set(const ui::EnvironmentRequest& request,
|
||||
uint64_t& revision, std::string& error, const Notice& notice, const std::function<void(bool)>& acknowledge) {
|
||||
return set_impl(request, revision, error, notice, acknowledge, false);
|
||||
}
|
||||
|
||||
// Console variant of set(): the staged state is published even if nothing changed.
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set_console(const ui::EnvironmentView& observed,
|
||||
int item, int level, uint64_t& revision, std::string& error, const Notice& notice) {
|
||||
return set_impl(request(observed, item, level), revision, error, notice, {}, true);
|
||||
}
|
||||
|
||||
// Shared implementation. The request must match the current revision, manager slot
|
||||
// (0..3), active manager and club, otherwise error is "stale_environment_owner". The change
|
||||
// is made on a staged copy; a notice callback may abort it. The revision increases only
|
||||
// when something changed. Returns nothing if the transaction was not accepted.
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set_impl(const ui::EnvironmentRequest& request,
|
||||
uint64_t& revision, std::string& error, const Notice& notice, const std::function<void(bool)>& acknowledge,
|
||||
bool publish_console_result) {
|
||||
@@ -333,6 +385,7 @@ std::optional<EnvironmentResult> EnvironmentActions::set_impl(const ui::Environm
|
||||
return result;
|
||||
}
|
||||
|
||||
// Builds a set_item request for `item` and `level` bound to the observed view.
|
||||
ui::EnvironmentRequest EnvironmentActions::request(const ui::EnvironmentView& observed, int item, int level) {
|
||||
ui::EnvironmentRequest request;
|
||||
request.kind = ui::EnvironmentRequestKind::set_item;
|
||||
@@ -345,10 +398,12 @@ ui::EnvironmentRequest EnvironmentActions::request(const ui::EnvironmentView& ob
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` through the native transaction wrapper.
|
||||
bool RescheduleActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_native(session_, revision, action);
|
||||
}
|
||||
|
||||
// Moves a league match to `day` or undoes a move; any other combination is invalid.
|
||||
RescheduleStatus RescheduleActions::change(GameState& state, int manager, const LeagueMatchRef& match,
|
||||
int day, ui::RescheduleActionKind kind) {
|
||||
if (kind == ui::RescheduleActionKind::move) return reschedule_league_match(state, manager, match, day);
|
||||
@@ -356,6 +411,9 @@ RescheduleStatus RescheduleActions::change(GameState& state, int manager, const
|
||||
return RescheduleStatus::invalid_match;
|
||||
}
|
||||
|
||||
// Handles a UI reschedule action: the owner must be the open menu 7 for the current
|
||||
// revision and active manager, and the match must be among the eligible (or already moved)
|
||||
// matches. The state changes only when the move succeeds.
|
||||
RescheduleStatus RescheduleActions::dispatch(const ui::RescheduleAction& request, uint64_t& revision,
|
||||
const std::function<void()>& acknowledge) {
|
||||
auto status = RescheduleStatus::invalid_match;
|
||||
@@ -379,6 +437,7 @@ RescheduleStatus RescheduleActions::dispatch(const ui::RescheduleAction& request
|
||||
return status;
|
||||
}
|
||||
|
||||
// Moves a match directly (console path); the revision increases on success.
|
||||
RescheduleStatus RescheduleActions::move(int manager, const LeagueMatchRef& match, int day, uint64_t& revision) {
|
||||
auto status = RescheduleStatus::invalid_match;
|
||||
apply(revision, [&] {
|
||||
@@ -390,6 +449,7 @@ RescheduleStatus RescheduleActions::move(int manager, const LeagueMatchRef& matc
|
||||
return status;
|
||||
}
|
||||
|
||||
// Console undo; the revision always increases, whatever the result of the undo.
|
||||
void RescheduleActions::undo_console(int manager, int day, uint64_t& revision) {
|
||||
apply(revision, [&] {
|
||||
// Keep the Console's existing accepted-command revision after its own
|
||||
@@ -400,6 +460,8 @@ void RescheduleActions::undo_console(int manager, int day, uint64_t& revision) {
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a contract request to the session. If an exception follows an accepted request,
|
||||
// the pending contract quote is cleared before rethrowing.
|
||||
bool ContractActions::dispatch(const ui::ContractRequest& request, uint64_t& revision,
|
||||
ui::ContractActionResult& result, std::string& error, const std::function<void()>& acknowledge) {
|
||||
bool accepted = false;
|
||||
@@ -417,6 +479,7 @@ bool ContractActions::dispatch(const ui::ContractRequest& request, uint64_t& rev
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a contract request of `kind` bound to the observed manager, club and revision.
|
||||
ui::ContractRequest ContractActions::bind(const ui::ContractsState& observed,
|
||||
ui::ContractActionKind kind, uint64_t request_id) {
|
||||
ui::ContractRequest request;
|
||||
@@ -428,6 +491,7 @@ ui::ContractRequest ContractActions::bind(const ui::ContractsState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for a player's contract demands (row and player id).
|
||||
ui::ContractRequest ContractActions::demands(const ui::ContractsState& observed,
|
||||
const ui::ContractPlayer& player, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::request_demands, request_id);
|
||||
@@ -436,6 +500,7 @@ ui::ContractRequest ContractActions::demands(const ui::ContractsState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request that sets team bonus `index` to `percent`, keeping the other proposed premiums.
|
||||
ui::ContractRequest ContractActions::team_bonus(const ui::ContractsState& observed,
|
||||
int index, uint8_t percent, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::submit_bonuses, request_id);
|
||||
@@ -444,6 +509,7 @@ ui::ContractRequest ContractActions::team_bonus(const ui::ContractsState& observ
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request to insure a player (quote, insurance form in the term column, months).
|
||||
ui::ContractRequest ContractActions::insurance(const ui::ContractsState& observed, int row,
|
||||
int player, uint64_t quote, uint8_t form, uint8_t months, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::insure_player, request_id);
|
||||
@@ -452,6 +518,8 @@ ui::ContractRequest ContractActions::insurance(const ui::ContractsState& observe
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for a contract offer. With years > 0 it is an offer for that term (salary and
|
||||
// the matching demand); with 0 years only the bonuses are submitted.
|
||||
ui::ContractRequest ContractActions::offer(const ui::ContractsState& observed, int row,
|
||||
int player, uint64_t quote, const std::array<uint8_t,7>& bonuses, int years, uint32_t salary,
|
||||
const std::array<uint32_t,4>& demands, uint64_t request_id) {
|
||||
@@ -466,10 +534,12 @@ ui::ContractRequest ContractActions::offer(const ui::ContractsState& observed, i
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` through the native transaction wrapper.
|
||||
bool FriendlyActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_native(session_, revision, action);
|
||||
}
|
||||
|
||||
// Converts the UI's friendly match request into the engine's booking request.
|
||||
FriendlyBookingRequest FriendlyActions::booking_request(const ui::FriendlyMatchRequest& observed) {
|
||||
FriendlyBookingQuote quote;
|
||||
quote.status = FriendlyQuoteStatus::quoted;
|
||||
@@ -487,6 +557,7 @@ FriendlyBookingRequest FriendlyActions::booking_request(const ui::FriendlyMatchR
|
||||
observed.accept_cost, observed.approving_manager};
|
||||
}
|
||||
|
||||
// Builds the acknowledgement for the UI from the booking outcome and the new revision.
|
||||
ui::FriendlyBookingAck FriendlyActions::acknowledgement(const ui::FriendlyMatchRequest& request,
|
||||
const FriendlyBookingResult& outcome, uint64_t revision) const {
|
||||
ui::FriendlyBookingAck ack;
|
||||
@@ -499,6 +570,9 @@ ui::FriendlyBookingAck FriendlyActions::acknowledgement(const ui::FriendlyMatchR
|
||||
return ack;
|
||||
}
|
||||
|
||||
// Books a friendly match (club or national). The request must be a book request for the
|
||||
// current revision, otherwise the quote is stale. After booking, the planner count must
|
||||
// have grown by 2, else the booking is rolled back and planner_mismatch is set.
|
||||
FriendlyActions::Booking FriendlyActions::book(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, bool national, const Accept& acknowledge) {
|
||||
Booking result;
|
||||
@@ -526,11 +600,14 @@ FriendlyActions::Booking FriendlyActions::book(const ui::FriendlyMatchRequest& r
|
||||
return result;
|
||||
}
|
||||
|
||||
// Books a club friendly.
|
||||
FriendlyActions::Booking FriendlyActions::book_club(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, const Accept& acknowledge) { return book(request, revision, false, acknowledge); }
|
||||
// Books a national team friendly.
|
||||
FriendlyActions::Booking FriendlyActions::book_national(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, const Accept& acknowledge) { return book(request, revision, true, acknowledge); }
|
||||
|
||||
// Console booking from an existing quote; the revision increases when it was booked.
|
||||
FriendlyBookingResult FriendlyActions::book_console(const FriendlyBookingQuote& quote, uint16_t day,
|
||||
bool accept_opponent, int consenting_manager, bool accept_cost, int approving_manager, uint64_t& revision) {
|
||||
FriendlyBookingResult result;
|
||||
@@ -544,19 +621,25 @@ FriendlyBookingResult FriendlyActions::book_console(const FriendlyBookingQuote&
|
||||
return result;
|
||||
}
|
||||
|
||||
// Quote functions (thin wrappers over the game functions): club friendly quote,
|
||||
FriendlyBookingQuote FriendlyActions::quote(int manager, int opponent, bool home) const {
|
||||
return quote_friendly_match(session_.state(), manager, opponent, home);
|
||||
}
|
||||
// national friendly quote (uses the random generator),
|
||||
NationalFriendlyQuote FriendlyActions::national_quote(const NationalFriendlyOwner& owner, int opponent, bool home) {
|
||||
return quote_national_friendly_match(session_.state(), owner, opponent, home, session_.rand());
|
||||
}
|
||||
// whether a club friendly can be played on a day,
|
||||
FriendlyDateStatus FriendlyActions::date_status(const FriendlyBookingQuote& quote, uint16_t day) const {
|
||||
return friendly_match_date_status(session_.state(), quote, day);
|
||||
}
|
||||
// the same for a national friendly,
|
||||
FriendlyDateStatus FriendlyActions::national_date_status(const NationalFriendlyQuote& quote,
|
||||
const NationalFriendlyOwner& owner, uint16_t day) const {
|
||||
return national_friendly_match_date_status(session_.state(), quote, owner, session_.rand(), day);
|
||||
}
|
||||
// and the owner identity of a national friendly built from the request (the last two
|
||||
// fields are fixed constants).
|
||||
NationalFriendlyOwner FriendlyActions::national_owner(const ui::FriendlyMatchRequest& request) {
|
||||
return {request.quote_id, request.revision, request.manager_slot, 0x165, 6};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Application-boundary facades for desk-level windows: one small class per owner (desk
|
||||
// settings, balance plan, other games, top scorers, opportunities, manager join, mailbox,
|
||||
// menu layout, environment, reschedule, contracts, friendly matches). Each wraps a
|
||||
// CareerSession reference; its apply() runs an action under a rollback transaction (see
|
||||
// action_transaction.hpp), and open()/dispatch() take the UI request plus the shared
|
||||
// revision counter and an optional "accept" callback that carries the front end's
|
||||
// acknowledgement. Implemented in desktop_actions.cpp; window_actions.hpp holds the club windows.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// SDL event helpers for the live match-day presentation, which runs while the engine is
|
||||
// synchronously paused in its observer hook. live_matchday_board_side() turns a mouse press
|
||||
// into a side (0 or 1) of the board only at the allowed minutes and screen intervals;
|
||||
// pump_live_matchday_events() drains the SDL queue, reports a quit request and an ESC skip
|
||||
// through its return value / out-parameter, and re-queues only non-interactive system events.
|
||||
// Header-only; owns no state.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
+525
-23
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Mouse pointer for the pitch page. SDL owns the pointer position; the UI only hands over
|
||||
// the original 11x11 pixel bitmap (121 ARGB values). PitchPointer builds an SDL colour
|
||||
// cursor from it, enlarged by an integer scale derived from the window size in points, and
|
||||
// caches it until the pixels or the scale change. set_default() sets the bitmap used on all
|
||||
// other pages. Header-only; the cursor is freed in clear() / the destructor.
|
||||
#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,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Quit confirmation (a deliberate deviation from the original): a native message box in
|
||||
// German or English whose default button is "Cancel". poll() and peep() wrap
|
||||
// SDL_PollEvent / SDL_PeepEvents and drop SDL_QUIT events the user does not confirm. The
|
||||
// dialog is shown from the UI thread only, and a dialog that fails to open counts as "not
|
||||
// confirmed". The presenter is injectable (defaults to SDL_ShowMessageBox). Header-only.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of StartScreen (start_screen.hpp): decodes the embedded JPEG
|
||||
// (start_screen_data.hpp) with stb_image into an RGB24 texture, switches the renderer's
|
||||
// logical size to the image size while presenting and restores the previous logical size in
|
||||
// the destructor. Errors are reported as std::runtime_error; the stb_image implementation
|
||||
// is compiled into this file only (JPEG decoding, no stdio).
|
||||
#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,26 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Start screen shown before the game data is loaded: one embedded picture drawn with its
|
||||
// own renderer logical size, independent of the indexed game canvas. Owns the SDL
|
||||
// texture; non-copyable. Implemented in start_screen.cpp, the image bytes come from
|
||||
// start_screen_data.hpp.
|
||||
#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,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Declares the embedded start screen artwork (JPEG bytes and their size); the definitions
|
||||
// live in a separate data translation unit. Consumed only by start_screen.cpp.
|
||||
#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
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// RAII guard for SDL video: SDL_Init(SDL_INIT_VIDEO) in the constructor (throws
|
||||
// std::runtime_error on failure) and SDL_Quit in the destructor. It must exist before any
|
||||
// native file picker is opened (see the comment on the class). Non-copyable, header-only.
|
||||
#pragma once
|
||||
#include <SDL.h>
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the club and league window facades declared in window_actions.hpp. Each
|
||||
// method validates the UI request against the session state, runs it on the CareerSession
|
||||
// inside an apply() transaction (state, RNG and revision are restored on rejection or an
|
||||
// exception) and hands the result to the front end's acknowledgement callback. Errors come
|
||||
// back through the std::string& error parameter; see controller.cpp for the overall model.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/window_actions.hpp"
|
||||
#include "app/action_transaction.hpp"
|
||||
@@ -11,6 +16,9 @@
|
||||
namespace bmh::app {
|
||||
using detail::apply_window;
|
||||
|
||||
// Runs `action` as a transaction on the league family state. Returns true if the action
|
||||
// succeeded; if it returns false or throws, the checkpoint and the revision are restored
|
||||
// (an exception is rethrown).
|
||||
bool LeagueFamilyActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
auto before = session_.league_family_checkpoint();
|
||||
const auto old_revision = revision;
|
||||
@@ -26,6 +34,8 @@ bool LeagueFamilyActions::apply(uint64_t& revision, const std::function<bool()>&
|
||||
return false;
|
||||
}
|
||||
|
||||
// Opens the league pairings screen from the desk (menu kind 1, using the desk item of
|
||||
// kind 1). Returns its state, or nothing with `error` set if the session refused.
|
||||
std::optional<ui::LeaguePairingsState> LeagueFamilyActions::open_pairings(
|
||||
const ui::DeskState& observed, uint64_t& revision, std::string& error) {
|
||||
ui::DeskRequest request;
|
||||
@@ -43,6 +53,7 @@ std::optional<ui::LeaguePairingsState> LeagueFamilyActions::open_pairings(
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends one pairings screen event (kind and value) to the session inside a transaction.
|
||||
std::optional<CareerSession::LeaguePairingsDispatch> LeagueFamilyActions::pairings(
|
||||
const ui::LeaguePairingsIdentity& observed, LeaguePairingsAction kind, int value,
|
||||
uint64_t& revision, std::string& error) {
|
||||
@@ -58,16 +69,19 @@ std::optional<CareerSession::LeaguePairingsDispatch> LeagueFamilyActions::pairin
|
||||
return result;
|
||||
}
|
||||
|
||||
// Builds the desk request that opens menu 1 (pairings) for the manager of `identity`.
|
||||
ui::DeskRequest LeagueFamilyActions::pairings_entry(const ui::StrengthsIdentity& identity,
|
||||
uint64_t revision) {
|
||||
return {ui::DeskRequestKind::open_menu, identity.manager, 0, 1, -1, revision};
|
||||
}
|
||||
|
||||
// Builds the pairings request that selects `league`.
|
||||
ui::LeaguePairingsRequest LeagueFamilyActions::pairings_selection(
|
||||
const ui::LeaguePairingsIdentity& identity, int league) {
|
||||
return {identity, {LeaguePairingsAction::select_league, league, -1}};
|
||||
}
|
||||
|
||||
// Turns a fresh strengths request into an `open` request bound to `identity`.
|
||||
ui::StrengthsRequest LeagueFamilyActions::strengths_entry(const ui::StrengthsRequest& fresh,
|
||||
const ui::StrengthsIdentity& identity) {
|
||||
auto request = fresh;
|
||||
@@ -76,6 +90,9 @@ ui::StrengthsRequest LeagueFamilyActions::strengths_entry(const ui::StrengthsReq
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction on the transfer state. Before it, the game state, random
|
||||
// generators, offer editor, poach state, club modal runtime and revision are copied; they
|
||||
// are all restored if the action returns false or throws (then rethrown).
|
||||
bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
auto state = session_.g_;
|
||||
const auto game = session_.game_;
|
||||
@@ -85,6 +102,7 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
|
||||
const auto owner_revision = session_.transfer_offer_revision_;
|
||||
auto runtime = session_.club_modal_runtime_;
|
||||
const auto old_revision = revision;
|
||||
// Puts every saved piece back into the session.
|
||||
const auto restore = [&] {
|
||||
session_.g_ = std::move(state);
|
||||
session_.game_ = game;
|
||||
@@ -105,15 +123,21 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
|
||||
return false;
|
||||
}
|
||||
|
||||
// Handles a transfer market request. In the normal interactive policy the session does
|
||||
// the work (with the sale hooks and the review callback). The other policy is an older
|
||||
// path that only allows listing a player and submitting a bid; it bumps the revision
|
||||
// only if the state or random stream really changed. `acknowledge` is called on success.
|
||||
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;
|
||||
// Body of the transaction; returning false rolls everything back.
|
||||
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 {
|
||||
@@ -150,6 +174,9 @@ std::optional<TransferActions::MarketDispatch> TransferActions::market(
|
||||
return result;
|
||||
}
|
||||
|
||||
// Checks a market request against the current state. Returns a German error text if the
|
||||
// request is stale or invalid, or an empty string if it may proceed. Bonus values may be
|
||||
// at most 255 (interactive policy) or 100 (legacy policy).
|
||||
std::string TransferActions::rejection(const ui::TransferMarketRequest& request,
|
||||
uint64_t revision, HumanBuyerMarketEntryPolicy policy) const {
|
||||
const auto& state = session_.state();
|
||||
@@ -174,11 +201,13 @@ 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 {};
|
||||
}
|
||||
|
||||
// Opens the transfer offer editor for a market request (one transaction).
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::open_offer(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error,
|
||||
const OfferAccept& acknowledge) {
|
||||
@@ -192,6 +221,7 @@ std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::open_
|
||||
return result;
|
||||
}
|
||||
|
||||
// Asks the session for a preview (quote) of a market request without committing it.
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> TransferActions::preview(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error,
|
||||
const PreviewAccept& acknowledge) {
|
||||
@@ -205,6 +235,8 @@ std::optional<CareerSession::TransferMarketPreviewDispatch> TransferActions::pre
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends an action of the outgoing offer editor to the session; the team and player
|
||||
// information presenters are used when it opens those screens.
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::offer(
|
||||
const ui::OutgoingTransferRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, const TransferOfferTeamInfoPresenter& team_info,
|
||||
@@ -219,6 +251,7 @@ std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::offer
|
||||
return result;
|
||||
}
|
||||
|
||||
// Starts a poaching attempt for the given manager and squad slot.
|
||||
std::optional<CareerSession::PoachDispatch> TransferActions::poach(int manager, int slot,
|
||||
uint64_t& revision, std::string& error) {
|
||||
std::optional<CareerSession::PoachDispatch> result;
|
||||
@@ -229,6 +262,8 @@ std::optional<CareerSession::PoachDispatch> TransferActions::poach(int manager,
|
||||
return result;
|
||||
}
|
||||
|
||||
// Builds the request to list the squad player `item` on the market (as a loan if `loan`),
|
||||
// bound to the observed state's manager, club and revision.
|
||||
ui::TransferMarketRequest TransferActions::listing(const ui::TransferMarketState& observed,
|
||||
const ui::TransferMarketSquadItem& item, bool loan) {
|
||||
ui::TransferMarketRequest request;
|
||||
@@ -244,6 +279,8 @@ ui::TransferMarketRequest TransferActions::listing(const ui::TransferMarketState
|
||||
return request;
|
||||
}
|
||||
|
||||
// Builds the request to open an offer for the market entry `item`; an existing own bid
|
||||
// is used as the starting point.
|
||||
ui::TransferMarketRequest TransferActions::opening(const ui::TransferMarketState& observed,
|
||||
const ui::TransferMarketItem& item, bool loan) {
|
||||
ui::TransferMarketRequest request;
|
||||
@@ -261,6 +298,7 @@ ui::TransferMarketRequest TransferActions::opening(const ui::TransferMarketState
|
||||
return request;
|
||||
}
|
||||
|
||||
// Builds a request from the offer editor's current state plus the changed field and value.
|
||||
ui::OutgoingTransferRequest TransferActions::editor(const ui::OutgoingTransferEditorState& observed,
|
||||
ui::OutgoingTransferRequestKind kind, ui::OutgoingTransferField field, uint32_t value) {
|
||||
ui::OutgoingTransferRequest request;
|
||||
@@ -280,11 +318,13 @@ ui::OutgoingTransferRequest TransferActions::editor(const ui::OutgoingTransferEd
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the bank checkpoint on failure.
|
||||
bool BankActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.bank_checkpoint(),
|
||||
[&](CareerSession::BankCheckpoint before) { session_.restore_bank_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Sends a bank request to the session; `acknowledge` is called when it was accepted.
|
||||
bool BankActions::dispatch(const ui::BankRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -294,6 +334,7 @@ bool BankActions::dispatch(const ui::BankRequest& request, uint64_t& revision, s
|
||||
});
|
||||
}
|
||||
|
||||
// Creates a bank request of `kind` bound to the observed manager, club and revision.
|
||||
ui::BankRequest BankActions::bind(const ui::BankState& observed, ui::BankRequestKind kind) {
|
||||
ui::BankRequest request;
|
||||
request.kind = kind;
|
||||
@@ -303,12 +344,14 @@ ui::BankRequest BankActions::bind(const ui::BankState& observed, ui::BankRequest
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request to move `amount` to the deposit account.
|
||||
ui::BankRequest BankActions::savings(const ui::BankState& observed, int32_t amount) {
|
||||
auto request = bind(observed, ui::BankRequestKind::move_to_deposit);
|
||||
request.amount = amount;
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for an investment action on asset index `asset` with `count` units.
|
||||
ui::BankRequest BankActions::investment(const ui::BankState& observed, ui::BankRequestKind kind,
|
||||
int asset, int count) {
|
||||
auto request = bind(observed, kind);
|
||||
@@ -317,6 +360,8 @@ ui::BankRequest BankActions::investment(const ui::BankState& observed, ui::BankR
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for a bank credit: carries the saved credit, the player's edits, whether the
|
||||
// fees are accepted and the counterparty.
|
||||
ui::BankRequest BankActions::credit(const ui::BankState& observed, const BankCreditContext& context,
|
||||
const BankCreditDraft& draft, bool accept_fees, int counterparty) {
|
||||
auto request = bind(observed, ui::BankRequestKind::bank_credit);
|
||||
@@ -327,11 +372,14 @@ ui::BankRequest BankActions::credit(const ui::BankState& observed, const BankCre
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the stadium checkpoint on failure.
|
||||
bool StadiumActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.stadium_checkpoint(),
|
||||
[&](CareerSession::StadiumCheckpoint before) { session_.restore_stadium_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Sends a stadium request to the session with the notice hooks; `acknowledge` is called
|
||||
// when it was accepted.
|
||||
bool StadiumActions::dispatch(const ui::StadiumRequest& request, uint64_t& revision, std::string& error,
|
||||
const ConstructionNoticeHook& construction, const SeasonTicketCompensationNoticeHook& compensation,
|
||||
const std::function<void()>& acknowledge) {
|
||||
@@ -342,6 +390,7 @@ bool StadiumActions::dispatch(const ui::StadiumRequest& request, uint64_t& revis
|
||||
});
|
||||
}
|
||||
|
||||
// Creates a stadium request bound to the observed club, revision, scope and sequence.
|
||||
ui::StadiumRequest StadiumActions::request(const ui::StadiumState& observed, ui::StadiumRequestKind kind,
|
||||
int object, int option, int32_t price, bool accept_tip) {
|
||||
ui::StadiumRequest request;
|
||||
@@ -359,6 +408,8 @@ ui::StadiumRequest StadiumActions::request(const ui::StadiumState& observed, ui:
|
||||
return request;
|
||||
}
|
||||
|
||||
// Sets the ticket price for the observed desk's club; the stable club identity is filled
|
||||
// in when the club index is valid.
|
||||
bool DeskActions::ticket_price(const ui::DeskState& observed, int price,
|
||||
uint64_t& revision, std::string& error) {
|
||||
TicketPriceRequest request;
|
||||
@@ -371,11 +422,13 @@ bool DeskActions::ticket_price(const ui::DeskState& observed, int price,
|
||||
return session_.dispatch_ticket_price(request, revision, error);
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the lineup checkpoint on failure.
|
||||
bool LineupActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.lineup_checkpoint(),
|
||||
[&](CareerSession::LineupCheckpoint before) { session_.restore_lineup_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Sends a lineup request to the session; `acknowledge` is called when accepted.
|
||||
bool LineupActions::lineup(const ui::LineupRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -385,6 +438,7 @@ bool LineupActions::lineup(const ui::LineupRequest& request, uint64_t& revision,
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a pitch request to the session; `acknowledge` is called when accepted.
|
||||
bool LineupActions::pitch(const ui::PitchRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -394,10 +448,13 @@ bool LineupActions::pitch(const ui::PitchRequest& request, uint64_t& revision, s
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a pitch swap request to the session as one transaction.
|
||||
bool LineupActions::pitch_swap(const ui::PitchRequest& request, uint64_t& revision, std::string& error) {
|
||||
return apply(revision, [&] { return session_.dispatch_pitch_swap(request, revision, error); });
|
||||
}
|
||||
|
||||
// Changes one order value (`aspect`) of a player. Only valid for the observed revision;
|
||||
// on success the revision is increased.
|
||||
bool LineupActions::order(const ui::LineupState& observed, const ui::LineupPlayer& player,
|
||||
int aspect, int value, uint64_t& revision) {
|
||||
return apply(revision, [&] {
|
||||
@@ -408,6 +465,9 @@ bool LineupActions::order(const ui::LineupState& observed, const ui::LineupPlaye
|
||||
});
|
||||
}
|
||||
|
||||
// Tries the requested pitch move on a copy of the state and tells whether the player ends
|
||||
// up paired with `second_row` (requested), with another player (other_pair) or whether the
|
||||
// move is invalid.
|
||||
LineupActions::PairTarget LineupActions::pair_target(const ui::PitchRequest& request, int second_row) const {
|
||||
auto preview = session_.state();
|
||||
if (!move_pitch_player_source(preview, request.manager_slot, request.runtime_club,
|
||||
@@ -419,6 +479,7 @@ LineupActions::PairTarget LineupActions::pair_target(const ui::PitchRequest& req
|
||||
? PairTarget::requested : PairTarget::other_pair;
|
||||
}
|
||||
|
||||
// Creates a lineup request that prepares the lineup of the observed state.
|
||||
ui::LineupRequest LineupActions::prepare(const ui::LineupState& observed) {
|
||||
ui::LineupRequest request;
|
||||
request.kind = ui::LineupRequestKind::prepare_lineup;
|
||||
@@ -428,6 +489,7 @@ ui::LineupRequest LineupActions::prepare(const ui::LineupState& observed) {
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to swap two players of the lineup.
|
||||
ui::LineupRequest LineupActions::swap(const ui::LineupState& observed,
|
||||
const ui::LineupPlayer& first, const ui::LineupPlayer& second) {
|
||||
auto request = prepare(observed);
|
||||
@@ -438,6 +500,8 @@ ui::LineupRequest LineupActions::swap(const ui::LineupState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a pitch request of `kind` bound to the observed lineup. The observed live mode
|
||||
// must be known, otherwise a FormatError is thrown.
|
||||
ui::PitchRequest LineupActions::bind_pitch(const ui::PreparationState& observed, ui::PitchRequestKind kind) {
|
||||
if (!observed.pitch || !observed.pitch->indoor.has_value())
|
||||
throw FormatError("pitch: missing observed live mode");
|
||||
@@ -450,6 +514,7 @@ ui::PitchRequest LineupActions::bind_pitch(const ui::PreparationState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to swap two players on the pitch (including their current positions).
|
||||
ui::PitchRequest LineupActions::swap_pitch(const ui::PreparationState& observed,
|
||||
const ui::LineupPlayer& first, const ui::LineupPlayer& second) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::swap_players);
|
||||
@@ -459,6 +524,7 @@ ui::PitchRequest LineupActions::swap_pitch(const ui::PreparationState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to switch the pitch page (toggles the 0x000c bits of the display word).
|
||||
ui::PitchRequest LineupActions::page(const ui::PreparationState& observed) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::select_pitch_page);
|
||||
request.expected_mode = uint8_t(observed.pitch->mode);
|
||||
@@ -470,6 +536,8 @@ ui::PitchRequest LineupActions::page(const ui::PreparationState& observed) {
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to load or save a formation in `slot`; saving copies the position
|
||||
// bytes of the 11 players on the pitch.
|
||||
ui::PitchRequest LineupActions::formation(const ui::PreparationState& observed,
|
||||
ui::PitchRequestKind kind, int slot) {
|
||||
auto request = bind_pitch(observed, kind);
|
||||
@@ -485,6 +553,7 @@ ui::PitchRequest LineupActions::formation(const ui::PreparationState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to move a player to the given depth and lane.
|
||||
ui::PitchRequest LineupActions::move(const ui::PreparationState& observed, const ui::LineupPlayer& player,
|
||||
int depth, int lane) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::move_player);
|
||||
@@ -495,6 +564,8 @@ ui::PitchRequest LineupActions::move(const ui::PreparationState& observed, const
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request that advances one of the three automatic weights (index 0..2) by one
|
||||
// step; each weight is a 2-bit value that wraps around after 3.
|
||||
ui::PitchRequest LineupActions::weight(const ui::PreparationState& observed, int index) {
|
||||
if (index < 0 || index > 2) throw FormatError("pitch: invalid automatic weight index");
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::set_automatic_weight);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Application-boundary facades for the club and league windows: league table/pairings/
|
||||
// strengths, transfer market and offers, bank, stadium, desk actions and lineup. Same pattern
|
||||
// as desktop_actions.hpp: a class per owner that wraps a CareerSession, offers apply() as a
|
||||
// rollback transaction and takes the shared revision counter plus an acknowledgement
|
||||
// callback from the front end. Implemented in window_actions.cpp, called from controller.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
@@ -38,7 +43,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&,
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of container.hpp: parse_container() checks the FORM/ALPTRAUM header and
|
||||
// walks the adjacent little-endian chunks (no alignment byte) with bounds checks, filling
|
||||
// a Container of offsets; decode_sample() and decode_original_cue() convert the bounded
|
||||
// sample data to PCM. Pure functions on byte spans, no state; failures are reported through
|
||||
// the std::string& error argument and a false result.
|
||||
#include "container.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Reader for the original sound container (a FORM/ALPTRAUM chunk wrapper) and for the PCM
|
||||
// samples inside it. A Container only lists chunk ids and payload offsets; the payload bytes
|
||||
// stay in the caller's buffer, which must outlive any use of the offsets. decode_sample()
|
||||
// turns unsigned 8-bit samples into signed 16-bit mono PCM; decode_original_cue() resolves
|
||||
// only the PCM-backed effects (original ids 17..22). Pairs with container.cpp; the PCM types
|
||||
// are shared by mixer, playback, semantic cues and the music fallback.
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of Mixer (mixer.hpp). Incoming PCM is resampled to the output rate with
|
||||
// range and overflow checks and a total/per-voice byte ceiling (2 MiB overall, an eighth of
|
||||
// that per voice); mix_block() sums music and active voices into the output block, applies
|
||||
// the volume and advances the cursors (the music loops).
|
||||
#include "mixer.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Small PCM mixer used by the software (non-original) playback path: one looping music
|
||||
// buffer plus up to 8 one-shot voices, all converted to the output rate when added.
|
||||
// start_music_loop()/add_voice() may allocate; mix_block() only reads the prepared buffers
|
||||
// and writes into caller-owned storage, so it is safe to call from the audio path. Owned
|
||||
// by Playback (playback.hpp); the byte limits are in mixer.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the synthetic matchday loop (music_fallback.hpp): a fixed 22050 Hz,
|
||||
// 108 bpm, 8-bar sequence of bass, chord and lead notes defined by constant MIDI tables,
|
||||
// rendered to mono PCM16. No game state or randomness is involved, so the output is the
|
||||
// same on every run.
|
||||
#include "music_fallback.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Synthetic fallback matchday music: a deterministic 8-bar loop generated in code. It is
|
||||
// presentation filler, not decoded original music and not tied to any original sound id.
|
||||
// The result is a PcmSample that Playback::start_music_loop() can play; implemented in
|
||||
// music_fallback.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of OriginalSynth (original.hpp). The hidden State holds the parsed
|
||||
// songs, tracks, channels, sample banks and the Nuked-OPL3 chip core (src/audio/third_party);
|
||||
// tick() runs one sequencer step of the original timer interrupt, render() produces output
|
||||
// samples from the chip and the PCM channel. load() validates every input and fails
|
||||
// cleanly on malformed data; the register and sample observers exist only for offline
|
||||
// validation (original_validation.cpp, sound_driver.cpp).
|
||||
#include "original.hpp"
|
||||
#include "container.hpp"
|
||||
#include "third_party/nuked-opl3/opl3.h"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Emulation of the original game's sound system (MIDI-style sequencer, OPL FM instruments
|
||||
// and one Sound Blaster PCM channel) as OriginalSynth. The application reads the sound
|
||||
// containers (S/2000..2003) and the frequency/operator tables from the user's executable
|
||||
// and hands them in as OriginalAssets; this module knows nothing about game state, file
|
||||
// layout, the simulation clock or random generators. command() takes the original sound ids
|
||||
// (0 title, 1 desk, 2 intro, 3 crowd, 8 stop, 10..22 effects); render() fills PCM blocks
|
||||
// without allocating. Implemented in original.cpp, driven by Playback and the audio tools.
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Validation executable for the original-sound emulation (original.hpp, playback.hpp). It
|
||||
// needs the user's game data directory as its single argument, loads the executable tables
|
||||
// and sound containers from it, and runs oracle checks on song/effect output, transitions,
|
||||
// malformed input, option and mute handling, effect priorities and the audio callback
|
||||
// lifecycle. With an empty argument it prints SKIP and exits with 77 (test skipped).
|
||||
// Contains no game assets itself.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "original.hpp"
|
||||
#include "playback.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of Playback (playback.hpp): opens the SDL audio device, feeds either the
|
||||
// OriginalSynth from the SDL callback (original mode) or bounded blocks from the Mixer via
|
||||
// pump() (software mode), and maps original ids and semantic cues to sound played on the
|
||||
// device. Duplicate or out-of-order event ids are rejected before anything is played;
|
||||
// shutdown() releases the device.
|
||||
#include "playback.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Audio output device wrapper (SDL) and the single audio object the application uses.
|
||||
// Playback owns the SDL device, a software Mixer (PCM effects, optional music loop) and the
|
||||
// OriginalSynth (the full original driver, streamed from SDL's audio callback so modal
|
||||
// windows cannot starve it). Cue requests carry a session id and an increasing event id
|
||||
// chosen by the controller; submit() consumes each event once and returns a CueStatus.
|
||||
// Mute and volume apply to both paths. Pairs with playback.cpp and app/audio.hpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of synthesize_semantic_cue() (semantic_cues.hpp): builds each cue in code
|
||||
// (the whistles from frequency sweeps with attack and release shaping) at 22050 Hz and
|
||||
// clamps the result to 16-bit PCM. Pure and deterministic.
|
||||
#include "semantic_cues.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Semantic sound cues (kickoff whistle, goal, full-time whistle) synthesized in code for
|
||||
// use when no verified original effect is available. They are labels of intent, never
|
||||
// original sound ids. The generator is deterministic mono PCM16 at 22050 Hz and has no
|
||||
// dependency on game state, randomness or rendering; implemented in semantic_cues.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Command line tool openbmh_sound for the audio module. It works either on one sound
|
||||
// container file (play or export a sample, a test tone, or an original effect id as WAV) or,
|
||||
// with --original DATA_DIR, on the user's game data through OriginalSynth (export a song or
|
||||
// effect to WAV, or play ids through the real device). It also plays or exports the
|
||||
// synthetic semantic cues and the fallback music loop. Own state only: parsed arguments.
|
||||
// Bounds on seconds, loops and ids are checked before anything runs.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "container.hpp"
|
||||
#include "music_fallback.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Self-contained checks for the audio module that need no game data: container parsing
|
||||
// against authored fixtures, sample and cue decoding, the mixer, the playback request
|
||||
// rules and the synthetic music fallback. The fixtures are built in code and are not
|
||||
// copied from any game asset. Returns non-zero on the first failed CHECK; companion of
|
||||
// original_validation.cpp, which covers the original-driver emulation.
|
||||
#include "container.hpp"
|
||||
#include "music_fallback.hpp"
|
||||
#include "playback.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the console line parser (parser.hpp): trimming, top-level splitting of
|
||||
// the argument list (commas inside quotes or brackets do not split), parsing of one
|
||||
// argument (positional or name=value), canonical name comparison that ignores case, '.' and
|
||||
// '_', line classification, and the integer/bool converters for arguments. Pure functions;
|
||||
// no console state. The console (console.cpp, windows_*.cpp) checks the argument types.
|
||||
#include "cli/console/parser.hpp"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of parse_json()/dump_json() (json.hpp): a small recursive-descent Parser
|
||||
// over a string_view that reports the byte position in JsonError messages, UTF-8 handling
|
||||
// for string escapes, and a serializer for the Json variant. No state beyond the parser's
|
||||
// position in the input.
|
||||
#include "cli/json.hpp"
|
||||
|
||||
#include <charconv>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Minimal JSON value type for the CLI protocol (no external library). A Json holds null,
|
||||
// bool, a 64-bit integer, string, array or object (std::map) in one std::variant; the
|
||||
// accessors return null pointers when the type does not match, so callers must check.
|
||||
// Numbers are integers only. parse_json() throws JsonError on bad input; dump_json() writes
|
||||
// compact text. Used by protocol.*, seat_hub.cpp and main.cpp; implemented in json.cpp.
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Entry point of openbmh_cli, the headless front end without a window. Besides parsing the
|
||||
// command line (Arguments) it offers several modes on top of the same engine: the JSON
|
||||
// protocol on stdin/stdout (protocol.hpp) with --log/--replay, the console language
|
||||
// (docs/CLI_CONCEPT) as plain session, replay, mailbox server (--serve), multi-seat server
|
||||
// (--seats, SeatHub), TCP listener on 127.0.0.1 (--listen), and --send to hand one block to
|
||||
// a running mailbox session. --data may be a game directory, the game's EXE or an archive
|
||||
// (src/launch resolves it). All game logic stays in the engine; this file only moves lines.
|
||||
#include "cli/protocol.hpp"
|
||||
#include "cli/console/console.hpp"
|
||||
#include "cli/seat_hub.hpp"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the JSON protocol (protocol.hpp). Protocol::handle() validates the
|
||||
// request keys per command (check_keys / check_command_keys), then calls the CareerSession
|
||||
// and the same projection functions the SDL front end uses (desk, table, mail, tactics,
|
||||
// training, camp, bank, stadium, kickoff, save/load, ...), and wraps the result with the
|
||||
// current revision. Errors are returned as {"ok": false, "error": ...}, never thrown to the
|
||||
// caller. The "replay" flag lets a logged session be played again (saves may overwrite).
|
||||
// text_request()/text_response() implement the one-line text form of the protocol.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "cli/protocol.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The JSON line protocol of openbmh_cli (the non-console mode): one request object with a
|
||||
// "cmd" field in, one response object ("ok", "revision", result or error) out. Protocol owns
|
||||
// one app::CareerSession (created by "new" or "load") and the revision counter that every
|
||||
// state-changing command must echo back, so stale requests are refused like in the UI
|
||||
// flow. text_request()/text_response() translate a simple one-line text form to and from the
|
||||
// same JSON. Implemented in protocol.cpp; Protocol::help() lists the commands.
|
||||
#pragma once
|
||||
|
||||
#include "cli/json.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of SeatHub (seat_hub.hpp): routes the blocks of several clients into one
|
||||
// console::Console. It runs a block as the seat's manager ("@k"), classifies each output
|
||||
// line with Console::LineInfo, queues lines that concern other seats as their "meanwhile"
|
||||
// feed, holds WaitTurn blocks until they can be answered, and holds the Run/Step of a live
|
||||
// match until every seat has sent one. State per seat is a small Seat record; the game
|
||||
// itself lives in the console.
|
||||
#include "cli/seat_hub.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Decides which club badge tokens the original draws as a fallback instead of an individual
|
||||
// crest. The cut-off for foreign clubs differs between game editions, so it is read from one
|
||||
// instruction in the loaded executable (layout::ForeignBadgeGateInstruction) and stored in the
|
||||
// process-wide original_foreign_badge_end by install_original_badge_policy(). An executable
|
||||
// that does not match the verified pattern falls back to 138. Header-only; the club
|
||||
// selectors themselves stay in the database and savegame data.
|
||||
#pragma once
|
||||
|
||||
#include "formats/executable_layout.hpp"
|
||||
@@ -9,10 +15,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 +31,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,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the basic file helpers declared in binary.hpp: read_file() loads a whole
|
||||
// file into a Bytes vector (FormatError if it cannot be opened) and iso646de_to_utf8()
|
||||
// converts the game's ISO 646-DE strings ([ \ ] { | } ~ stand for the umlauts and the sharp s)
|
||||
// to UTF-8. No state.
|
||||
#include "formats/binary.hpp"
|
||||
#include "formats/resource_bundle.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
@@ -8,8 +11,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,43 +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 {};
|
||||
const auto raw=read_file(file);
|
||||
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,24 +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 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;
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the .FBM savegame container (fbm.hpp): fbm_encrypt()/fbm_decrypt() are the
|
||||
// stream cipher whose key changes by 0x29 per byte, and load_savegame() finds the "KRON_FBM"
|
||||
// magic, splits the plain header from the encrypted stream, decrypts it and verifies the
|
||||
// one-byte checksum, which is reported in Savegame::checksum_ok (not thrown). The decrypted
|
||||
// stream is interpreted by savestate.cpp. Pure functions, no state.
|
||||
#include "formats/fbm.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the .FNT bitmap font loader and renderer (font.hpp): load_font() reads
|
||||
// the header, the 1-bit glyph bitmap and the per-character location (and spacing) tables and
|
||||
// checks that the file size matches exactly; Font::glyph(), text_width() and draw() look up
|
||||
// glyphs (out-of-range characters use the last glyph) and draw them into an indexed Image.
|
||||
// No state beyond the Font object.
|
||||
#include "formats/font.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
+7
-97
@@ -1,7 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the executable image loader (le.hpp): load_le() reads the original
|
||||
// DOS/4GW LE executable, places its objects at their link addresses and applies the internal
|
||||
// fixups (FormatError for other files or external fixups). It also accepts the OpenBMH image
|
||||
// format written by save_image(), so a translated image can replace the executable.
|
||||
// LeImage::cstring() reads NUL-terminated strings from the image. No global state.
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/data_profile.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
@@ -18,10 +21,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 +40,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 +136,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,18 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Reads from the loaded executable how many league levels a player can see; the original
|
||||
// separates internal domestic league slots from these visible levels. Throws
|
||||
// std::invalid_argument when the stored constants fail the sanity check. Header-only,
|
||||
// stateless; the address comes from executable_layout.hpp and the image from le.hpp.
|
||||
#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);
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -1,6 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the M3D.MAN master database loader (m3d.hpp). load_database() reads the
|
||||
// file sequentially with a bounds-checked Reader: first the lengths of the four string pools
|
||||
// (clubs, players, referees, stadiums), then the pools, the name offset tables and the raw
|
||||
// record blocks, whose sizes depend on the DbCounts passed in. Several blocks are kept as raw
|
||||
// bytes in the Database (raw_* fields). Throws FormatError on a truncated file.
|
||||
#include "formats/m3d.hpp"
|
||||
#include "formats/data_profile.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -35,17 +39,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) {
|
||||
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);
|
||||
@@ -62,8 +62,8 @@ Database load_database(const std::filesystem::path& path, 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");
|
||||
|
||||
+1
-5
@@ -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,7 +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 load_database(const std::filesystem::path& path, const DbCounts& counts = {});
|
||||
|
||||
} // namespace bmh
|
||||
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Accepted savegame version markers for the native (original-layout) save format. The FBM
|
||||
// container (fbm.hpp) carries a version string; V2.24 and V3.7 share the same block order,
|
||||
// while expanded careers use their own marker (O1.1) and layout. require_native_savegame()
|
||||
// throws FormatError on a bad checksum or an unsupported marker; callers still validate the
|
||||
// full state layout afterwards (savestate.hpp). Header-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.
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the palette loader (palette.hpp). load_palette() reads a 256-entry,
|
||||
// 6 bits per channel RGB file and converts it to 32-bit ARGB via vga_dac_rgb8();
|
||||
// load_optional_embedded_palette() reads the palette that may follow the RLE data of a VGA
|
||||
// image file (std::nullopt if there is none); Palette::nearest() returns the index of the
|
||||
// closest colour by squared RGB distance. FormatError on short or inconsistent files.
|
||||
#include "formats/palette.hpp"
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
@@ -16,6 +21,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);
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the savegame stream layout (savestate.hpp). save_layout() lists the
|
||||
// blocks in the exact order the original wrote them, with sizes that are constants or depend
|
||||
// on DbCounts; the SaveState constructor splits a decrypted stream along that list, reads
|
||||
// the four string-pool trailer blocks and the optional OpenBMH extension, and throws
|
||||
// FormatError if the sizes do not add up. append_save_extension() writes that extension.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/savestate.hpp"
|
||||
|
||||
@@ -31,7 +36,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 +48,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 +56,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 +103,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 +111,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 +182,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) {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the TEXTD.BLK loader (textd.hpp): skips the 7-byte header, keeps the whole
|
||||
// blob and splits it into NUL-terminated strings, recording each string's offset. Exactly
|
||||
// TEXT_COUNT strings must be found, otherwise FormatError. No state.
|
||||
#include "formats/textd.hpp"
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the .VGA image support (vga.hpp): Image::blit() copies one indexed image
|
||||
// into another with clipping, decode_vga() unpacks the run-length data (a byte of 0x80 or
|
||||
// more is a run, below that a literal block) and checks the length fields and the single
|
||||
// trailing byte, and load_vga() reads a file and decodes it. FormatError on malformed data.
|
||||
#include "formats/vga.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
+11
-15
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Business plan (balance plan) screen of a human manager: builds a draft of the plan rows
|
||||
// (income, running costs, shares and loans, catering, ticket price), checks per-row maxima when
|
||||
// the player edits a row and writes the accepted plan back on close.
|
||||
// Reads and writes the manager records in GameState (manager_records); reads schedule, table and
|
||||
// prediction data for the forecast. Draws no random numbers.
|
||||
// Interface in balance_plan.hpp; monthly bookings of similar figures live in month.cpp / week.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/balance_plan.hpp"
|
||||
@@ -30,7 +36,7 @@ constexpr uint16_t kFacilityCost[22] = {2000, 3000, 3000, 8000, 4000, 3000, 2500
|
||||
// BalancePlanRuntimeField6: monthly income of the first six facilities (FacilityIncome)
|
||||
constexpr uint16_t kFacilityIncome[6] = {0, 5000, 5000, 4800, 2400, 8000};
|
||||
// BalancePlanRuntimeField7: catering income per visitor of the facilities 0-13 (BookMoney)
|
||||
constexpr uint8_t kPerVisitor[14] = {0, 10, 10, 3, 5, 15, 3, 3, 3, 3, 2, 2, 2, 2};
|
||||
constexpr uint8_t kPerVisitor[14] = {0, 10, 15, 3, 5, 10, 3, 3, 3, 3, 2, 2, 2, 2}; // Diamond 3.7 (entries 2 and 5 were 10 and 15)
|
||||
// Rec32: price units of the six funds (BMH.exe+MonthRuntimeField10)
|
||||
constexpr int32_t kShareUnits[6] = {15, 18, 21, 24, 27, 30};
|
||||
|
||||
@@ -56,19 +62,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 +74,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 +257,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;
|
||||
|
||||
+109
-11
@@ -1,7 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Bank credit dialog: loans from the bank or from another manager, held in the per-manager loan
|
||||
// matrix of the manager records. Implements the amount/fee/monthly-payment arithmetic (with the
|
||||
// original's extended-precision rounding emulated in integers), draft editing with bounds, and
|
||||
// the interest-rate change. Reads the manager records and executable tables via BankCreditContext;
|
||||
// only change_bank_credit_interest writes GameState here. Draws no random numbers.
|
||||
// Types are declared in bank_credit.hpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/bank_credit.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
@@ -29,6 +36,102 @@ uint32_t read_record(const GameState& g, size_t at) {
|
||||
for (int i = 0; i < 4; ++i) v |= uint32_t(g.manager_records.at(at + i)) << (i * 8);
|
||||
return v;
|
||||
}
|
||||
// The original evaluates ((base / 100) * den) / 100 on the x87 stack: every step is rounded to a
|
||||
// 64-bit mantissa (round to nearest even), only the final store rounds to a 53-bit double. The
|
||||
// host's long double is not that format (64 bits on MSVC and on Apple silicon), which changed the
|
||||
// result by 1 for loans of about a million and more. This evaluates the same chain exactly with
|
||||
// integers, so the result is the same on every platform. Returns the value truncated toward zero.
|
||||
struct Wide { // 128-bit unsigned, little-endian 32-bit limbs
|
||||
std::array<uint32_t, 4> l{};
|
||||
unsigned bit_length() const {
|
||||
for (int i = 3; i >= 0; --i)
|
||||
if (l[size_t(i)]) return unsigned(i) * 32 + unsigned(32 - std::countl_zero(l[size_t(i)]));
|
||||
return 0;
|
||||
}
|
||||
bool bit(unsigned n) const { return n < 128 && (l[n / 32] >> (n % 32)) & 1u; }
|
||||
bool any_below(unsigned n) const { // any bit below position n set
|
||||
for (unsigned i = 0; i < n && i < 128; ++i) if (bit(i)) return true;
|
||||
return false;
|
||||
}
|
||||
static Wide from(uint64_t v) { Wide w; w.l[0] = uint32_t(v); w.l[1] = uint32_t(v >> 32); return w; }
|
||||
uint64_t window(unsigned lo) const { // the 64 bits starting at bit `lo`
|
||||
uint64_t v = 0;
|
||||
for (unsigned i = 0; i < 64; ++i) if (bit(lo + i)) v |= uint64_t(1) << i;
|
||||
return v;
|
||||
}
|
||||
};
|
||||
struct Extended { uint64_t m = 0; int e = 0; }; // value = m * 2^e, m has 64 bits (or is zero)
|
||||
// Round `w` (plus a "something was dropped" flag) to 64 bits, nearest even; value = w * 2^exp.
|
||||
Extended round_to_64(const Wide& w, bool sticky, int exp) {
|
||||
const unsigned len = w.bit_length();
|
||||
Extended r;
|
||||
if (len == 0) return r;
|
||||
if (len <= 64) {
|
||||
const unsigned up = 64 - len;
|
||||
r.m = w.window(0) << up;
|
||||
r.e = exp - int(up);
|
||||
return r;
|
||||
}
|
||||
const unsigned s = len - 64;
|
||||
r.m = w.window(s);
|
||||
const bool guard = w.bit(s - 1), rest = sticky || w.any_below(s - 1);
|
||||
r.e = exp + int(s);
|
||||
if (guard && (rest || (r.m & 1))) {
|
||||
if (++r.m == 0) { r.m = uint64_t(1) << 63; ++r.e; }
|
||||
}
|
||||
return r;
|
||||
}
|
||||
Extended x87_divide_small(const Extended& a, uint32_t d) {
|
||||
Wide n; // a.m * 2^64, divided limb by limb
|
||||
n.l[2] = uint32_t(a.m); n.l[3] = uint32_t(a.m >> 32);
|
||||
uint64_t rem = 0;
|
||||
Wide q;
|
||||
for (int i = 3; i >= 0; --i) {
|
||||
const uint64_t cur = (rem << 32) | n.l[size_t(i)];
|
||||
q.l[size_t(i)] = uint32_t(cur / d);
|
||||
rem = cur % d;
|
||||
}
|
||||
return round_to_64(q, rem != 0, a.e - 64);
|
||||
}
|
||||
Extended x87_multiply_small(const Extended& a, uint32_t b) {
|
||||
Wide p;
|
||||
uint64_t carry = 0;
|
||||
const uint32_t limb[2] = {uint32_t(a.m), uint32_t(a.m >> 32)};
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
const uint64_t cur = uint64_t(limb[i]) * b + carry;
|
||||
p.l[size_t(i)] = uint32_t(cur);
|
||||
carry = cur >> 32;
|
||||
}
|
||||
p.l[2] = uint32_t(carry);
|
||||
return round_to_64(p, false, a.e);
|
||||
}
|
||||
// ((base / 100) * den) / 100 stored as a double and truncated toward zero. `zero` reports an exact
|
||||
// zero before truncation (the original's "exact zero becomes 1" rule looks at the stored double).
|
||||
int64_t x87_amount_chain(int32_t base, uint32_t den, bool& zero) {
|
||||
zero = base == 0 || den == 0;
|
||||
if (zero) return 0;
|
||||
const bool negative = base < 0;
|
||||
const uint64_t magnitude = negative ? uint64_t(-int64_t(base)) : uint64_t(base);
|
||||
Extended v = round_to_64(Wide::from(magnitude), false, 0);
|
||||
v = x87_divide_small(v, 100);
|
||||
v = x87_multiply_small(v, den);
|
||||
v = x87_divide_small(v, 100);
|
||||
// store as double: 53-bit mantissa, nearest even
|
||||
uint64_t m53 = v.m >> 11;
|
||||
int e = v.e + 11;
|
||||
const bool guard = (v.m >> 10) & 1, rest = (v.m & 0x3ff) != 0;
|
||||
if (guard && (rest || (m53 & 1))) ++m53; // a carry to 2^53 is still exact
|
||||
uint64_t whole;
|
||||
if (e >= 0) {
|
||||
if (e > 10) throw std::invalid_argument("invalid native credit amount");
|
||||
whole = m53 << e;
|
||||
} else {
|
||||
whole = -e >= 64 ? 0 : m53 >> unsigned(-e);
|
||||
}
|
||||
if (whole > uint64_t(std::numeric_limits<int32_t>::max()) + (negative ? 1u : 0u))
|
||||
throw std::invalid_argument("invalid native credit amount");
|
||||
return negative ? -int64_t(whole) : int64_t(whole);
|
||||
}
|
||||
// Amount: signed IMUL/IDIV, x87 intermediate, QWORD store,
|
||||
// exact-zero floor, then Amount2's explicit rounding toward zero.
|
||||
int32_t amount(const BankCreditContext& c, uint32_t months, int32_t principal) {
|
||||
@@ -37,15 +140,10 @@ int32_t amount(const BankCreditContext& c, uint32_t months, int32_t principal) {
|
||||
const int32_t factor = c.rate_table[months];
|
||||
const int32_t base = divide(mul(principal, factor), 100);
|
||||
const int32_t den = divide(10000, factor - 100);
|
||||
const long double intermediate = (static_cast<long double>(base) / c.divisor)
|
||||
* den / c.divisor;
|
||||
double raw = static_cast<double>(intermediate);
|
||||
if (raw == 0 && principal != 0) raw = 1;
|
||||
raw = std::trunc(raw);
|
||||
if (!std::isfinite(raw) || raw < std::numeric_limits<int32_t>::min()
|
||||
|| raw > std::numeric_limits<int32_t>::max())
|
||||
throw std::invalid_argument("invalid native credit amount");
|
||||
return static_cast<int32_t>(raw);
|
||||
bool zero = false;
|
||||
int64_t result = x87_amount_chain(base, uint32_t(den), zero);
|
||||
if (zero && principal != 0) result = 1;
|
||||
return static_cast<int32_t>(result);
|
||||
}
|
||||
void balance(const BankCreditContext& c, BankCreditDraft& d) {
|
||||
int32_t result = add(c.cash, signed_word(d.values[0]));
|
||||
@@ -136,7 +234,7 @@ BankCreditBounds bank_credit_bounds(const BankCreditContext& c, const BankCredit
|
||||
int32_t lo = 0, hi = 0;
|
||||
if (field == 0) {
|
||||
lo = 1000;
|
||||
hi = sub(12000000, accrued);
|
||||
hi = sub(8000000, accrued); // Diamond 3.7: credit limit 8 million (12 million before)
|
||||
// case 5: no more than the lender can pay out (balance + credit line)
|
||||
if (c.counterparty && c.lender_liquidity < hi) hi = sub(c.lender_liquidity, accrued);
|
||||
}
|
||||
@@ -158,7 +256,7 @@ BankCreditBounds bank_credit_bounds(const BankCreditContext& c, const BankCredit
|
||||
if (field == 6) { hi = liquidity < accrued ? liquidity : signed_word(v[0]); }
|
||||
// Source checks availability before overriding the principal bounds.
|
||||
if (lo >= hi) return {};
|
||||
if (field == 0 && lo < signed_word(c.saved[0])) { lo = signed_word(c.saved[0]); hi = 12000000; }
|
||||
if (field == 0 && lo < signed_word(c.saved[0])) { lo = signed_word(c.saved[0]); hi = 8000000; }
|
||||
if (lo < 0 || hi < 0 || lo >= hi) return {};
|
||||
return {word(lo), word(hi), word(lo - (lo == 1)), true};
|
||||
} catch (const std::invalid_argument&) { return {}; }
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface of the bank credit dialog: context (rate table, liquidity, saved loan row), draft,
|
||||
// edit and bounds types plus the projection/edit functions implemented in bank_credit.cpp.
|
||||
// Case "bank" and case "another manager lends" share these types; projection and draft editing
|
||||
// are read-only with respect to GameState. No random numbers are drawn.
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Per-manager guard against repeated bank robbery events: one blocked month key per manager,
|
||||
// stored in an OpenBMH-owned extension block of the static memory in GameState (not in the
|
||||
// original save fields). The month key function is implemented in week.cpp.
|
||||
// Header-only accessors; no random numbers are drawn.
|
||||
#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);
|
||||
}
|
||||
+16
-1
@@ -1,16 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Calendar epoch (start year and weekday of the season calendar), read from the date setup code
|
||||
// of the loaded executable image. Unknown or unverified setups are rejected with FormatError.
|
||||
// Holds one process-wide installed epoch; reads no GameState and draws no random numbers.
|
||||
// Declared in calendar.hpp.
|
||||
#include "game/calendar.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/le.hpp"
|
||||
namespace bmh {
|
||||
namespace { CalendarEpoch installed_epoch{2026, 2}; }
|
||||
CalendarEpoch calendar_epoch_from_executable(const LeImage& exe) {
|
||||
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)
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface for the calendar epoch (start year and weekday) used for date calculations.
|
||||
// calendar_epoch_from_executable validates the loaded executable, install_calendar_rules makes it
|
||||
// active, calendar_epoch returns it (a synthetic default for isolated test states).
|
||||
// Implemented in calendar.cpp; no GameState access and no random numbers.
|
||||
#pragma once
|
||||
namespace bmh {
|
||||
class LeImage;
|
||||
|
||||
+32
-21
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Start of a new career: league strength ranges read from the executable, generation of players
|
||||
// (startup squads, the extra and market players), initial club moods and markets, the starting
|
||||
// state built from the data files, plus new-manager setup (stadium, sponsors, competition blocks).
|
||||
// Writes most of GameState (players, squad_slots, memory, manager records).
|
||||
// Draws from both generators: WatcomRandom for attributes and levels, GameRandom for the
|
||||
// reseeding done by stir_random and the mood reset.
|
||||
// Interface in career.hpp; the season-wide steps follow in season.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/career.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
@@ -12,12 +19,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 +108,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 +161,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 +178,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 +224,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 +269,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.
|
||||
@@ -399,7 +410,7 @@ void starting_sponsors(GameState& g, int m) {
|
||||
const size_t rec = size_t(m) * kRecord;
|
||||
int league = g.manager_records.at(rec + 0x210);
|
||||
if (league > 2) league--;
|
||||
const int v = (((league * -20 + 80) * 60000 + 1000000) / 12 * (mem.u8(::bmh::layout::Difficulty) * -5 + 0xaa)) / 3000000 * 10000;
|
||||
const int v = (((league * -20 + 80) * 60000 + 1000000) / 12 * (mem.u8(::bmh::layout::Difficulty) * -5 + 0x7d)) / 3000000 * 10000;
|
||||
for (size_t o : {size_t(0xae8), size_t(0xadc), size_t(0xa34)}) put32(g.manager_records, rec + o, uint32_t(v));
|
||||
for (size_t o : {size_t(0xaed), size_t(0xae1), size_t(0xa39)}) g.manager_records.at(rec + o) = 1;
|
||||
}
|
||||
@@ -431,17 +442,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,9 +565,9 @@ 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;
|
||||
const uint32_t money = level == 0 ? 50000000u : 3000000u - level * 200000u; // Diamond 3.7: 3 million start capital step base (4 million before)
|
||||
put32(r, rec + 0x314, money);
|
||||
put32(r, rec + 0x324, money);
|
||||
r.at(rec + 0x219) = r.at(rec + 0x218) = 0xf;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Club information screen preparation: sets the line-up markers (first eleven / bench) in the
|
||||
// club's squad_slots, clears markers of injured players and applies the chosen player category.
|
||||
// Reads players and squad ranges, writes squad_slots in GameState. Draws no random numbers.
|
||||
// Interface in club_info.hpp; line-up rules themselves are in lineup.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/club_info.hpp"
|
||||
#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)
|
||||
|
||||
Loaded 100 of 409 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user