Compare commits
63
Commits
obdeddi-v0.1.0
...
v1.0.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cccbb01d3 | ||
|
|
8780d7b5a5 | ||
|
|
a279bfb6df | ||
|
|
0535764834 | ||
|
|
2f5303d9bd | ||
|
|
7cc7c3a7ea | ||
|
|
f33b381f18 | ||
|
|
39de3dc9d4 | ||
|
|
fcd6eb9204 | ||
|
|
16ae7df7f8 | ||
|
|
b8a37353cc | ||
|
|
7cfc8267b6 | ||
|
|
f12857414e | ||
|
|
81ae6ad236 | ||
|
|
38f69fa37b | ||
|
|
1e7df751a0 | ||
|
|
af634ae8ff | ||
|
|
04ff3b7656 | ||
|
|
f7d20dad9e | ||
|
|
d661ec5eb0 | ||
|
|
048f617395 | ||
|
|
249bdca1a8 | ||
|
|
b8904db92d | ||
|
|
9ec136a09f | ||
|
|
a275ffa1a9 | ||
|
|
fcb6ac14bb | ||
|
|
acdc7d5c14 | ||
|
|
0faad16148 | ||
|
|
f44de65e22 | ||
|
|
bea5478433 | ||
|
|
2d744e380c | ||
|
|
9140fb4b03 | ||
|
|
02f47f7972 | ||
|
|
564af00d8d | ||
|
|
e8ba78e135 | ||
|
|
fcbe1ebc13 | ||
|
|
8b1dc16233 | ||
|
|
9c10a2bfeb | ||
|
|
6f33f9c155 | ||
|
|
9c82cb16b5 | ||
|
|
0bfa705ec5 | ||
|
|
c6341aa4f9 | ||
|
|
8862bd4f89 | ||
|
|
a5aa4c6a08 | ||
|
|
2a2fd17d07 | ||
|
|
0e8cfe5cd9 | ||
|
|
feb6ca2717 | ||
|
|
5caf23c452 | ||
|
|
30843fc9f3 | ||
|
|
8e2f491d5e | ||
|
|
4a93d9fd88 | ||
|
|
540178b264 | ||
|
|
86e2bfd32a | ||
|
|
8baf80564a | ||
|
|
d57b6b5a96 | ||
|
|
70082ef825 | ||
|
|
f87d927c8d | ||
|
|
777039832d | ||
|
|
fc07e45bbc | ||
|
|
7482697248 | ||
|
|
7b5cd6988e | ||
|
|
c8ae7a31d2 | ||
|
|
db56c323aa |
No files matched your search
@@ -62,4 +62,4 @@ jobs:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
gh release create "$RELEASE_TAG" dist/*.zip dist/SHA256SUMS dist/QA-REPORT.json --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/1.0/RELEASE_NOTES.md
|
||||
gh release create "$RELEASE_TAG" dist/*.zip dist/SHA256SUMS dist/QA-REPORT.json --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/1.0.7/RELEASE_NOTES.md
|
||||
+70
-1
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 1.0.2 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 1.0.7 LANGUAGES CXX C)
|
||||
if(APPLE)
|
||||
# Enable native languages before dependencies/subdirectories inherit rules.
|
||||
enable_language(OBJC OBJCXX)
|
||||
@@ -232,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
|
||||
@@ -340,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)
|
||||
@@ -444,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)
|
||||
@@ -492,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}")
|
||||
@@ -512,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)
|
||||
@@ -936,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}")
|
||||
@@ -1120,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)
|
||||
@@ -1152,3 +1185,39 @@ endif()
|
||||
add_executable(desktop_feedback_tests tests/desktop_feedback_tests.cpp)
|
||||
target_link_libraries(desktop_feedback_tests PRIVATE bmhui)
|
||||
bmh_add_data_test(NAME desktop_feedback_tests COMMAND desktop_feedback_tests "${BMH_DATA}")
|
||||
|
||||
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)
|
||||
|
||||
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,5 +1,10 @@
|
||||
# OpenBMH
|
||||
|
||||
**Classic-Version: 1.0.7.** Die originalgetreue Linie bleibt in diesem Repository.
|
||||
Erweiterte Ligen, die gemeinsame deutsche/englische Karriere und der Dateneditor
|
||||
werden separat als **[OpenBMH-Extended 1.0 Beta](https://github.com/Weyoune/OpenBMH-extended)** entwickelt.
|
||||
|
||||
|
||||
A faithful, standalone community reconstruction of *Bundesliga Manager Hattrick*, using the player's original installation and SDL2 interface.
|
||||
|
||||
OpenBMH 1.0 builds on v0.1.2 with reviewed bug fixes and starts directly with the original game data. Original game files, graphics, audio and manuals are not distributed. German CD-compatible BMH and verified Diamond editions are the primary release targets. Football Limited remains experimental; the older floppy executable is not supported.
|
||||
@@ -23,7 +28,9 @@ From a terminal in the extracted package on Linux or macOS:
|
||||
|
||||
In Windows PowerShell, use `.\OpenBMH.exe` and `.\openbmh_cli.exe` instead.
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0/RELEASE_NOTES.md).
|
||||
To report a problem, start the game with `-debug`. It then writes `openbmh-debug.log` (timestamped events, errors and refused actions) and `openbmh-stderr.log` into the `debug` sub folder of the save directory, and saves the game there after every match day (`DBG00001.FBM`, `DBG00002.FBM`, ...). Attach the log and the last save to the report.
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0.7/RELEASE_NOTES.md).
|
||||
|
||||
## Features and direction
|
||||
|
||||
@@ -106,3 +113,5 @@ OpenBMH's own code and documentation are licensed under **GNU GPL version 3 only
|
||||
Every published binary release identifies its matching source tag and provides a corresponding source archive. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
|
||||
|
||||
Bundled components retain their own licenses, including Nuked OPL3 under LGPL-2.1-or-later. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and [ACKNOWLEDGEMENTS.md](ACKNOWLEDGEMENTS.md).
|
||||
|
||||
The supplied project start artwork is embedded at native resolution; see [start-screen artwork](docs/START_SCREEN.md). It replaces the original title image while the game continues to use your own original data and assets.
|
||||
@@ -4,6 +4,7 @@ OpenBMH's own code and documentation use GPL-3.0-only. This does not replace the
|
||||
|
||||
| Component | Version used by the build | License | Included notice |
|
||||
|---|---|---|---|
|
||||
| [stb_image](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h) | 2.30, vendored header; JPEG decoder only | MIT or public-domain alternative | [stb_image.txt](docs/licenses/stb_image.txt) |
|
||||
| [SDL2](https://github.com/libsdl-org/SDL/tree/release-2.32.10) | 2.32.10, or an explicitly selected system SDL2 | zlib license | [SDL2.txt](docs/licenses/SDL2.txt) |
|
||||
| SDL2 HIDAPI code | Included with SDL2 | BSD-3-Clause option; upstream also offers GPL-3.0 and its original license | [license options](docs/licenses/SDL2-HIDAPI-options.txt), [BSD text](docs/licenses/SDL2-HIDAPI-BSD.txt), [original text](docs/licenses/SDL2-HIDAPI-original.txt) |
|
||||
| SDL2 yuv2rgb code | Included with SDL2 | BSD-3-Clause | [SDL2-yuv2rgb.txt](docs/licenses/SDL2-yuv2rgb.txt) |
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# OpenBMH Classic start artwork
|
||||
|
||||
The project maintainer supplied this new start-screen artwork for use and
|
||||
repository distribution with this application. It is not extracted game content.
|
||||
The repository license applies to project artwork; original game assets remain
|
||||
external. The unmodified upstream decoder has its separate documented license.
|
||||
|
||||
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
|
||||
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
|
||||
without EXIF or other input metadata. It occupies 587,410 bytes.
|
||||
The application embeds it at build time and decodes it once at startup, so
|
||||
installed applications need no image sidecar or original title-screen VGA.
|
||||
|
||||
The SDL renderer uses the actual image dimensions while showing the title,
|
||||
including high-DPI output and aspect-preserving side bars, then restores the
|
||||
320 × 240 game/input canvas. A complete left or right mouse click continues;
|
||||
there is no loading-ball animation. Changing the artwork also requires an
|
||||
explicit review/update of its SHA256 in the public-source guard.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 574 KiB |
@@ -0,0 +1,4 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
file(READ "${INPUT}" artwork HEX)
|
||||
string(REGEX REPLACE "(..)" "0x\\1," artwork "${artwork}")
|
||||
file(WRITE "${OUTPUT}" "// Generated from the repository-owned compressed start screen.\n#include \"app/start_screen_data.hpp\"\nnamespace bmh::app {\nconst unsigned char start_screen_jpeg[] = {${artwork}};\nconst std::size_t start_screen_jpeg_size=sizeof(start_screen_jpeg);\n}\n")
|
||||
@@ -139,6 +139,8 @@ This index includes registered and reserved names. `ListOptions` and `Help` from
|
||||
| `SetSquadSheet` | sheet:enum(A,B) | Set Squad Sheet. See current Help for behaviour and bounds. |
|
||||
| `SetMarketVisible` | on:bool | Set Market Visible. See current Help for behaviour and bounds. |
|
||||
| `ShowPlayer` | player:Player | Show Player. See current Help for behaviour and bounds. |
|
||||
| `ShowOffers` | player:Player | existing bids for an owned listing; raw bid slots 0..3 |
|
||||
| `AcceptOffer` | player:Player, bid:int(0..3) | accept an existing bid before weekly expiry |
|
||||
| `SellPlayer` | player:Player | VER-KAUFEN: put an own player on the list |
|
||||
| `LoanOutPlayer` | player:Player, months:int(12\|24) | VER-LEIHEN: offer an own player for loan |
|
||||
| `BuyPlayer` | player:Player | VER-KAUFEN on a market player: the offer editor |
|
||||
|
||||
+136
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
OpenBMH aims to preserve the familiar game while handling malformed input and unsafe edge cases explicitly. A reconstruction can remain faithful without reproducing a crash or pretending to implement an unknown path.
|
||||
|
||||
- Content such as names, text, graphics and edition-specific tables is loaded from the user's installation. The loaded program retains its own rule-table values; loading no longer applies the former shared replacement profile.
|
||||
- Names, text, graphics and compatible data tables come from the user's installation. The common gameplay implementation follows the documented Diamond 3.7 engine policy; original programme instructions are not executed or selected as separate engines.
|
||||
- Safety checks reject transactions that would exhaust required return capacity, use stale identities or lose a valid state. Unsupported operations report their limitation rather than inventing an outcome.
|
||||
- Calendar progression handles boundary days and seasonal transitions without relying on unsafe fixed-day assumptions.
|
||||
- Saves are written from the committed session state. Saving does not deliberately replay unrelated game actions.
|
||||
@@ -23,14 +23,33 @@ An unavailable native message box also cancels the request. This applies to
|
||||
voluntary application exits, including quit events received during animations;
|
||||
normal completed-career handling remains separate.
|
||||
|
||||
## Original edition rules in 1.0
|
||||
## Common engine and source data
|
||||
|
||||
Loaded executable images retain their own rule tables. Career strength ranges are read from all nine pairs of the supplied original table.
|
||||
|
||||
The six-budget monthly environment implementation has been checked against the provided CD and Diamond 3.6/3.7 program code. Its budget increments are read from that program's own table. Capability recognition uses verified code fingerprints, never directory names. Unrecognized environment implementations cannot be edited or simulated through a guessed model; they require separate compatibility verification. Older Diamond academy patches are not silently treated as the monthly model. The old floppy executable remains unsupported, and Football Limited remains experimental.
|
||||
The common engine uses the Diamond 3.7 six-budget monthly environment model for every supported source-data edition, including Diamond 3.6 and Football Limited. Original programme instruction fingerprints do not select another engine or block compatible data. The six numeric budget increments are read from the supplied table and installed together only when all are present and nonzero; malformed layouts remain rejected. Existing saved lump-sum academy contracts retain their established accounting until edited. English translation supplies the actual English geometry, steps and suffixes for this common model. The old floppy executable remains unsupported, and Football Limited remains experimental.
|
||||
|
||||
Football Limited's data distinguishes five internal domestic slots from four
|
||||
player-visible levels. Fresh manager selection cycles those four levels and
|
||||
hides the internal fifth picker group; confirmation rejects hidden targets and
|
||||
clubs before changing options or consuming RNG. Additional club pages remain
|
||||
separate. Internal sizes, squads, rankings and fixtures are retained, and saved
|
||||
internal league values do not cause a general load rejection.
|
||||
|
||||
Release acceptance of individual editions is recorded separately from their recognition. Source compatibility and automated tests do not establish full original-game or platform validation.
|
||||
|
||||
OpenBMH deviates from the original: graphical startup shows the supplied static
|
||||
137.VGA title with its embedded palette, without the DOS loading animation.
|
||||
It waits for a complete left or right mouse click before the game options.
|
||||
The title does not advance on a timer; its confirming press and release are
|
||||
consumed so they cannot also change a setup option.
|
||||
|
||||
Setup restores ordinary scene-backed manager dialogs before a career is created
|
||||
or loaded. The executable's boot-only black dialog mode is process state and is
|
||||
not restored from native save files. Football Limited's translated data includes
|
||||
its own verified calendar year and weekday operands; German epochs are not used
|
||||
as a substitute for the English edition.
|
||||
|
||||
## Diamond 3.7 foreign crests
|
||||
|
||||
The supplied edition controls whether foreign league clubs use individual
|
||||
@@ -41,3 +60,117 @@ Older drawing gates retain their own behaviour; no external crest pack is needed
|
||||
The automatic lineup installs the supplied foreign-player rule switch alongside the career tables. Where enabled, it restores the original three/two-player limit, reserve swaps with board-coordinate preservation and the short-lineup outcome when domestic reserves are unavailable. This does not consume additional random draws.
|
||||
|
||||
New careers correct the original all-zero EM qualification placeholders to the original national-team placeholders. Supplied nonzero seeds and restored savegame state are not rewritten by this initialization.
|
||||
|
||||
## Stadium extension in1.0.3
|
||||
|
||||
The user-requested stadium extension raises standard A–H maxima to14/24/14/20/
|
||||
14/24/14/20thousand places (144,000total), keeping larger supplied custom limits
|
||||
where the saved byte fields can represent them. Original unit prices remain
|
||||
edition-owned. Each stand's base build period is at least two weeks per1,000
|
||||
places of its expanded maximum and never shorter than the edition's original
|
||||
period. Contractor shortening remains unchanged.
|
||||
|
||||
The original Diamond3.6/3.7 table's14k stands really used25weeks versus30weeks
|
||||
for8k and37weeks for18k. That was original data, not a mistaken timer. Expanded
|
||||
limits/time policy is an intentional improvement. The UI now validates quotes
|
||||
against the actual edition and this shared policy rather than hardcoded Diamond
|
||||
prices and sizes. Existing eight capacity/construction bytes and saves are retained.
|
||||
## Daily interest at large native balances
|
||||
|
||||
OpenBMH deviates from the original: daily debt and deposit interest uses 64-bit
|
||||
intermediate arithmetic before the original integer divisions. The balance-plan
|
||||
preview uses the same calculation. Original rates, division order and random
|
||||
consumption remain unchanged. Account balances and accumulated statistics retain
|
||||
the native 32-bit save representation; this change does not add unlimited account
|
||||
balances or change the original high-cash deduction policy.
|
||||
OpenBMH deviates from the original: the legacy transfer market allows an owned
|
||||
listing to open incoming offers before its weekly expiry. Select the player and
|
||||
use the sale action (or Enter). Cancel keeps the listing and offers unchanged;
|
||||
acceptance uses the existing buyer eligibility, player salary qualification and
|
||||
transaction rules. Human-buyer loans still require their separate consent and
|
||||
allocator context and are unavailable in this early review. Viewing/canceling
|
||||
consumes no RNG. The weekly auction remains unchanged.
|
||||
|
||||
The transfer overview processes one selected player per action and renders action
|
||||
feedback in its footer. A cleared unsuccessful listing can be listed again
|
||||
immediately; there is no additional cooldown. The manager listing action refuses a full ordinary market
|
||||
without allocating a reserved special-offer row. These are explicit
|
||||
application outcomes instead of the Original's destructive overflow/dialog paths.
|
||||
|
||||
OpenBMH deviates from the original: a newly initialized squad board entry clears
|
||||
retirement, refused-negotiation and month-processing flags left by its previous
|
||||
occupant. The Original leaves that byte intact when reusing the row, so purchases
|
||||
and academy arrivals can inherit a refusal to renew. Existing players' genuine
|
||||
retirement/refusal flags remain effective. The initial academy contract remains
|
||||
two years; a young arrival can immediately negotiate any supported renewal term.
|
||||
This corrects the reused-row mechanism; it does not establish a fixed 200–300
|
||||
season threshold or repair ambiguous refusal flags in existing saved careers.
|
||||
|
||||
Bank finance-overview totals and gains use 64-bit read-only projections and
|
||||
currency formatting, including values beyond a signed native account word.
|
||||
Saved cash, deposits, loan fields and holdings retain their original widths.
|
||||
This prevents a positive combined portfolio from appearing negative; it does
|
||||
not recover amounts that have already overflowed inside a native saved field.
|
||||
|
||||
Live ball, set-piece and shot animations retain
|
||||
visible scoreboard digits at the chance-preview value until the result view.
|
||||
The simulation still commits goals, statistics and random draws at their existing
|
||||
boundaries. Post-match overview dismissal owns its full mouse gesture, including
|
||||
release after pointer movement, before the following calendar decision can open.
|
||||
The pitch uses each edition's original position-distance tables, atlas swatches
|
||||
and pointer bitmap for placement feedback; this display state is not serialized.
|
||||
OpenBMH deviates from the original: cumulative human-club appearances, goals and
|
||||
assists have optional 64-bit counters. Original byte/word fields keep their
|
||||
modulo representation for gameplay/layout compatibility; roster projections use
|
||||
the wider values. Tracking begins with the surviving legacy values, so high bits
|
||||
already lost in an imported save cannot be recovered. A new arrival clears the
|
||||
previous squad occupant's totals. Club promotion remaps counter ownership.
|
||||
|
||||
Title-holder and cup-winner lists retain all observed seasons in the same optional
|
||||
OpenBMH save extension. The Original nine-by-fifty table remains a rolling window.
|
||||
The archive captures that window before it shifts, and the title list can page
|
||||
through the archived rows. Late legacy imports start with their surviving fifty
|
||||
seasons; earlier winners are unknown and are not fabricated. Stored winner names
|
||||
are historical snapshots, so later renaming and promotion cannot change them.
|
||||
The separate manager-achievements graph retains its Original fifty-season view.
|
||||
|
||||
These records use a versioned `OBMHEXT1` extension after the Original name pools;
|
||||
see [save format](formats/LONG_CAREER.md). Original programs and older OpenBMH
|
||||
writers do not preserve this archive. Keep an OpenBMH backup when exchanging
|
||||
careers with those writers. The native calendar still has its existing signed
|
||||
16-bit season limit; this patch does not claim an unlimited calendar.
|
||||
## Monthly high-cash loss limit
|
||||
|
||||
OpenBMH deviates from the original: the high-cash bank robbery can occur at most
|
||||
once per manager and calendar month. The original threshold above 100 million
|
||||
and random loss of 10–20 million remain. A blocked repeat consumes no random
|
||||
draw. Month boundaries follow the same source calendar used by daily processing,
|
||||
and the guard is stored in the optional BRM1 section of OBMHEXT1 saves.
|
||||
|
||||
An older save has no record of past robberies. Its first qualifying high-cash month
|
||||
receives a grace period without a loss or random draw; subsequent saves retain
|
||||
that guard. The next calendar month can trigger the ordinary loss. Import cannot
|
||||
infer whether an event already occurred before this feature. Fresh histories
|
||||
receive the same initial grace month.
|
||||
|
||||
|
||||
OpenBMH deviates from the original: monthly fund/property dividends multiply
|
||||
unit price by the dividend factor in 64 bits before the existing integer division.
|
||||
The monthly and annual previews and weekly offers use the same widened product.
|
||||
Per-unit rounding and the selected legacy/typed recipient policy are unchanged.
|
||||
This corrects intermediate overflow for representable dividends; account,
|
||||
deposit, property book value and monthly totals still use their native 32-bit
|
||||
storage and can overflow. It is not a complete large-balance finance fix.
|
||||
|
||||
|
||||
Release-driven incoming-transfer presenters require a matching press observed
|
||||
inside that modal. An orphan or repeated release from the preceding result table
|
||||
cannot decline an offer or dismiss its confirmation. Repeated presses while a
|
||||
button is held still form one gesture; fresh left/right clicks keep their actions.
|
||||
|
||||
## Host file overwrite confirmation
|
||||
|
||||
The file picker reuses the Original overwrite question and Ja/Nein button
|
||||
layout. A separate Yes click or Enter confirms; repeated double-clicks do not.
|
||||
OpenBMH deviates from the original: host file operations use the shared dialog's
|
||||
system identity because the picker does not own a live manager portrait projection.
|
||||
@@ -6,27 +6,40 @@ See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These en
|
||||
describe deliberate changes; they are not a list of every known compatibility limit.
|
||||
|
||||
- [src/app/career_session.cpp](../src/app/career_session.cpp): supports designated set-piece record initialization and validation.
|
||||
- [src/app/main.cpp](../src/app/main.cpp): display the repository-owned title at its native resolution until a complete left/right click, without loading balls.
|
||||
- [src/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
|
||||
- [src/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
||||
- [src/game/career.hpp](../src/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
- [src/game/desk_actions.cpp](../src/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): supports designated set-piece records and the supported transfer-editor rules.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): a seller may accept an existing bid before expiry.
|
||||
- [src/game/environment.cpp](../src/game/environment.cpp): the common Diamond 3.7 monthly environment model applies to every supported source-data edition.
|
||||
- [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image.
|
||||
- [src/game/lineup.hpp](../src/game/lineup.hpp): supports owner-bound designated set-piece selection.
|
||||
- [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules.
|
||||
- [src/game/match_engine.cpp](../src/game/match_engine.cpp): supports designated set-piece takers, the enhanced injury tables, and the extended suspension fields.
|
||||
- [src/game/month.cpp](../src/game/month.cpp): keep the price product in 64 bits until division, retaining per-unit truncation and recipient policy.
|
||||
- [src/game/national.cpp](../src/game/national.cpp): a new arrival must not inherit the previous occupant's retirement/refusal/month-processing flags.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): age/retire each player once, even when a temporary offer row references his club slot or regeneration moves him to a later free-agent slot.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): includes transfer-market players in retirement so the five-bit age cannot wrap to 16.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): initializes the empty EM qualifier seeds with national teams, preventing club zero from entering the EM.
|
||||
- [src/game/season.hpp](../src/game/season.hpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/stadium_blocks.cpp](../src/game/stadium_blocks.cpp): allow 144,000 standard places and size-aware construction times while retaining edition-owned unit prices.
|
||||
- [src/game/state.hpp](../src/game/state.hpp): retains designated set-piece selections in the supported manager-record extension.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): widen products before annual-rate division so valid native account amounts do not overflow intermediate sums.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): an unknown history receives a grace month; later losses occur at most once per source month.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): uses the enhanced training rules: focus strength is at least five below its target, and completed skills rotate to another focus.
|
||||
- [src/game/week.hpp](../src/game/week.hpp): uses the enhanced assistant-training rules, retaining the selected skill until it reaches its maximum.
|
||||
- [src/game/weekly.cpp](../src/game/weekly.cpp): uses the supported weekly-event configuration, with its rule switch disabled.
|
||||
- [src/game/weekly.hpp](../src/game/weekly.hpp): uses the supported weekly processing and transfer rule profile.
|
||||
- [src/ui/bank.cpp](../src/ui/bank.cpp): read-only totals use wide arithmetic; individual saved account, price, holding and paid fields are unchanged.
|
||||
- [src/ui/desk_state.cpp](../src/ui/desk_state.cpp): the desk shows the opponent's badge whenever the data has one.
|
||||
- [src/ui/league_pairings.cpp](../src/ui/league_pairings.cpp): the computer tip is ignored silently once a visible result is known, instead of raising an engine error.
|
||||
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
|
||||
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): omits DOS drive and delete buttons in the directory-confined save/load view.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): the host file picker uses the shared dialog's system identity without a live manager portrait projection.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): permits cancelling host file dialogs with the right mouse button.
|
||||
- [src/ui/settings.cpp](../src/ui/settings.cpp): the settings page names the product and its build version instead of the original's version text.
|
||||
@@ -0,0 +1,18 @@
|
||||
# OpenBMH Classic start artwork
|
||||
|
||||
The project maintainer supplied this new start-screen artwork for use and
|
||||
repository distribution with this application. It is not extracted game content.
|
||||
The repository license applies to project artwork; original game assets remain
|
||||
external. The unmodified upstream decoder has its separate documented license.
|
||||
|
||||
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
|
||||
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
|
||||
without EXIF or other input metadata. It occupies 587,410 bytes.
|
||||
The application embeds it at build time and decodes it once at startup, so
|
||||
installed applications need no image sidecar or original title-screen VGA.
|
||||
|
||||
The SDL renderer uses the actual image dimensions while showing the title,
|
||||
including high-DPI output and aspect-preserving side bars, then restores the
|
||||
320 × 240 game/input canvas. A complete left or right mouse click continues;
|
||||
there is no loading-ball animation. Changing the artwork also requires an
|
||||
explicit review/update of its SHA256 in the public-source guard.
|
||||
@@ -0,0 +1,51 @@
|
||||
# Desktop and advertising mouse input fixes
|
||||
|
||||
The optional desktop frame bit controls decoration, not whether the visible
|
||||
widget contents accept input. The corrections reuse the Original renderer,
|
||||
coordinates, layout records and action dispatchers.
|
||||
|
||||
- The date widget activates the same owned advance action as Anstoß, with or
|
||||
without a frame. In a multiplayer turn this first hands control to the next
|
||||
manager. The separate calendar/rescheduling menu keeps its own behavior.
|
||||
- Stored icons remain clickable and draggable from unframed folders. Extraction
|
||||
restores the actual icon record to the visible chain; the folder stays put.
|
||||
Hidden or unlinked owners remain invalid. Removal corners keep their separate
|
||||
transaction and mouse-release barrier. The same frame-origin correction also
|
||||
covers the existing admission scale and five automation controls.
|
||||
- A true double-click on an existing save opens the shared Original-style
|
||||
overwrite question. A separate single click on Ja confirms, Nein returns to
|
||||
the picker, and repeated double-click releases cannot write. Enter and cancel
|
||||
paths remain. FBM, EIN and MEN use the same confirmation boundary.
|
||||
- Advertising follows all nineteen original hit rectangles with palette0x27
|
||||
outlines and the installed edition's detail/help text. Motion alone does not
|
||||
change the career, revision or either random stream. Offers/calculators retain
|
||||
their input owner; returning from them reevaluates the actual pointer, avoiding
|
||||
a stale highlight without requiring another mouse movement.
|
||||
|
||||
## Validation
|
||||
|
||||
The focused configured-data tests are `app_desktop_input_tests`,
|
||||
`app_advertising_input_tests`, `ui_desktop_input_tests`, `ui_save_load_tests` and
|
||||
`ui_advertising_tests`. They cover frame variants, exact field boundaries,
|
||||
canonical actions, stale/hidden-owner refusal, cancellation, input release,
|
||||
overwrite confirmation and unchanged game/random state for presentation-only
|
||||
input. The desktop input test isolates these checks from unrelated private
|
||||
text/badge inventories; the existing full test retains its additional checks.
|
||||
|
||||
Private Linux SDL before/after captures and actual saved games are maintained in
|
||||
`bmh_4k_ui/docs/qa/classic-extended-ui-input`. The fixtures use actual club/player
|
||||
data with a controlled desktop layout. No results are fabricated. A successful
|
||||
compile or CI run alone is not native Windows/macOS UI verification.
|
||||
|
||||
Tracked reports: [#51](https://github.com/Weyoune/openbmh/issues/51), [#52](https://github.com/Weyoune/openbmh/issues/52), [#53](https://github.com/Weyoune/openbmh/issues/53), [#54](https://github.com/Weyoune/openbmh/issues/54).
|
||||
|
||||
The primary regression run uses the supplied Diamond 3.7 installation. Unrelated
|
||||
historical rendering fixtures retain their declared reference requirements.
|
||||
Two existing Classic test fixtures were aligned with the already implemented
|
||||
stadium-capacity policy and verified edition-specific crest gate; product
|
||||
validation was not relaxed to satisfy those tests.
|
||||
|
||||
The overwrite prompt also maps the actual Football Limited English pointer.
|
||||
The translation copies exactly that four-byte pointer and preserves adjacent
|
||||
empty slots. The launcher translation-cache revision is advanced, so an existing
|
||||
cached English installation receives the newly supported prompt as well.
|
||||
@@ -783,7 +783,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishLayoutTranslation157` | `0x6e094` | English image adapter |
|
||||
| `EnglishLayoutTranslation158` | `0x6e0b8` | English image adapter |
|
||||
| `EnglishLayoutTranslation159` | `0x6e0bb` | English image adapter |
|
||||
| `EnglishLayoutTranslation16` | `0x6be4f` | English image adapter |
|
||||
| `EnglishLayoutTranslation16` | `0x6be50` | English image adapter |
|
||||
| `EnglishLayoutTranslation160` | `0x6e0d8` | English image adapter |
|
||||
| `EnglishLayoutTranslation161` | `0x6e110` | English image adapter |
|
||||
| `EnglishLayoutTranslation162` | `0x6e11c` | English image adapter |
|
||||
@@ -1005,7 +1005,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishLayoutTranslation70` | `0x6d270` | English image adapter |
|
||||
| `EnglishLayoutTranslation71` | `0x6d272` | English image adapter |
|
||||
| `EnglishLayoutTranslation72` | `0x6d274` | English image adapter |
|
||||
| `EnglishLayoutTranslation73` | `0x6d29c` | English image adapter |
|
||||
| `EnglishLayoutTranslation73` | `0x6d29d` | English image adapter |
|
||||
| `EnglishLayoutTranslation74` | `0x6d3b4` | English image adapter |
|
||||
| `EnglishLayoutTranslation75` | `0x6d404` | English image adapter |
|
||||
| `EnglishLayoutTranslation76` | `0x6d408` | English image adapter |
|
||||
@@ -1495,6 +1495,14 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `Pitch_Render_TextPointer3` | `0xae0f0` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer4` | `0xae0f4` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer5` | `0xae0f8` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceDepthBases` | `0xa3cc3` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceRed` | `0xa3cc7` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceGreen` | `0xa3cd1` | German-compatible image / runtime field |
|
||||
| `OriginalPointerPixels` | `0xa45b4` | German-compatible image / runtime field |
|
||||
| `EnglishPitchPreferenceDepthBases` | `0x6e230` | English image adapter |
|
||||
| `EnglishPitchPreferenceRed` | `0x6e234` | English image adapter |
|
||||
| `EnglishPitchPreferenceGreen` | `0x6e240` | English image adapter |
|
||||
| `EnglishOriginalPointerPixels` | `0x70554` | English image adapter |
|
||||
| `PitchOrderPositionPointers` | `0xa2a37` | German-compatible image / runtime field |
|
||||
| `PitchOrderZoneMasks` | `0xa2a4b` | German-compatible image / runtime field |
|
||||
| `PitchOrderZoneTextPointers` | `0xae818` | German-compatible image / runtime field |
|
||||
@@ -1570,6 +1578,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `SaveLoad_Render_RuntimeField` | `0xa2334` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_RuntimeField2` | `0xa233f` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_RuntimeField3` | `0xa234a` | German-compatible image / runtime field |
|
||||
| `SaveLoad_OverwriteQuestionPointer` | `0xa21c4` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_TextPointer` | `0xa1512` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_TextPointer2` | `0xae5f0` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_TextPointer3` | `0xae620` | German-compatible image / runtime field |
|
||||
@@ -1991,13 +2000,11 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishSixTeamFixtureTable` | `0x6eed4` | English image adapter |
|
||||
| `EnglishTwelveTeamFixtureTable` | `0x6f0bc` | English image adapter |
|
||||
| `EnglishTwentyTeamFixtureTable` | `0x6ee40` | English image adapter |
|
||||
|
||||
## Verified edition-dependent parameters
|
||||
|
||||
| Field | Address | Use |
|
||||
|---|---|---|
|
||||
| `CalendarDateSetup` | `0x21270` | Verified date setup: weekday byte at +4, initial year dword at +13. Original CD uses 1995/Saturday; checked Diamond editions use 2026/Wednesday. |
|
||||
| `ForeignBadgeGateInstruction` | `0x10070` | Verified original drawing gate; operand at +3 selects neutral foreign crests or individual W-sheet selectors. |
|
||||
| `EnvironmentBudgetSteps` | `0xa50ff` | Six budget increments in the verified monthly environment implementation. |
|
||||
|
||||
Calendar presentation, engine weekday processing and save-list headers share the supplied installation's epoch. The original four-year date arithmetic is preserved; this reader does not substitute a different calendar system or rewrite the installation. Unknown date setup instructions and invalid values are rejected.
|
||||
| `EnglishDesktopBinSourceX` | `0x6e180` | English image adapter |
|
||||
| `EnglishDesktopBinSourceY` | `0x6e182` | English image adapter |
|
||||
| `EnglishDesktopSocketSourceX` | `0x6e184` | English image adapter |
|
||||
| `EnvironmentBudgetSteps` | `0xa50ff` | German-compatible image / runtime field |
|
||||
| `EnvironmentVerifiedCodeBegin` | `0x6c000` | English image adapter |
|
||||
| `EnvironmentVerifiedCodeEnd` | `0x6cb40` | English image adapter |
|
||||
| `EnvironmentVerifiedHookBegin` | `0x7af65` | English image adapter |
|
||||
| `EnvironmentVerifiedHookEnd` | `0x7b020` | English image adapter |
|
||||
+37
-1
@@ -9,7 +9,7 @@
|
||||
| Plain header | Variable | Manager/date information for the load list |
|
||||
| Signature area | 10 bytes | Eight-byte `KRON_FBM` signature and two following bytes |
|
||||
| First ID | u32 | Container identifier |
|
||||
| Version | 6 bytes | NUL-terminated version field, normally `V2.24` for the supported state layout |
|
||||
| Version | 6 bytes | NUL-terminated version field, `V2.24` or the verified Diamond `V3.7` marker for this state layout |
|
||||
| Second ID | u32 | Save identifier |
|
||||
| Random byte | u8 | Header value |
|
||||
| Initial key | u8 | Rolling-cipher seed |
|
||||
@@ -26,8 +26,44 @@ The supported layout contains a fixed ordered block table, followed by four name
|
||||
|
||||
Each name pool has a u16 byte length followed by that many bytes, in club, player, referee and stadium order. These pools preserve renamed entities. The splitter rejects missing/truncated blocks or pools and requires exact stream consumption. See [STATE](STATE.md) for interpreted records and [M3D](M3D.md) for pool references.
|
||||
|
||||
## Optional OpenBMH state
|
||||
|
||||
After the four name pools, OpenBMH can append `OBMHEXT1`, a u16 block count,
|
||||
then each block as a u32 identifier, u32 byte length and payload. There is at
|
||||
most one such container and the decoder requires exact consumption of it.
|
||||
Original saves have no container. The entire extension is included in the outer
|
||||
rolling cipher and checksum.
|
||||
|
||||
Known OpenBMH-owned sections include:
|
||||
|
||||
| Identifier | Payload | Purpose |
|
||||
|---|---|---|
|
||||
| `OBLC` (`0x4f424c43`) | Versioned variable-length archive | [Long-career player counters and title winners](LONG_CAREER.md) |
|
||||
| `BRM1` (`0x314d5242`) | Four little-endian u32 month-start keys (16 bytes) | Per-manager monthly high-cash robbery guard |
|
||||
|
||||
A robbery key is the absolute first day of the last blocked source-calendar
|
||||
month. `UINT32_MAX` means unknown. An unknown high-cash history receives a
|
||||
first qualifying grace month; later deductions can occur at most once per
|
||||
calendar month. Managers have independent keys. A truncated or duplicate BRM1
|
||||
section is rejected before game state is published.
|
||||
|
||||
These identifiers describe OpenBMH-owned payloads, not original executable
|
||||
addresses. The container can also hold explicitly supported compatibility blocks,
|
||||
such as edition-specific cup state. Unrecognized payloads are not a general
|
||||
persistence API. Original programs and older OpenBMH writers may reject or
|
||||
discard optional information: keep a backup before opening a new save with them.
|
||||
|
||||
## Edition compatibility
|
||||
|
||||
Diamond 3.7 uses the `V3.7` container label with the verified German V2.24 state
|
||||
layout. Career loading, saved-desktop/preparation import and browser information
|
||||
accept that exact label as well as `V2.24`. The checksum, full block/pool structure
|
||||
and installed edition's database dimensions are still required. An accepted
|
||||
version label cannot make a malformed or mismatched state valid. Ordinary
|
||||
OpenBMH native saves continue to use the canonical `V2.24` output marker.
|
||||
Unknown labels are rejected separately from checksum failures.
|
||||
|
||||
|
||||
Original Football Limited V2.20 saves use a different state block list despite sharing the signature and rolling cipher. They are not interchangeable with the V2.24 layout. Reading an English installation and importing its original saves are separate features; do not edit a version string to bypass the distinction. OpenBMH's own English careers use the session's supported save representation.
|
||||
|
||||
Keep a backup before using a save with another engine version. Unknown bytes retained for compatibility are not safe targets for direct client manipulation.
|
||||
@@ -0,0 +1,34 @@
|
||||
# Optional long-career statistics and title archive
|
||||
|
||||
The existing `OBMHEXT1` container can contain block `0x4f424c43` (OpenBMH-owned,
|
||||
not a guest memory address). Original state blocks and all four name pools retain
|
||||
their sizes and ordering. No extension is emitted until an archive is needed.
|
||||
Payload integers use little-endian encoding:
|
||||
|
||||
| Field | Encoding |
|
||||
|---|---|
|
||||
| Payload version | u32, currently 1 |
|
||||
| Player/club record count | u32 |
|
||||
| Known season record count | u32 |
|
||||
| Each player/club record | u32 key, then six u64 counters |
|
||||
| Each season record | u32 absolute zero-based season, then nine names |
|
||||
| Each name | u16 byte length followed by Original-encoding bytes |
|
||||
|
||||
The player key is `(runtime_club << 12) | player_id`. The six counters are league,
|
||||
national-cup and European-cup appearances, total appearances, goals and assists.
|
||||
Club swaps remap keys; fresh squad entry initialization resets the new player's
|
||||
club record. The Original byte/word fields continue to update normally.
|
||||
|
||||
Season names follow the nine Original title categories. An empty name is a known
|
||||
season with no holder for that category. Missing season records are unknown,
|
||||
not an assertion that no competition was held. Names are owned snapshots at the
|
||||
award/capture time, independent of future club-number and name-pool changes.
|
||||
A legacy import contributes only its surviving window; no earlier information
|
||||
is inferred. The title list uses the earliest known absolute season when paging
|
||||
and compensates for the native rolling-window year offset.
|
||||
|
||||
The decoder rejects unknown versions, truncated payloads, invalid/duplicate
|
||||
identities and seasons, duplicate blocks and trailing bytes before publishing
|
||||
archive state. Season records remain within the native signed 16-bit calendar
|
||||
range. The surrounding FBM checksum covers the extension. Older writers may
|
||||
discard extensions; Original-game roundtrip preservation is not promised.
|
||||
@@ -12,3 +12,5 @@ These files preserve upstream license and attribution wording. They are not a gr
|
||||
- [LGPL version 2.1](LGPL-2.1.txt): full license supplied with Nuked OPL3. Its source notices permit version 2.1 or any later version.
|
||||
|
||||
[THIRD_PARTY_NOTICES.md](../../THIRD_PARTY_NOTICES.md) identifies the upstream versions and distribution requirements. Include this directory, that notice file and the root LICENSE with release packages. Preserve upstream attribution within these verbatim texts.
|
||||
|
||||
- [stb_image](stb_image.txt): complete upstream dual-license text from the vendored 2.30 header. JPEG-only decoding is used for the supplied project start screen.
|
||||
@@ -0,0 +1,38 @@
|
||||
This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
@@ -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.
|
||||
+97
-78
@@ -1,8 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/career_session.hpp"
|
||||
#include "formats/league_visibility.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <system_error>
|
||||
@@ -372,8 +374,15 @@ void restore_saved_turn_cursor(TurnDriver& driver, GameState& state, const Datab
|
||||
const int manager_count = int(state.manager_teams.size());
|
||||
if (manager_count > 4 || !state.memory.has(::bmh::layout::ActiveManager) || !state.memory.has(::bmh::layout::DeskPosition))
|
||||
throw std::runtime_error("saved turn cursor: manager continuation fields are missing");
|
||||
const int position = int(state.memory.u8(::bmh::layout::DeskPosition));
|
||||
int position = int(state.memory.u8(::bmh::layout::DeskPosition));
|
||||
const int active = int(state.memory.u8(::bmh::layout::ActiveManager));
|
||||
// A completed manager loop leaves DeskPosition == ManagerCount (the day's desks are done). A desk
|
||||
// that was saved in that state is the first desk again for a single manager: nothing else can
|
||||
// follow it. Reading the byte as 0 lets the day go on instead of refusing the whole save.
|
||||
if (manager_count == 1 && position == 1 && active == 0) {
|
||||
position = 0;
|
||||
state.memory.set8(::bmh::layout::DeskPosition, 0);
|
||||
}
|
||||
if (position < 0 || position >= manager_count)
|
||||
throw std::runtime_error("saved turn cursor: manager position is outside the saved roster");
|
||||
if (manager_count == 1) {
|
||||
@@ -549,9 +558,9 @@ static void install_league_sizes(const LeImage& exe) {
|
||||
}
|
||||
|
||||
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed)
|
||||
: data_directory_(data), exe_(load_le(data / "BMH.exe")),
|
||||
db_(load_database(data / "M3D.MAN")),
|
||||
texts_(load_textd(data / "TEXTD.BLK")),
|
||||
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))),
|
||||
db_(load_database(ui::asset_path(data, "M3D.MAN"))),
|
||||
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))),
|
||||
rand_(watcom_seed) {
|
||||
install_league_sizes(exe_);
|
||||
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
|
||||
@@ -560,7 +569,7 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
? TransferAllocatorContext::zero : TransferAllocatorContext::blocked;
|
||||
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
|
||||
initialize_club_modal_runtime();
|
||||
g_ = startup_state(exe_, db_, read_file(data / "M3.MEN"), read_file(data / "M3.DAT"));
|
||||
g_ = startup_state(exe_, db_, read_file(ui::asset_path(data, "M3.MEN")), read_file(ui::asset_path(data, "M3.DAT")));
|
||||
g_.texts = &texts_;
|
||||
g_.currency_suffix = exe_.cstring(::bmh::layout::CurrencySuffixText); // CurrencySuffixText
|
||||
configure_training_camp_data(g_, exe_);
|
||||
@@ -576,8 +585,8 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
|
||||
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed,
|
||||
const std::filesystem::path& save_path)
|
||||
: data_directory_(data), exe_(load_le(data / "BMH.exe")), db_(load_database(data / "M3D.MAN")),
|
||||
texts_(load_textd(data / "TEXTD.BLK")), rand_(watcom_seed) {
|
||||
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))), db_(load_database(ui::asset_path(data, "M3D.MAN"))),
|
||||
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))), rand_(watcom_seed) {
|
||||
install_league_sizes(exe_);
|
||||
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
|
||||
turn_driver_.disable_match_events = exe_.u8(::bmh::layout::MatchEventsDisabled) != 0;
|
||||
@@ -586,7 +595,7 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
|
||||
initialize_club_modal_runtime();
|
||||
const Savegame file = load_savegame(save_path);
|
||||
if (!file.checksum_ok || file.version != "V2.24") throw std::runtime_error("savegame: unsupported or damaged FBM");
|
||||
require_native_savegame(file);
|
||||
const DbCounts counts{exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
const SaveState save(file.stream, counts);
|
||||
g_ = GameState::from_save(save, counts);
|
||||
@@ -727,6 +736,9 @@ bool CareerSession::confirm_manager_join(const ui::ManagerChoice& choice, std::s
|
||||
selected.name = choice.name; selected.team = runtime_club(draft.state, choice.master_club);
|
||||
selected.league = choice.start_league; selected.strength = choice.strength; selected.portrait = choice.portrait;
|
||||
if (selected.team < 0) throw FormatError("join: club not found");
|
||||
const auto visible=player_league_count(exe_);
|
||||
const auto club_league=team_league(selected.team);
|
||||
if(selected.league>=visible||(club_league>=visible&&club_league<5))throw FormatError("join: league is not available for human management");
|
||||
MinuteReport report;
|
||||
if (!career_add_manager(draft.state, exe_, choice.slot, selected, true, draft.game, draft.rand, report))
|
||||
throw FormatError(report.reason);
|
||||
@@ -756,6 +768,9 @@ bool CareerSession::commit_manager_join(ui::CareerInitializationResult& result,
|
||||
// ConfirmManager retains the current desk/cursor. Weiter performs the later handoff.
|
||||
const auto next_revision = revision + 1;
|
||||
turn_driver_.revision = next_revision;
|
||||
// The next opponent of every manager is captured per day for the manager count of that day;
|
||||
// the joined manager has only the default ("no game") until it is captured again.
|
||||
capture_source_desk_callargs();
|
||||
ui::CareerInitializationResult next;
|
||||
next.desktop = desktop_projection(next_revision); next.managers = managers_;
|
||||
next.preparation = preparation_projection(next_revision);
|
||||
@@ -806,6 +821,12 @@ void CareerSession::apply_options(const ui::SetupOptions& o) {
|
||||
bool CareerSession::confirm_manager(const ui::SetupOptions& options, const ui::ManagerChoice& choice, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return false; }
|
||||
const auto visible=player_league_count(exe_);
|
||||
const auto selected_team=runtime_club(choice.master_club);
|
||||
const auto selected_league=selected_team>=0?team_league(selected_team):-1;
|
||||
if(choice.start_league<0||choice.start_league>=visible||(selected_league>=visible&&selected_league<5)) {
|
||||
error="league is not available for human management";return false;
|
||||
}
|
||||
if (!options_applied_) apply_options(options);
|
||||
const int m = int(managers_.size());
|
||||
if (m >= options.managers) {
|
||||
@@ -926,6 +947,9 @@ std::optional<PendingOfferResult> CareerSession::dispatch_club_player_pending_of
|
||||
}
|
||||
|
||||
void CareerSession::initialize_club_modal_runtime() {
|
||||
// Setup clears the boot-only dialog mode before either creating or loading
|
||||
// a career. This process flag is deliberately absent from native saves.
|
||||
club_modal_runtime_.emplace(layout::CompactDialogFrame, 0);
|
||||
// LE object4 has bb cdd/de/e1 in its zero-initialized virtual tail;
|
||||
// CareerSession_InitializeClubModalRuntime_ExecutableField is file-backed zero. These are explicit process-start values,
|
||||
// carried by this runtime owner across modal entry/return, not FBM bytes.
|
||||
@@ -2243,7 +2267,10 @@ std::optional<ui::StrengthsIdentity> CareerSession::dispatch_family_table_team_i
|
||||
before.family==after.family&&before.next_family_id==after.next_family_id&&
|
||||
before.next_strengths_scope==after.next_strengths_scope&&
|
||||
!before.strengths&&!after.strengths&&!before.pairings&&!after.pairings;
|
||||
if(!live_unchanged||!accepted||(poach_selection?entry_calls<1:entry_calls!=1))
|
||||
// The club information enters the club again on every redraw (view toggle, statistics, player
|
||||
// card), so one entry is the minimum; requiring exactly one threw away the whole visit, also the
|
||||
// Nein/Radio/Video setting made in it.
|
||||
if(!live_unchanged||!accepted||entry_calls<1)
|
||||
throw FormatError("league family: TeamInfo presenter changed owner or did not enter the selected club");
|
||||
const size_t record=size_t(id.manager)*0xb0c;
|
||||
if(next.date!=g_.date||next.manager_teams!=g_.manager_teams||
|
||||
@@ -2331,13 +2358,17 @@ std::optional<CareerSession::StrengthsDispatch> CareerSession::dispatch_strength
|
||||
const ui::StrengthsRequest& request,uint64_t& revision,std::string& error,
|
||||
const TransferOfferTeamInfoPresenter& team_info,bool family_transition) {
|
||||
error.clear();const auto& id=request.identity;const bool opening=request.kind==ui::StrengthsAction::open;
|
||||
// The turn driver marks the claimed turn as Failed until it completes (a guard against replaying
|
||||
// a half-played turn), so inside the running matchday the stage is not a desk. The Stärken page
|
||||
// of the live overview (G key, results page after a phase) belongs to that running turn.
|
||||
const bool running_turn=live_overview_owner_.has_value()&&turn_driver_.stage==TurnDriver::Stage::Failed;
|
||||
if(league_family_teaminfo_active_||strengths_dispatch_active_||revision==UINT64_MAX||id.revision!=revision||id.sequence==UINT64_MAX||
|
||||
id.manager<0||id.manager>3||!g_.memory.has(::bmh::layout::ActiveManager)||g_.memory.u8(::bmh::layout::ActiveManager)!=id.manager||
|
||||
size_t(id.manager)>=g_.manager_teams.size()||id.runtime_club!=g_.manager_teams[size_t(id.manager)]||
|
||||
id.runtime_club<0||size_t(id.runtime_club)>=g_.club_ids.size()||
|
||||
id.club_identity!=int(g_.club_ids[size_t(id.runtime_club)])||id.day_counter!=g_.date||
|
||||
id.league<0||id.league>8||career_complete()||
|
||||
(turn_driver_.stage!=TurnDriver::Stage::MatchdayDesks&&turn_driver_.stage!=TurnDriver::Stage::SeasonEndDesk)||
|
||||
(turn_driver_.stage!=TurnDriver::Stage::MatchdayDesks&&turn_driver_.stage!=TurnDriver::Stage::SeasonEndDesk&&!running_turn)||
|
||||
pending_offer_dispatch_active_||market_dispatch_active_||calendar_advance_active_||league_pairings_draft_||
|
||||
league_pairings_dispatch_active_||transfer_offer_editor_||manager_join_||contract_quote_||
|
||||
stadium_.investment||stadium_.tip||stadium_.periphery_quote||top_scorers_owner_||top_scorers_dispatch_active_ || stadium_.block_expansion||other_games_owner_||other_games_dispatch_active_) {
|
||||
@@ -3982,7 +4013,8 @@ std::optional<CareerSession::TransferMarketPreviewDispatch> CareerSession::previ
|
||||
|
||||
std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& presenters,
|
||||
uint64_t& revision, std::string& error) {
|
||||
uint64_t& revision, std::string& error,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
@@ -3995,7 +4027,18 @@ std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
error = "transfer market: stale or nested request";
|
||||
return std::nullopt;
|
||||
}
|
||||
if (request.kind == ui::TransferMarketRequestKind::submit_bid) {
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
if (!review || request.bid.manager != request.manager_slot || request.bid.list_entry < 0 ||
|
||||
request.bid.list_entry >= 40 || request.bid.source_slot != 0xb70 + request.bid.list_entry ||
|
||||
request.squad_row != -1 || !request.selected_players.empty()) {
|
||||
error = "transfer market: invalid offer review"; return std::nullopt;
|
||||
}
|
||||
const auto view = project_transfer_offer_list(g_, request.bid.list_entry);
|
||||
if (!view.valid || view.player != request.bid.player || view.seller != request.runtime_club ||
|
||||
view.seller_manager != request.manager_slot) {
|
||||
error = "transfer market: stale seller listing"; return std::nullopt;
|
||||
}
|
||||
} else if (request.kind == ui::TransferMarketRequestKind::submit_bid) {
|
||||
if (request.bid.manager != request.manager_slot || request.squad_row != -1 ||
|
||||
request.expected_player != -1 ||
|
||||
std::any_of(request.bid.bonuses.begin(), request.bid.bonuses.end(),
|
||||
@@ -4061,7 +4104,21 @@ std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
try {
|
||||
const auto before = save_stream(g_);
|
||||
TransferActionResult result;
|
||||
if (request.kind == ui::TransferMarketRequestKind::list_player)
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
const auto view = project_transfer_offer_list(next_state, request.bid.list_entry);
|
||||
const int selected = view.offer_count ? review(next_state, view) : -1;
|
||||
result.player = view.player; result.list_entry = view.list_entry;
|
||||
result.status = TransferActionStatus::pending;
|
||||
if (selected != -1) {
|
||||
auto allocator = TransferAllocatorContext::unsupported;
|
||||
if (turn_driver_.transfer_allocator_context == PendingOfferAllocatorGate::zero)
|
||||
allocator = TransferAllocatorContext::zero;
|
||||
else if (turn_driver_.transfer_allocator_context == PendingOfferAllocatorGate::blocked)
|
||||
allocator = TransferAllocatorContext::blocked;
|
||||
result = accept_manager_transfer_offer(next_state, request.manager_slot,
|
||||
view.list_entry, view.player, selected, next_rand, report, allocator);
|
||||
}
|
||||
} else if (request.kind == ui::TransferMarketRequestKind::list_player)
|
||||
result = list_manager_player(next_state, request.manager_slot, request.squad_row, next_rand, report);
|
||||
else
|
||||
result = submit_transfer_bid_source_human_buyer(next_state, request.bid, next_rand, hooks, report);
|
||||
@@ -4499,42 +4556,11 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
|
||||
const uint8_t old = raw_value;
|
||||
uint8_t next = old;
|
||||
if (request.operation == ui::SettingsEdit::toggle_binary) {
|
||||
// Inventory of actual current consumers: direct match-engine buttons,
|
||||
// matchday/season flags and the live-scene switch. Other cells are not
|
||||
// made writable merely because the Original UI displayed a cell.
|
||||
// Tie the write whitelist to the concrete consumer ranges. League
|
||||
// remapping reads rows 0..4, columns 0..3; matchday display kinds 1/2
|
||||
// map to columns 0..2 and rows 0..4 or 17..19.
|
||||
const bool consumed = (sound_cell && sound_capabilities_.has_value()) ||
|
||||
(request.row == 0 && request.column == 4) || // A5: match/Sportschau sound
|
||||
((request.row <= 4 && request.column <= 3) ||
|
||||
((request.row <= 4 || request.row >= 17) && request.column <= 2)) ||
|
||||
((request.row == 5 || (request.row >= 9 && request.row <= 12)) && request.column == 0) ||
|
||||
(request.row == 1 && request.column == 4) || // B5 live-scene option
|
||||
(request.row == 2 && request.column == 4) || // C5: Reality player numbers (RealityMatch_FormatError_ExecutableField)
|
||||
(request.row == 5 && request.column == 5) || // F6: Source manager-match desk gate (MatchdaySetup_MatchdayNeedsManagerDesks_RuntimeField)
|
||||
(request.row == 6 && request.column == 5) || // G6: transfer confirmation wait (OutcomeDelayDisabled)
|
||||
(request.row == 16 && request.column == 6) || // Q7: own-club Sportschau preference (MatchdaySetup_ConsiderSportschauFixture_RuntimeField)
|
||||
(request.row == 13 && request.column == 6) || // N7: Source kickoff competition list (SportschauAwards_MatchdayIntroView_RuntimeField)
|
||||
(request.row == 1 && request.column == 6) || // B7: SportschauIntro intro gate (Controller_FormatError_RuntimeField)
|
||||
(request.row == 2 && request.column == 6) || // C7: SportschauIntro intro-animation gate (Controller_FormatError_RuntimeField2)
|
||||
(request.row == 3 && request.column == 6) || // D7: selected report progression (ReplayProgressionMode)
|
||||
(request.row == 4 && request.column == 6) || // E7: Source-owned Sportschau scenes (ReplayChanceMode)
|
||||
(request.row == 5 && request.column == 6) || // F7: SportschauIntro fixture-report gate (Controller_FormatError_RuntimeField3)
|
||||
(request.row == 6 && request.column == 6) || // G7: MatchdayIntro player/award rating (SportschauAwards_FinishSportschauAwards_RuntimeField)
|
||||
(request.row == 7 && request.column == 6) || // H7: SportschauTeamInfo competition totals (SportschauAwards_SportschauTeamInfoView_RuntimeField)
|
||||
(request.row == 2 && request.column == 5) || // C6 drawer-handle behavior (CareerSession_DispatchDesktopLayout_RuntimeField)
|
||||
(request.row == 3 && request.column == 5) || // D6 native desktop drag raster (CareerSession_DispatchDesktopLayout_RuntimeField2)
|
||||
(request.row == 4 && request.column == 5) || // E6 always-visible shortcut bar (DeskState_FormatError_RuntimeField3)
|
||||
(request.row == 7 && request.column == 5) || // H6 transfer option
|
||||
(request.row == 8 && (request.column == 5 || request.column == 6)) || // I6/I7
|
||||
(request.row >= 10 && request.row <= 13 && request.column == 4) || // K5:N5 match buttons
|
||||
(request.row >= 10 && request.row <= 12 && request.column == 6) || // K7:M7 presentation
|
||||
(request.row == 9 && request.column == 6) || // J7 season-entrant visibility (SeasonEntrants_SeasonEntrantsFromGame_TextPointer)
|
||||
(request.row == 15 && request.column == 4) || // P5
|
||||
(request.row == 16 && request.column == 4) || // Q5
|
||||
(request.row == 17 && request.column == 4); // R5: secondary leagues (CalendarState_FormatError_RuntimeField2)
|
||||
if (!consumed || (old != 0 && old != 1)) {
|
||||
// The original edits every unlocked switch: the page only stores the value and each
|
||||
// consumer reads it where it needs it. A switch without a consumer in OpenBMH yet is still
|
||||
// stored (and saved) and never refused. Locks (bit 7 of the entry-time availability) and
|
||||
// values other than 0/1 are refused above and below.
|
||||
if (old != 0 && old != 1) {
|
||||
error = "Diese Einstellung ist noch nicht verfügbar.";
|
||||
return false;
|
||||
}
|
||||
@@ -4553,17 +4579,8 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
|
||||
}
|
||||
next = old ^ 1;
|
||||
} else {
|
||||
// Column8: existing presentation speeds B8:F8, H8 process budget,
|
||||
// J8 postponed limit and K8 autosave. Column9 only exposes values
|
||||
// already read by Main's Source live presenters or CupDrawScreen.
|
||||
const bool consumed = (request.column == 7 &&
|
||||
((request.row <= 6) || request.row == 7 || request.row == 9 || request.row == 10 ||
|
||||
(scoped_settings && request.row == 8))) ||
|
||||
// A9 match minutes; B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
|
||||
// I9 cup draw; K9 Reality report; M9 preview/shootout; P9 shot.
|
||||
(request.column == 8 && ((request.row >= 0 && request.row <= 6) ||
|
||||
request.row == 7 || request.row == 8 || request.row == 10 || request.row == 12 || request.row == 15));
|
||||
if (!consumed || old >= 200) {
|
||||
// The numeric columns are stored the same way; values from 200 up are blank cells.
|
||||
if (old >= 200) {
|
||||
error = "Diese Einstellung ist noch nicht verfügbar.";
|
||||
return false;
|
||||
}
|
||||
@@ -5596,15 +5613,20 @@ bool CareerSession::dispatch_desk_widget(const ui::DeskRequest& request, uint64_
|
||||
identity.stable_club_identity = int(g_.club_ids[size_t(identity.runtime_club)]);
|
||||
}
|
||||
if (!validate_desk_setting_owner(identity, revision, error, false)) return false;
|
||||
// Refuse malformed saved formation state before projecting widget ownership.
|
||||
// The desktop renderer cannot project indices outside the stored 0..8 range.
|
||||
if (g_.manager_options[size_t(active) * 5] > 8) {
|
||||
error = "invalid_saved_formation_automation"; return false;
|
||||
}
|
||||
const bool price = request.kind == ui::DeskRequestKind::change_ticket_price;
|
||||
if (!price && request.kind != ui::DeskRequestKind::change_option) {
|
||||
error = "unsupported_desk_widget"; return false;
|
||||
}
|
||||
// Keep SDL requests bound to a visible, open and enabled MEN drawer/item.
|
||||
// Keep SDL requests bound to a visible and enabled MEN drawer/item; the frame bit is optional.
|
||||
const auto desk = desktop_projection(revision);
|
||||
const int expected_kind = price ? 55 : 64;
|
||||
const auto item = std::find_if(desk.items.begin(), desk.items.end(), [&](const ui::DeskItem& item) {
|
||||
return item.id == request.item_id && item.kind == expected_kind && item.open && !item.disabled;
|
||||
return item.id == request.item_id && item.kind == expected_kind && !item.disabled;
|
||||
});
|
||||
if (request.menu_kind != expected_kind || item == desk.items.end()) {
|
||||
error = "stale_or_closed_desk_widget"; return false;
|
||||
@@ -5714,19 +5736,20 @@ bool CareerSession::dispatch_desktop_layout(const ui::DeskRequest& request, uint
|
||||
(expected[at+13]&0x7f)!=folder||expected[at+12]>=50) {
|
||||
error="invalid_desk_folder_child_return"; return false;
|
||||
}
|
||||
bool owner_open=false;
|
||||
bool owner_visible=false;
|
||||
for(size_t item=1;item<kItems;++item) {
|
||||
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+13]&0x80)==0) continue;
|
||||
// The frame bit does not hide folder contents; require a visible linked owner.
|
||||
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+1]&0x10)!=0) continue;
|
||||
int cursor=0;size_t visited=0;
|
||||
while(++visited<kItems) {
|
||||
const int next=expected[size_t(cursor)*kStride+5];
|
||||
if(next==int(item)) { owner_open=true;break; }
|
||||
if(next==int(item)) { owner_visible=true;break; }
|
||||
if(next<=0||next>=int(kItems)) break;
|
||||
cursor=next;
|
||||
}
|
||||
if(owner_open) break;
|
||||
if(owner_visible) break;
|
||||
}
|
||||
if(!owner_open) { error="desk_folder_child_owner_closed"; return false; }
|
||||
if(!owner_visible) { error="desk_folder_child_owner_hidden"; return false; }
|
||||
const int max_x=std::max(1,319-int(expected[at+3])),max_y=std::max(1,239-int(expected[at+4]));
|
||||
const int source_x=int(moved_x&0xefff);
|
||||
const bool snap=g_.memory.has(::bmh::layout::CareerSession_DispatchDesktopLayout_RuntimeField2)&&g_.memory.u8(::bmh::layout::CareerSession_DispatchDesktopLayout_RuntimeField2)==0;
|
||||
@@ -5767,19 +5790,20 @@ bool CareerSession::dispatch_desktop_layout(const ui::DeskRequest& request, uint
|
||||
(expected[at+13]&0x7f)!=folder||expected[at+12]>=50) {
|
||||
error="invalid_desk_bin_restore";return false;
|
||||
}
|
||||
bool owner_open=false;
|
||||
bool owner_visible=false;
|
||||
for(size_t item=1;item<kItems;++item) {
|
||||
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+13]&0x80)==0) continue;
|
||||
// The frame bit does not hide folder contents; require a visible linked owner.
|
||||
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+1]&0x10)!=0) continue;
|
||||
int cursor=0;size_t visited=0;
|
||||
while(++visited<kItems) {
|
||||
const int next=expected[size_t(cursor)*kStride+5];
|
||||
if(next==int(item)) { owner_open=true;break; }
|
||||
if(next==int(item)) { owner_visible=true;break; }
|
||||
if(next<=0||next>=int(kItems)) break;
|
||||
cursor=next;
|
||||
}
|
||||
if(owner_open)break;
|
||||
if(owner_visible)break;
|
||||
}
|
||||
if(!owner_open) { error="desk_bin_restore_folder_closed";return false; }
|
||||
if(!owner_visible) { error="desk_bin_restore_folder_hidden";return false; }
|
||||
int tail=0;size_t guard=0;
|
||||
while(expected[size_t(tail)*kStride+5]!=0) {
|
||||
if(++guard>=kItems) { error="invalid_desk_layout_chain";return false; }
|
||||
@@ -8102,12 +8126,7 @@ bool CareerSession::dispatch_stadium(const ui::StadiumRequest& supplied_request,
|
||||
if (request.object != -1 || request.option != -1 || request.price != 0 ||
|
||||
(request.kind != ui::StadiumRequestKind::expansion_answer_tip && request.accept_tip))
|
||||
return invalid("invalid_block_expansion_envelope");
|
||||
StadiumBlockExpansionConstants block_constants;
|
||||
for (unsigned i = 0; i < 8; ++i) {
|
||||
block_constants.price_per_1000[i] = exe_.u32(::bmh::layout::CareerSession_DispatchStadium_RuntimeField + (i + 8) * 4);
|
||||
block_constants.weeks[i] = exe_.u8(::bmh::layout::CareerSession_DispatchStadium_RuntimeField2 + (i + 22) * 5);
|
||||
block_constants.max_places[i] = uint32_t(exe_.u8(::bmh::layout::CareerSession_Invalid_RuntimeField + i)) * 1000;
|
||||
}
|
||||
const auto block_constants=stadium_block_expansion_constants(exe_);
|
||||
const auto quote_block = [&](StadiumBlockSlot slot, uint32_t total, uint8_t features) {
|
||||
return quote_stadium_block_expansion(g_, active, slot, total, features,
|
||||
stadium_.price_percent, block_constants);
|
||||
|
||||
@@ -175,7 +175,8 @@ public:
|
||||
// result with valid dependent projections becomes the live state.
|
||||
std::optional<TransferActionResult> dispatch_transfer_market(
|
||||
const ui::TransferMarketRequest&, const HumanBuyerSaleHooks&,
|
||||
uint64_t& revision, std::string& error);
|
||||
uint64_t& revision, std::string& error,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
|
||||
|
||||
struct TransferMarketPreviewDispatch {
|
||||
ui::PreparationState preparation;
|
||||
|
||||
+40
-10
@@ -2,6 +2,7 @@
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/controller.hpp"
|
||||
#include "app/debug_log.hpp"
|
||||
#include "app/window_actions.hpp"
|
||||
#include "app/desktop_actions.hpp"
|
||||
#include "app/audio.hpp"
|
||||
@@ -370,9 +371,11 @@ std::string transfer_status_message(TransferActionStatus status, ui::TransferMar
|
||||
case TransferActionStatus::accepted:
|
||||
return kind == ui::TransferMarketRequestKind::list_player
|
||||
? "Der Spieler steht jetzt auf der Transferliste." : "Der Spieler hat das Angebot angenommen.";
|
||||
case TransferActionStatus::pending: return "Der Spieler entscheidet sich nächste Woche.";
|
||||
case TransferActionStatus::pending: return kind == ui::TransferMarketRequestKind::list_player
|
||||
? "Der Spieler steht bereits auf der Transferliste." : "Der Spieler entscheidet sich nächste Woche.";
|
||||
case TransferActionStatus::offer_too_low: return "Das Angebot ist zu niedrig.";
|
||||
case TransferActionStatus::blocked_by_board: return "Der Vorstand genehmigt diesen Transfer nicht.";
|
||||
case TransferActionStatus::blocked_by_board: return kind == ui::TransferMarketRequestKind::list_player
|
||||
? "Transferliste voll oder Spieler nicht verfügbar." : "Der Vorstand genehmigt diesen Transfer nicht.";
|
||||
case TransferActionStatus::insufficient_funds: return "Das Geld reicht für diesen Transfer nicht aus.";
|
||||
case TransferActionStatus::no_squad_room: return "Im Kader ist kein Platz für diesen Spieler.";
|
||||
case TransferActionStatus::rejected: return "Der Spieler hat das Angebot abgelehnt.";
|
||||
@@ -384,7 +387,8 @@ void serve_transfer_action(ui::StartupFlow& flow, CareerSession& session,
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision,
|
||||
const HumanBuyerSaleHooks& presenters,
|
||||
HumanBuyerMarketEntryPolicy entry_policy,
|
||||
const CareerSession::PoachPlayerSelector& poach_selector, const PoachNoticePresenter& poach_notice) {
|
||||
const CareerSession::PoachPlayerSelector& poach_selector, const PoachNoticePresenter& poach_notice,
|
||||
const TransferOfferPresenter& review) {
|
||||
const auto* pending = flow.pending_transfer_market();
|
||||
// JSON covers every offer field except its redundant nested manager identity.
|
||||
// Check that identity too, before an engine helper can consume a random draw.
|
||||
@@ -473,13 +477,22 @@ void serve_transfer_action(ui::StartupFlow& flow, CareerSession& session,
|
||||
const auto outcome = TransferActions(session).market(request, hooks, revision, error, entry_policy,
|
||||
[&](const TransferActions::MarketDispatch& applied) {
|
||||
// Preserve the Source caller's existing notice/ACK sequence.
|
||||
const bool source_finished = entry_policy == HumanBuyerMarketEntryPolicy::normal_interactive &&
|
||||
(source_notice_presented || applied.action.status == TransferActionStatus::pending);
|
||||
const bool source_finished = request.kind != ui::TransferMarketRequestKind::review_offers &&
|
||||
entry_policy == HumanBuyerMarketEntryPolicy::normal_interactive &&
|
||||
(source_notice_presented || (request.kind == ui::TransferMarketRequestKind::submit_bid &&
|
||||
applied.action.status == TransferActionStatus::pending));
|
||||
auto notice = source_finished ? std::string{} : transfer_status_message(applied.action.status, request.kind);
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
notice = applied.action.status == TransferActionStatus::accepted
|
||||
? "Das Angebot wurde angenommen."
|
||||
: applied.action.status == TransferActionStatus::pending
|
||||
? "Spieler bleibt auf der Transferliste."
|
||||
: "Angebot abgelehnt; Transferliste unverändert.";
|
||||
}
|
||||
if (!applied.changed && source_finished) flow.acknowledge_unchanged_transfer_market();
|
||||
else if (!applied.changed) flow.reject_preparation_action(std::move(notice));
|
||||
else flow.acknowledge_preparation(session.preparation_projection(revision), std::move(notice));
|
||||
});
|
||||
}, review);
|
||||
if (!outcome) throw FormatError(error);
|
||||
} catch (const std::exception&) {
|
||||
flow.reject_preparation_action("Diese Transferaktion konnte nicht übernommen werden.");
|
||||
@@ -566,6 +579,8 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
opened.identity.runtime_team!=desk.runtime_club||
|
||||
opened.identity.day_counter!=desk.day_counter||desk.manager_slot<0||
|
||||
size_t(desk.manager_slot)>=desk.managers.size()||
|
||||
// The session identifies the national-coach desk by the home club
|
||||
// (stable team behind the desk), not by the desk's own runtime club.
|
||||
opened.identity.club_identity!=desk.managers[size_t(desk.manager_slot)].club_identity_key)
|
||||
throw FormatError("other games: stale desktop identity");
|
||||
flow.show_other_games(std::move(opened),session->preparation_projection(revision),result.desk_action);
|
||||
@@ -809,14 +824,14 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
const bool national_source_case=flow.national_friendly_family_active();
|
||||
const int stable_identity=national_source_case&&flow.desktop()&&
|
||||
owner.manager_slot>=0&&size_t(owner.manager_slot)<flow.desktop()->state().managers.size()?
|
||||
flow.desktop()->state().managers[size_t(owner.manager_slot)].club_identity_key:-1;
|
||||
flow.desktop()->state().session_identity_key(size_t(owner.manager_slot)):-1;
|
||||
auto page=OpportunitiesActions(*session).open(owner,revision,underlay,error,
|
||||
national_source_case,stable_identity,[&](ui::OpportunitiesState& opened) {
|
||||
const auto& desk=flow.desktop()->state();
|
||||
if(opened.identity.manager_slot!=desk.manager_slot||opened.identity.runtime_team!=desk.runtime_club||
|
||||
opened.identity.day_counter!=desk.day_counter||desk.manager_slot<0||
|
||||
size_t(desk.manager_slot)>=desk.managers.size()||
|
||||
opened.identity.stable_club_identity!=int(desk.managers[size_t(desk.manager_slot)].club_identity_key))
|
||||
opened.identity.stable_club_identity!=int(desk.session_identity_key(size_t(desk.manager_slot))))
|
||||
throw FormatError("opportunities: stale desktop identity");
|
||||
flow.show_opportunities(std::move(opened),session->preparation_projection(revision),owner);
|
||||
});
|
||||
@@ -926,6 +941,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
opened.identity.day_counter!=desk.day_counter||
|
||||
desk.manager_slot<0||
|
||||
size_t(desk.manager_slot)>=desk.managers.size()||
|
||||
// Same home-club identity as the session builds for the national desk.
|
||||
opened.identity.club_identity!=desk.managers[size_t(desk.manager_slot)].club_identity_key)
|
||||
throw FormatError("top scorers: stale desktop identity");
|
||||
flow.show_top_scorers(std::move(opened),session->preparation_projection(revision),result.desk_action);
|
||||
@@ -1308,7 +1324,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
const auto& desk=flow.desktop()->state();
|
||||
if(!semantic||semantic->identity.manager!=desk.manager_slot||semantic->identity.runtime_club!=desk.runtime_club||
|
||||
semantic->identity.day_counter!=desk.day_counter||desk.manager_slot<0||size_t(desk.manager_slot)>=desk.managers.size()||
|
||||
semantic->identity.club_identity!=desk.managers[size_t(desk.manager_slot)].club_identity_key)
|
||||
semantic->identity.club_identity!=desk.session_identity_key(size_t(desk.manager_slot)))
|
||||
throw FormatError("strengths: stale desktop identity");
|
||||
const auto applied=session->dispatch_strengths(*semantic,revision,error);
|
||||
if(!applied)throw FormatError(error.empty()?"league family Strengths entry rejected":error);
|
||||
@@ -1533,7 +1549,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
} else if (result.request == ui::FlowRequest::submenu_action && session &&
|
||||
std::holds_alternative<ui::TransferMarketRequest>(result.submenu_action)) {
|
||||
serve_transfer_action(flow, *session, std::get<ui::TransferMarketRequest>(result.submenu_action), revision,
|
||||
market_sale_presenter, market_entry_policy, poach_player_selector, poach_notice_presenter);
|
||||
market_sale_presenter, market_entry_policy, poach_player_selector, poach_notice_presenter, transfer_presenter);
|
||||
} else if (result.request == ui::FlowRequest::submenu_action && session &&
|
||||
std::holds_alternative<ui::OutgoingTransferRequest>(result.submenu_action)) {
|
||||
serve_transfer_offer(flow, *session, std::get<ui::OutgoingTransferRequest>(result.submenu_action), revision,
|
||||
@@ -1854,6 +1870,20 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
});
|
||||
const auto advanced = session->dispatch_kickoff(result.desk_action, revision, error);
|
||||
start_original_desk_audio(playback, session->state(), music_enabled);
|
||||
if (app::debug::enabled()) {
|
||||
// -debug: one savegame after every match day, in the debug folder (DBG00001.FBM, ...).
|
||||
app::debug::log("kickoff handled: " + std::string(advanced.kind == TurnDeskKind::Failed ? "failed" : "ok") +
|
||||
", date counter " + std::to_string(session->state().date) + ", revision " + std::to_string(revision) +
|
||||
(error.empty() ? std::string() : ", error " + error));
|
||||
if (advanced.kind != TurnDeskKind::Failed) {
|
||||
const auto path = app::debug::next_save_path();
|
||||
std::string save_error;
|
||||
const int slot = int(session->state().memory.u8(::bmh::layout::ActiveManager));
|
||||
const bool saved = session->save_game(path, slot, true, save_error);
|
||||
app::debug::log(saved ? "debug savegame " + path.filename().string()
|
||||
: "debug savegame failed: " + save_error);
|
||||
}
|
||||
}
|
||||
if (advanced.kind == TurnDeskKind::Failed || advanced.kind == TurnDeskKind::WaitingAtDesk) {
|
||||
flow.reject_desk_action(error.empty() ? advanced.reason : error);
|
||||
return {};
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace bmh::app::debug {
|
||||
|
||||
// The debug mode (command line -debug): a log with timestamps next to everything the game prints
|
||||
// to stderr, and a savegame after every played match day, both in one sub folder of the save
|
||||
// directory. Off by default; every function is a no-op until init() has run.
|
||||
struct State {
|
||||
bool enabled = false;
|
||||
std::filesystem::path directory;
|
||||
unsigned saves = 0;
|
||||
std::mutex mutex;
|
||||
};
|
||||
inline State& state() { static State s; return s; }
|
||||
|
||||
inline bool enabled() { return state().enabled; }
|
||||
inline const std::filesystem::path& directory() { return state().directory; }
|
||||
|
||||
inline std::string timestamp() {
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
const std::time_t t = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm parts{};
|
||||
#ifdef _WIN32
|
||||
localtime_s(&parts, &t);
|
||||
#else
|
||||
localtime_r(&t, &parts);
|
||||
#endif
|
||||
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count() % 1000;
|
||||
char text[40];
|
||||
std::snprintf(text, sizeof text, "%04d-%02d-%02d %02d:%02d:%02d.%03d", parts.tm_year + 1900, parts.tm_mon + 1,
|
||||
parts.tm_mday, parts.tm_hour, parts.tm_min, parts.tm_sec, int(ms));
|
||||
return text;
|
||||
}
|
||||
|
||||
// One line, flushed at once so that a crash or a hang loses nothing.
|
||||
inline void log(const std::string& line) {
|
||||
auto& s = state();
|
||||
if (!s.enabled) return;
|
||||
std::lock_guard<std::mutex> lock(s.mutex);
|
||||
std::ofstream out(s.directory / "openbmh-debug.log", std::ios::app);
|
||||
if (out) out << timestamp() << " " << line << '\n';
|
||||
}
|
||||
|
||||
// Creates the folder and redirects stderr into the same folder, so the messages the game
|
||||
// prints on its own (for example the live overview errors) are kept as well.
|
||||
inline bool init(const std::filesystem::path& directory) {
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(directory, ec);
|
||||
if (ec || !std::filesystem::is_directory(directory)) return false;
|
||||
auto& s = state();
|
||||
s.directory = directory;
|
||||
s.enabled = true;
|
||||
const auto errors = (directory / "openbmh-stderr.log").string();
|
||||
if (std::FILE* redirected = std::freopen(errors.c_str(), "a", stderr)) std::setvbuf(redirected, nullptr, _IONBF, 0);
|
||||
log("debug mode on, folder " + directory.string());
|
||||
return true;
|
||||
}
|
||||
|
||||
// The file name of the next automatic savegame: DBG00001.FBM, DBG00002.FBM, ... (8.3 like the original).
|
||||
inline std::filesystem::path next_save_path() {
|
||||
auto& s = state();
|
||||
char name[16];
|
||||
std::snprintf(name, sizeof name, "DBG%05u.FBM", ++s.saves);
|
||||
return s.directory / name;
|
||||
}
|
||||
|
||||
} // namespace bmh::app::debug
|
||||
+108
-18
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/start_screen.hpp"
|
||||
#include "ui/live_timing.hpp"
|
||||
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
|
||||
// career initialised by the engine (app/career_session.hpp) and its desk.
|
||||
@@ -33,6 +34,8 @@
|
||||
#include "version.hpp"
|
||||
#include "app/video_session.hpp"
|
||||
#include "app/live_matchday_events.hpp"
|
||||
#include "app/debug_log.hpp"
|
||||
#include "app/pitch_pointer.hpp"
|
||||
#include "audio/playback.hpp"
|
||||
#include "app/audio.hpp"
|
||||
#include "formats/palette.hpp"
|
||||
@@ -113,7 +116,7 @@ int main(int argc, char** argv) {
|
||||
const std::vector<std::string> args = launch::utf8_arguments(argc, argv); // (file names beyond the code page)
|
||||
fs::path data, save_directory;
|
||||
uint32_t seed = uint32_t(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
bool muted = false, music_enabled = true;
|
||||
bool muted = false, music_enabled = true, debug_mode = false;
|
||||
int live_frame_ms = 0;
|
||||
bool live_frame_ms_explicit = false;
|
||||
if (const char* configured = std::getenv("BMH_LIVE_FRAME_MS")) {
|
||||
@@ -137,6 +140,8 @@ int main(int argc, char** argv) {
|
||||
data = launch::path_from_utf8(args[++i]);
|
||||
} else if (is("--seed") && value) {
|
||||
seed = uint32_t(std::strtoul(args[++i].c_str(), nullptr, 0));
|
||||
} else if (is("-debug") || is("--debug")) {
|
||||
debug_mode = true;
|
||||
} else if (is("--save-directory") && value) {
|
||||
save_directory = launch::path_from_utf8(args[++i]);
|
||||
} else if (is("--volume") && value) {
|
||||
@@ -146,7 +151,7 @@ int main(int argc, char** argv) {
|
||||
return 0;
|
||||
} else if (is("--help") || is("-h")) {
|
||||
std::printf("usage: OpenBMH [<game directory | BMH.EXE | game.zip | game.7z>] [--seed <Watcom seed>] "
|
||||
"[--save-directory <directory>] [--mute] [--volume <0..1>] [--no-music] [--live-frame-ms <0..1000>]\n");
|
||||
"[--save-directory <directory>] [--mute] [--volume <0..1>] [--no-music] [--live-frame-ms <0..1000>] [-debug]\n");
|
||||
return 0;
|
||||
} else if (args[i].rfind("--", 0) != 0 && data.empty()) {
|
||||
data = launch::path_from_utf8(args[i]);
|
||||
@@ -193,6 +198,13 @@ int main(int argc, char** argv) {
|
||||
data = game.check.directory;
|
||||
}
|
||||
if (save_directory.empty()) save_directory = data;
|
||||
if (debug_mode) {
|
||||
// -debug: log in <saves>/debug, with a savegame after every match day (app/debug_log.hpp).
|
||||
if (!app::debug::init(save_directory / "debug")) std::fprintf(stderr, "debug folder cannot be created\n");
|
||||
app::debug::log(std::string("OpenBMH ") + bmh::kOpenBmhVersion + ", data " + data.string() + ", saves " + save_directory.string() + ", seed " + std::to_string(seed));
|
||||
SDL_version linked; SDL_GetVersion(&linked);
|
||||
app::debug::log("SDL " + std::to_string(linked.major) + "." + std::to_string(linked.minor) + "." + std::to_string(linked.patch) + ", platform " + SDL_GetPlatform());
|
||||
}
|
||||
try {
|
||||
const Palette palette = load_palette(ui::asset_path(data, "M3PC.COL"));
|
||||
ui::StartupFlow flow(data, save_directory);
|
||||
@@ -207,7 +219,7 @@ int main(int argc, char** argv) {
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
|
||||
const std::string window_title = std::string("OpenBMH ") + bmh::kOpenBmhVersion +
|
||||
(english_game ? " - Football Limited (experimental)" : "");
|
||||
SDL_Window* window = SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 720, SDL_WINDOW_RESIZABLE);
|
||||
SDL_Window* window = SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 720, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
if (!window) throw FormatError(SDL_GetError());
|
||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
|
||||
if (!renderer) renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
|
||||
@@ -215,6 +227,7 @@ int main(int argc, char** argv) {
|
||||
SDL_RenderSetLogicalSize(renderer, 320, 240);
|
||||
SDL_Texture* texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 320, 240);
|
||||
if (!texture) throw FormatError(SDL_GetError());
|
||||
app::PitchPointer pitch_pointer;
|
||||
std::vector<uint32_t> pixels(320 * 240);
|
||||
ui::LiveMatchdayScreen live_screen(data);
|
||||
ui::RealityReporterPanel reality_reporter(data);
|
||||
@@ -223,8 +236,21 @@ int main(int argc, char** argv) {
|
||||
ui::SportschauEleven sportschau_eleven(data);
|
||||
ui::SportschauTeamInfo sportschau_team_info(data);
|
||||
ui::CompetitionWinnerScreen competition_winner(data);
|
||||
ui::set_settings_product_version(bmh::kOpenBmhVersion);
|
||||
const auto season_exe = load_le(ui::asset_path(data, "BMH.exe"));
|
||||
english_game = english_game || season_exe.u8(layout::LeagueSizes) == 20;
|
||||
{
|
||||
// The pointer of the original is its default 11x11 bitmap (index 0 transparent, hot spot
|
||||
// top left, set when a window object is created); the pitch page draws the same bitmap
|
||||
// with its own fill colour. The edition's own bitmap is used for the English version.
|
||||
std::array<uint32_t, 121> bitmap{};
|
||||
for (uint32_t i = 0; i < bitmap.size(); ++i) {
|
||||
const auto index = season_exe.u8(layout::OriginalPointerPixels + i);
|
||||
bitmap[i] = index == 0 ? 0 : palette.argb[index];
|
||||
}
|
||||
pitch_pointer.set_default(bitmap);
|
||||
pitch_pointer.show({}, renderer);
|
||||
}
|
||||
app::QuitConfirmation quit_confirmation(window, english_game);
|
||||
try {
|
||||
if (!playback.initialize_original(app::original_audio_assets(data, season_exe), audio_error))
|
||||
@@ -1702,6 +1728,7 @@ int main(int argc, char** argv) {
|
||||
std::optional<Uint64> timed_notice_presented_at;
|
||||
std::optional<Uint8> timed_notice_release;
|
||||
auto handle = [&](const ui::FlowResult& r) {
|
||||
pitch_pointer.show({}, renderer);
|
||||
if (r.request == ui::FlowRequest::end_session && !quit_confirmation.confirm()) {
|
||||
flow.reject_desk_action(english_game ? "Quit cancelled." : "Beenden abgebrochen.");
|
||||
dirty = true;
|
||||
@@ -1781,6 +1808,7 @@ int main(int argc, char** argv) {
|
||||
bool closed = false;
|
||||
const auto apply_live_pitch = [&](const ui::PitchRequest& action) {
|
||||
if (action.kind == ui::PitchRequestKind::none) return;
|
||||
pitch_pointer.show({}, renderer);
|
||||
if (action.kind == ui::PitchRequestKind::open_player_info) {
|
||||
try {
|
||||
if (action.row < 0 || size_t(action.row) >= screen.state().players.size() ||
|
||||
@@ -1820,6 +1848,7 @@ int main(int argc, char** argv) {
|
||||
};
|
||||
bool left_held = false, left_release_consumed = false, right_held = false;
|
||||
while (running && !closed) {
|
||||
pitch_pointer.show(screen.pointer_cursor(palette), renderer);
|
||||
const Image image = screen.render();
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
pixels[i] = palette.argb[image.pixels[i]];
|
||||
@@ -1880,8 +1909,10 @@ int main(int argc, char** argv) {
|
||||
scope_finished = true;
|
||||
completed = true;
|
||||
}
|
||||
pitch_pointer.show({}, renderer);
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_matchday");
|
||||
} catch (const std::exception& e) {
|
||||
pitch_pointer.show({}, renderer);
|
||||
if (scope_started && !scope_finished)
|
||||
dispatch_scope(app::LiveInterventionBoundary::abort, 2,
|
||||
selected_manager, selected_team, scope_error);
|
||||
@@ -2096,11 +2127,16 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
};
|
||||
SDL_FlushEvent(SDL_KEYUP);
|
||||
while (running && !closed) {
|
||||
while (running && (!closed || down)) {
|
||||
SDL_Event input;
|
||||
bool redrawn = false;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; break; }
|
||||
if (closed) {
|
||||
if (input.type == SDL_MOUSEBUTTONUP && down &&
|
||||
input.button.button == down->button) { down.reset(); break; }
|
||||
continue;
|
||||
}
|
||||
if (input.type == SDL_MOUSEMOTION) {
|
||||
const bool changed = table_screen ? table_screen->move(input.motion.x, input.motion.y)
|
||||
: pairings_screen ? pairings_screen->move(input.motion.x, input.motion.y)
|
||||
@@ -2119,8 +2155,7 @@ int main(int argc, char** argv) {
|
||||
else cup_screen->pointer_down(input.button.x, input.button.y,
|
||||
input.button.button == SDL_BUTTON_RIGHT);
|
||||
} else if (input.type == SDL_MOUSEBUTTONUP && down &&
|
||||
input.button.button == down->button && input.button.x == down->x &&
|
||||
input.button.y == down->y) {
|
||||
input.button.button == down->button) {
|
||||
down.reset();
|
||||
if (table_screen) table_screen->click(input.button.x, input.button.y,
|
||||
input.button.button == SDL_BUTTON_RIGHT);
|
||||
@@ -2141,19 +2176,21 @@ int main(int argc, char** argv) {
|
||||
else if (cup_screen && cup_screen->pending())
|
||||
action = *cup_screen->pending();
|
||||
if (action) { dispatch_action(*action); redrawn = true; }
|
||||
if (closed || !running) break;
|
||||
if ((closed && !down) || !running) break;
|
||||
}
|
||||
if (!running || closed) break;
|
||||
if (!running || (closed && !down)) break;
|
||||
if (closed) { SDL_Delay(8); continue; }
|
||||
if (pairings_screen && pairings_screen->tick_source_seconds(overview_source_seconds())) {
|
||||
if (pairings_screen->pending())
|
||||
dispatch_action(app::CareerSession::LiveOverviewAction{*pairings_screen->pending()});
|
||||
redrawn = true;
|
||||
}
|
||||
if (closed || !running) break;
|
||||
if ((closed && !down) || !running) break;
|
||||
if (!redrawn) SDL_Delay(8);
|
||||
}
|
||||
return running && closed;
|
||||
};
|
||||
ui::LiveScoreReveal live_score_reveal;
|
||||
std::optional<ui::LiveChanceProjection> live_chance_context;
|
||||
std::unique_ptr<ui::RealityFieldScreen> reality_field;
|
||||
ui::RealityReporterLayoutState reality_layout;
|
||||
@@ -2212,10 +2249,13 @@ int main(int argc, char** argv) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return -1; }
|
||||
std::optional<int> answer;
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
answer = offer_screen.click(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT);
|
||||
offer_screen.pointer_down(event.button.button == SDL_BUTTON_RIGHT);
|
||||
} else if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
answer = offer_screen.pointer_up(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT);
|
||||
offer_dirty = true;
|
||||
} else if (event.type == SDL_KEYDOWN) {
|
||||
if (offer_screen.notice_active()) {
|
||||
@@ -2280,9 +2320,12 @@ int main(int argc, char** argv) {
|
||||
SDL_Event event;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))
|
||||
(void)decision_screen.click(event.button.x, event.button.y,
|
||||
decision_screen.pointer_down(event.button.button == SDL_BUTTON_RIGHT);
|
||||
else if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))
|
||||
(void)decision_screen.pointer_up(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT, elapsed);
|
||||
}
|
||||
if (confirmation ? decision_screen.confirmation_dismissed() : decision_screen.outcome_dismissed()) return;
|
||||
@@ -2650,7 +2693,8 @@ int main(int argc, char** argv) {
|
||||
file_input.button.button == SDL_BUTTON_RIGHT)) {
|
||||
file_changed |= file_screen.click(file_input.button.x,
|
||||
file_input.button.y,
|
||||
file_input.button.button == SDL_BUTTON_RIGHT);
|
||||
file_input.button.button == SDL_BUTTON_RIGHT,
|
||||
file_input.button.clicks >= 2);
|
||||
} else if (file_input.type == SDL_KEYDOWN && !file_input.key.repeat) {
|
||||
std::string_view key;
|
||||
switch (file_input.key.keysym.sym) {
|
||||
@@ -2911,7 +2955,7 @@ int main(int argc, char** argv) {
|
||||
}, [&](const LiveBallEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
const auto frame = live_score_reveal.project(ui::live_matchday_frame(event.minute, groups, state));
|
||||
if (frame.matches.empty()) return;
|
||||
const auto present = [&](const Image& image) {
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]];
|
||||
@@ -2958,6 +3002,7 @@ int main(int argc, char** argv) {
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
live_score_reveal.observe(event.stage, frame);
|
||||
if (frame.matches.empty()) return;
|
||||
const auto chance = ui::live_chance_projection(event, groups, state, season_exe);
|
||||
if (event.stage == LiveChanceStage::preview) live_chance_context = chance;
|
||||
@@ -2990,7 +3035,7 @@ int main(int argc, char** argv) {
|
||||
}, [&](const LiveShotEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
const auto frame = live_score_reveal.project(ui::live_matchday_frame(event.minute, groups, state));
|
||||
if (frame.matches.empty()) return;
|
||||
const auto frames = live_screen.render_shot(frame, event);
|
||||
const auto shot_colors = live_screen.shot_palette(palette, event, groups, state);
|
||||
@@ -3048,7 +3093,7 @@ int main(int argc, char** argv) {
|
||||
}, [&](const LiveSetPieceEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame=ui::live_matchday_frame(event.minute,groups,state);
|
||||
const auto frame=live_score_reveal.project(ui::live_matchday_frame(event.minute,groups,state));
|
||||
if (frame.matches.empty()) return;
|
||||
const auto images=live_screen.render_set_piece(frame,event);
|
||||
LiveShotEvent palette_event;
|
||||
@@ -3204,6 +3249,7 @@ int main(int argc, char** argv) {
|
||||
}, &request);
|
||||
if (!closed) throw FormatError("phase results: viewer stopped before Source ACK");
|
||||
}, true);
|
||||
if (app::debug::enabled()) app::debug::log("request " + std::to_string(int(r.request)) + (message.empty() ? std::string(" ok") : " -> " + message));
|
||||
if (message == "career_complete") { running = false; return; }
|
||||
if (!message.empty()) std::fprintf(stderr, "engine: %s\n", message.c_str());
|
||||
if (session) {
|
||||
@@ -3599,6 +3645,42 @@ int main(int argc, char** argv) {
|
||||
if (expired.request != ui::FlowRequest::none || expired.changed) handle(expired);
|
||||
}
|
||||
};
|
||||
// OpenBMH deviates from the original: display the repository-owned title
|
||||
// at its native resolution until a complete left/right click, without loading balls.
|
||||
{
|
||||
app::StartScreen title_screen(renderer);
|
||||
title_screen.present();
|
||||
bool opening_confirmed = false;
|
||||
std::optional<Uint8> opening_press;
|
||||
while (running && !opening_confirmed) {
|
||||
SDL_Event opening_event;
|
||||
while (quit_confirmation.poll(&opening_event)) {
|
||||
if (opening_event.type == SDL_QUIT) running = false;
|
||||
if (opening_event.type == SDL_KEYDOWN && opening_event.key.keysym.sym == SDLK_ESCAPE &&
|
||||
quit_confirmation.confirm()) running = false;
|
||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||
(opening_event.window.event == SDL_WINDOWEVENT_EXPOSED ||
|
||||
opening_event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED))
|
||||
title_screen.present();
|
||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||
opening_event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
opening_press.reset();
|
||||
if (opening_event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(opening_event.button.button == SDL_BUTTON_LEFT ||
|
||||
opening_event.button.button == SDL_BUTTON_RIGHT))
|
||||
opening_press = opening_event.button.button;
|
||||
if (opening_event.type == SDL_MOUSEBUTTONUP && opening_press &&
|
||||
opening_event.button.button == *opening_press)
|
||||
opening_confirmed = true;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
} // Restore the indexed game canvas and its logical input mapping.
|
||||
// Opening input must not also change an option on the first setup frame.
|
||||
SDL_FlushEvents(SDL_KEYDOWN, SDL_KEYUP);
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
season_backdrop.reset();
|
||||
dirty = true;
|
||||
SDL_StartTextInput();
|
||||
bool filename_input_active = false;
|
||||
std::array<bool, 2> setup_button_down{};
|
||||
@@ -3787,6 +3869,12 @@ int main(int argc, char** argv) {
|
||||
const auto released = held ? flow.hold(e.button.x, e.button.y, 2000)
|
||||
: flow.click(e.button.x, e.button.y, e.button.button == SDL_BUTTON_RIGHT, e.button.clicks >= 2);
|
||||
present_formation_save_feedback();
|
||||
// JA of the manager confirmation is shown pushed in briefly before the
|
||||
// (possibly slow) next step starts, as in the original.
|
||||
if (flow.screen_name() == "manager_accepted") {
|
||||
present_season(flow.render(), "OpenBMH - manager_accepted");
|
||||
SDL_Delay(150);
|
||||
}
|
||||
handle(released);
|
||||
present_desk_record_points();
|
||||
press.reset();
|
||||
@@ -3877,6 +3965,7 @@ int main(int argc, char** argv) {
|
||||
throw std::runtime_error(std::string("Source modal texture: ") + SDL_GetError());
|
||||
dirty = false;
|
||||
}
|
||||
pitch_pointer.show(flow.pitch_pointer_cursor(palette), renderer);
|
||||
const int cleared = SDL_RenderClear(renderer);
|
||||
const int copied = SDL_RenderCopy(renderer, texture, nullptr, nullptr);
|
||||
if (source_modal_redraw && (cleared != 0 || copied != 0))
|
||||
@@ -3901,6 +3990,7 @@ int main(int argc, char** argv) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
SDL_StopTextInput();
|
||||
pitch_pointer.clear();
|
||||
SDL_DestroyTexture(texture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
// SDL owns pointer position; the UI supplies only the original bitmap/colors. Everywhere but on the
|
||||
// pitch page the pointer is the original's default 11x11 bitmap (set_default); the pitch page
|
||||
// passes the same bitmap with its position-colour fill.
|
||||
class PitchPointer {
|
||||
public:
|
||||
~PitchPointer() { clear(); }
|
||||
void clear() {
|
||||
if (cursor_) {
|
||||
SDL_SetCursor(SDL_GetDefaultCursor());
|
||||
SDL_FreeCursor(cursor_);
|
||||
cursor_ = nullptr;
|
||||
}
|
||||
pixels_.reset();
|
||||
}
|
||||
void set_default(const std::optional<std::array<uint32_t,121>>& pixels) { default_ = pixels; }
|
||||
void show(const std::optional<std::array<uint32_t,121>>& requested, SDL_Renderer* renderer) {
|
||||
const auto& pixels = requested ? requested : default_;
|
||||
if (!pixels) { SDL_SetCursor(SDL_GetDefaultCursor()); return; }
|
||||
// Cursor bitmaps are sized in window points, not in pixels: on a high-DPI display (macOS
|
||||
// Retina) the renderer's output is larger than the window, and a bitmap scaled to it would
|
||||
// show twice as large. SDL_GetWindowSize gives the points.
|
||||
int width = 320, height = 240;
|
||||
if (SDL_Window* window = SDL_RenderGetWindow(renderer)) SDL_GetWindowSize(window, &width, &height);
|
||||
else SDL_GetRendererOutputSize(renderer, &width, &height);
|
||||
const int scale = std::max(1, std::min(width / 320, height / 240));
|
||||
if (!cursor_ || pixels != pixels_ || scale != scale_) {
|
||||
std::vector<uint32_t> enlarged(size_t(11 * scale) * size_t(11 * scale));
|
||||
for (int y = 0; y < 11 * scale; ++y) for (int x = 0; x < 11 * scale; ++x)
|
||||
enlarged[size_t(y) * size_t(11 * scale) + size_t(x)] =
|
||||
pixels->at(size_t(y / scale) * 11 + size_t(x / scale));
|
||||
SDL_Surface* surface = SDL_CreateRGBSurfaceWithFormatFrom(enlarged.data(),
|
||||
11 * scale, 11 * scale, 32, 11 * scale * 4, SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_Cursor* next = surface ? SDL_CreateColorCursor(surface, 0, 0) : nullptr;
|
||||
if (surface) SDL_FreeSurface(surface);
|
||||
if (!next) return; // A headless SDL driver may not support host cursors.
|
||||
clear(); cursor_ = next; pixels_ = pixels; scale_ = scale;
|
||||
}
|
||||
SDL_SetCursor(cursor_);
|
||||
}
|
||||
private:
|
||||
SDL_Cursor* cursor_ = nullptr;
|
||||
std::optional<std::array<uint32_t,121>> pixels_, default_;
|
||||
int scale_ = 1;
|
||||
};
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -0,0 +1,40 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "app/start_screen.hpp"
|
||||
#include "app/start_screen_data.hpp"
|
||||
#include <SDL.h>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#define STBI_ONLY_JPEG
|
||||
#define STBI_NO_STDIO
|
||||
#define STBI_NO_HDR
|
||||
#define STBI_NO_LINEAR
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "app/third_party/stb_image.h"
|
||||
namespace bmh::app {
|
||||
StartScreen::StartScreen(SDL_Renderer* renderer):renderer_(renderer) {
|
||||
if(!renderer_)throw std::runtime_error("Start screen: missing renderer");
|
||||
SDL_RenderGetLogicalSize(renderer_,&previous_width_,&previous_height_);
|
||||
int channels=0;
|
||||
const std::unique_ptr<unsigned char,decltype(&stbi_image_free)> pixels(
|
||||
stbi_load_from_memory(start_screen_jpeg,int(start_screen_jpeg_size),&width_,&height_,&channels,3),stbi_image_free);
|
||||
if(!pixels)throw std::runtime_error("Start screen: embedded artwork could not be decoded");
|
||||
texture_=SDL_CreateTexture(renderer_,SDL_PIXELFORMAT_RGB24,SDL_TEXTUREACCESS_STATIC,width_,height_);
|
||||
if(!texture_)throw std::runtime_error(SDL_GetError());
|
||||
if(SDL_UpdateTexture(texture_,nullptr,pixels.get(),width_*3)!=0||SDL_SetTextureScaleMode(texture_,SDL_ScaleModeLinear)!=0) {
|
||||
const std::string error=SDL_GetError();SDL_DestroyTexture(texture_);texture_=nullptr;throw std::runtime_error(error);
|
||||
}
|
||||
}
|
||||
StartScreen::~StartScreen() {
|
||||
SDL_DestroyTexture(texture_);
|
||||
SDL_RenderSetLogicalSize(renderer_,previous_width_,previous_height_);
|
||||
}
|
||||
void StartScreen::present() {
|
||||
if(SDL_RenderSetLogicalSize(renderer_,width_,height_)!=0)throw std::runtime_error(SDL_GetError());
|
||||
Uint8 r=0,g=0,b=0,a=0;SDL_GetRenderDrawColor(renderer_,&r,&g,&b,&a);
|
||||
SDL_SetRenderDrawColor(renderer_,0,0,0,255);
|
||||
const int cleared=SDL_RenderClear(renderer_);SDL_SetRenderDrawColor(renderer_,r,g,b,a);
|
||||
if(cleared!=0||SDL_RenderCopy(renderer_,texture_,nullptr,nullptr)!=0)throw std::runtime_error(SDL_GetError());
|
||||
SDL_RenderPresent(renderer_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
struct SDL_Renderer;
|
||||
struct SDL_Texture;
|
||||
namespace bmh::app {
|
||||
// Owned, embedded artwork, rendered independently of the indexed game canvas.
|
||||
// Destruction restores the caller's logical size and therefore its input mapping.
|
||||
class StartScreen {
|
||||
public:
|
||||
explicit StartScreen(SDL_Renderer*);
|
||||
~StartScreen();
|
||||
StartScreen(const StartScreen&)=delete;
|
||||
StartScreen& operator=(const StartScreen&)=delete;
|
||||
void present();
|
||||
int width()const{return width_;}
|
||||
int height()const{return height_;}
|
||||
private:
|
||||
SDL_Renderer* renderer_;
|
||||
SDL_Texture* texture_=nullptr;
|
||||
int width_=0,height_=0,previous_width_=0,previous_height_=0;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
namespace bmh::app {
|
||||
extern const unsigned char start_screen_jpeg[];
|
||||
extern const std::size_t start_screen_jpeg_size;
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
# stb_image
|
||||
|
||||
Unmodified upstream stb_image 2.30 header, commit `013ac3beddff3dbffafd5177e7972067cd2b5083`.
|
||||
Source: [013ac3beddff3dbffafd5177e7972067cd2b5083](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h).
|
||||
SHA256: `594c2fe35d49488b4382dbfaec8f98366defca819d916ac95becf3e75f4200b3`.
|
||||
|
||||
Only JPEG decoding is compiled. The complete dual MIT/public-domain license
|
||||
is retained in the header and in `docs/licenses/stb_image.txt`.
|
||||
Vendored
+7988
File diff suppressed because it is too large.
Load diff
@@ -108,12 +108,13 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
|
||||
std::optional<TransferActions::MarketDispatch> TransferActions::market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, HumanBuyerMarketEntryPolicy policy,
|
||||
const MarketAccept& acknowledge) {
|
||||
const MarketAccept& acknowledge,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
|
||||
std::optional<MarketDispatch> result;
|
||||
apply(revision, [&] {
|
||||
const auto old_revision = revision;
|
||||
if (policy == HumanBuyerMarketEntryPolicy::normal_interactive) {
|
||||
const auto action = session_.dispatch_transfer_market(request, hooks, revision, error);
|
||||
const auto action = session_.dispatch_transfer_market(request, hooks, revision, error, review);
|
||||
if (!action) return false;
|
||||
result = MarketDispatch{*action, revision != old_revision};
|
||||
} else {
|
||||
@@ -174,7 +175,8 @@ std::string TransferActions::rejection(const ui::TransferMarketRequest& request,
|
||||
return "Dieser Spieler gehört nicht mehr zur gewählten Kaderposition.";
|
||||
} else if (request.kind != ui::TransferMarketRequestKind::open_offer &&
|
||||
request.kind != ui::TransferMarketRequestKind::preview_quote &&
|
||||
request.kind != ui::TransferMarketRequestKind::open_poach)
|
||||
request.kind != ui::TransferMarketRequestKind::open_poach &&
|
||||
request.kind != ui::TransferMarketRequestKind::review_offers)
|
||||
return "Diese Transferaktion ist nicht verfügbar.";
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ public:
|
||||
std::optional<MarketDispatch> market(const ui::TransferMarketRequest&, const HumanBuyerSaleHooks&,
|
||||
uint64_t& revision, std::string& error,
|
||||
HumanBuyerMarketEntryPolicy = HumanBuyerMarketEntryPolicy::normal_interactive,
|
||||
const MarketAccept& = {});
|
||||
const MarketAccept& = {},
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> open_offer(const ui::TransferMarketRequest&,
|
||||
uint64_t& revision, std::string& error, const OfferAccept& = {});
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> preview(const ui::TransferMarketRequest&,
|
||||
|
||||
@@ -160,6 +160,8 @@ void Console::register_transfer_commands() {
|
||||
require_engine(false, "transfer", error);
|
||||
}
|
||||
flush_notices();
|
||||
if (outcome->action.status != TransferActionStatus::accepted)
|
||||
fail("E_RULE", "Der Spieler konnte nicht auf die Transferliste gesetzt werden.");
|
||||
emit('+', utf8(item.name) + (loan
|
||||
? " steht auf der Transferliste; der Entleiher wählt 12 oder 24 Monate im Angebot"
|
||||
: " is on the transfer list"));
|
||||
@@ -175,6 +177,42 @@ void Console::register_transfer_commands() {
|
||||
list_player(v.text("player"), true);
|
||||
});
|
||||
|
||||
add({"Transfer", "ShowOffers", {player}, "incoming offers for an own listed player", false},
|
||||
[this, market_item](const Values& v) {
|
||||
const auto item = market_item(v.text("player"));
|
||||
if (!item.own_listing) fail("E_RULE", "the listing belongs to another club");
|
||||
const auto offers = project_transfer_offer_list(session_->state(), item.list_entry);
|
||||
std::vector<std::vector<std::string>> rows;
|
||||
for (const auto& offer : offers.offers) {
|
||||
if (!offer.present) continue;
|
||||
rows.push_back({std::to_string(offer.bid_index), utf8(session_->state().club_name(offer.buyer)),
|
||||
money(offer.fee), money(offer.monthly_salary), std::to_string(offer.contract_months),
|
||||
offer.loan ? "loan" : "sale",
|
||||
offer.eligible && offer.loan_permitted && offer.transaction_supported ? "yes" : "no"});
|
||||
}
|
||||
emit_table({"Bid", "Club", "Fee", "Monthly salary", "Months", "Type", "Available"}, rows);
|
||||
if (rows.empty()) emit('i', "Noch keine Angebote für diesen Spieler.");
|
||||
});
|
||||
add({"Transfer", "AcceptOffer", {player, integer("bid", 0, 3)}, "accept an existing bid before weekly expiry", true},
|
||||
[this, market, market_item, hooks, flush_notices](const Values& v) {
|
||||
const auto observed = market();
|
||||
const auto item = market_item(v.text("player"));
|
||||
if (!item.own_listing) fail("E_RULE", "the listing belongs to another club");
|
||||
auto request = app::TransferActions::opening(observed, item, false);
|
||||
request.kind = ui::TransferMarketRequestKind::review_offers;
|
||||
request.selected_players.clear();
|
||||
const int bid = int(v.integer("bid"));
|
||||
std::string error;
|
||||
const auto outcome = app::TransferActions(*session_).market(request, hooks(), revision_, error,
|
||||
app::HumanBuyerMarketEntryPolicy::normal_interactive, {},
|
||||
[bid](const GameState&, const TransferOfferListView&) { return bid; });
|
||||
if (!outcome) require_engine(false, "transfer", error);
|
||||
flush_notices();
|
||||
if (outcome->action.status != TransferActionStatus::accepted)
|
||||
fail("E_RULE", "Dieses Angebot kann nicht angenommen werden; die Transferliste bleibt unverändert.");
|
||||
emit('+', "Das Angebot wurde angenommen.");
|
||||
});
|
||||
|
||||
// --- Transfer.Negotiate: the offer editor (06-verein 5.2) -----------------------------
|
||||
auto show_offer = [this] {
|
||||
if (!offer_editor_) fail("E_INTERNAL", "no offer editor");
|
||||
|
||||
@@ -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;
|
||||
@@ -1476,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;
|
||||
@@ -1551,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;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include <stdexcept>
|
||||
namespace bmh {
|
||||
// Original data separates internal domestic slots from player-visible levels.
|
||||
inline int player_league_count(const LeImage& image) {
|
||||
const auto address=layout::LeaguePairings_LeaguePairingsConstants_RuntimeField;
|
||||
if(!image.contains(address+1)||image.u8(address)!=5||image.u8(address+1)<1||image.u8(address+1)>5)
|
||||
throw std::invalid_argument("invalid player-facing league count");
|
||||
return image.u8(address+1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "formats/fbm.hpp"
|
||||
#include <string_view>
|
||||
|
||||
namespace bmh {
|
||||
// Verified German V2.24 state layout: the supplied Diamond 3.7 changes its
|
||||
// container label, while retaining the same block order and database counts.
|
||||
// Expanded careers have their own layout and must not accept these markers.
|
||||
inline bool supported_native_save_version(std::string_view version, bool expanded = false) {
|
||||
return expanded ? version == "O1.1" : version == "V2.24" || version == "V3.7";
|
||||
}
|
||||
inline void require_native_savegame(const Savegame& save, bool expanded = false) {
|
||||
if (!save.checksum_ok) throw FormatError("savegame: FBM checksum mismatch");
|
||||
if (!supported_native_save_version(save.version, expanded))
|
||||
throw FormatError("savegame: unsupported FBM version " + save.version);
|
||||
// Callers still parse the complete state using the installed edition's
|
||||
// exact DbCounts; a recognized marker never bypasses layout validation.
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,24 @@ Palette load_palette(const std::filesystem::path& path) {
|
||||
return p;
|
||||
}
|
||||
|
||||
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path) {
|
||||
const Bytes bytes = read_file(path);
|
||||
if (bytes.size() < 8) throw FormatError("VGA palette source is truncated");
|
||||
const size_t rle_end = 8 + size_t(le32(bytes, 4));
|
||||
if (rle_end > bytes.size()) throw FormatError("VGA RLE length exceeds palette source");
|
||||
const size_t trailing = bytes.size() - rle_end;
|
||||
if (trailing == 0) return std::nullopt;
|
||||
if (trailing < 768) throw FormatError("truncated embedded VGA palette");
|
||||
Palette palette;
|
||||
for (size_t i = 0; i < palette.argb.size(); ++i) {
|
||||
const auto channel = [&](size_t component) {
|
||||
return uint32_t(vga_dac_rgb8(bytes[rle_end + i * 3 + component]));
|
||||
};
|
||||
palette.argb[i] = 0xff000000u | channel(0) << 16 | channel(1) << 8 | channel(2);
|
||||
}
|
||||
return palette;
|
||||
}
|
||||
|
||||
uint8_t Palette::nearest(uint8_t r, uint8_t g, uint8_t b) const {
|
||||
int best = 0, best_dist = INT32_MAX;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -21,5 +22,7 @@ constexpr uint8_t vga_dac_rgb8(uint8_t channel) {
|
||||
}
|
||||
|
||||
Palette load_palette(const std::filesystem::path& path);
|
||||
// Some full-screen VGA pictures carry their own DAC palette after the RLE data.
|
||||
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path);
|
||||
|
||||
} // namespace bmh
|
||||
@@ -56,19 +56,9 @@ uint32_t facility_level(const GameState& g, int m, int k) {
|
||||
// (balance 1 %, fixed deposit 2 % a year), positive an expense (overdraft 12 %, beyond the
|
||||
// credit line 18 %). The divisor is -36500.
|
||||
int32_t daily_interest_preview(const GameState& g, int m) {
|
||||
constexpr int32_t kAnnual = -0x8e94;
|
||||
const int32_t balance = rec32(g, m, 0x314), deposit = rec32(g, m, 0x318), credit = rec32(g, m, 0x31c);
|
||||
int32_t result = 0;
|
||||
if (balance < 0) {
|
||||
const int32_t with_credit = wrap(int64_t(balance) + credit);
|
||||
if (with_credit < 0) result = wrap(int64_t(with_credit) * 0x12) / kAnnual;
|
||||
int32_t below = wrap(-int64_t(credit));
|
||||
if (below < balance) below = balance;
|
||||
result = wrap(int64_t(result) + wrap(int64_t(below) * 0xc) / kAnnual);
|
||||
} else {
|
||||
result = balance / kAnnual;
|
||||
}
|
||||
return wrap(int64_t(result) + wrap(int64_t(deposit / 10000) * 20000) / kAnnual);
|
||||
const auto interest = daily_interest_amounts(balance, deposit, credit);
|
||||
return interest.borrowing + interest.cash_and_deposit;
|
||||
}
|
||||
|
||||
// SharesAndLoans(manager, flags, months): flags 1 the dividends of the manager's funds and
|
||||
@@ -78,7 +68,7 @@ int32_t shares_and_loans(const GameState& g, int m, int flags, int months) {
|
||||
int32_t sum = 0;
|
||||
if (flags & 1) {
|
||||
for (int k = 0; k < 6; k++) {
|
||||
const uint32_t unit = g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c) * uint32_t(kShareUnits[k]) / 10000;
|
||||
const uint32_t unit = uint32_t((uint64_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c)) * uint32_t(kShareUnits[k])) / 10000);
|
||||
sum = wrap(int64_t(sum) + int64_t(unit * g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c)));
|
||||
}
|
||||
if (flags & 4) sum = wrap(int64_t(sum) * months);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "game/state.hpp"
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
|
||||
namespace bmh {
|
||||
// OpenBMH-owned OBMHEXT1 section BRM1: four little-endian blocked month-start keys.
|
||||
// Unknown histories use UINT32_MAX; original save fields are not repurposed.
|
||||
inline constexpr uint32_t kBankRobberyMonthExtension = 0x314d5242;
|
||||
inline constexpr uint32_t kUnknownBankRobberyMonth = std::numeric_limits<uint32_t>::max();
|
||||
inline constexpr uint32_t kBankRobberyMonthBytes = 16;
|
||||
|
||||
inline std::optional<uint32_t> bank_robbery_guard_month(const GameState& state, int manager) {
|
||||
if (manager < 0 || manager > 3) throw FormatError("bank robbery: invalid manager");
|
||||
if (!state.memory.has(kBankRobberyMonthExtension)) return {};
|
||||
if (!state.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
|
||||
throw FormatError("bank robbery: truncated monthly guard");
|
||||
const auto key = state.memory.u32(kBankRobberyMonthExtension + uint32_t(manager) * 4);
|
||||
return key == kUnknownBankRobberyMonth ? std::nullopt : std::optional<uint32_t>{key};
|
||||
}
|
||||
inline void set_bank_robbery_guard_month(GameState& state, int manager, std::optional<uint32_t> key) {
|
||||
if (manager < 0 || manager > 3) throw FormatError("bank robbery: invalid manager");
|
||||
if (!state.memory.has(kBankRobberyMonthExtension)) {
|
||||
state.memory.add_block(kBankRobberyMonthExtension, kBankRobberyMonthBytes);
|
||||
for (uint32_t slot = 0; slot < 4; ++slot)
|
||||
state.memory.set32(kBankRobberyMonthExtension + slot * 4, kUnknownBankRobberyMonth);
|
||||
}
|
||||
if (!state.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
|
||||
throw FormatError("bank robbery: truncated monthly guard");
|
||||
state.memory.set32(kBankRobberyMonthExtension + uint32_t(manager) * 4, key.value_or(kUnknownBankRobberyMonth));
|
||||
}
|
||||
// The first absolute day of the source calendar month, distinct across years.
|
||||
uint32_t bank_robbery_month_key(uint32_t date);
|
||||
}
|
||||
@@ -10,6 +10,18 @@ CalendarEpoch calendar_epoch_from_executable(const LeImage& exe) {
|
||||
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)
|
||||
|
||||
@@ -171,6 +171,10 @@ GameState startup_state(const LeImage& exe, const Database& db, const Bytes& m3_
|
||||
}
|
||||
const SaveState save(stream, counts);
|
||||
GameState g = GameState::from_save(save, counts);
|
||||
// The original options entry restores ordinary dialogs before any manager
|
||||
// confirmation. The executable's initial value belongs to its boot screens.
|
||||
g.memory.add_block(layout::CompactDialogFrame, 1);
|
||||
g.memory.set8(layout::CompactDialogFrame, 0);
|
||||
competition_pointers(g.memory, exe); // CompetitionPointers
|
||||
return g;
|
||||
}
|
||||
|
||||
+2
-2
@@ -622,7 +622,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
|
||||
g.manager_records.at(at) = uint8_t(n + 1), g.manager_records.at(at + 1) = uint8_t((n + 1) >> 8);
|
||||
}
|
||||
// ListTitleHoldersAf(winner, title): the list of title holders (Titles)
|
||||
mem.set16(::bmh::layout::Titles + uint32_t(title) * 100 + uint32_t(std::min<int>(g.season, 0x31)) * 2, winners[0]);
|
||||
record_title_holder(g, title, winners[0]);
|
||||
}
|
||||
if (type == 0 && !winners.empty()) {
|
||||
// the national cup: winner (Cup_AdvanceCup_RuntimeField5) and the previous holder
|
||||
@@ -654,7 +654,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
|
||||
if (mem.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && winner_display)
|
||||
winner_display(g, {7, winner});
|
||||
if (mem.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && mem.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2)) mem.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2, 0);
|
||||
mem.set16(::bmh::layout::Titles + 7 * 100 + uint32_t(std::min<int>(g.season, 0x31)) * 2, winner);
|
||||
record_title_holder(g, 7, winner);
|
||||
if (mem.has(::bmh::layout::Cup_AdvanceCup_RuntimeField7)) mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField7, winner);
|
||||
const int manager = g.manager_of(winner);
|
||||
if (manager >= 0) {
|
||||
|
||||
@@ -538,6 +538,13 @@ TransferActionResult list_manager_player(GameState& g, int manager, int squad_ro
|
||||
out.status = TransferActionStatus::invalid_player;
|
||||
return out;
|
||||
}
|
||||
bool free_entry = false;
|
||||
for (size_t entry = 0; entry < 40; ++entry) {
|
||||
const int listed = g.squad_slots.at(0xb70 + entry) & 0xfff;
|
||||
if (listed == player) { out.status = TransferActionStatus::pending; out.player = player; out.list_entry = int(entry); return out; }
|
||||
free_entry = free_entry || listed == 0xfff;
|
||||
}
|
||||
if (!free_entry) { out.status = TransferActionStatus::blocked_by_board; return out; }
|
||||
if (!list_transfer_player(g, slot, rand, report)) {
|
||||
out.status = report.unsupported ? TransferActionStatus::invalid_request : TransferActionStatus::blocked_by_board;
|
||||
return out;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "game/transfer_allocator.hpp"
|
||||
// OpenBMH deviates from the original: supports designated set-piece records and the supported transfer-editor rules.
|
||||
// Actions a human manager can take at his desk that change the game state and draw random
|
||||
// numbers (BMH.exe V2.24 + supported rule profile patch). The screens themselves belong to the UI; these
|
||||
@@ -272,6 +273,12 @@ struct TransferOfferEditorSubmitResult {
|
||||
TransferOfferEditorSubmitResult submit_transfer_offer_editor_source(GameState&,
|
||||
const TransferOfferEditorState&,WatcomRandom&,const HumanBuyerSaleHooks&,MinuteReport&);
|
||||
|
||||
// OpenBMH deviates from the original: a seller may accept an existing bid before expiry.
|
||||
// The caller stages state/RNG; cancellation is handled before invoking this action.
|
||||
TransferActionResult accept_manager_transfer_offer(GameState&, int manager, int list_entry,
|
||||
int expected_player, int bid_index, WatcomRandom&, MinuteReport&,
|
||||
TransferAllocatorContext = TransferAllocatorContext::unsupported);
|
||||
|
||||
// Submit a manager bid on an existing list entry. A full-value fee and salary meeting
|
||||
// the demand complete an immediate agreement; lower viable offers persist for weekly review.
|
||||
TransferActionResult submit_transfer_bid(GameState& g, const TransferBidRequest& request, WatcomRandom& rand);
|
||||
|
||||
+10
-12
@@ -33,18 +33,16 @@ uint32_t academy_paid(const GameState& g, int manager) {
|
||||
}
|
||||
}
|
||||
void install_environment_rules(const LeImage& exe) {
|
||||
for (size_t i=0;i<kEnvironmentStep.size();++i) {
|
||||
const uint32_t at=layout::EnvironmentBudgetSteps+uint32_t(i);
|
||||
if (!exe.contains(at) || exe.u8(at)==0) { supported_environment=false; return; }
|
||||
kEnvironmentStep[i]=int32_t(exe.u8(at))*1000;
|
||||
// OpenBMH deviates from the original: the common Diamond 3.7 monthly
|
||||
// environment model applies to every supported source-data edition.
|
||||
// Numeric steps are data; an edition's original instructions are not run.
|
||||
auto steps=kEnvironmentStep;
|
||||
for(size_t i=0;i<steps.size();++i) {
|
||||
const auto at=layout::EnvironmentBudgetSteps+uint32_t(i);
|
||||
if(!exe.contains(at)||exe.u8(at)==0){supported_environment=false;return;}
|
||||
steps[i]=int32_t(exe.u8(at))*1000;
|
||||
}
|
||||
uint64_t fingerprint = 14695981039346656037ull;
|
||||
for (const auto [first,last] : {std::pair{layout::EnvironmentVerifiedCodeBegin,layout::EnvironmentVerifiedCodeEnd},std::pair{layout::EnvironmentVerifiedHookBegin,layout::EnvironmentVerifiedHookEnd}}) {
|
||||
if (!exe.contains(first) || !exe.contains(last-1)) { supported_environment=false; return; }
|
||||
for (uint32_t at=first;at<last;++at) fingerprint=(fingerprint ^ exe.u8(at))*1099511628211ull;
|
||||
}
|
||||
// Fingerprints identify verified behaviour, not filenames, dates or artwork.
|
||||
supported_environment = fingerprint==0xc2488a656f340e99ull || fingerprint==0x19adba7ef3eda507ull;
|
||||
kEnvironmentStep=steps;supported_environment=true;
|
||||
}
|
||||
bool environment_rules_supported() { return supported_environment; }
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
|
||||
@@ -57,7 +55,7 @@ bool environment_academy_active(const GameState& g, int manager) {
|
||||
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
|
||||
}
|
||||
EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
if (!supported_environment) throw FormatError("environment: this original program variant is not verified");
|
||||
if (!supported_environment) throw FormatError("environment: monthly budget steps are missing or invalid");
|
||||
validate_manager(g, manager);
|
||||
EnvironmentState result;
|
||||
for (int i = 0; i < kEnvironmentItems; ++i) {
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
#include "game/state.hpp"
|
||||
|
||||
namespace bmh {
|
||||
// Verified original-program capability; unknown environment variants are not guessed.
|
||||
// Install validated numeric steps for the common Diamond 3.7 monthly model.
|
||||
void install_environment_rules(const LeImage&);
|
||||
bool environment_rules_supported();
|
||||
constexpr int kEnvironmentItems = 6;
|
||||
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
|
||||
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
|
||||
// Monthly environment model verified in the supported CD and Diamond 3.6/3.7 programs.
|
||||
// Canonical monthly environment model; source editions supply compatible data.
|
||||
inline std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
struct EnvironmentState {
|
||||
std::array<int32_t, kEnvironmentItems> monthly{};
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/long_career.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace bmh {
|
||||
namespace {
|
||||
uint32_t key(int team, int player) {
|
||||
if (team < 0 || team > 0xfff || player < 0 || player >= 0xfff)
|
||||
throw FormatError("long career: invalid player/club identity");
|
||||
return uint32_t(team) << 12 | uint32_t(player);
|
||||
}
|
||||
int manager_team(const GameState& g, int manager) {
|
||||
if (manager >= 0 && size_t(manager) < g.manager_teams.size()) return g.manager_teams[size_t(manager)];
|
||||
const size_t at = size_t(manager) * 0xb0c + 0x290;
|
||||
if (manager < 0 || manager > 4 || at + 1 >= g.manager_records.size())
|
||||
throw FormatError("long career: invalid manager");
|
||||
return int(g.manager_records[at] | uint16_t(g.manager_records[at + 1]) << 8);
|
||||
}
|
||||
PlayerClubStatistics legacy(const std::array<uint8_t, 0x58>& b) {
|
||||
auto word = [&](size_t at) { return uint64_t(b[at] | uint16_t(b[at + 1]) << 8); };
|
||||
return {{b[7], b[8], b[9]}, word(0x48), word(0x4a), word(0x4c)};
|
||||
}
|
||||
void increment(uint64_t& n) {
|
||||
if (n == std::numeric_limits<uint64_t>::max()) throw FormatError("long career: statistics counter exhausted");
|
||||
++n;
|
||||
}
|
||||
void put(Bytes& b, uint64_t n, int width) { for (int i = 0; i < width; ++i) b.push_back(uint8_t(n >> (i * 8))); }
|
||||
struct Reader {
|
||||
const Bytes& bytes; size_t pos = 0;
|
||||
uint64_t get(int width) {
|
||||
if (size_t(width) > bytes.size() - pos) throw FormatError("long career: truncated extension");
|
||||
uint64_t n = 0; for (int i = 0; i < width; ++i) n |= uint64_t(bytes[pos++]) << (i * 8); return n;
|
||||
}
|
||||
std::string string() {
|
||||
const size_t size = size_t(get(2));
|
||||
if (size > bytes.size() - pos) throw FormatError("long career: truncated title name");
|
||||
std::string s(bytes.begin() + pos, bytes.begin() + pos + size); pos += size; return s;
|
||||
}
|
||||
};
|
||||
}
|
||||
PlayerClubStatistics player_club_statistics(const GameState& g, int team, int player,
|
||||
const std::array<uint8_t, 0x58>& board) {
|
||||
const auto found = g.player_statistics.find(key(team, player));
|
||||
return found == g.player_statistics.end() ? legacy(board) : found->second;
|
||||
}
|
||||
void record_player_statistics(GameState& g, int manager, int row, int player, int cls, int kind) {
|
||||
const size_t at = size_t(manager) * 0x840 + size_t(row) * 0x58;
|
||||
if (manager < 0 || row < 0 || row >= 24 || at + 0x58 > g.tactics.size() || cls < 0 || cls > 3 || kind < 0 || kind > 2)
|
||||
throw FormatError("long career: invalid statistics row/event");
|
||||
std::array<uint8_t, 0x58> board; std::copy_n(g.tactics.begin() + at, board.size(), board.begin());
|
||||
const auto identity = key(manager_team(g, manager), player);
|
||||
auto [found, inserted] = g.player_statistics.try_emplace(identity, legacy(board));
|
||||
auto next = found->second;
|
||||
if (kind == 0) { if (cls < 3) increment(next.appearances[size_t(cls)]); increment(next.total); }
|
||||
else if (kind == 1) increment(next.goals);
|
||||
else increment(next.assists);
|
||||
found->second = next;
|
||||
}
|
||||
void reset_player_statistics(GameState& g, int manager, int player) {
|
||||
g.player_statistics.erase(key(manager_team(g, manager), player));
|
||||
}
|
||||
void swap_statistics_clubs(GameState& g, int first, int second) {
|
||||
PlayerStatisticsArchive next;
|
||||
for (const auto& [identity, value] : g.player_statistics) {
|
||||
const int club = int(identity >> 12), player = int(identity & 0xfff);
|
||||
next.emplace(key(club == first ? second : club == second ? first : club, player), value);
|
||||
}
|
||||
g.player_statistics = std::move(next);
|
||||
}
|
||||
TitleHistoryArchive title_history_rows(const GameState& g) {
|
||||
if (g.season < 0) throw FormatError("long career: negative season index");
|
||||
auto rows = g.title_history;
|
||||
if (!g.memory.has(layout::Titles + 899)) return rows;
|
||||
const int first = std::max(0, g.season - 49);
|
||||
for (int slot = 0; slot < 50 && first + slot <= g.season; ++slot) {
|
||||
const auto season = uint32_t(first + slot);
|
||||
if (rows.contains(season)) continue;
|
||||
std::array<std::string, 9> winners;
|
||||
for (size_t category = 0; category < 9; ++category) {
|
||||
const auto team = g.memory.u16(layout::Titles + uint32_t(category) * 100 + uint32_t(slot) * 2);
|
||||
if (team != 0xffff) winners[category] = g.club_name(team);
|
||||
}
|
||||
rows.emplace(season, std::move(winners));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
void capture_title_history(GameState& g) { g.title_history = title_history_rows(g); }
|
||||
void record_title_holder(GameState& g, int category, uint16_t winner) {
|
||||
if (category < 0 || category >= 9 || g.season < 0 || winner >= g.club_ids.size())
|
||||
throw FormatError("long career: invalid title award");
|
||||
capture_title_history(g);
|
||||
const auto name = g.club_name(winner);
|
||||
g.memory.set16(layout::Titles + uint32_t(category) * 100 + uint32_t(std::min(g.season, 49)) * 2, winner);
|
||||
g.title_history[uint32_t(g.season)][size_t(category)] = name;
|
||||
}
|
||||
void shift_legacy_title_history(GameState& g) {
|
||||
if (g.season <= 49) return;
|
||||
for (uint32_t category = 0; category < 9; ++category) {
|
||||
for (uint32_t i = 0; i < 98; ++i)
|
||||
g.memory.set8(layout::Titles + category * 100 + i,
|
||||
g.memory.u8(layout::Season_SeasonEndSteps_RuntimeField + category * 100 + i));
|
||||
g.memory.set16(layout::Season_SeasonEndSteps_RuntimeField2 + category * 100, 0xffff);
|
||||
}
|
||||
}
|
||||
Bytes encode_long_career(const GameState& g) {
|
||||
if (g.player_statistics.empty() && g.title_history.empty()) return {};
|
||||
Bytes b; put(b, 1, 4); put(b, g.player_statistics.size(), 4); put(b, g.title_history.size(), 4);
|
||||
for (const auto& [identity, s] : g.player_statistics) {
|
||||
put(b, identity, 4); for (const auto n : s.appearances) put(b, n, 8);
|
||||
for (const auto n : {s.total, s.goals, s.assists}) put(b, n, 8);
|
||||
}
|
||||
for (const auto& [season, names] : g.title_history) {
|
||||
if (season > 32767) throw FormatError("long career: archived season exceeds native calendar range");
|
||||
put(b, season, 4);
|
||||
for (const auto& name : names) {
|
||||
if (name.size() > UINT16_MAX) throw FormatError("long career: title name too long");
|
||||
put(b, name.size(), 2); b.insert(b.end(), name.begin(), name.end());
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
void decode_long_career(GameState& g, const Bytes& bytes) {
|
||||
Reader r{bytes};
|
||||
if (r.get(4) != 1) throw FormatError("long career: unsupported extension version");
|
||||
const auto players = r.get(4), seasons = r.get(4);
|
||||
if (players > (bytes.size() - r.pos) / 52 || seasons > 32768)
|
||||
throw FormatError("long career: invalid extension counts");
|
||||
PlayerStatisticsArchive stats; TitleHistoryArchive history;
|
||||
for (uint64_t i = 0; i < players; ++i) {
|
||||
const auto identity = uint32_t(r.get(4));
|
||||
if (identity > 0xffffff || (identity & 0xfff) == 0xfff) throw FormatError("long career: invalid archived identity");
|
||||
PlayerClubStatistics s; for (auto& n : s.appearances) n = r.get(8);
|
||||
s.total = r.get(8); s.goals = r.get(8); s.assists = r.get(8);
|
||||
if (!stats.emplace(identity, s).second) throw FormatError("long career: duplicate archived identity");
|
||||
}
|
||||
for (uint64_t i = 0; i < seasons; ++i) {
|
||||
const auto season = uint32_t(r.get(4));
|
||||
if (season > 32767) throw FormatError("long career: invalid archived season");
|
||||
std::array<std::string, 9> names; for (auto& name : names) name = r.string();
|
||||
if (!history.emplace(season, std::move(names)).second) throw FormatError("long career: duplicate archived season");
|
||||
}
|
||||
if (r.pos != bytes.size()) throw FormatError("long career: trailing extension bytes");
|
||||
g.player_statistics = std::move(stats); g.title_history = std::move(history);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "formats/binary.hpp"
|
||||
|
||||
namespace bmh {
|
||||
struct GameState;
|
||||
struct PlayerClubStatistics {
|
||||
std::array<uint64_t, 3> appearances{};
|
||||
uint64_t total = 0, goals = 0, assists = 0;
|
||||
bool operator==(const PlayerClubStatistics&) const = default;
|
||||
};
|
||||
// Optional OBMHEXT1 block, outside the Original guest address space. Payload v1.
|
||||
inline constexpr uint32_t kLongCareerExtension = 0x4f424c43;
|
||||
using PlayerStatisticsArchive = std::map<uint32_t, PlayerClubStatistics>;
|
||||
using TitleHistoryArchive = std::map<uint32_t, std::array<std::string, 9>>;
|
||||
PlayerClubStatistics player_club_statistics(const GameState&, int team, int player,
|
||||
const std::array<uint8_t, 0x58>& board);
|
||||
void record_player_statistics(GameState&, int manager, int row, int player, int competition_class, int kind);
|
||||
void reset_player_statistics(GameState&, int manager, int player);
|
||||
void swap_statistics_clubs(GameState&, int first, int second);
|
||||
TitleHistoryArchive title_history_rows(const GameState&);
|
||||
void capture_title_history(GameState&);
|
||||
void record_title_holder(GameState&, int category, uint16_t winner);
|
||||
void shift_legacy_title_history(GameState&);
|
||||
Bytes encode_long_career(const GameState&);
|
||||
void decode_long_career(GameState&, const Bytes&);
|
||||
}
|
||||
@@ -242,6 +242,7 @@ void player_statistic(GameState& g, int type, int player, int manager, int slot,
|
||||
if (cls == 3 && (g.player_bonus.at(player) & 0x7F) < 0x7F) g.player_bonus.at(player)++;
|
||||
if (manager >= 0) {
|
||||
pay_bonus(g, manager, slot, 2, true);
|
||||
record_player_statistics(g, manager, slot, player, cls, kind);
|
||||
if (cls < 3) g.tactics.at(board + 7 + cls)++;
|
||||
wr16(g.tactics, board + 0x48, uint16_t(rd16(g.tactics, board + 0x48) + 1));
|
||||
}
|
||||
@@ -249,13 +250,17 @@ void player_statistic(GameState& g, int type, int player, int manager, int slot,
|
||||
} else if (kind == 1) { // goal
|
||||
if (manager >= 0) {
|
||||
pay_bonus(g, manager, slot, 0, true);
|
||||
record_player_statistics(g, manager, slot, player, cls, kind);
|
||||
wr16(g.tactics, board + 0x4a, uint16_t(rd16(g.tactics, board + 0x4a) + 1));
|
||||
if (cls == 0) g.manager_records.at(size_t(manager) * kManagerRecord + 0x1ae + std::min(minute, 89) / 5)++;
|
||||
}
|
||||
// league goals in bits 2-7 (a 64th goal carries into bit 8, as in the original)
|
||||
if (cls == 0) p.w364 = (w364 & 0xFFFFFF03u) | ((((w364 >> 2) & 0x3F) << 2) + 4);
|
||||
} else if (kind == 2) { // assist
|
||||
if (manager >= 0) wr16(g.tactics, board + 0x4c, uint16_t(rd16(g.tactics, board + 0x4c) + 1));
|
||||
if (manager >= 0) {
|
||||
record_player_statistics(g, manager, slot, player, cls, kind);
|
||||
wr16(g.tactics, board + 0x4c, uint16_t(rd16(g.tactics, board + 0x4c) + 1));
|
||||
}
|
||||
if (cls == 0) p.w368 = (p.w368 & 0xFF03FFFFu) | ((((p.w368 >> 18) & 0x3F) + 1) << 18);
|
||||
}
|
||||
}
|
||||
@@ -776,7 +781,7 @@ void advance_league_rounds(GameState& g, uint32_t competitions, WatcomRandom& ra
|
||||
if (g.memory.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && winner)
|
||||
winner(g, {0, uint16_t(champion)});
|
||||
if (g.memory.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && g.memory.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2)) g.memory.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2, 0);
|
||||
g.memory.set16(::bmh::layout::Titles + uint32_t(std::min<int>(g.season, 0x31)) * 2, uint16_t(champion));
|
||||
record_title_holder(g, 0, uint16_t(champion));
|
||||
const int manager = g.manager_of(champion);
|
||||
if (manager >= 0) {
|
||||
const size_t at = size_t(manager) * kManagerRecord + 0x8a4;
|
||||
|
||||
+44
-9
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -113,13 +114,8 @@ std::string message_text_following(const GameState& g, uint32_t pointer_variable
|
||||
return text;
|
||||
}
|
||||
|
||||
std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
if (flags & 0x100) {
|
||||
// ConvertCurrency: currency conversion (1/1 unless the savegame says otherwise)
|
||||
const int32_t mul = g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1;
|
||||
const int32_t div = g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1;
|
||||
if (div != 0) value = value * mul / div;
|
||||
}
|
||||
namespace {
|
||||
std::string format_number_digits(const GameState& g, int64_t value, int flags) {
|
||||
// FormatGroupedDigits: digits from the right; with grouping (bit 0x40 clear) a dot before the
|
||||
// 4th, 8th and 12th character; padded to the width (bits 0-5), leading blanks for the
|
||||
// dots a wide field reserves
|
||||
@@ -127,12 +123,12 @@ std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
const int width = flags & 0x3F;
|
||||
int blanks = group && width > 3 ? (width - 4) / 3 + 1 : 0;
|
||||
const bool negative = value < 0;
|
||||
uint32_t v = negative ? uint32_t(-int64_t(value)) : uint32_t(value);
|
||||
uint64_t v = negative ? uint64_t(-(value + 1)) + 1 : uint64_t(value);
|
||||
std::string reversed;
|
||||
int dots = 0;
|
||||
while (v != 0) {
|
||||
const size_t n = reversed.size();
|
||||
if (group && (n == 3 || n == 7 || n == 11)) reversed.push_back('.'), blanks--, dots++;
|
||||
if (group && n % 4 == 3) reversed.push_back('.'), blanks--, dots++;
|
||||
reversed.push_back(char('0' + v % 10));
|
||||
v /= 10;
|
||||
}
|
||||
@@ -149,6 +145,45 @@ std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
if (flags & 0x100) {
|
||||
// ConvertCurrency: currency conversion (1/1 unless the savegame says otherwise)
|
||||
const int32_t mul = g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1;
|
||||
const int32_t div = g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1;
|
||||
if (div != 0) value = value * mul / div;
|
||||
}
|
||||
return format_number_digits(g, value, flags);
|
||||
}
|
||||
|
||||
std::string format_number_wide(const GameState& g, int64_t value, int flags) {
|
||||
if (flags & 0x100) {
|
||||
const int32_t mul = g.memory.has(layout::CurrencyMultiplier) ? int32_t(g.memory.u32(layout::CurrencyMultiplier)) : 1;
|
||||
const int32_t div = g.memory.has(layout::CurrencyDivisor) ? int32_t(g.memory.u32(layout::CurrencyDivisor)) : 1;
|
||||
if (div != 0) {
|
||||
const bool negative = (value < 0) != ((mul < 0) != (div < 0));
|
||||
const uint64_t magnitude = value < 0 ? uint64_t(-(value + 1)) + 1 : uint64_t(value);
|
||||
const uint64_t multiplier = mul < 0 ? uint64_t(-int64_t(mul)) : uint64_t(mul);
|
||||
const uint64_t divisor = div < 0 ? uint64_t(-int64_t(div)) : uint64_t(div);
|
||||
const uint64_t limit = uint64_t(std::numeric_limits<int64_t>::max()) + uint64_t(negative);
|
||||
// Split before multiplication, keeping exact truncation without
|
||||
// requiring nonportable 128-bit integers for currency conversion.
|
||||
const uint64_t whole = magnitude / divisor;
|
||||
if (multiplier && whole > limit / multiplier)
|
||||
throw FormatError("wide currency amount exceeds display range");
|
||||
const uint64_t base = whole * multiplier;
|
||||
const uint64_t fraction = (magnitude % divisor) * multiplier / divisor;
|
||||
if (fraction > limit - base)
|
||||
throw FormatError("wide currency amount exceeds display range");
|
||||
const uint64_t converted = base + fraction;
|
||||
value = negative ? (converted == uint64_t(std::numeric_limits<int64_t>::max()) + 1
|
||||
? std::numeric_limits<int64_t>::min() : -int64_t(converted)) : int64_t(converted);
|
||||
}
|
||||
}
|
||||
return format_number_digits(g, value, flags);
|
||||
}
|
||||
|
||||
std::string format_amount(const GameState& g, int32_t value) { return format_number(g, value, 0x101); }
|
||||
|
||||
void install_message_texts(const LeImage& exe) {
|
||||
|
||||
@@ -72,5 +72,7 @@ std::string format_amount(const GameState& g, int32_t value);
|
||||
// FormatNumber(buf, value, flags, ""): bits 0-5 the field width, bit 0x40 no dot grouping,
|
||||
// bit 0x100 an amount of money (converted, " EU" appended).
|
||||
std::string format_number(const GameState& g, int32_t value, int flags);
|
||||
// Read-only aggregates can exceed a native save word; preserve currency and padding.
|
||||
std::string format_number_wide(const GameState& g, int64_t value, int flags);
|
||||
|
||||
} // namespace bmh
|
||||
+11
-4
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <optional>
|
||||
@@ -654,7 +655,7 @@ void board_month(GameState& g, int m, WatcomRandom& rand, MinuteReport& report,
|
||||
for (int s = 0; s < 24; s++) g.tactics.at(board(s) + 0xb) &= 0x7F;
|
||||
}
|
||||
|
||||
// MonthChange2: share prices grow by 2.5 %, dividends, loans between the managers.
|
||||
// MonthChange2: share prices grow by 0.25 %, dividends, loans between the managers.
|
||||
void shares_and_loans(GameState& g) {
|
||||
StaticMemory& mem = g.memory;
|
||||
std::vector<uint8_t>& r = g.manager_records;
|
||||
@@ -665,12 +666,16 @@ void shares_and_loans(GameState& g) {
|
||||
uint32_t price = mem.u32(at);
|
||||
price += ((price / 10000) * 0x19 / 10) * 10;
|
||||
mem.set32(at, price);
|
||||
// OpenBMH deviates from the original: keep the price product in 64 bits
|
||||
// until division, retaining per-unit truncation and recipient policy.
|
||||
const uint64_t unit_dividend = (uint64_t(price) * uint32_t(kShareFactor[k])) / 10000;
|
||||
// (a bug of the original: only the last manager's dividend is kept and it is booked
|
||||
// for the manager after the last one)
|
||||
int32_t dividend = 0;
|
||||
for (int m = 0; m < managers; m++)
|
||||
dividend = int32_t(mem.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c) *
|
||||
((price * uint32_t(kShareFactor[k])) / 10000));
|
||||
dividend = std::bit_cast<int32_t>(uint32_t(
|
||||
mem.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c) *
|
||||
unit_dividend));
|
||||
book_money(g, managers, -dividend, true);
|
||||
add32(r, size_t(managers) * kRecord + 0x870, dividend);
|
||||
}
|
||||
@@ -694,6 +699,8 @@ void shares_and_loans(GameState& g) {
|
||||
|
||||
} // namespace
|
||||
|
||||
void monthly_shares_and_loans(GameState& g) { shares_and_loans(g); }
|
||||
|
||||
bool list_transfer_player(GameState& g, int slot, WatcomRandom& rand, MinuteReport& report) {
|
||||
return list_player(g, slot, rand, report);
|
||||
}
|
||||
@@ -989,7 +996,7 @@ void month_change(GameState& g, WatcomRandom& rand, MinuteReport& report, GameRa
|
||||
if (report.unsupported) return;
|
||||
// 5. shares and loans
|
||||
turn_step = "month_change: shares";
|
||||
shares_and_loans(g);
|
||||
monthly_shares_and_loans(g);
|
||||
}
|
||||
|
||||
} // namespace bmh
|
||||
@@ -28,6 +28,9 @@ namespace bmh {
|
||||
// `game` is needed when a player leaves at the end of his contract (MonthChange).
|
||||
void month_change(GameState& g, WatcomRandom& rand, MinuteReport& report, GameRandom* game = nullptr);
|
||||
|
||||
// The investment/loan phase, retaining the original dividend recipient policy.
|
||||
void monthly_shares_and_loans(GameState& g);
|
||||
|
||||
// CareerFirstSteps: new players on the transfer list (part of the month change; also at the
|
||||
// start of a season).
|
||||
void new_transfer_list_entries(GameState& g, WatcomRandom& rand, MinuteReport& report);
|
||||
|
||||
@@ -74,6 +74,11 @@ void new_board_entry(GameState& g, int manager, int index, int slot, WatcomRando
|
||||
uint8_t* e = &g.tactics.at(size_t(manager) * kBoard + size_t(index) * kBoardSlot);
|
||||
std::memset(e + 7, 0, 3);
|
||||
std::memset(e + 0x19, 0, 0x24);
|
||||
// OpenBMH deviates from the original: a new arrival must not inherit the
|
||||
// previous occupant's retirement/refusal/month-processing flags.
|
||||
e[0xb] = 0;
|
||||
std::memset(e + 0x48, 0, 6); // Fresh arrivals do not inherit the previous player's totals.
|
||||
reset_player_statistics(g, manager, g.squad_slots.at(size_t(slot)) & 0xfff);
|
||||
e[10] = 2;
|
||||
for (int k = 0; k < 4; k++) e[2 + k] = index < 2 ? 1 : uint8_t(rand.range(2, 0x27));
|
||||
e[0x3f] = 0xff;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/bank_robbery.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
@@ -126,6 +127,16 @@ Bytes save_stream(const GameState& live) {
|
||||
for (uint32_t i = 0; i < size; ++i) bytes[i] = g.memory.u8(at + i);
|
||||
extension.push_back({at, std::move(bytes)});
|
||||
}
|
||||
auto history = encode_long_career(g);
|
||||
if (!history.empty()) extension.push_back({kLongCareerExtension, std::move(history)});
|
||||
if (g.memory.has(kBankRobberyMonthExtension)) {
|
||||
if (!g.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
|
||||
throw FormatError("savegame: truncated bank robbery monthly guard");
|
||||
Bytes months(kBankRobberyMonthBytes);
|
||||
for (uint32_t i = 0; i < months.size(); ++i)
|
||||
months[i] = g.memory.u8(kBankRobberyMonthExtension + i);
|
||||
extension.push_back({kBankRobberyMonthExtension, std::move(months)});
|
||||
}
|
||||
append_save_extension(stream, extension);
|
||||
return stream;
|
||||
}
|
||||
|
||||
+3
-4
@@ -787,6 +787,7 @@ void change_places(GameState& g, int a, int b) {
|
||||
mem.set32(::bmh::layout::Career_RemoveJoinLoans_RuntimeField + k * 4, (e & 0xfff) | uint32_t(seller) << 12 | uint32_t(buyer) << 22);
|
||||
}
|
||||
if (!g.club_table.empty() && a < 0xa8 && b < 0xa8) swap_bytes(g.club_table, size_t(a) * 0x4a, size_t(b) * 0x4a, 0x4a);
|
||||
swap_statistics_clubs(g, a, b);
|
||||
std::swap(g.club_ids.at(size_t(a)), g.club_ids.at(size_t(b)));
|
||||
swap_bytes(g.club_heap_bc, size_t(a) * 2, size_t(b) * 2, 2);
|
||||
std::swap(g.team_morale.at(size_t(a)), g.team_morale.at(size_t(b)));
|
||||
@@ -1284,10 +1285,7 @@ SeasonTransitionOutcome season_end_steps(GameState& g, GameRandom& game, WatcomR
|
||||
TransferAllocatorContext allocator) {
|
||||
StaticMemory& mem = g.memory;
|
||||
if (g.season > 0x31) { // SeasonEndSteps
|
||||
for (uint32_t k = 0; k < 9; k++) {
|
||||
for (uint32_t i = 0; i < 0x62; i++) mem.set8(::bmh::layout::Titles + k * 100 + i, mem.u8(::bmh::layout::Season_SeasonEndSteps_RuntimeField + k * 100 + i));
|
||||
mem.set16(::bmh::layout::Season_SeasonEndSteps_RuntimeField2 + k * 100, 0xffff);
|
||||
}
|
||||
shift_legacy_title_history(g);
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++) {
|
||||
for (size_t i = 0; i < 0x93; i++) rec8(g, int(m), 0xda + i) = rec8(g, int(m), 0xdd + i);
|
||||
const size_t at = m * 0xB0C + 0x2aa;
|
||||
@@ -1610,6 +1608,7 @@ SeasonTransitionOutcome season_transition(GameState& g, GameRandom& game, Watcom
|
||||
}
|
||||
g.memory.set8(::bmh::layout::CareerSession_RuntimeError_RuntimeField4, 0);
|
||||
if (g.memory.has(::bmh::layout::Season_SeasonTransition_RuntimeField)) g.memory.set8(::bmh::layout::Season_SeasonTransition_RuntimeField, 0);
|
||||
capture_title_history(g); // Preserve the current window before it advances/shifts.
|
||||
g.season = int16_t(g.season + 1); // SeasonIndex
|
||||
reset_club_moods(g, game, rand);
|
||||
european_setup(g, game, rand, cup_draw);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "game/stadium_blocks.hpp"
|
||||
|
||||
#include "game/matchday.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
@@ -63,6 +64,32 @@ bool valid_resolved_offer(const StandBlockOffer& offer, const StadiumBlockExpans
|
||||
}
|
||||
} // namespace
|
||||
|
||||
StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage& image) {
|
||||
// OpenBMH deviates from the original: allow 144,000 standard places and
|
||||
// size-aware construction times while retaining edition-owned unit prices.
|
||||
static constexpr std::array<uint32_t, 8> minima{
|
||||
14000, 24000, 14000, 20000, 14000, 24000, 14000, 20000};
|
||||
StadiumBlockExpansionConstants out;
|
||||
uint32_t total = 0;
|
||||
for (size_t i = 0; i < minima.size(); ++i) {
|
||||
out.price_per_1000[i] = image.u32(
|
||||
layout::CareerSession_DispatchStadium_RuntimeField + uint32_t((i + 8) * 4));
|
||||
const auto original = uint32_t(image.u8(
|
||||
layout::CareerSession_Invalid_RuntimeField + uint32_t(i))) * 1000;
|
||||
out.max_places[i] = std::max(original, minima[i]);
|
||||
total += out.max_places[i];
|
||||
const auto source_weeks = image.u8(
|
||||
layout::CareerSession_DispatchStadium_RuntimeField2 + uint32_t((i + 22) * 5));
|
||||
const auto weeks = std::max<uint32_t>(source_weeks, 2 * (out.max_places[i] / 1000));
|
||||
if (weeks > 255)
|
||||
throw FormatError("stadium: expanded construction period exceeds saved byte");
|
||||
out.weeks[i] = uint8_t(weeks);
|
||||
}
|
||||
if (total > 255000)
|
||||
throw FormatError("stadium: combined stand limits exceed saved capacity byte");
|
||||
return out;
|
||||
}
|
||||
|
||||
std::optional<StadiumBlockExpansionQuote> quote_stadium_block_expansion(
|
||||
const GameState& g, int manager, StadiumBlockSlot slot, uint32_t total_target_places,
|
||||
uint8_t desired_features, int company_price_percent,
|
||||
|
||||
@@ -20,6 +20,10 @@ struct StadiumBlockExpansionConstants {
|
||||
std::array<uint32_t, 8> max_places{};
|
||||
};
|
||||
|
||||
// OpenBMH1.0.3 expands standard A-H limits to at least144k total. Prices
|
||||
// still come from the edition; larger blocks have at least2weeks per1000places.
|
||||
StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage&);
|
||||
|
||||
// An immutable quote binds the Source owner and every record/table value that
|
||||
// affects the quote. Commit recomputes this value before it touches money.
|
||||
struct StadiumBlockExpansionQuote {
|
||||
|
||||
+13
-1
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "game/bank_robbery.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -99,7 +100,16 @@ GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
|
||||
g.foreign_strength = bytes(::bmh::layout::ForeignClubStrength);
|
||||
g.memory = StaticMemory(save);
|
||||
// memory OpenBMH saves behind the trailer (the English cup blocks, career.hpp)
|
||||
for (const auto& b : save.extension()) {
|
||||
bool long_career_seen=false,robbery_months_seen=false;
|
||||
for(const auto& b:save.extension()){
|
||||
if(b.address==kLongCareerExtension){
|
||||
if(long_career_seen)throw FormatError("long career: duplicate extension block");
|
||||
decode_long_career(g,b.bytes);long_career_seen=true;continue;
|
||||
}
|
||||
if(b.address==kBankRobberyMonthExtension){
|
||||
if(robbery_months_seen||b.bytes.size()!=kBankRobberyMonthBytes)throw FormatError("savegame: invalid or duplicate bank robbery monthly guard");
|
||||
robbery_months_seen=true;
|
||||
}
|
||||
if (!g.memory.has(b.address)) g.memory.add_block(b.address, uint32_t(b.bytes.size()));
|
||||
for (size_t i = 0; i < b.bytes.size(); ++i) g.memory.set8(b.address + uint32_t(i), b.bytes[i]);
|
||||
}
|
||||
@@ -110,6 +120,8 @@ GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
|
||||
g.stadium_names = save.pool(3);
|
||||
g.player_name_offsets = words16(::bmh::layout::PlayerNameOffsets);
|
||||
g.season = int16_t(save.data(::bmh::layout::SeasonIndex)[0] | save.data(::bmh::layout::SeasonIndex)[1] << 8);
|
||||
if (!g.title_history.empty() && (g.season < 0 || g.title_history.rbegin()->first > uint32_t(g.season)))
|
||||
throw FormatError("long career: archived season is beyond the saved calendar");
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "formats/textd.hpp"
|
||||
#include "game/memory.hpp"
|
||||
#include "game/random.hpp"
|
||||
#include "game/long_career.hpp"
|
||||
#include "game/reality_motion.hpp"
|
||||
|
||||
namespace bmh {
|
||||
@@ -36,6 +37,8 @@ constexpr uint16_t kEmptySlot = 0x0FFF;
|
||||
constexpr uint16_t kSlotInLineup = 0x8000;
|
||||
|
||||
struct GameState {
|
||||
PlayerStatisticsArchive player_statistics;
|
||||
TitleHistoryArchive title_history;
|
||||
std::vector<uint16_t> squad_slots; // *SquadSlots, all squads back to back (see squad_range)
|
||||
std::vector<Player> players; // *PlayerConditionTechniqueForm / *PlayerSkillWords / *PlayerIdentityWords, names not filled
|
||||
std::vector<uint8_t> team_morale; // *TeamMorale, per team: bits 0-5 morale / 2, bits 6-7 flags
|
||||
|
||||
+46
-17
@@ -2,12 +2,14 @@
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/week.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
#include "game/bank_robbery.hpp"
|
||||
|
||||
#include "game/matchday.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -24,6 +26,23 @@ void wr32(std::vector<uint8_t>& v, size_t o, int32_t x) {
|
||||
|
||||
} // namespace
|
||||
|
||||
DailyInterestAmounts daily_interest_amounts(int32_t cash, int32_t deposit, int32_t credit) {
|
||||
// OpenBMH deviates from the original: widen products before annual-rate
|
||||
// division so valid native account amounts do not overflow intermediate sums.
|
||||
// Preserve truncation at each original division, including deposit / 10000.
|
||||
DailyInterestAmounts result;
|
||||
if (cash < 0) {
|
||||
const int64_t with_credit = int64_t(cash) + credit;
|
||||
int64_t borrowing = with_credit < 0 ? with_credit * 18 / -36500 : 0;
|
||||
borrowing += std::max(int64_t(cash), -int64_t(credit)) * 12 / -36500;
|
||||
result.borrowing = int32_t(borrowing);
|
||||
} else {
|
||||
result.cash_and_deposit = cash / -36500;
|
||||
}
|
||||
result.cash_and_deposit += int32_t(int64_t(deposit / 10000) * 20000 / -36500);
|
||||
return result;
|
||||
}
|
||||
|
||||
void daily_interest(GameState& g, WatcomRandom& rand) {
|
||||
// (DailyInterest before the day step: the training camp visits of today are over)
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++) g.manager_records.at(m * kManagerRecord + 0x21f) &= 0x7f;
|
||||
@@ -32,25 +51,29 @@ void daily_interest(GameState& g, WatcomRandom& rand) {
|
||||
const int32_t balance = rd32(g.manager_records, rec + 0x314);
|
||||
const int32_t deposit = rd32(g.manager_records, rec + 0x318);
|
||||
const int32_t credit = rd32(g.manager_records, rec + 0x31c);
|
||||
int32_t amount = 0; // positive = cost
|
||||
const auto interest = daily_interest_amounts(balance, deposit, credit);
|
||||
if (balance < 0) {
|
||||
if (balance + credit < 0) amount = ((balance + credit) * 18) / -36500;
|
||||
int32_t used = -credit < balance ? balance : -credit;
|
||||
amount += (used * 12) / -36500;
|
||||
wr32(g.manager_records, rec + 0x89c, rd32(g.manager_records, rec + 0x89c) + amount);
|
||||
book_money(g, k, amount, true);
|
||||
amount = 0;
|
||||
} else {
|
||||
amount = balance / -36500;
|
||||
const auto statistic = uint32_t(rd32(g.manager_records, rec + 0x89c)) + uint32_t(interest.borrowing);
|
||||
wr32(g.manager_records, rec + 0x89c, std::bit_cast<int32_t>(statistic));
|
||||
book_money(g, k, interest.borrowing, true);
|
||||
}
|
||||
amount += ((deposit / 10000) * 20000) / -36500;
|
||||
wr32(g.manager_records, rec + 0x870, rd32(g.manager_records, rec + 0x870) - amount);
|
||||
book_money(g, k, amount, true);
|
||||
if (rd32(g.manager_records, rec + 0x314) > 100000000) { // read again after the bookings
|
||||
int32_t extra = int32_t(rand.range(10000, 20000)) * 1000;
|
||||
// BookMoney2 with the statistics flag set: counts as an expense (+0x8a0)
|
||||
wr32(g.manager_records, rec + 0x8a0, rd32(g.manager_records, rec + 0x8a0) + extra);
|
||||
book_money(g, k, extra, true);
|
||||
const auto statistic = uint32_t(rd32(g.manager_records, rec + 0x870)) - uint32_t(interest.cash_and_deposit);
|
||||
wr32(g.manager_records, rec + 0x870, std::bit_cast<int32_t>(statistic));
|
||||
book_money(g, k, interest.cash_and_deposit, true);
|
||||
if (rd32(g.manager_records, rec + 0x314) > 100000000) {
|
||||
const auto robbery_month = bank_robbery_month_key(g.date);
|
||||
const auto guard = bank_robbery_guard_month(g, k);
|
||||
// OpenBMH deviates from the original: an unknown history receives
|
||||
// a grace month; later losses occur at most once per source month.
|
||||
if (!guard) {
|
||||
set_bank_robbery_guard_month(g, k, robbery_month);
|
||||
} else if (*guard != robbery_month) {
|
||||
const int32_t extra = int32_t(rand.range(10000, 20000)) * 1000;
|
||||
const auto expense = uint32_t(rd32(g.manager_records, rec + 0x8a0)) + uint32_t(extra);
|
||||
wr32(g.manager_records, rec + 0x8a0, std::bit_cast<int32_t>(expense));
|
||||
book_money(g, k, extra, true);
|
||||
set_bank_robbery_guard_month(g, k, robbery_month);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,6 +391,12 @@ void stock_market(GameState& g, GameRandom& game) {
|
||||
|
||||
namespace bmh {
|
||||
|
||||
uint32_t bank_robbery_month_key(uint32_t date) {
|
||||
const int month = month_code(date);
|
||||
while (date > 0 && month_code(date - 1) == month) --date;
|
||||
return date;
|
||||
}
|
||||
|
||||
int month_code(uint32_t date) {
|
||||
// DeskState_DeskDate_RuntimeField: days per month (index 1-12; February 29 in leap years)
|
||||
uint8_t days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
@@ -28,6 +28,12 @@ namespace bmh {
|
||||
// cleared for every manager.
|
||||
void daily_interest(GameState& g, WatcomRandom& rand);
|
||||
|
||||
struct DailyInterestAmounts {
|
||||
int32_t borrowing = 0;
|
||||
int32_t cash_and_deposit = 0; // Negative amounts are interest income.
|
||||
};
|
||||
DailyInterestAmounts daily_interest_amounts(int32_t cash, int32_t deposit, int32_t credit);
|
||||
|
||||
} // namespace bmh
|
||||
|
||||
namespace bmh {
|
||||
|
||||
+44
-1
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
#include "game/pending_offer.hpp"
|
||||
#include "game/human_buyer_sale.hpp"
|
||||
#include "game/transfer_bid.hpp"
|
||||
@@ -215,7 +216,7 @@ void manager_offers(GameState& g, int manager, WatcomRandom& rand, MinuteReport&
|
||||
if (kind == 14) {
|
||||
for (int k = 0; k < 6; k++) {
|
||||
const uint32_t held = g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(k) * 0x1c);
|
||||
const uint32_t value = uint32_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c) * uint32_t(kShareFactor[k])) / 10000;
|
||||
const uint32_t value = uint32_t((uint64_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c)) * uint32_t(kShareFactor[k])) / 10000);
|
||||
sum += int(uint32_t(rand.range(10, 20)) * (held * value));
|
||||
}
|
||||
if (sum == 0) continue;
|
||||
@@ -1637,6 +1638,7 @@ static TransferOfferListView project_transfer_offer_list_impl(const GameState& g
|
||||
view.player = player;
|
||||
view.seller = g.memory.u16(list + 8) & 0x7fff;
|
||||
view.seller_manager = g.manager_of(view.seller);
|
||||
offer_bases(g.memory, list, -1, view.asking_fee, view.asking_monthly_salary);
|
||||
for (int bid = 0; bid < 4; ++bid) view.offers[size_t(bid)].bid_index = bid;
|
||||
if (view.seller_manager >= 0 && g.memory.has(::bmh::layout::DeskActions_Unsupported_RuntimeField + uint32_t(view.seller_manager)))
|
||||
view.seller_loan_count = g.memory.u8(::bmh::layout::DeskActions_Unsupported_RuntimeField + uint32_t(view.seller_manager));
|
||||
@@ -2621,6 +2623,47 @@ PendingOfferResult process_national_nomination_pending_after_desk(GameState& g,
|
||||
return process_natural_pending_offers_after_desk(g,request,game,rand,hooks,report);
|
||||
}
|
||||
|
||||
TransferActionResult accept_manager_transfer_offer(GameState& g, int manager, int entry,
|
||||
int expected_player, int bid, WatcomRandom& rand, MinuteReport& report, TransferAllocatorContext allocator) {
|
||||
TransferActionResult result;
|
||||
const auto view = project_transfer_offer_list(g, entry);
|
||||
if (!view.valid || manager < 0 || view.seller_manager != manager ||
|
||||
view.player != expected_player || bid < 0 || bid >= 4) return result;
|
||||
const auto& offer = view.offers[size_t(bid)];
|
||||
if (!offer.present) return result;
|
||||
if (!offer.affordable) { result.status = TransferActionStatus::insufficient_funds; return result; }
|
||||
if (!offer.has_squad_room) { result.status = TransferActionStatus::no_squad_room; return result; }
|
||||
if (!offer.passes_foreign_limit || !offer.loan_permitted) {
|
||||
result.status = TransferActionStatus::blocked_by_board; return result;
|
||||
}
|
||||
if (!offer.transaction_supported) { result.status = TransferActionStatus::unsupported; return result; }
|
||||
const uint32_t list = kTransferList + uint32_t(entry) * kListEntry;
|
||||
auto staged = g;
|
||||
auto staged_rand = rand;
|
||||
const uint32_t salary_at = list + 0x0c + uint32_t(bid) * 4;
|
||||
const auto salary = staged.memory.u32(salary_at);
|
||||
staged.memory.set32(salary_at, (salary * 10u) >> 3);
|
||||
uint32_t fee_pct = 0, salary_pct = 0;
|
||||
const bool rated = evaluate_bid(staged, list, bid, fee_pct, salary_pct, staged_rand, report);
|
||||
staged.memory.set32(salary_at, salary);
|
||||
if (!rated || report.unsupported) { result.status = TransferActionStatus::unsupported; return result; }
|
||||
if (!salary_pct) { result.status = TransferActionStatus::rejected; return result; }
|
||||
if (!accept_transfer_bid_immediately(staged, entry, bid, staged_rand, report,
|
||||
allocator) || report.unsupported) {
|
||||
result.status = TransferActionStatus::unsupported; return result;
|
||||
}
|
||||
const auto buyer_range = squad_range(offer.buyer);
|
||||
const bool moved = std::any_of(staged.squad_slots.begin() + buyer_range.first,
|
||||
staged.squad_slots.begin() + buyer_range.first + buyer_range.count,
|
||||
[&](uint16_t slot) { return (slot & 0xfff) == expected_player; });
|
||||
if (!moved) { result.status = TransferActionStatus::unsupported; return result; }
|
||||
g = std::move(staged); rand = staged_rand;
|
||||
result.status = TransferActionStatus::accepted;
|
||||
result.player = expected_player; result.list_entry = entry;
|
||||
result.fee = int32_t(offer.fee); result.annual_salary = int32_t(offer.monthly_salary);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool accept_transfer_bid_immediately(GameState& g, int entry, int bid, WatcomRandom& rand,
|
||||
MinuteReport& report, TransferAllocatorContext allocator) {
|
||||
if (entry < 0 || entry >= 40 || bid < 0 || bid >= 4) return false;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "launch/fltd.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
@@ -25,6 +26,8 @@ namespace {
|
||||
constexpr uint32_t kEnFileOffset = 0x496d;
|
||||
constexpr uint32_t kEnDataStart = ::bmh::layout::EnDataStart, kEnDataEnd = ::bmh::layout::Career_CompetitionPointersEnglish_RuntimeField;
|
||||
constexpr uint32_t kFltdSize = 507925;
|
||||
constexpr uint32_t kEnglishCalendarDateSetup = 0x684;
|
||||
constexpr uint32_t kEnglishOverwriteQuestionPointer = 0x6c43c;
|
||||
// The German image the engine expects: LE objects from layout field, data object GermanDataSegmentBegin-layout field.
|
||||
constexpr uint32_t kDeBase = 0x10000, kDeEnd = ::bmh::layout::GermanImageEnd;
|
||||
// A zero byte in the German BSS: the empty string of empty_pointers entries.
|
||||
@@ -118,6 +121,21 @@ LeImage translate_fltd(const fs::path& fltd_exe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Preserve the English date-setup operands in the shared epoch slot. The
|
||||
// English routine uses a different stack layout; the calendar reader
|
||||
// verifies that layout before reading its year and weekday.
|
||||
for (uint32_t i = 0; i < 14; ++i)
|
||||
put(layout::CalendarDateSetup + i, en(kEnglishCalendarDateSetup + i));
|
||||
// The native 11x11 pointer is an edition-owned indexed bitmap.
|
||||
for (uint32_t i = 0; i < 11 * 11; ++i)
|
||||
put(::bmh::layout::OriginalPointerPixels + i,
|
||||
en(::bmh::layout::EnglishOriginalPointerPixels + i));
|
||||
// Copy the actual English six-budget geometry, numeric steps and suffixes
|
||||
// for the common monthly environment model.
|
||||
for(const auto [to,from,count]:{std::array<uint32_t,3>{layout::Environment_FormatError_RuntimeField,layout::EnglishEnvironmentTileX,6},
|
||||
{layout::Environment_FormatError_RuntimeField2,layout::EnglishEnvironmentTileY,6},{layout::EnvironmentYouthColors,layout::EnglishEnvironmentYouthColors,3},
|
||||
{layout::EnvironmentBudgetSteps,layout::EnglishEnvironmentBudgetSteps,6},{layout::EnvironmentYouthPositionSuffix,layout::EnglishEnvironmentYouthPositionSuffix,5},
|
||||
{layout::EnvironmentCostSuffix,layout::EnglishEnvironmentCostSuffix,2}})for(uint32_t i=0;i<count;++i)put(to+i,en(from+i));
|
||||
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
|
||||
return out;
|
||||
}
|
||||
|
||||
+12
-1
@@ -122,7 +122,15 @@
|
||||
{::bmh::layout::TransferMarket_Click_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation246, {}},
|
||||
{::bmh::layout::TransferMarket_Click_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation246, {}},
|
||||
{::bmh::layout::TransferMarket_Click_RuntimeField3, 74, Kind::copy, ::bmh::layout::EnglishLayoutTranslation247, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_RuntimeField, 144, Kind::empty_pointers, 0, {}},
|
||||
// Keep the overwrite pointer's next entry exactly four bytes away: copy
|
||||
// entries extend to their following destination, while other slots stay empty.
|
||||
{::bmh::layout::Bank_OriginalToUtf8_RuntimeField,
|
||||
::bmh::layout::SaveLoad_OverwriteQuestionPointer - ::bmh::layout::Bank_OriginalToUtf8_RuntimeField,
|
||||
Kind::empty_pointers, 0, {}},
|
||||
{::bmh::layout::SaveLoad_OverwriteQuestionPointer, 4, Kind::copy, kEnglishOverwriteQuestionPointer, {}},
|
||||
{::bmh::layout::SaveLoad_OverwriteQuestionPointer + 4,
|
||||
::bmh::layout::Bank_OriginalToUtf8_RuntimeField + 144 - (::bmh::layout::SaveLoad_OverwriteQuestionPointer + 4),
|
||||
Kind::empty_pointers, 0, {}},
|
||||
{::bmh::layout::Analytics_FormatError_ExecutableField, 72, Kind::copy, ::bmh::layout::EnglishLayoutTranslation50, {}}, // EN196f1: graph labels, distinct from fund-name suffixes
|
||||
{::bmh::layout::AdGroupId, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation51, {}},
|
||||
{::bmh::layout::GameEnd_SourceHyphenator_ExecutableField, 18, Kind::copy, ::bmh::layout::EnglishLayoutTranslation52, {}},
|
||||
@@ -225,6 +233,9 @@
|
||||
{::bmh::layout::ClubPlayerDetail_ClubPlayerDetailRedraw_RuntimeField2, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation156, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField7, 10, Kind::copy, ::bmh::layout::EnglishLayoutTranslation157, {}},
|
||||
{::bmh::layout::Pitch_Render_RuntimeField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation163, {}},
|
||||
{::bmh::layout::PitchPreferenceDepthBases, 4, Kind::copy, ::bmh::layout::EnglishPitchPreferenceDepthBases, {}},
|
||||
{::bmh::layout::PitchPreferenceRed, 10, Kind::copy, ::bmh::layout::EnglishPitchPreferenceRed, {}},
|
||||
{::bmh::layout::PitchPreferenceGreen, 10, Kind::copy, ::bmh::layout::EnglishPitchPreferenceGreen, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation176, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation177, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField3, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation178, {}},
|
||||
|
||||
@@ -379,7 +379,7 @@ ResolvedGame resolve_game(const fs::path& input, const fs::path& cache) {
|
||||
const fs::path marker = prepared / ".openbmh-english";
|
||||
// the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built
|
||||
// by another version is built again
|
||||
constexpr const char* kTranslation = "english translation 13"; // 13: setup toggle rows, positive balance colour and desktop bar controls
|
||||
constexpr const char* kTranslation = "english translation 17"; // 17: English monthly environment tables (16: overwrite question)
|
||||
std::string built;
|
||||
{
|
||||
std::ifstream in(marker);
|
||||
|
||||
@@ -94,6 +94,7 @@ set(BMH_UI_REFERENCE_SAVE "" CACHE FILEPATH "Optional original LABA0012 desktop
|
||||
add_executable(ui_desktop_tests desktop_tests.cpp)
|
||||
target_link_libraries(ui_desktop_tests PRIVATE bmhui)
|
||||
set(BMH_TEST_UI_DESKTOP_TESTS_INPUT_1 "" CACHE PATH "External input 1 for ui_desktop_tests; not distributed")
|
||||
bmh_add_data_test(NAME ui_desktop_input_tests COMMAND ui_desktop_tests "${BMH_DATA}" --input-only)
|
||||
bmh_add_data_test(NAME ui_desktop_tests REQUIRED_OPTIONS BMH_TEST_UI_DESKTOP_TESTS_INPUT_1 COMMAND ui_desktop_tests "${BMH_DATA}" "${BMH_UI_REFERENCE_SAVE}"
|
||||
"${BMH_TEST_UI_DESKTOP_TESTS_INPUT_1}")
|
||||
set(BMH_UI_PREPARATION_SAVE "" CACHE FILEPATH "Optional original LABA0020 reference after observed menu entry effects; never bundled")
|
||||
@@ -243,3 +244,7 @@ bmh_add_data_test(NAME transfer_history_tests COMMAND transfer_history_tests "${
|
||||
add_executable(sportschau_ui_tests ../../tests/sportschau_ui_tests.cpp)
|
||||
target_link_libraries(sportschau_ui_tests PRIVATE bmhui)
|
||||
bmh_add_data_test(NAME sportschau_ui_tests COMMAND sportschau_ui_tests "${BMH_DATA}")
|
||||
|
||||
add_executable(live_score_reveal_tests live_score_reveal_tests.cpp)
|
||||
target_link_libraries(live_score_reveal_tests PRIVATE bmhui)
|
||||
add_test(NAME live_score_reveal_tests COMMAND live_score_reveal_tests)
|
||||
+71
-18
@@ -88,7 +88,7 @@ int32_t original_share_adjustment(const GameState& game, int manager, bool incom
|
||||
if (income) {
|
||||
for (int k = 0; k < 6; ++k) {
|
||||
const uint32_t shares = game.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c);
|
||||
const uint32_t unit = uint32_t(shares) * uint32_t(kShareUnits[size_t(k)]) / 10000;
|
||||
const uint32_t unit = uint32_t((uint64_t(shares) * uint32_t(kShareUnits[size_t(k)])) / 10000);
|
||||
const uint32_t owned = game.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(k) * 0x1c);
|
||||
amount = wrap_add(amount, signed32(unit * owned));
|
||||
}
|
||||
@@ -679,16 +679,14 @@ Image AdvertisingScreen::render() const {
|
||||
draw_finance(state_.finance_preview.expenses_text, 198, 222);
|
||||
text(image, 254, 218, state_.finance_preview.balance_text, 0x6b, 64);
|
||||
|
||||
if (selected_contract_ >= 0) {
|
||||
const auto& contract = selected_contract_ < kBoardCount
|
||||
? state_.boards[size_t(selected_contract_)]
|
||||
: selected_contract_ == 14 ? state_.shirt : state_.television;
|
||||
if (selected_contract_ < 16) {
|
||||
const int i = selected_contract_;
|
||||
rectangle(image, exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + uint32_t(i) * 2), exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + uint32_t(i) * 2),
|
||||
exe.u16(::bmh::layout::Advertising_Click_RuntimeField5 + uint32_t(i) * 2), exe.u16(::bmh::layout::Advertising_Click_RuntimeField6 + uint32_t(i) * 2), 0x27);
|
||||
}
|
||||
const auto& offer_list = state_.offers[size_t(selected_contract_)];
|
||||
// The original details panel follows the pointer until the offer browser owns it.
|
||||
const int details_target = offer_open_ ? selected_contract_ :
|
||||
hovered_target_ >= 0 && hovered_target_ < 16 ? hovered_target_ : -1;
|
||||
if (details_target >= 0) {
|
||||
const auto& contract = details_target < kBoardCount
|
||||
? state_.boards[size_t(details_target)]
|
||||
: details_target == 14 ? state_.shirt : state_.television;
|
||||
const auto& offer_list = state_.offers[size_t(details_target)];
|
||||
const bmh::AdvertisingOfferCandidate* offer = nullptr;
|
||||
if (offer_open_ && selected_offer_ >= 0)
|
||||
for (const auto& candidate : offer_list.offers)
|
||||
@@ -732,7 +730,7 @@ Image AdvertisingScreen::render() const {
|
||||
}
|
||||
text(image, 156, 185, show_offer ? state_.offer_label : state_.bonus_label, 0x6c, 34);
|
||||
text(image, 191, 185, original_to_utf8(exe_.cstring(::bmh::layout::Advertising_FormatError_ExecutableField)) + (show_offer
|
||||
? state_.offer_amount_text[size_t(selected_contract_)][size_t(selected_offer_)]
|
||||
? state_.offer_amount_text[size_t(details_target)][size_t(selected_offer_)]
|
||||
: contract.amount_text), 0x6c, 100);
|
||||
if (!offer_open_ && contract.active && contract.months_remaining == 0 &&
|
||||
contract.extension_months != 0)
|
||||
@@ -758,13 +756,18 @@ Image AdvertisingScreen::render() const {
|
||||
copy(image, logos_, 32, 217, 138, 174, 11, 14);
|
||||
|
||||
button(image, 89, 191, 66, state_.cancel_label);
|
||||
button(image, 164, 191, 66, state_.accept_label);
|
||||
// The original shows ABBRECHEN only when the selected offer cannot be accepted
|
||||
// (for example while a running sponsor contract is not terminable).
|
||||
if (offer_acceptable())
|
||||
button(image, 164, 191, 66, state_.accept_label);
|
||||
}
|
||||
}
|
||||
if (selected_spending_slot_ >= 16 && selected_spending_slot_ <= 18) {
|
||||
const uint32_t i = uint32_t(selected_spending_slot_);
|
||||
rectangle(image, exe_.u16(::bmh::layout::Advertising_Click_RuntimeField3 + i * 2), exe_.u16(::bmh::layout::Advertising_Click_RuntimeField4 + i * 2),
|
||||
exe_.u16(::bmh::layout::Advertising_Click_RuntimeField5 + i * 2), exe_.u16(::bmh::layout::Advertising_Click_RuntimeField6 + i * 2), 0x27);
|
||||
if (hovered_target_ >= 0) {
|
||||
const uint32_t at = uint32_t(hovered_target_) * 2;
|
||||
rectangle(image, exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + at),
|
||||
exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + at),
|
||||
exe.u16(::bmh::layout::Advertising_Click_RuntimeField5 + at),
|
||||
exe.u16(::bmh::layout::Advertising_Click_RuntimeField6 + at), 0x27);
|
||||
}
|
||||
if (spending_calculator_open_ && spending_backdrop_) image = *spending_backdrop_;
|
||||
if (notification_open()) draw_notification(image);
|
||||
@@ -858,6 +861,7 @@ void AdvertisingScreen::draw_notification(Image& out) const {
|
||||
bool AdvertisingScreen::dismiss_notification() {
|
||||
if (!notification_open()) return false;
|
||||
notification_dismissed_ = true;
|
||||
refresh_hover();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -894,6 +898,7 @@ void AdvertisingScreen::open_spending_calculator(int display_slot) {
|
||||
void AdvertisingScreen::close_spending_calculator() {
|
||||
spending_calculator_open_ = false;
|
||||
spending_backdrop_.reset();
|
||||
refresh_hover();
|
||||
}
|
||||
|
||||
bool AdvertisingScreen::accept_spending_calculator() {
|
||||
@@ -941,6 +946,7 @@ bool AdvertisingScreen::text(std::string_view input) {
|
||||
|
||||
void AdvertisingScreen::begin_offer_browser(int display_slot) {
|
||||
selected_contract_ = display_slot;
|
||||
hovered_target_ = display_slot;
|
||||
offer_open_ = true;
|
||||
selected_offer_ = -1;
|
||||
const auto& offers = state_.offers[size_t(display_slot)].offers;
|
||||
@@ -967,6 +973,14 @@ bool AdvertisingScreen::open_offers(int display_slot) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AdvertisingScreen::offer_acceptable() const {
|
||||
if (!offer_open_ || selected_contract_ < 0 || selected_contract_ >= 16 || selected_offer_ < 0) return false;
|
||||
for (const auto& candidate : state_.offers[size_t(selected_contract_)].offers)
|
||||
if (candidate.raw_slot == selected_offer_)
|
||||
return candidate.present && candidate.can_accept && candidate.monthly_amount != 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void AdvertisingScreen::submit_selected_offer() {
|
||||
if (pending_ || !offer_open_ || selected_contract_ < 0 || selected_contract_ >= 16 || selected_offer_ < 0)
|
||||
return;
|
||||
@@ -1000,11 +1014,41 @@ bool AdvertisingScreen::reject_action(std::string reason) {
|
||||
(void)utf8_to_original(reason);
|
||||
if (pending_->kind == AdvertisingActionKind::set_spending) close_spending_calculator();
|
||||
pending_.reset();
|
||||
refresh_hover();
|
||||
feedback_ = std::move(reason);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AdvertisingScreen::refresh_hover() {
|
||||
if (pointer_position_) (void)move((*pointer_position_)[0], (*pointer_position_)[1]);
|
||||
else hovered_target_ = -1;
|
||||
}
|
||||
|
||||
bool AdvertisingScreen::move(int x, int y) {
|
||||
// Modal input freezes the parent view, but its last physical position must
|
||||
// be sampled again as soon as that modal returns.
|
||||
pointer_position_ = std::array<int, 2>{x, y};
|
||||
if (close_requested_ || pending_ || notification_open() || spending_calculator_open_ || offer_open_)
|
||||
return false;
|
||||
int target = -1;
|
||||
for (int i = 0; i < 19; ++i) {
|
||||
const uint32_t at = uint32_t(i) * 2;
|
||||
const int left = exe_.u16(::bmh::layout::Advertising_Click_RuntimeField3 + at);
|
||||
const int top = exe_.u16(::bmh::layout::Advertising_Click_RuntimeField4 + at);
|
||||
const int width = exe_.u16(::bmh::layout::Advertising_Click_RuntimeField5 + at);
|
||||
const int height = exe_.u16(::bmh::layout::Advertising_Click_RuntimeField6 + at);
|
||||
if (x >= left && x < left + width && y >= top && y < top + height) {
|
||||
target = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (target == hovered_target_) return false;
|
||||
hovered_target_ = target;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AdvertisingScreen::click(int x, int y) {
|
||||
pointer_position_ = std::array<int, 2>{x, y};
|
||||
if (close_requested_ || pending_ || x < 0 || y < 0 || x >= 320 || y >= 240) return false;
|
||||
if (notification_open()) return dismiss_notification();
|
||||
if (spending_calculator_open_) {
|
||||
@@ -1035,6 +1079,7 @@ bool AdvertisingScreen::click(int x, int y) {
|
||||
offer_open_ = false;
|
||||
selected_offer_ = -1;
|
||||
feedback_.clear();
|
||||
refresh_hover();
|
||||
return true;
|
||||
}
|
||||
if (x >= 164 && x <= 229 && y >= 191 && y <= 200) {
|
||||
@@ -1056,6 +1101,7 @@ bool AdvertisingScreen::click(int x, int y) {
|
||||
const int right = left + exe_.u16(::bmh::layout::Advertising_Click_RuntimeField5 + uint32_t(i) * 2);
|
||||
const int bottom = top + exe_.u16(::bmh::layout::Advertising_Click_RuntimeField6 + uint32_t(i) * 2);
|
||||
if (x >= left && x < right && y >= top && y < bottom) {
|
||||
(void)move(x, y);
|
||||
const auto& projected = state_.offers[size_t(i)];
|
||||
const bool renewal_due = projected.contract_slot >= 0 && projected.contract_slot < 16 &&
|
||||
(projected.contract_bytes[6] & 0x7f) != 0 && projected.contract_bytes[5] == 0;
|
||||
@@ -1086,6 +1132,7 @@ bool AdvertisingScreen::click(int x, int y) {
|
||||
const int right = left + exe_.u16(::bmh::layout::Advertising_Click_RuntimeField5 + uint32_t(i) * 2);
|
||||
const int bottom = top + exe_.u16(::bmh::layout::Advertising_Click_RuntimeField6 + uint32_t(i) * 2);
|
||||
if (x >= left && x < right && y >= top && y < bottom) {
|
||||
(void)move(x, y);
|
||||
selected_contract_ = -1;
|
||||
selected_spending_slot_ = i;
|
||||
open_spending_calculator(i);
|
||||
@@ -1110,7 +1157,12 @@ bool AdvertisingScreen::key(std::string_view value) {
|
||||
return text(value);
|
||||
}
|
||||
if (value == "ESC") {
|
||||
if (offer_open_) { offer_open_ = false; selected_offer_ = -1; return true; }
|
||||
if (offer_open_) {
|
||||
offer_open_ = false;
|
||||
selected_offer_ = -1;
|
||||
refresh_hover();
|
||||
return true;
|
||||
}
|
||||
close_requested_ = true;
|
||||
return true;
|
||||
}
|
||||
@@ -1122,6 +1174,7 @@ std::string AdvertisingScreen::state_json() const {
|
||||
if (!result.empty() && result.back() == '}') result.pop_back();
|
||||
result += ",\"spending_calculator_open\":" +
|
||||
std::string(spending_calculator_open_ ? "true" : "false") +
|
||||
",\"hovered_target\":" + std::to_string(hovered_target_) +
|
||||
",\"selected_spending_slot\":" + std::to_string(selected_spending_slot_) +
|
||||
",\"spending_input\":" + std::to_string(spending_input_) +
|
||||
",\"notification_open\":" + std::string(notification_open() ? "true" : "false");
|
||||
|
||||
@@ -105,6 +105,7 @@ public:
|
||||
AdvertisingScreen(const std::filesystem::path& data, AdvertisingState state,
|
||||
uint64_t request_id_seed = 1);
|
||||
Image render() const;
|
||||
bool move(int x, int y);
|
||||
bool click(int x, int y);
|
||||
bool key(std::string_view key);
|
||||
bool open_offers(int display_slot);
|
||||
@@ -112,6 +113,8 @@ public:
|
||||
const std::optional<AdvertisingRequest>& pending() const { return pending_; }
|
||||
bool reject_action(std::string reason);
|
||||
int selected_contract() const { return selected_contract_; }
|
||||
int hovered_target() const { return hovered_target_; }
|
||||
std::optional<std::array<int, 2>> pointer_position() const { return pointer_position_; }
|
||||
int selected_offer() const { return selected_offer_; }
|
||||
bool offer_open() const { return offer_open_; }
|
||||
bool spending_calculator_open() const { return spending_calculator_open_; }
|
||||
@@ -136,6 +139,8 @@ private:
|
||||
std::optional<Image> badge_atlas_;
|
||||
std::optional<Image> spending_backdrop_;
|
||||
int selected_contract_ = -1;
|
||||
int hovered_target_ = -1;
|
||||
std::optional<std::array<int, 2>> pointer_position_;
|
||||
int selected_spending_slot_ = -1;
|
||||
int selected_offer_ = -1;
|
||||
uint64_t next_request_id_ = 1;
|
||||
@@ -153,10 +158,13 @@ private:
|
||||
int max_width = 310, bool use_gradient = true) const;
|
||||
void begin_offer_browser(int display_slot);
|
||||
void submit_selected_offer();
|
||||
// True when the selected offer of the open browser can be accepted (draws ANNEHMEN).
|
||||
bool offer_acceptable() const;
|
||||
void open_spending_calculator(int display_slot);
|
||||
bool accept_spending_calculator();
|
||||
void close_spending_calculator();
|
||||
bool dismiss_notification();
|
||||
void refresh_hover();
|
||||
void draw_spending_calculator(Image&) const;
|
||||
void draw_notification(Image&) const;
|
||||
void pattern_rect(Image&, int x, int y, int width, int height) const;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ui/advertising.hpp"
|
||||
#include "ui/source_notice_test_helpers.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
@@ -281,6 +282,54 @@ int main(int argc, char** argv) {
|
||||
check(pixel(first, exe.u16(::bmh::layout::Advertising_Click_RuntimeField3) + x, exe.u16(::bmh::layout::Advertising_Click_RuntimeField4) + y) ==
|
||||
pixel(logos, x, y),
|
||||
"active board logos use the original KB/34 partner sprite and hitbox coordinates");
|
||||
// Motion alone must display the original rectangle and details; it must
|
||||
// never open negotiations, spending, or emit an engine action.
|
||||
AdvertisingScreen hover(data, state);
|
||||
for (int target = 0; target < 19; ++target) {
|
||||
const uint32_t at = uint32_t(target) * 2;
|
||||
const int x = exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + at);
|
||||
const int y = exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + at);
|
||||
const int width = exe.u16(::bmh::layout::Advertising_Click_RuntimeField5 + at);
|
||||
const int height = exe.u16(::bmh::layout::Advertising_Click_RuntimeField6 + at);
|
||||
check(hover.move(x + 1, y + 1) && hover.hovered_target() == target &&
|
||||
!hover.move(x + 2, y + 2) && !hover.pending() && !hover.offer_open() &&
|
||||
!hover.spending_calculator_open() && hover.selected_contract() == -1,
|
||||
"pointer motion follows every original advertising target without an action");
|
||||
const auto highlighted = hover.render();
|
||||
for (int dx = 0; dx < width; ++dx)
|
||||
check(pixel(highlighted, x + dx, y) == 0x27 &&
|
||||
pixel(highlighted, x + dx, y + height - 1) == 0x27,
|
||||
"hover paints the original yellow top and bottom rectangle edges");
|
||||
for (int dy = 0; dy < height; ++dy)
|
||||
check(pixel(highlighted, x, y + dy) == 0x27 &&
|
||||
pixel(highlighted, x + width - 1, y + dy) == 0x27,
|
||||
"hover paints the original yellow left and right rectangle edges");
|
||||
check(hover.move(-1, -1) && hover.hovered_target() == -1 &&
|
||||
hover.render().pixels == first.pixels && !hover.move(-1, -1),
|
||||
"leaving a target restores both the outline and details without sticky selection");
|
||||
}
|
||||
const int empty_slot = int(std::find_if(state.boards.begin(), state.boards.end(),
|
||||
[](const auto& contract) { return !contract.active; }) - state.boards.begin());
|
||||
check(empty_slot < 14 && !state.space_available_text.empty(),
|
||||
"fixture provides an empty advertising surface and edition-specific help");
|
||||
auto no_help_state = state;
|
||||
no_help_state.space_available_text.clear();
|
||||
AdvertisingScreen no_help(data, no_help_state);
|
||||
const int empty_x = exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + empty_slot * 2) + 1;
|
||||
const int empty_y = exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + empty_slot * 2) + 1;
|
||||
check(hover.move(empty_x, empty_y) && no_help.move(empty_x, empty_y) &&
|
||||
hover.render().pixels != no_help.render().pixels &&
|
||||
state.space_available_text == original_to_utf8(message_text(game,
|
||||
::bmh::layout::Advertising_FormatError_TextPointer7)),
|
||||
"empty-surface hover renders help from the installation's actual TEXTD pointer");
|
||||
AdvertisingScreen spending_hover(data, state);
|
||||
const int spending_x = exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + 17 * 2) + 1;
|
||||
const int spending_y = exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + 17 * 2) + 1;
|
||||
check(spending_hover.move(spending_x, spending_y) && hover.move(spending_x, spending_y) &&
|
||||
hover.render().pixels == spending_hover.render().pixels,
|
||||
"moving directly from empty-surface help to spending clears the contract detail panel");
|
||||
check(game.manager_records == records_before,
|
||||
"all hover targets and help rendering leave the manager records unchanged");
|
||||
check(screen.click(exe.u16(::bmh::layout::Advertising_Click_RuntimeField3) + 1, exe.u16(::bmh::layout::Advertising_Click_RuntimeField4) + 1) &&
|
||||
screen.selected_contract() == 0,
|
||||
"a board click selects a local read-only details panel");
|
||||
@@ -295,6 +344,9 @@ int main(int argc, char** argv) {
|
||||
screen.key("ESC") && screen.close_requested() && !screen.key("LEFT"),
|
||||
"ESC closes an existing offer browser before the screen");
|
||||
} else {
|
||||
check(screen.move(-1, -1) && screen.render().pixels == first.pixels &&
|
||||
screen.selected_contract() == 0,
|
||||
"a clicked contract without offers does not leave a sticky outline or details");
|
||||
check(screen.key("ESC") && screen.close_requested() && !screen.key("LEFT"),
|
||||
"without a saved offer, ESC closes the contract details directly");
|
||||
}
|
||||
@@ -318,6 +370,10 @@ int main(int argc, char** argv) {
|
||||
const bool opened = offers.open_offers(0);
|
||||
check(opened && offers.offer_open() && offers.selected_offer() == 5,
|
||||
"opening the source offer browser selects the highest saved raw offer");
|
||||
const auto offer_pixels = offers.render().pixels;
|
||||
check(!offers.move(empty_x, empty_y) && offers.render().pixels == offer_pixels &&
|
||||
offers.selected_offer() == 5 && !offers.pending(),
|
||||
"offer browser keeps its input and details when the pointer crosses the parent targets");
|
||||
check(offers.click(140, 164) && offers.selected_offer() == 4 &&
|
||||
!offers.click(190, 195) && !offers.pending(),
|
||||
"an empty raw slot cannot create an acceptance request");
|
||||
@@ -351,6 +407,17 @@ int main(int argc, char** argv) {
|
||||
offers.close_requested(),
|
||||
"cancel closes the offer browser first; a second ESC closes the screen");
|
||||
|
||||
AdvertisingScreen resumed_offers(data, offer_state);
|
||||
const auto closed_offer_pixels = resumed_offers.render().pixels;
|
||||
check(resumed_offers.open_offers(0) && !resumed_offers.move(-1, -1) &&
|
||||
resumed_offers.key("ESC") && resumed_offers.hovered_target() == -1 &&
|
||||
resumed_offers.render().pixels == closed_offer_pixels,
|
||||
"offer ESC rechecks the pointer moved during the modal without another motion event");
|
||||
check(resumed_offers.open_offers(0) && resumed_offers.click(110, 195) &&
|
||||
resumed_offers.hovered_target() == -1 &&
|
||||
resumed_offers.render().pixels == closed_offer_pixels,
|
||||
"offer cancel rechecks its own click position and removes the old target outline");
|
||||
|
||||
// The three source spending controls open the original calculator. All
|
||||
// editing remains local; only J/Enter on a changed value creates a
|
||||
// manager/revision-bound request for the app controller.
|
||||
@@ -377,6 +444,9 @@ int main(int argc, char** argv) {
|
||||
"the original merchandise hitbox opens its calculator with the saved value");
|
||||
const auto calculator_art = load_vga(asset_path(data / "KB", "6.VGA"));
|
||||
const auto calculator_image = merchandise.render();
|
||||
check(!merchandise.move(empty_x, empty_y) &&
|
||||
merchandise.render().pixels == calculator_image.pixels && !merchandise.pending(),
|
||||
"spending calculator retains its captured parent and does not hover through it");
|
||||
check(calculator_image.pixels[size_t(55) * 320 + 103] == calculator_art.pixels[0],
|
||||
"the calculator opens over the original advertising screen using KB/6 at source coordinates");
|
||||
check(merchandise.text("200000") && merchandise.spending_input() == 200000 &&
|
||||
@@ -411,6 +481,20 @@ int main(int argc, char** argv) {
|
||||
unchanged_budget.spending_input() == 10000 && unchanged_budget.key("J") &&
|
||||
!unchanged_budget.pending() && !unchanged_budget.spending_calculator_open(),
|
||||
"accepting an unchanged monthly budget closes locally without an engine request");
|
||||
AdvertisingScreen resumed_budget(data, spending_state);
|
||||
const auto closed_budget_pixels = resumed_budget.render().pixels;
|
||||
check(resumed_budget.click(budget_x, budget_y) && !resumed_budget.move(-1, -1) &&
|
||||
resumed_budget.key("ESC") && resumed_budget.hovered_target() == -1 &&
|
||||
resumed_budget.render().pixels == closed_budget_pixels,
|
||||
"calculator ESC restores the current off-target pointer without another motion event");
|
||||
AdvertisingScreen expected_parent(data, spending_state);
|
||||
check(expected_parent.move(empty_x, empty_y) &&
|
||||
resumed_budget.click(budget_x, budget_y) && !resumed_budget.move(empty_x, empty_y) &&
|
||||
resumed_budget.key("J") && !resumed_budget.pending() &&
|
||||
resumed_budget.hovered_target() == empty_slot &&
|
||||
resumed_budget.render().pixels == expected_parent.render().pixels,
|
||||
"unchanged calculator acceptance resumes hover over the current parent target");
|
||||
|
||||
|
||||
AdvertisingScreen preset_budget(data, spending_state, 0x300000018ULL);
|
||||
const int preset0_x = 103 + exe.u16(::bmh::layout::Advertising_Click_RuntimeField + 15 * 2);
|
||||
|
||||
+23
-26
@@ -100,8 +100,8 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
}
|
||||
state.credit_currency = {g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1,
|
||||
g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1};
|
||||
const auto currency = [&](int32_t amount, int flags) {
|
||||
std::string value = format_number(g, amount, flags);
|
||||
const auto currency = [&](int64_t amount, int flags) {
|
||||
std::string value = format_number_wide(g, amount, flags);
|
||||
// FormatNumber appends currency (CurrencySuffixText) and the caller's Bank_FormatError_ExecutableField suffix.
|
||||
value += exe.cstring(::bmh::layout::Bank_FormatError_ExecutableField);
|
||||
return original_to_utf8(value);
|
||||
@@ -141,8 +141,8 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
fund.owned = g.memory.u16(at + 0x14 + uint32_t(manager) * 2);
|
||||
fund.max_to_buy = fund.price == 0 ? 0 : max_fund_units(g, manager, int(i));
|
||||
fund.name = original_to_utf8(message_text(g, ::bmh::layout::Bank_OriginalToUtf8_TextPointer3 + uint32_t(i) * 4));
|
||||
fund.unit_price_text = currency(wrap_i32(fund.price), 0x108);
|
||||
fund.average_paid_text = currency(fund.owned ? wrap_i32(fund.paid / fund.owned) : 0, 0x108);
|
||||
fund.unit_price_text = currency(fund.price, 0x108);
|
||||
fund.average_paid_text = currency(fund.owned ? fund.paid / fund.owned : 0, 0x108);
|
||||
fund.quantity_text = original_to_utf8(format_number(g, fund.owned, 0x82) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField2));
|
||||
fund.one_quantity_text = original_to_utf8(format_number(g, 1, 0x82) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField2));
|
||||
const uint32_t suffix = exe.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField + uint32_t(i) * 8);
|
||||
@@ -154,49 +154,46 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
// and the separate overdraft limit. All inputs are copied/read-only.
|
||||
state.finance_values[0] = state.balance;
|
||||
state.finance_values[1] = state.deposit;
|
||||
int32_t investment_value = 0, investment_gain = 0;
|
||||
// OpenBMH deviates from the original: read-only totals use wide arithmetic;
|
||||
// individual saved account, price, holding and paid fields are unchanged.
|
||||
int64_t investment_value = 0, investment_gain = 0;
|
||||
for (size_t i = 0; i < state.funds.size(); ++i) {
|
||||
const uint32_t price = g.memory.u32(::bmh::layout::FundBlock + uint32_t(i) * 0x1c);
|
||||
const uint32_t held = g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(i) * 0x1c);
|
||||
const int32_t value = wrap_i32(price * held);
|
||||
investment_value = wrap_sum(investment_value, value);
|
||||
const int32_t paid = wrap_i32(g.memory.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField5 + uint32_t(i) * 0x1c + uint32_t(manager) * 4));
|
||||
if (held) investment_gain = wrap_sum(investment_gain, wrap_i32(uint32_t(value) - uint32_t(paid)));
|
||||
const int64_t value = int64_t(price) * held;
|
||||
investment_value += value;
|
||||
const int64_t paid = g.memory.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField5 + uint32_t(i) * 0x1c + uint32_t(manager) * 4);
|
||||
if (held) investment_gain += value - paid;
|
||||
}
|
||||
state.finance_values[2] = investment_value;
|
||||
state.finance_gains[0] = investment_gain;
|
||||
int32_t stock_value = 0, stock_gain = 0;
|
||||
int64_t stock_value = 0, stock_gain = 0;
|
||||
for (size_t i = 0; i < state.stocks.size(); ++i) {
|
||||
const int32_t value = wrap_i32(uint32_t(state.stocks[i].price) * state.stocks[i].owned);
|
||||
stock_value = wrap_sum(stock_value, value);
|
||||
if (state.stocks[i].owned) stock_gain = wrap_sum(stock_gain, wrap_i32(uint32_t(value) - uint32_t(state.stocks[i].paid)));
|
||||
const int64_t value = int64_t(state.stocks[i].price) * state.stocks[i].owned;
|
||||
stock_value += value;
|
||||
if (state.stocks[i].owned) stock_gain += value - state.stocks[i].paid;
|
||||
}
|
||||
state.finance_values[3] = stock_value;
|
||||
state.finance_gains[1] = stock_gain;
|
||||
int32_t debts = 0, debt_assets = 0;
|
||||
int64_t debts = 0, debt_assets = 0;
|
||||
for (uint32_t loan = 0; loan < 5; ++loan) {
|
||||
const uint32_t at = ::bmh::layout::Analytics_SourceAssetMaskE_RuntimeField + uint32_t(manager) * 0x78 + loan * 0x18;
|
||||
const uint32_t borrowed = g.memory.u32(at);
|
||||
const uint32_t repaid = g.memory.u32(at + 0x10);
|
||||
debts = wrap_sum(debts, wrap_i32(borrowed - repaid));
|
||||
debt_assets = wrap_sum(debt_assets, wrap_i32(borrowed));
|
||||
debts += int64_t(borrowed) - repaid;
|
||||
debt_assets += borrowed;
|
||||
}
|
||||
state.finance_values[4] = debts;
|
||||
int32_t net = state.balance;
|
||||
net = wrap_sum(net, state.deposit);
|
||||
net = wrap_sum(net, investment_value);
|
||||
net = wrap_sum(net, stock_value);
|
||||
net = wrap_sum(net, wrap_i32(0u - uint32_t(debt_assets)));
|
||||
state.finance_values[5] = net;
|
||||
state.finance_values[5] = int64_t(state.balance) + state.deposit + investment_value + stock_value - debt_assets;
|
||||
state.finance_values[6] = state.credit_line;
|
||||
for (size_t i = 0; i < state.finance_value_text.size(); ++i)
|
||||
state.finance_value_text[i] = currency(state.finance_values[i], 0x188);
|
||||
for (size_t i = 0; i < state.finance_gains.size(); ++i) {
|
||||
const int32_t gain = state.finance_gains[i];
|
||||
const int64_t gain = state.finance_gains[i];
|
||||
const uint32_t sign_address = gain < 0 ? ::bmh::layout::Bank_OriginalToUtf8_ExecutableField5 : gain > 0 ? ::bmh::layout::Bank_OriginalToUtf8_ExecutableField6 : ::bmh::layout::Bank_OriginalToUtf8_ExecutableField7;
|
||||
const int32_t magnitude = gain < 0 ? wrap_i32(0u - uint32_t(gain)) : gain;
|
||||
const int64_t magnitude = gain < 0 ? -gain : gain;
|
||||
state.finance_gain_text[i] = original_to_utf8(exe.cstring(sign_address) +
|
||||
format_number(g, magnitude, 0x101) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
|
||||
format_number_wide(g, magnitude, 0x101) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
|
||||
// 0x101 appends; Source preserves market value and adds signed gain in parentheses.
|
||||
if (state.finance_values[i + 2] != 0)
|
||||
state.finance_value_text[i + 2] += original_to_utf8(exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField4)) + state.finance_gain_text[i];
|
||||
@@ -226,7 +223,7 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
state.finance_fund_labels[i] = original_to_utf8(format_number(g, fund.owned, 0x82) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField2) +
|
||||
message_text(g, ::bmh::layout::Bank_OriginalToUtf8_TextPointer3 + uint32_t(i) * 4) +
|
||||
exe.cstring(exe.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField + uint32_t(i) * 8 + (fund.owned > 1 ? 4 : 0))));
|
||||
state.finance_fund_prices[i] = original_to_utf8("(" + format_number(g, wrap_i32(fund.price), 0x108) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
|
||||
state.finance_fund_prices[i] = original_to_utf8("(" + format_number_wide(g, fund.price, 0x108) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
|
||||
}
|
||||
for (size_t i = 0; i < state.stocks.size(); ++i) {
|
||||
const auto& stock = state.stocks[i];
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@ struct BankState {
|
||||
std::string investment_limit_text;
|
||||
int manager_portrait = 0, badge_sprite = 0;
|
||||
// MaxSharesToBuy case 1: the seven read-only values shown in the finance view.
|
||||
std::array<int32_t, 7> finance_values{};
|
||||
std::array<int32_t, 2> finance_gains{};
|
||||
std::array<int64_t, 7> finance_values{};
|
||||
std::array<int64_t, 2> finance_gains{};
|
||||
std::array<std::string, 7> finance_value_text{};
|
||||
std::array<std::string, 2> finance_gain_text{};
|
||||
// Case 4 (bank credit) readonly values as seen before any local edits.
|
||||
|
||||
+23
-2
@@ -77,9 +77,30 @@ CalendarScreen::CalendarScreen(const std::filesystem::path& data, CalendarState
|
||||
void CalendarScreen::text(Image& out, int x, int baseline, std::string_view bytes, uint8_t color) const {
|
||||
// TextWidth3 refuses text outside the original screen; no UTF-8 enters BMH3.
|
||||
const int top = baseline - font_.baseline;
|
||||
if (x >= 0 && top >= 0 && top + font_.height <= out.height &&
|
||||
x + font_.text_width(bytes) <= out.width)
|
||||
if (!(x >= 0 && top >= 0 && top + font_.height <= out.height &&
|
||||
x + font_.text_width(bytes) <= out.width)) return;
|
||||
// With the gradient on, every set pixel of a glyph takes the colour its row has in the original's
|
||||
// table for this palette token (six rows per token); a token the table does not know stays flat.
|
||||
unsigned slot = 0;
|
||||
while (slot < 32 && exe_.u8(::bmh::layout::Advertising_Text_RuntimeField2 + slot) != color) ++slot;
|
||||
if (!state_.gradient_text || slot == 32) {
|
||||
font_.draw(out, x, top, bytes, color);
|
||||
return;
|
||||
}
|
||||
int pen_x = x;
|
||||
for (unsigned char ch : bytes) {
|
||||
const auto& glyph = font_.glyph(ch);
|
||||
for (int row = 0; row < font_.height; ++row) {
|
||||
const uint8_t row_color = exe_.u8(::bmh::layout::Advertising_Text_RuntimeField + slot * 6 + std::min(row, 5));
|
||||
if (row_color == 0) continue;
|
||||
for (int col = 0; col < glyph.bit_width; ++col) {
|
||||
const int bit = glyph.bit_offset + col;
|
||||
if (!(font_.bitmap[size_t(row) * font_.modulo + bit / 8] & (0x80 >> (bit % 8)))) continue;
|
||||
out.at(pen_x + col, top + row) = row_color;
|
||||
}
|
||||
}
|
||||
pen_x += glyph.advance;
|
||||
}
|
||||
}
|
||||
|
||||
std::string CalendarScreen::information(const CalendarDayProjection& day) const {
|
||||
|
||||
@@ -24,12 +24,13 @@ void require_memory(const GameState& game, uint32_t address) {
|
||||
CalendarState calendar_from_game(const GameState& game, const LeImage& executable) {
|
||||
if (!executable.contains(::bmh::layout::CalendarState_CalendarFromGame_ExecutableField) || !executable.contains(::bmh::layout::CalendarState_CalendarFromGame_ExecutableField2))
|
||||
throw FormatError("calendar: missing executable month lengths");
|
||||
require_memory(game, ::bmh::layout::CalendarState_FormatError_RuntimeField3);
|
||||
require_memory(game, ::bmh::layout::DaysIntoSeason);
|
||||
const uint32_t native_start = game.memory.u16(::bmh::layout::CalendarState_FormatError_RuntimeField3);
|
||||
const int native_current = game.memory.u16(::bmh::layout::DaysIntoSeason);
|
||||
if (game.date < native_start || game.date - native_start != uint32_t(native_current))
|
||||
throw FormatError("calendar: saved native season cursor disagrees with current date");
|
||||
// The season origin and the day of the season are the live values of the game. Their copies in
|
||||
// the memory image hold only the day the game was loaded or saved; they are not kept up to date
|
||||
// while the career runs, so reading them failed from the first kickoff on.
|
||||
const uint32_t native_start = game.season_start;
|
||||
const int native_current = game.season_day();
|
||||
if (game.date < native_start || native_current < 0)
|
||||
throw FormatError("calendar: the season origin lies after the current date");
|
||||
const DeskDate first_native_date = desk_date(native_start, executable);
|
||||
if (first_native_date.month != 7 || first_native_date.day < 1 || first_native_date.day > 7)
|
||||
throw FormatError("calendar: native season start is outside the first July week");
|
||||
@@ -105,6 +106,10 @@ CalendarState calendar_from_game(const GameState& game, const LeImage& executabl
|
||||
if (current_display >= int(state.days.size()))
|
||||
throw FormatError("calendar: current date is outside the season calendar");
|
||||
state.current_day = current_display;
|
||||
// TextGradientDisabled (a settings switch) clear and the edition's gradient mode 2: the text
|
||||
// takes the original's six-row colour table, as on every other page.
|
||||
state.gradient_text = !game.memory.has(::bmh::layout::TextGradientDisabled) ||
|
||||
(game.memory.u8(::bmh::layout::TextGradientDisabled) == 0 && executable.u8(::bmh::layout::TextGradientMode) == 2);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ struct CalendarState {
|
||||
bool friendly_selection = false;
|
||||
std::vector<RescheduleOption> reschedule_options;
|
||||
std::vector<LeagueMatchRef> moved_matches;
|
||||
bool gradient_text = true; // six-row colour table of the original instead of flat colours
|
||||
};
|
||||
|
||||
// Projects the current saved season without preparing fixtures, advancing the date,
|
||||
|
||||
@@ -28,7 +28,7 @@ void rect(Image& out, int x, int y, int w, int h, uint8_t color) {
|
||||
for (int yy = std::max(0, y); yy < std::min(out.height, y + h); ++yy)
|
||||
for (int xx = std::max(0, x); xx < std::min(out.width, x + w); ++xx) out.at(xx, yy) = color;
|
||||
}
|
||||
std::string padded(int value, int width = 2) {
|
||||
std::string padded(uint64_t value, int width = 2) {
|
||||
std::string s = std::to_string(value);
|
||||
if (int(s.size()) < width) s.insert(0, size_t(width - int(s.size())), '%');
|
||||
return s;
|
||||
@@ -110,7 +110,10 @@ ClubInfoProjection club_info_from_game(const GameState& g, int team,
|
||||
player.cards = g.player_cards[id];
|
||||
player.bonus = g.player_bonus[id];
|
||||
}
|
||||
if (board) player.manager_board = std::move(board);
|
||||
if (board) {
|
||||
player.manager_board = std::move(board);
|
||||
if (player.player_id >= 0) player.statistics = player_club_statistics(g, team, player.player_id, *player.manager_board);
|
||||
}
|
||||
if (!player.borrowed && player.player_id >= 0) {
|
||||
for (int loan = 0; loan < 200; ++loan) {
|
||||
const uint32_t address = ::bmh::layout::Career_RemoveJoinLoans_RuntimeField + uint32_t(loan) * 4;
|
||||
@@ -296,9 +299,9 @@ Image ClubInfoScreen::render() const {
|
||||
std::string attrs = padded(p.bonus & 127, 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
|
||||
if (p.manager_board) {
|
||||
const auto& b = *p.manager_board;
|
||||
attrs += padded(b[7], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + padded(b[9], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
|
||||
Bytes raw(b.begin(), b.end()); attrs += padded(le16(raw, 0x48), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
|
||||
padded(le16(raw, 0x4a), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + padded(le16(raw, 0x4c), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField);
|
||||
attrs += padded(p.statistics ? p.statistics->appearances[0] : b[7], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + padded(p.statistics ? p.statistics->appearances[2] : b[9], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
|
||||
Bytes raw(b.begin(), b.end()); attrs += padded((p.statistics ? p.statistics->total : le16(raw, 0x48)), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
|
||||
padded((p.statistics ? p.statistics->goals : le16(raw, 0x4a)), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + padded((p.statistics ? p.statistics->assists : le16(raw, 0x4c)), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField);
|
||||
}
|
||||
text(out, 165, baseline, attrs, 0x6c);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ struct ClubInfoPlayer {
|
||||
bool offer_name_color = false;
|
||||
// Present only when this runtime club belongs to a human manager.
|
||||
std::optional<std::array<uint8_t, 0x58>> manager_board;
|
||||
std::optional<PlayerClubStatistics> statistics;
|
||||
};
|
||||
|
||||
// Owned inputs for one render of ClubInfoFromGame / LineupScreen. Build this from the actual
|
||||
|
||||
@@ -15,7 +15,9 @@ void rect(Image& out,int x,int y,int w,int h,uint8_t c) {
|
||||
for(int xx=std::max(0,x);xx<std::min(out.width,x+w);++xx)out.at(xx,yy)=c;
|
||||
}
|
||||
void copy(Image& out,const Image& src,int sx,int sy,int x,int y,int w,int h,int transparent=-1) {
|
||||
if(sx<0||sy<0||sx+w>src.width||sy+h>src.height)throw FormatError("player card: original atlas bounds");
|
||||
if(sx<0||sy<0||sx+w>src.width||sy+h>src.height)
|
||||
throw FormatError("club player detail: original atlas bounds "+std::to_string(sx)+","+std::to_string(sy)+
|
||||
":"+std::to_string(w)+"x"+std::to_string(h)+" in "+std::to_string(src.width)+"x"+std::to_string(src.height));
|
||||
for(int yy=0;yy<h;++yy)for(int xx=0;xx<w;++xx){
|
||||
const auto c=src.pixels.at(size_t(sy+yy)*src.width+sx+xx);
|
||||
if(c!=transparent&&x+xx>=0&&x+xx<out.width&&y+yy>=0&&y+yy<out.height)out.at(x+xx,y+yy)=c;
|
||||
|
||||
@@ -148,6 +148,7 @@ ContractsState contracts_from_game(const GameState& game, int manager_slot, uint
|
||||
view.source.name = game.player_name(player); view.source.attributes = source;
|
||||
view.source.cards = game.player_cards.at(size_t(player)); view.source.bonus = game.player_bonus.at(size_t(player));
|
||||
std::copy_n(game.tactics.begin() + std::ptrdiff_t(at), 0x58, view.source.board.begin());
|
||||
view.source.statistics = player_club_statistics(game, team, player, view.source.board);
|
||||
state.players.push_back(std::move(view));
|
||||
}
|
||||
if (!state.players.empty()) {
|
||||
@@ -314,6 +315,7 @@ Image ContractsScreen::render_roster() const {
|
||||
text(out, x, y, original_to_utf8(raw), color, -1);
|
||||
};
|
||||
const auto fixed = [](uint32_t value, int width, bool grouped = false) { return original_number(value, width, grouped); };
|
||||
const auto count = [](uint64_t value) { auto s = std::to_string(value); if(s.size()<3)s.insert(0,3-s.size(),'%'); return s; };
|
||||
const auto title = original_to_utf8(texts_[(::bmh::layout::Contracts_RenderRoster_TextPointer2 - ::bmh::layout::TextPointerTable) / 4]);
|
||||
sprite_font_.draw(out, SpriteFont::centered_title_x(sprite_font_.text_width(title)), 13, title, 5);
|
||||
sprite_font_.draw(out, 5, 235, state_.club_name, 5);
|
||||
@@ -374,9 +376,9 @@ Image ContractsScreen::render_roster() const {
|
||||
original_text(65, baseline, fixed(a.age(), 2) + texts_[(::bmh::layout::ClubInfo_Render_TextPointer5 - ::bmh::layout::TextPointerTable) / 4], 0x6c);
|
||||
for (int skill = 0; skill < 7; ++skill) copy_region(out, atlas_, 256 + a.skill(Player::Skill(skill)) * 16, 32, 87 + skill * 10, baseline - 5, 16, 5, true);
|
||||
auto word = [&](int at) { return uint16_t(s.board[at] | uint16_t(s.board[at + 1]) << 8); };
|
||||
original_text(165, baseline, fixed(s.bonus & 127, 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + fixed(s.board[7], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) +
|
||||
fixed(s.board[9], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + fixed(word(0x48), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
|
||||
fixed(word(0x4a), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + fixed(word(0x4c), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField), 0x6c);
|
||||
original_text(165, baseline, fixed(s.bonus & 127, 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + count(s.statistics ? s.statistics->appearances[0] : s.board[7]) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) +
|
||||
count(s.statistics ? s.statistics->appearances[2] : s.board[9]) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + count(s.statistics ? s.statistics->total : word(0x48)) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
|
||||
count(s.statistics ? s.statistics->goals : word(0x4a)) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + count(s.statistics ? s.statistics->assists : word(0x4c)) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField), 0x6c);
|
||||
}
|
||||
baseline += 7;
|
||||
}
|
||||
@@ -394,7 +396,7 @@ Image ContractsScreen::render() const {
|
||||
}
|
||||
const auto selected = std::find_if(state_.players.begin(), state_.players.end(),
|
||||
[&](const auto& p) { return p.row == state_.selected_row; });
|
||||
static constexpr std::array<std::string_view, 4> tabs{"DATEN-A", "DATEN-B", "GEHALT", "TEAM-PRÄMIEN"};
|
||||
const std::array<std::string,4> tabs{original_to_utf8(texts_[117]),original_to_utf8(texts_[118]),original_to_utf8(texts_[119]),original_to_utf8(texts_[120])};
|
||||
for (int i = 0; i < (state_.mode_three?4:3); ++i) {
|
||||
const int x = i * 60 + 2, w = i == 3 ? 71 : 51;
|
||||
if(i!=tab_) {fill(out,x+2,225,w,2,0x40);fill(out,x+w,217,2,10,0x40);}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/contracts.hpp"
|
||||
#include "ui/source_notice_test_helpers.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -23,6 +26,20 @@ int main(int argc, char** argv) {
|
||||
state.club_name = "UNIT FOOTBALL CLUB";
|
||||
state.players.push_back({0, 150, "TORWART", 25, 0, 8, 180000});
|
||||
state.players.push_back({1, 151, "STÜRMER", 21, 3, 14, 90000});
|
||||
{
|
||||
auto language_state=state;language_state.mode_three=true;
|
||||
ContractsScreen language(argv[1],language_state);const auto frame=language.render();
|
||||
const auto data=std::filesystem::path(argv[1]);const auto exe=bmh::load_le(asset_path(data,"BMH.exe"));
|
||||
const auto texts=bmh::load_textd(asset_path(data,"TEXTD.BLK"));SpriteFont source_font(data);
|
||||
for(int tab=0;tab<4;++tab) {
|
||||
const auto caption=original_to_utf8(texts[size_t(117+tab)]);const int width=tab==3?71:51;
|
||||
const int x=tab*60+2+(tab==2?2:0),y=215+(tab==2?2:0);
|
||||
bmh::Image expected(320,240,0xfd);
|
||||
source_font.draw(expected,x+width/2-source_font.text_width(caption)/2,y+7,caption,exe.u8(bmh::layout::Advertising_Button_RuntimeField+(tab==2)));
|
||||
size_t ink=0;for(size_t pixel=0;pixel<expected.pixels.size();++pixel)if(expected.pixels[pixel]!=0xfd){check(frame.pixels[pixel]==expected.pixels[pixel],"contract tab does not render its authoritative source-language caption");++ink;}
|
||||
check(ink>10,"source-language contract tab oracle contains no glyphs");
|
||||
}
|
||||
}
|
||||
auto blocked_state = state;
|
||||
blocked_state.players[0].offer_blocked = true;
|
||||
ContractsScreen blocked(argv[1], blocked_state);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
@@ -233,6 +234,7 @@ DeskState project(const StaticMemory& memory, const Tables& t, const LeImage& ex
|
||||
d.managers.at(0).club_identity_key = coach->club_identity_key;
|
||||
}
|
||||
if (d.runtime_club < 0 || d.runtime_club >= int(t.name_offsets.size())) throw FormatError("desk: invalid runtime club");
|
||||
d.runtime_club_identity = int(t.name_offsets.at(size_t(d.runtime_club)));
|
||||
if (d.national_team && ((!d.options.world && !d.national_coach_takeover) ||
|
||||
d.manager_slot != 0 || d.options.managers != 1))
|
||||
throw FormatError("desk: national team requires one manager and world-mode or source takeover evidence");
|
||||
@@ -620,7 +622,10 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
*d.next_opponent < int(g.club_ids.size())) {
|
||||
const int opponent = *d.next_opponent;
|
||||
d.next_opponent_name = g.club_name(opponent);
|
||||
const bool fallback = original_badge_fallback(opponent,&exe);
|
||||
// OpenBMH deviates from the original: the desk shows the opponent's badge whenever the data has one.
|
||||
// The original draws a computer icon for the clubs between its two gate values (the foreign league
|
||||
// clubs); only the cup-only teams and the empty selector keep the icon.
|
||||
const bool fallback = (opponent & 0xfff) == 0xfff || (opponent >= 168 && opponent < 357);
|
||||
d.next_opponent_badge_fallback = fallback;
|
||||
if (!fallback) {
|
||||
const size_t badge_at = size_t(opponent) * 2;
|
||||
@@ -690,8 +695,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
|
||||
DeskState load_reference_desk(const std::filesystem::path& path, const LeImage& exe) {
|
||||
auto fbm = load_savegame(path);
|
||||
if (!fbm.checksum_ok) throw FormatError("desk: FBM checksum mismatch");
|
||||
if (fbm.version != "V2.24") throw FormatError("desk: unsupported FBM version");
|
||||
require_native_savegame(fbm);
|
||||
DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
SaveState save(fbm.stream, counts);
|
||||
auto d = desk_from_save(save, exe);
|
||||
|
||||
@@ -63,6 +63,15 @@ struct DeskState {
|
||||
// In a multiplayer career the visible national desk has only the coach in slot 0.
|
||||
std::vector<DeskManagerIdentity> national_return_roster;
|
||||
bool national_team = false;
|
||||
// Stable name-pool identity of the runtime club (GameState::club_ids): at the national desk that of
|
||||
// the national team, whereas managers[slot].club_identity_key keeps the home club for the hand-back.
|
||||
int runtime_club_identity = -1;
|
||||
// The identity the session's pages carry for this desk's manager (Table, Stärken, ...): the runtime
|
||||
// club's own identity, so at the national desk that of the national team.
|
||||
int session_identity_key(size_t slot) const {
|
||||
return national_team && int(slot) == manager_slot && runtime_club_identity >= 0
|
||||
? runtime_club_identity : managers.at(slot).club_identity_key;
|
||||
}
|
||||
// SwapManagerSlots2 temporary coach assignment (CoachActive). This can make
|
||||
// a league-only, single-manager career temporarily project team 0x165.
|
||||
bool national_coach_takeover = false;
|
||||
|
||||
+24
-9
@@ -309,8 +309,12 @@ std::optional<DeskItem> DesktopScreen::folder_child_at(int x,int y) const {
|
||||
const int inset = folder.kind >= 50 && !folder.open ? 8 : 0;
|
||||
if (x < folder.x || y < folder.y || x >= folder.x + folder.width - inset ||
|
||||
y >= folder.y + folder.height - inset) continue;
|
||||
if(folder.disabled||folder.kind<50||folder.kind>52||!folder.open) return std::nullopt;
|
||||
const int folder_id=folder.kind-50,left=folder.x+9,top=folder.y+8,right=folder.x+folder.width-4,bottom=folder.y+folder.height-4;
|
||||
if(folder.disabled||folder.kind<50||folder.kind>52) return std::nullopt;
|
||||
// The open bit adds a frame; unframed folders still draw usable tiles.
|
||||
// Match DeskDrawerRenderer's content origin and wrapping bounds.
|
||||
const int frame = folder.open ? 4 : 0;
|
||||
const int folder_id=folder.kind-50,left=folder.x+frame+5,top=folder.y+frame+4;
|
||||
const int right=folder.x+frame+folder.width-4,bottom=folder.y+frame+folder.height-4;
|
||||
int child_x=left,child_y=top;
|
||||
for(uint8_t id:state_.folder_icon_slots[size_t(folder_id)]) {
|
||||
if(child_x+32>right) child_x=left,child_y+=27;
|
||||
@@ -396,9 +400,9 @@ DeskRequest DesktopScreen::pointer_down(int x, int y, bool right) {
|
||||
}
|
||||
if (right && !state_.drawer_handles) return {};
|
||||
if (right && bin_mode_ && item.kind!=12) return {};
|
||||
if (!right && item.kind==55 && item.open && !state_.national_team &&
|
||||
x-item.x-4>34 && x-item.x-4<87) return {}; // Original ticket-price scale.
|
||||
if (!right && item.kind==64 && item.open) return {}; // Source automation controls remain clicks.
|
||||
if (!right && item.kind==55 && !state_.national_team &&
|
||||
x-item.x-(item.open?4:0)>34 && x-item.x-(item.open?4:0)<87) return {}; // Original ticket-price scale.
|
||||
if (!right && item.kind==64) return {}; // Source automation controls remain clicks.
|
||||
const bool drawer_handle=item.kind>=50&&state_.drawer_handles&&x<=item.x+3&&y<=item.y+3;
|
||||
if (!right) return {}; // LMB closes/activates; RMB alone starts a drag.
|
||||
layout_drag_ = LayoutDrag{item.id, x - item.x, y - item.y, item.x, item.y, -1, false, false, drawer_handle, right};
|
||||
@@ -653,10 +657,12 @@ DeskRequest DesktopScreen::click(int x, int y, bool right) {
|
||||
// The corner closes through the same transaction as the quickbar.
|
||||
if (item.open && state_.drawer_handles && x <= item.x + 3 && y <= item.y + 3)
|
||||
return close_drawer(item);
|
||||
if (item.kind == 58 && item.open) return request(DeskRequestKind::advance_turn, item);
|
||||
if (item.kind == 55 && item.open && !state_.national_team && x - item.x - 4 > 34 && x - item.x - 4 < 87)
|
||||
return request(DeskRequestKind::change_ticket_price, item, (x - item.x - 4 - 35) / 3 + 8);
|
||||
if (item.kind == 64 && item.open) return request(DeskRequestKind::change_option, item, std::clamp((x - item.x - 4) / 33, 0, 4));
|
||||
// The date remains an advance control with or without its optional frame.
|
||||
if (item.kind == 58) return request(DeskRequestKind::advance_turn, item);
|
||||
const int content_x = item.x + (item.open ? 4 : 0);
|
||||
if (item.kind == 55 && !state_.national_team && x - content_x > 34 && x - content_x < 87)
|
||||
return request(DeskRequestKind::change_ticket_price, item, (x - content_x - 35) / 3 + 8);
|
||||
if (item.kind == 64) return request(DeskRequestKind::change_option, item, std::clamp((x - content_x) / 33, 0, 4));
|
||||
return {}; // Noninteractive status fields must not invent layout/game changes.
|
||||
}
|
||||
return {};
|
||||
@@ -733,8 +739,17 @@ void DesktopScreen::acknowledge(DeskState updated) {
|
||||
Image next_badge = badge_;
|
||||
if ((updated.badge >> 3) != (state_.badge >> 3))
|
||||
next_badge = load_vga(asset_path(data_ / "W", std::to_string(updated.badge >> 3) + ".VGA"));
|
||||
// The opponent changes from day to day: its badge sheet (one W file holds eight badges) is
|
||||
// reloaded with the state, not kept from the day the screen was built.
|
||||
std::optional<Image> next_opponent_badge;
|
||||
if (updated.next_opponent && *updated.next_opponent >= 0 && updated.next_opponent_badge &&
|
||||
!updated.next_opponent_badge_fallback) {
|
||||
const int selector = *updated.next_opponent_badge & 0x1ff;
|
||||
next_opponent_badge = load_vga(asset_path(data_ / "W", std::to_string(selector >> 3) + ".VGA"));
|
||||
}
|
||||
shortcut_bar_visible_ = updated.shortcut_bar_always || shortcut_bar_edge_toggle_;
|
||||
state_ = std::move(updated); badge_ = std::move(next_badge);
|
||||
next_opponent_badge_ = std::move(next_opponent_badge);
|
||||
pending_.reset(); last_rejection_.clear();
|
||||
}
|
||||
void DesktopScreen::acknowledge_mailbox_parent(DeskState updated) {
|
||||
|
||||
+362
-255
@@ -315,8 +315,14 @@ void calendar_projection_tests(const LeImage& exe) {
|
||||
"saved calendar mask 0xa2594 clears effective bit 0x10");
|
||||
|
||||
auto malformed = calendar_fixture(exe,0,0);
|
||||
malformed.memory.set16(::bmh::layout::CalendarState_FormatError_RuntimeField3,1);
|
||||
malformed.season_start = 5; // the origin of the season lies after the current date
|
||||
rejected([&]{ calendar_from_game(malformed,exe); });
|
||||
// the memory copies of origin and day hold only the day the game was loaded: after a kickoff the
|
||||
// live values rule (this failed the calendar from the first kickoff on)
|
||||
auto advanced = calendar_fixture(exe,0,0);
|
||||
advanced.date = 24;
|
||||
check(calendar_from_game(advanced,exe).current_day == 24,
|
||||
"the calendar follows the live day of the season, not the load-day copy in memory");
|
||||
auto outside = calendar_fixture(exe,0,0);
|
||||
outside.date = 365;
|
||||
rejected([&]{ calendar_from_game(outside,exe); });
|
||||
@@ -592,13 +598,354 @@ void set_preparation_revision_source(PreparationState& state, uint64_t revision,
|
||||
if(state.pitch){state.pitch->revision=revision;state.pitch->source=source;}
|
||||
for(auto& card:state.player_cards){card.lineup.revision=revision;card.lineup.source=source;}
|
||||
}
|
||||
// Pointer regressions share synthetic desktop records across supported editions.
|
||||
void folder_pointer_input_tests(const std::filesystem::path& data,const LeImage& exe) {
|
||||
auto menu_game = fixture();
|
||||
menu_game.memory.set8(::bmh::layout::Desktops + 44 * 16 + 12, 63); // mailbox occurs before the menu shortcut in this scan
|
||||
menu_game.memory.set8(::bmh::layout::Desktops + 53 * 16 + 12, 72); // final compact-bar cell dispatches MEN
|
||||
auto menu_desk = desk_from_game(menu_game, exe, 6);
|
||||
check(menu_desk.mailbox_shortcut && menu_desk.menu_layout_shortcut &&
|
||||
menu_desk.menu_layout_shortcut->id == 53,
|
||||
"Source final compact-bar cell resolves record 53/kind 72 independently of linked drawers");
|
||||
menu_desk.shortcut_bar_always = false;
|
||||
DesktopScreen edge_bar(data, menu_desk);
|
||||
const auto edge_hidden = edge_bar.render();
|
||||
check(!edge_bar.pointer_move(160, 238), "Source quickbar edge requires exactly y239");
|
||||
check(edge_bar.pointer_move(160, 239) && edge_bar.render().pixels != edge_hidden.pixels &&
|
||||
!edge_bar.pending() && edge_bar.state().layout_records == menu_desk.layout_records,
|
||||
"lower-edge motion shows quickbar without an action or Native layout edits");
|
||||
const auto edge_shown = edge_bar.render();
|
||||
const auto quickbar_art = load_vga(asset_path(data / "KB", "3.VGA"));
|
||||
for (int y = 0; y < 20; ++y) for (int x = 0; x < 20; ++x)
|
||||
check(edge_shown.pixels[size_t(207 + y) * 320 + 299 + x] ==
|
||||
quickbar_art.pixels[size_t(75 + y) * quickbar_art.width + exe.u8(::bmh::layout::Desktop_Render_RuntimeField3) + x],
|
||||
"visible Source quickbar copies the complete normal socket sprite before any press");
|
||||
check(!edge_bar.pointer_move(250, 239) && edge_bar.click(250, 239).kind == DeskRequestKind::none &&
|
||||
edge_bar.render().pixels == edge_shown.pixels,
|
||||
"motion along edge and click at the same edge do not toggle the Source y latch twice");
|
||||
check(edge_bar.pointer_move(292, 221), "MEN quickbar cell motion selects its Source hover label");
|
||||
const auto hover_frame = edge_bar.render();
|
||||
int hover_pixels = 0;
|
||||
for (int y = 0; y < 240; ++y) for (int x = 0; x < 320; ++x)
|
||||
if (hover_frame.pixels[size_t(y) * 320 + x] != edge_shown.pixels[size_t(y) * 320 + x]) {
|
||||
check(y >= 230 && y <= 235, "Source quickbar label changes only the footer Font3 rows");
|
||||
++hover_pixels;
|
||||
}
|
||||
check(hover_pixels > 0 && !edge_bar.pointer_move(291, 221),
|
||||
"Source hover title renders once and stays stable inside the same cell");
|
||||
check(edge_bar.pointer_move(160, 238) && edge_bar.render().pixels == edge_shown.pixels,
|
||||
"leaving the cell restores the footer without hiding the quickbar");
|
||||
check(edge_bar.pointer_move(160, 239) && edge_bar.render().pixels == edge_hidden.pixels,
|
||||
"re-entering the lower edge toggles the quickbar off without a click");
|
||||
auto always_desk = menu_desk; always_desk.shortcut_bar_always = true;
|
||||
DesktopScreen always_bar(data, always_desk);
|
||||
const auto always_frame = always_bar.render();
|
||||
always_bar.pointer_move(160, 239); always_bar.pointer_move(160, 238); always_bar.pointer_move(160, 239);
|
||||
check(always_bar.render().pixels == always_frame.pixels && !always_bar.pending(),
|
||||
"format field bit1 keeps Always quickbar visible through both bit0 edge transitions");
|
||||
DesktopScreen menu_bar(data, menu_desk);
|
||||
check(menu_bar.click(292,221).kind == DeskRequestKind::none,
|
||||
"MEN shortcut is unavailable before the original compact bar is shown");
|
||||
menu_bar.pointer_move(64,239);
|
||||
auto menu_save = menu_bar.click(292,221);
|
||||
check(menu_save.kind == DeskRequestKind::open_menu && menu_save.menu_kind == 53 &&
|
||||
menu_save.item_id == 53 && menu_save.value == 1,
|
||||
"compact last-cell left click opens the Original menu-layout save path from record 53");
|
||||
menu_bar.resolve_local_menu();
|
||||
auto menu_load = menu_bar.click(292,221,true);
|
||||
check(menu_load.kind == DeskRequestKind::open_menu && menu_load.menu_kind == 53 &&
|
||||
menu_load.item_id == 53 && menu_load.value == 0,
|
||||
"compact last-cell right click opens the Original menu-layout load path from record 53");
|
||||
auto quickbar_drawer = menu_desk;
|
||||
quickbar_drawer.layout_records[50][5]=0xff;
|
||||
quickbar_drawer.layout_records[50][6]=0xff;
|
||||
quickbar_drawer.layout_records[50][12]=50;
|
||||
DesktopScreen quickbar_open(data,quickbar_drawer);
|
||||
quickbar_open.pointer_move(64,239);
|
||||
const auto append_drawer=quickbar_open.click(22,221);
|
||||
check(quickbar_open.take_sound_ids()==std::vector<uint8_t>{15} && quickbar_open.take_sound_ids().empty(),
|
||||
"Source drawer append emits ID15 exactly once through the application boundary");
|
||||
quickbar_open.render(); quickbar_open.pointer_move(23,221); quickbar_open.click(22,221);
|
||||
check(quickbar_open.take_sound_ids().empty(),"render/hover/pending input never replay a drawer sound");
|
||||
check(append_drawer.kind==DeskRequestKind::change_layout&&
|
||||
append_drawer.layout_operation==DeskLayoutOperation::toggle_quickbar_drawer&&
|
||||
append_drawer.layout_after[50*16+5]==0&&append_drawer.layout_after[50*16+13]&0x80,
|
||||
"Original quickbar LMB appends a hidden drawer record and sets its open bit");
|
||||
auto quickbar_close_state=menu_desk;
|
||||
quickbar_close_state.layout_records[0][5]=50;
|
||||
quickbar_close_state.layout_records[50][5]=0;
|
||||
quickbar_close_state.layout_records[50][6]=0;
|
||||
quickbar_close_state.layout_records[50][12]=50;
|
||||
DesktopScreen quickbar_close(data,quickbar_close_state);
|
||||
quickbar_close.pointer_move(64,239);
|
||||
const auto unlink_drawer=quickbar_close.click(22,221,true);
|
||||
check(quickbar_close.take_sound_ids()==std::vector<uint8_t>{12},"Source drawer unlink emits ID12");
|
||||
check(unlink_drawer.kind==DeskRequestKind::change_layout&&
|
||||
unlink_drawer.layout_operation==DeskLayoutOperation::toggle_quickbar_drawer&&
|
||||
unlink_drawer.layout_after[0*16+5]==0&&unlink_drawer.layout_after[50*16+5]==0xff&&
|
||||
unlink_drawer.layout_after[50*16+6]==0xff,
|
||||
"Original quickbar RMB unlinks a visible drawer record with cleared links");
|
||||
auto child_desk=menu_desk;
|
||||
child_desk.layout_records[3][5]=child_desk.layout_records[3][6]=0xff;
|
||||
child_desk.layout_records[3][12]=2;
|
||||
child_desk.layout_records[3][13]=0;
|
||||
child_desk.layout_records[49][12]=50;
|
||||
child_desk.layout_records[49][13]=0x80;
|
||||
child_desk.layout_records[0][5]=49;
|
||||
child_desk.layout_records[49][5]=child_desk.layout_records[49][6]=0;
|
||||
child_desk.folder_icon_slots[0]={3};
|
||||
child_desk.drawer_handles=true;
|
||||
child_desk.items.push_back(DeskItem{49,40,40,100,65,50,0,0,true,false});
|
||||
DesktopScreen folder_click(data,child_desk);
|
||||
const auto child_action=folder_click.click(50,49);
|
||||
check(child_action.kind==DeskRequestKind::open_menu&&child_action.item_id==3&&child_action.menu_kind==2,
|
||||
"Source folder child uses its native record/kind on ordinary LMB activation");
|
||||
DesktopScreen folder_drag(data,child_desk);
|
||||
folder_drag.pointer_down(50,49,true);
|
||||
check(folder_drag.take_sound_ids()==std::vector<uint8_t>({15,12,15}),
|
||||
"folder-child RMB start preserves Source restore/unlink/append ordering");
|
||||
folder_drag.pointer_move(176,100);
|
||||
const auto child_return=folder_drag.pointer_up(176,100,true);
|
||||
check(child_return.kind==DeskRequestKind::change_layout&&
|
||||
child_return.layout_operation==DeskLayoutOperation::return_folder_child&&
|
||||
child_return.layout_before[3*16+5]==0xff&&child_return.layout_after[0*16+5]==49&&
|
||||
child_return.layout_after[49*16+5]==3&&child_return.layout_after[3*16+5]==0&&
|
||||
child_return.layout_after[3*16+6]==49,
|
||||
"RMB drag from the rendered 32×25 folder tile returns it to the visible chain");
|
||||
check(folder_drag.take_sound_ids().empty(),"folder-child release cannot replay its down-event append");
|
||||
// Unframed folders render the same tiles four pixels nearer the origin.
|
||||
auto unframed_child_desk=child_desk;
|
||||
unframed_child_desk.layout_snap=true;
|
||||
unframed_child_desk.items.back().open=false;
|
||||
unframed_child_desk.items.back().width=50;
|
||||
unframed_child_desk.items.back().height=41;
|
||||
unframed_child_desk.layout_records[49][13]=0;
|
||||
unframed_child_desk.layout_records[13]=unframed_child_desk.layout_records[3];
|
||||
unframed_child_desk.layout_records[13][12]=12;
|
||||
unframed_child_desk.folder_icon_slots[0]={13};
|
||||
DesktopScreen unframed_child(data,unframed_child_desk);
|
||||
check(unframed_child.pointer_down(46,45).kind==DeskRequestKind::none &&
|
||||
unframed_child.pointer_up(46,45).kind==DeskRequestKind::advance_turn,
|
||||
"LMB on an unframed folder tile activates its native kickoff action");
|
||||
DesktopScreen unframed_drag(data,unframed_child_desk);
|
||||
unframed_drag.pointer_down(46,45,true);
|
||||
check(unframed_drag.take_sound_ids()==std::vector<uint8_t>({15,12,15}),
|
||||
"unframed child starts extraction rather than dragging the folder body");
|
||||
unframed_drag.pointer_move(176,100);
|
||||
const auto unframed_return=unframed_drag.pointer_up(176,100,true);
|
||||
check(unframed_return.item_id==13 && unframed_return.menu_kind==12 &&
|
||||
unframed_return.layout_operation==DeskLayoutOperation::return_folder_child &&
|
||||
unframed_return.layout_after[13*16]==175 && unframed_return.layout_after[13*16+2]==95 &&
|
||||
unframed_return.layout_after[49*16+5]==13,
|
||||
"RMB extraction uses the rendered unframed tile origin and returns the kickoff icon");
|
||||
DesktopScreen folder_drop(data,child_desk);
|
||||
folder_drop.pointer_down(50,49,true); folder_drop.take_sound_ids();
|
||||
folder_drop.pointer_move(55,52);
|
||||
const auto dropped_child=folder_drop.pointer_up(55,52,true);
|
||||
check(dropped_child.layout_operation==DeskLayoutOperation::set_folder &&
|
||||
folder_drop.take_sound_ids()==std::vector<uint8_t>{12},
|
||||
"Source fully enclosed drop unlinks the dragged child exactly once");
|
||||
DesktopScreen folder_corner(data,child_desk);
|
||||
const auto corner_close=folder_corner.pointer_down(41,41);
|
||||
check(corner_close.kind==DeskRequestKind::change_layout &&
|
||||
corner_close.layout_operation==DeskLayoutOperation::toggle_quickbar_drawer &&
|
||||
corner_close.item_id==49 && corner_close.layout_target_item==49 &&
|
||||
corner_close.layout_after[5]==0 && corner_close.layout_after[49*16+5]==0xff &&
|
||||
corner_close.layout_after[49*16+6]==0xff &&
|
||||
folder_corner.take_sound_ids()==std::vector<uint8_t>{12},
|
||||
"framed folder LMB corner unlinks its native record and emits the Source removal sound");
|
||||
auto without_folder=child_desk; ++without_folder.revision;
|
||||
without_folder.items.pop_back();
|
||||
for(size_t i=0;i<54;++i)
|
||||
std::copy_n(corner_close.layout_after.begin()+i*16,16,without_folder.layout_records[i].begin());
|
||||
folder_corner.acknowledge(without_folder);
|
||||
check(folder_corner.pointer_up(41,41).kind==DeskRequestKind::none &&
|
||||
!folder_corner.pending() && folder_corner.take_sound_ids().empty(),
|
||||
"folder removal owns its release after ACK without activating the underlying date");
|
||||
check(folder_corner.pointer_up(41,41).kind==DeskRequestKind::advance_turn,
|
||||
"folder removal release barrier leaves a subsequent independent date click available");
|
||||
auto covered_child=child_desk;
|
||||
covered_child.items.push_back(DeskItem{6,60,48,32,25,21,0,0,false,false});
|
||||
covered_child.layout_records[49][5]=6;
|
||||
covered_child.layout_records[6][5]=0;
|
||||
covered_child.layout_records[6][6]=49;
|
||||
covered_child.layout_records[6][12]=21;
|
||||
DesktopScreen stacked_icon(data,covered_child);
|
||||
const auto exposed_folder_frame=folder_click.render();
|
||||
const auto covered_folder_frame=stacked_icon.render();
|
||||
const auto desktop_atlas=load_vga(asset_path(data/"KB","3.VGA"));
|
||||
for(int y=0;y<25;++y) for(int x=0;x<32;++x)
|
||||
check(covered_folder_frame.pixels[size_t(48+y)*320+60+x]==
|
||||
desktop_atlas.pixels[size_t(50+y)*desktop_atlas.width+160+x],
|
||||
"top icon renders over the folder child using its own native KB3 tile");
|
||||
check(covered_folder_frame.pixels[size_t(49)*320+50]==exposed_folder_frame.pixels[size_t(49)*320+50],
|
||||
"the uncovered part of a folder child remains visible below the stacked icon");
|
||||
const auto covering_icon_action=stacked_icon.click(65,49);
|
||||
check(covering_icon_action.kind==DeskRequestKind::open_menu&&covering_icon_action.item_id==6&&
|
||||
covering_icon_action.menu_kind==21&&stacked_icon.state().layout_records==covered_child.layout_records,
|
||||
"LMB activates the rendered top icon rather than the covered folder child without layout edits");
|
||||
DesktopScreen stacked_drag(data,covered_child);
|
||||
stacked_drag.pointer_down(65,49,true);
|
||||
check(stacked_drag.take_sound_ids()==std::vector<uint8_t>({12,15}),
|
||||
"visible RMB drag starts with the Source unlink/append pair");
|
||||
stacked_drag.pointer_move(200,120);
|
||||
const auto covering_icon_drag=stacked_drag.pointer_up(200,120,true);
|
||||
check(covering_icon_drag.kind==DeskRequestKind::change_layout&&covering_icon_drag.item_id==6&&
|
||||
covering_icon_drag.layout_operation==DeskLayoutOperation::move_item&&
|
||||
covering_icon_drag.layout_after[3*16+5]==0xff&&covering_icon_drag.layout_after[3*16+6]==0xff,
|
||||
"RMB drags the rendered top icon and leaves the covered child outside the visible link chain");
|
||||
check(stacked_drag.take_sound_ids().empty(),"ordinary move release adds no structural sound");
|
||||
DesktopScreen still_drag(data,covered_child);
|
||||
still_drag.pointer_down(65,49,true); still_drag.pointer_up(65,49,true);
|
||||
check(still_drag.take_sound_ids()==std::vector<uint8_t>({12,15}),
|
||||
"Source RMB reordering sounds happen even without pointer motion");
|
||||
DesktopScreen exposed_child(data,covered_child);
|
||||
check(exposed_child.click(50,49).item_id==3,"an exposed folder tile still opens its native child action");
|
||||
auto status_cover=child_desk;
|
||||
status_cover.items.push_back(DeskItem{48,48,48,42,35,56,0,0,true,false});
|
||||
DesktopScreen stacked_status(data,status_cover);
|
||||
check(stacked_status.render().pixels!=exposed_folder_frame.pixels&&
|
||||
stacked_status.pointer_down(50,49).kind==DeskRequestKind::none&&
|
||||
stacked_status.pointer_up(50,49).kind==DeskRequestKind::none&&!stacked_status.pending(),
|
||||
"an open status drawer covers a folder child and its inert body cannot activate that child");
|
||||
auto empty_folder_cover=child_desk;
|
||||
empty_folder_cover.items.push_back(DeskItem{48,48,48,45,35,51,0,1,true,false});
|
||||
DesktopScreen stacked_empty_folder(data,empty_folder_cover);
|
||||
check(stacked_empty_folder.click(50,49).kind==DeskRequestKind::none&&!stacked_empty_folder.pending(),
|
||||
"an empty part of the top folder blocks a lower folder child");
|
||||
DesktopScreen covered_bin_restore(data,empty_folder_cover);
|
||||
covered_bin_restore.pointer_move(160,239);
|
||||
covered_bin_restore.click(10,215);
|
||||
check(covered_bin_restore.pointer_down(50,49,true).kind==DeskRequestKind::none&&
|
||||
covered_bin_restore.pointer_up(50,49,true).kind==DeskRequestKind::none&&
|
||||
!covered_bin_restore.pending()&&covered_bin_restore.state().layout_records==empty_folder_cover.layout_records,
|
||||
"bin-mode RMB on a covering empty folder cannot restore the lower child or change links");
|
||||
check(covered_bin_restore.take_sound_ids().empty(),"covered bin child cannot emit a restore sound");
|
||||
DesktopScreen exposed_bin_restore(data,covered_child);
|
||||
exposed_bin_restore.pointer_move(160,239);
|
||||
exposed_bin_restore.click(10,215);
|
||||
const auto exposed_restore=exposed_bin_restore.click(50,49,true);
|
||||
check(exposed_bin_restore.take_sound_ids()==std::vector<uint8_t>{15},"bin-mode restore emits only append ID15");
|
||||
check(exposed_restore.layout_operation==DeskLayoutOperation::restore_folder_child&&exposed_restore.item_id==3,
|
||||
"bin-mode RMB still restores an exposed folder child using its native owner");
|
||||
DesktopScreen bin_send(data,covered_child);
|
||||
bin_send.pointer_move(160,239); bin_send.click(10,215);
|
||||
const auto sent_icon=bin_send.click(65,49,true);
|
||||
check(sent_icon.layout_operation==DeskLayoutOperation::send_to_folder &&
|
||||
bin_send.take_sound_ids()==std::vector<uint8_t>{12},"bin-mode send emits only unlink ID12");
|
||||
auto closed_cover=child_desk;
|
||||
closed_cover.items.push_back(DeskItem{48,48,48,14,14,63,0,0,false,false});
|
||||
DesktopScreen stacked_closed_drawer(data,closed_cover);
|
||||
check(stacked_closed_drawer.click(50,49).kind==DeskRequestKind::none&&!stacked_closed_drawer.pending(),
|
||||
"a closed drawer blocks hits inside its Source dimensions minus eight");
|
||||
DesktopScreen outside_closed_drawer(data,closed_cover);
|
||||
check(outside_closed_drawer.click(55,49).item_id==3,
|
||||
"the eight-pixel closed drawer inset allows hits on the exposed lower folder child");
|
||||
const auto menu_test_dir = std::filesystem::temp_directory_path() /
|
||||
("openbmh-menu-layout-picker-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
std::filesystem::create_directories(menu_test_dir / "load");
|
||||
std::filesystem::create_directories(menu_test_dir / "save");
|
||||
{ std::ofstream(menu_test_dir / "load" / "LAYOUT.MEN") << "fixture";
|
||||
std::ofstream(menu_test_dir / "load" / "NOTGAME.FBM") << "fixture"; }
|
||||
SaveLoadScreen menu_load_picker(data, menu_test_dir / "load", SaveLoadMode::load, 0, 6,
|
||||
menu_bar.render(), true, SaveLoadFileKind::menu_layout, 52);
|
||||
check(menu_load_picker.entries().size() == 1 &&
|
||||
menu_load_picker.entries()[0].path.extension() == ".MEN" &&
|
||||
!menu_load_picker.info_press(60,45),
|
||||
"menu-layout picker filters to MEN and never interprets a layout as an FBM information header");
|
||||
menu_load_picker.click(60,45); menu_load_picker.click(60,45);
|
||||
check(menu_load_picker.pending() && menu_load_picker.pending()->file_kind == SaveLoadFileKind::menu_layout &&
|
||||
menu_load_picker.pending()->origin_item_id == 52 &&
|
||||
menu_load_picker.pending()->path.extension() == ".MEN",
|
||||
"MEN load request retains its typed file kind and source drawer identity");
|
||||
SaveLoadScreen menu_save_picker(data, menu_test_dir / "save", SaveLoadMode::save, 0, 6,
|
||||
menu_bar.render(), true, SaveLoadFileKind::menu_layout, 52);
|
||||
menu_save_picker.click(120,214); menu_save_picker.text("LAYOUT"); menu_save_picker.key("ENTER");
|
||||
check(menu_save_picker.pending() && menu_save_picker.pending()->file_kind == SaveLoadFileKind::menu_layout &&
|
||||
menu_save_picker.pending()->path.filename() == "LAYOUT.MEN" &&
|
||||
save_load_request_json(*menu_save_picker.pending()).find("\"file_kind\":\"menu_layout\"") != std::string::npos,
|
||||
"MEN save request uses the native extension and an explicit JSON file-kind discriminator");
|
||||
std::filesystem::remove_all(menu_test_dir);
|
||||
}
|
||||
|
||||
void desktop_control_input_tests(const std::filesystem::path& data,DeskState& d) {
|
||||
DesktopScreen desk(data,d);
|
||||
const auto pixels = desk.render().pixels;
|
||||
check(desk.render().pixels == pixels,"repeat render is deterministic");
|
||||
check(desk.click(5,23).kind == DeskRequestKind::none,"calendar handle must not advance a turn");
|
||||
auto action = desk.click(50,125);
|
||||
check(action.kind == DeskRequestKind::open_menu && action.menu_kind == 3 && action.manager_slot == 0 && action.revision == 10,"lineup request");
|
||||
check(desk.click(20,40).kind == DeskRequestKind::none,"pending command blocks another turn");
|
||||
rejected([&]{ desk.acknowledge(d); });
|
||||
++d.revision; desk.acknowledge(d);
|
||||
check(desk.click(20,40).kind == DeskRequestKind::advance_turn,"open calendar advances");
|
||||
check(desk.click(20,40).kind == DeskRequestKind::none,"no duplicate advance request");
|
||||
++d.revision; desk.acknowledge(d);
|
||||
check(desk.click(165,125).kind == DeskRequestKind::advance_turn,"kickoff icon advances");
|
||||
auto unframed_date=d;
|
||||
unframed_date.items.front().open=false;
|
||||
unframed_date.layout_records[1][13]&=0x7f;
|
||||
DesktopScreen date_click(data,unframed_date);
|
||||
check(date_click.pointer_down(20,40).kind==DeskRequestKind::none,
|
||||
"date press waits for its release without entering layout drag");
|
||||
const auto date_turn=date_click.pointer_up(20,40);
|
||||
check(date_turn.kind==DeskRequestKind::advance_turn && date_turn.menu_kind==58 &&
|
||||
date_turn.manager_slot==d.manager_slot && date_turn.revision==d.revision &&
|
||||
date_click.pointer_up(20,40).kind==DeskRequestKind::none,
|
||||
"unframed date body emits exactly one authenticated advance action");
|
||||
DesktopScreen date_drag(data,unframed_date);
|
||||
date_drag.pointer_down(20,40,true); date_drag.pointer_move(40,60);
|
||||
check(date_drag.pointer_up(40,60,true).layout_operation==DeskLayoutOperation::move_item,
|
||||
"unframed date retains right-button movement");
|
||||
check(desk.render().pixels == pixels,"commands cannot mutate the saved game view");
|
||||
for(bool framed : {true,false}) {
|
||||
auto controls=d;
|
||||
controls.items={{1,20,80,98,36,55,0,0,framed,false},
|
||||
{2,20,130,173,38,64,0,0,framed,false}};
|
||||
const int origin=20+(framed?4:0);
|
||||
for(int offset : {34,35,86,87}) {
|
||||
DesktopScreen price_control(data,controls);
|
||||
price_control.pointer_down(origin+offset,90);
|
||||
const auto price_action=price_control.pointer_up(origin+offset,90);
|
||||
check(price_action.kind==((offset==35||offset==86)?
|
||||
DeskRequestKind::change_ticket_price:DeskRequestKind::none),
|
||||
"framed and unframed admission controls use the rendered Source endpoints");
|
||||
if(offset==35||offset==86)
|
||||
check(price_action.value==(offset==35?8:25),"admission endpoint preserves its exact value");
|
||||
}
|
||||
for(int offset : {32,33,65,66,98,99,131,132}) {
|
||||
DesktopScreen automation_control(data,controls);
|
||||
automation_control.pointer_down(origin+offset,140);
|
||||
const auto option_action=automation_control.pointer_up(origin+offset,140);
|
||||
check(option_action.kind==DeskRequestKind::change_option && option_action.value==offset/33,
|
||||
"automation cell boundaries follow the optional frame offset");
|
||||
}
|
||||
}
|
||||
desk.reject_action("unsupported_menu");
|
||||
check(!desk.pending() && desk.render().pixels == pixels,"rejected command preserves state");
|
||||
check(desk.key("A").menu_kind == 3,"original A hotkey opens lineup");
|
||||
desk.reject_action("not_implemented");
|
||||
check(desk.key("D").menu_kind == 18,"original D hotkey opens tactics");
|
||||
desk.reject_action("not_implemented");
|
||||
check(desk.key("I").menu_kind == 16 && desk_menu_name(16)=="training" && desk_menu_name(15)=="training_camp",
|
||||
"original I and dispatch distinguish training from training camp");
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
try {
|
||||
paired_closing_selection();
|
||||
if (argc < 2) throw std::runtime_error("data directory required");
|
||||
const bool input_only=argc>2 && std::string_view(argv[2])=="--input-only";
|
||||
const std::filesystem::path data = argv[1]; const auto exe = bmh::test::load_executable(asset_path(data,"BMH.exe"));
|
||||
if(input_only) {
|
||||
folder_pointer_input_tests(data,exe);
|
||||
auto input_desk=desk_from_game(fixture(),exe,10);
|
||||
desktop_control_input_tests(data,input_desk);
|
||||
std::cout << "Desktop pointer, folders, removal corners and framed/unframed controls passed.\n";
|
||||
return 0;
|
||||
}
|
||||
paired_closing_selection();
|
||||
paired_selection_matrix(exe);
|
||||
if(argc>3)paired_saved_projection(argv[3],exe);
|
||||
// The date arithmetic is checked against a controlled epoch aligned with
|
||||
@@ -667,234 +1014,7 @@ int main(int argc, char** argv) {
|
||||
check(ranked_high_frame.pixels[size_t(50)*size_t(ranked_high_frame.width)+150]==
|
||||
source_ranked_art.pixels[size_t(25)*size_t(source_ranked_art.width)+50],
|
||||
"ranked menu-26 copies Source decimal asset 51 (legacy routine argument 0x33)");
|
||||
auto menu_game = fixture();
|
||||
menu_game.memory.set8(::bmh::layout::Desktops + 44 * 16 + 12, 63); // mailbox occurs before the menu shortcut in this scan
|
||||
menu_game.memory.set8(::bmh::layout::Desktops + 53 * 16 + 12, 72); // final compact-bar cell dispatches MEN
|
||||
auto menu_desk = desk_from_game(menu_game, exe, 6);
|
||||
check(menu_desk.mailbox_shortcut && menu_desk.menu_layout_shortcut &&
|
||||
menu_desk.menu_layout_shortcut->id == 53,
|
||||
"Source final compact-bar cell resolves record 53/kind 72 independently of linked drawers");
|
||||
menu_desk.shortcut_bar_always = false;
|
||||
DesktopScreen edge_bar(data, menu_desk);
|
||||
const auto edge_hidden = edge_bar.render();
|
||||
check(!edge_bar.pointer_move(160, 238), "Source quickbar edge requires exactly y239");
|
||||
check(edge_bar.pointer_move(160, 239) && edge_bar.render().pixels != edge_hidden.pixels &&
|
||||
!edge_bar.pending() && edge_bar.state().layout_records == menu_desk.layout_records,
|
||||
"lower-edge motion shows quickbar without an action or Native layout edits");
|
||||
const auto edge_shown = edge_bar.render();
|
||||
const auto quickbar_art = load_vga(asset_path(data / "KB", "3.VGA"));
|
||||
for (int y = 0; y < 20; ++y) for (int x = 0; x < 20; ++x)
|
||||
check(edge_shown.pixels[size_t(207 + y) * 320 + 299 + x] ==
|
||||
quickbar_art.pixels[size_t(75 + y) * quickbar_art.width + exe.u8(::bmh::layout::Desktop_Render_RuntimeField3) + x],
|
||||
"visible Source quickbar copies the complete normal socket sprite before any press");
|
||||
check(!edge_bar.pointer_move(250, 239) && edge_bar.click(250, 239).kind == DeskRequestKind::none &&
|
||||
edge_bar.render().pixels == edge_shown.pixels,
|
||||
"motion along edge and click at the same edge do not toggle the Source y latch twice");
|
||||
check(edge_bar.pointer_move(292, 221), "MEN quickbar cell motion selects its Source hover label");
|
||||
const auto hover_frame = edge_bar.render();
|
||||
int hover_pixels = 0;
|
||||
for (int y = 0; y < 240; ++y) for (int x = 0; x < 320; ++x)
|
||||
if (hover_frame.pixels[size_t(y) * 320 + x] != edge_shown.pixels[size_t(y) * 320 + x]) {
|
||||
check(y >= 230 && y <= 235, "Source quickbar label changes only the footer Font3 rows");
|
||||
++hover_pixels;
|
||||
}
|
||||
check(hover_pixels > 0 && !edge_bar.pointer_move(291, 221),
|
||||
"Source hover title renders once and stays stable inside the same cell");
|
||||
check(edge_bar.pointer_move(160, 238) && edge_bar.render().pixels == edge_shown.pixels,
|
||||
"leaving the cell restores the footer without hiding the quickbar");
|
||||
check(edge_bar.pointer_move(160, 239) && edge_bar.render().pixels == edge_hidden.pixels,
|
||||
"re-entering the lower edge toggles the quickbar off without a click");
|
||||
auto always_desk = menu_desk; always_desk.shortcut_bar_always = true;
|
||||
DesktopScreen always_bar(data, always_desk);
|
||||
const auto always_frame = always_bar.render();
|
||||
always_bar.pointer_move(160, 239); always_bar.pointer_move(160, 238); always_bar.pointer_move(160, 239);
|
||||
check(always_bar.render().pixels == always_frame.pixels && !always_bar.pending(),
|
||||
"format field bit1 keeps Always quickbar visible through both bit0 edge transitions");
|
||||
DesktopScreen menu_bar(data, menu_desk);
|
||||
check(menu_bar.click(292,221).kind == DeskRequestKind::none,
|
||||
"MEN shortcut is unavailable before the original compact bar is shown");
|
||||
menu_bar.pointer_move(64,239);
|
||||
auto menu_save = menu_bar.click(292,221);
|
||||
check(menu_save.kind == DeskRequestKind::open_menu && menu_save.menu_kind == 53 &&
|
||||
menu_save.item_id == 53 && menu_save.value == 1,
|
||||
"compact last-cell left click opens the Original menu-layout save path from record 53");
|
||||
menu_bar.resolve_local_menu();
|
||||
auto menu_load = menu_bar.click(292,221,true);
|
||||
check(menu_load.kind == DeskRequestKind::open_menu && menu_load.menu_kind == 53 &&
|
||||
menu_load.item_id == 53 && menu_load.value == 0,
|
||||
"compact last-cell right click opens the Original menu-layout load path from record 53");
|
||||
auto quickbar_drawer = menu_desk;
|
||||
quickbar_drawer.layout_records[50][5]=0xff;
|
||||
quickbar_drawer.layout_records[50][6]=0xff;
|
||||
quickbar_drawer.layout_records[50][12]=50;
|
||||
DesktopScreen quickbar_open(data,quickbar_drawer);
|
||||
quickbar_open.pointer_move(64,239);
|
||||
const auto append_drawer=quickbar_open.click(22,221);
|
||||
check(quickbar_open.take_sound_ids()==std::vector<uint8_t>{15} && quickbar_open.take_sound_ids().empty(),
|
||||
"Source drawer append emits ID15 exactly once through the application boundary");
|
||||
quickbar_open.render(); quickbar_open.pointer_move(23,221); quickbar_open.click(22,221);
|
||||
check(quickbar_open.take_sound_ids().empty(),"render/hover/pending input never replay a drawer sound");
|
||||
check(append_drawer.kind==DeskRequestKind::change_layout&&
|
||||
append_drawer.layout_operation==DeskLayoutOperation::toggle_quickbar_drawer&&
|
||||
append_drawer.layout_after[50*16+5]==0&&append_drawer.layout_after[50*16+13]&0x80,
|
||||
"Original quickbar LMB appends a hidden drawer record and sets its open bit");
|
||||
auto quickbar_close_state=menu_desk;
|
||||
quickbar_close_state.layout_records[0][5]=50;
|
||||
quickbar_close_state.layout_records[50][5]=0;
|
||||
quickbar_close_state.layout_records[50][6]=0;
|
||||
quickbar_close_state.layout_records[50][12]=50;
|
||||
DesktopScreen quickbar_close(data,quickbar_close_state);
|
||||
quickbar_close.pointer_move(64,239);
|
||||
const auto unlink_drawer=quickbar_close.click(22,221,true);
|
||||
check(quickbar_close.take_sound_ids()==std::vector<uint8_t>{12},"Source drawer unlink emits ID12");
|
||||
check(unlink_drawer.kind==DeskRequestKind::change_layout&&
|
||||
unlink_drawer.layout_operation==DeskLayoutOperation::toggle_quickbar_drawer&&
|
||||
unlink_drawer.layout_after[0*16+5]==0&&unlink_drawer.layout_after[50*16+5]==0xff&&
|
||||
unlink_drawer.layout_after[50*16+6]==0xff,
|
||||
"Original quickbar RMB unlinks a visible drawer record with cleared links");
|
||||
auto child_desk=menu_desk;
|
||||
child_desk.layout_records[3][5]=child_desk.layout_records[3][6]=0xff;
|
||||
child_desk.layout_records[3][12]=2;
|
||||
child_desk.layout_records[3][13]=0;
|
||||
child_desk.layout_records[49][12]=50;
|
||||
child_desk.layout_records[49][13]=0x80;
|
||||
child_desk.layout_records[0][5]=49;
|
||||
child_desk.layout_records[49][5]=child_desk.layout_records[49][6]=0;
|
||||
child_desk.folder_icon_slots[0]={3};
|
||||
child_desk.drawer_handles=true;
|
||||
child_desk.items.push_back(DeskItem{49,40,40,100,65,50,0,0,true,false});
|
||||
DesktopScreen folder_click(data,child_desk);
|
||||
const auto child_action=folder_click.click(50,49);
|
||||
check(child_action.kind==DeskRequestKind::open_menu&&child_action.item_id==3&&child_action.menu_kind==2,
|
||||
"Source folder child uses its native record/kind on ordinary LMB activation");
|
||||
DesktopScreen folder_drag(data,child_desk);
|
||||
folder_drag.pointer_down(50,49,true);
|
||||
check(folder_drag.take_sound_ids()==std::vector<uint8_t>({15,12,15}),
|
||||
"folder-child RMB start preserves Source restore/unlink/append ordering");
|
||||
folder_drag.pointer_move(176,100);
|
||||
const auto child_return=folder_drag.pointer_up(176,100,true);
|
||||
check(child_return.kind==DeskRequestKind::change_layout&&
|
||||
child_return.layout_operation==DeskLayoutOperation::return_folder_child&&
|
||||
child_return.layout_before[3*16+5]==0xff&&child_return.layout_after[0*16+5]==49&&
|
||||
child_return.layout_after[49*16+5]==3&&child_return.layout_after[3*16+5]==0&&
|
||||
child_return.layout_after[3*16+6]==49,
|
||||
"RMB drag from the rendered 32×25 folder tile returns it to the visible chain");
|
||||
check(folder_drag.take_sound_ids().empty(),"folder-child release cannot replay its down-event append");
|
||||
DesktopScreen folder_drop(data,child_desk);
|
||||
folder_drop.pointer_down(50,49,true); folder_drop.take_sound_ids();
|
||||
folder_drop.pointer_move(55,52);
|
||||
const auto dropped_child=folder_drop.pointer_up(55,52,true);
|
||||
check(dropped_child.layout_operation==DeskLayoutOperation::set_folder &&
|
||||
folder_drop.take_sound_ids()==std::vector<uint8_t>{12},
|
||||
"Source fully enclosed drop unlinks the dragged child exactly once");
|
||||
DesktopScreen unchanged_handle(data,child_desk);
|
||||
unchanged_handle.pointer_down(41,41);
|
||||
check(!unchanged_handle.pending() && unchanged_handle.take_sound_ids().empty(),
|
||||
"existing LMB handle gesture has no invented RMB sound mapping");
|
||||
unchanged_handle.pointer_up(41,41);
|
||||
check(unchanged_handle.take_sound_ids().empty(),"handle release remains silent at this Source boundary");
|
||||
auto covered_child=child_desk;
|
||||
covered_child.items.push_back(DeskItem{6,60,48,32,25,21,0,0,false,false});
|
||||
covered_child.layout_records[49][5]=6;
|
||||
covered_child.layout_records[6][5]=0;
|
||||
covered_child.layout_records[6][6]=49;
|
||||
covered_child.layout_records[6][12]=21;
|
||||
DesktopScreen stacked_icon(data,covered_child);
|
||||
const auto exposed_folder_frame=folder_click.render();
|
||||
const auto covered_folder_frame=stacked_icon.render();
|
||||
const auto desktop_atlas=load_vga(asset_path(data/"KB","3.VGA"));
|
||||
for(int y=0;y<25;++y) for(int x=0;x<32;++x)
|
||||
check(covered_folder_frame.pixels[size_t(48+y)*320+60+x]==
|
||||
desktop_atlas.pixels[size_t(50+y)*desktop_atlas.width+160+x],
|
||||
"top icon renders over the folder child using its own native KB3 tile");
|
||||
check(covered_folder_frame.pixels[size_t(49)*320+50]==exposed_folder_frame.pixels[size_t(49)*320+50],
|
||||
"the uncovered part of a folder child remains visible below the stacked icon");
|
||||
const auto covering_icon_action=stacked_icon.click(65,49);
|
||||
check(covering_icon_action.kind==DeskRequestKind::open_menu&&covering_icon_action.item_id==6&&
|
||||
covering_icon_action.menu_kind==21&&stacked_icon.state().layout_records==covered_child.layout_records,
|
||||
"LMB activates the rendered top icon rather than the covered folder child without layout edits");
|
||||
DesktopScreen stacked_drag(data,covered_child);
|
||||
stacked_drag.pointer_down(65,49,true);
|
||||
check(stacked_drag.take_sound_ids()==std::vector<uint8_t>({12,15}),
|
||||
"visible RMB drag starts with the Source unlink/append pair");
|
||||
stacked_drag.pointer_move(200,120);
|
||||
const auto covering_icon_drag=stacked_drag.pointer_up(200,120,true);
|
||||
check(covering_icon_drag.kind==DeskRequestKind::change_layout&&covering_icon_drag.item_id==6&&
|
||||
covering_icon_drag.layout_operation==DeskLayoutOperation::move_item&&
|
||||
covering_icon_drag.layout_after[3*16+5]==0xff&&covering_icon_drag.layout_after[3*16+6]==0xff,
|
||||
"RMB drags the rendered top icon and leaves the covered child outside the visible link chain");
|
||||
check(stacked_drag.take_sound_ids().empty(),"ordinary move release adds no structural sound");
|
||||
DesktopScreen still_drag(data,covered_child);
|
||||
still_drag.pointer_down(65,49,true); still_drag.pointer_up(65,49,true);
|
||||
check(still_drag.take_sound_ids()==std::vector<uint8_t>({12,15}),
|
||||
"Source RMB reordering sounds happen even without pointer motion");
|
||||
DesktopScreen exposed_child(data,covered_child);
|
||||
check(exposed_child.click(50,49).item_id==3,"an exposed folder tile still opens its native child action");
|
||||
auto status_cover=child_desk;
|
||||
status_cover.items.push_back(DeskItem{48,48,48,42,35,56,0,0,true,false});
|
||||
DesktopScreen stacked_status(data,status_cover);
|
||||
check(stacked_status.render().pixels!=exposed_folder_frame.pixels&&
|
||||
stacked_status.pointer_down(50,49).kind==DeskRequestKind::none&&
|
||||
stacked_status.pointer_up(50,49).kind==DeskRequestKind::none&&!stacked_status.pending(),
|
||||
"an open status drawer covers a folder child and its inert body cannot activate that child");
|
||||
auto empty_folder_cover=child_desk;
|
||||
empty_folder_cover.items.push_back(DeskItem{48,48,48,45,35,51,0,1,true,false});
|
||||
DesktopScreen stacked_empty_folder(data,empty_folder_cover);
|
||||
check(stacked_empty_folder.click(50,49).kind==DeskRequestKind::none&&!stacked_empty_folder.pending(),
|
||||
"an empty part of the top folder blocks a lower folder child");
|
||||
DesktopScreen covered_bin_restore(data,empty_folder_cover);
|
||||
covered_bin_restore.pointer_move(160,239);
|
||||
covered_bin_restore.click(10,215);
|
||||
check(covered_bin_restore.pointer_down(50,49,true).kind==DeskRequestKind::none&&
|
||||
covered_bin_restore.pointer_up(50,49,true).kind==DeskRequestKind::none&&
|
||||
!covered_bin_restore.pending()&&covered_bin_restore.state().layout_records==empty_folder_cover.layout_records,
|
||||
"bin-mode RMB on a covering empty folder cannot restore the lower child or change links");
|
||||
check(covered_bin_restore.take_sound_ids().empty(),"covered bin child cannot emit a restore sound");
|
||||
DesktopScreen exposed_bin_restore(data,covered_child);
|
||||
exposed_bin_restore.pointer_move(160,239);
|
||||
exposed_bin_restore.click(10,215);
|
||||
const auto exposed_restore=exposed_bin_restore.click(50,49,true);
|
||||
check(exposed_bin_restore.take_sound_ids()==std::vector<uint8_t>{15},"bin-mode restore emits only append ID15");
|
||||
check(exposed_restore.layout_operation==DeskLayoutOperation::restore_folder_child&&exposed_restore.item_id==3,
|
||||
"bin-mode RMB still restores an exposed folder child using its native owner");
|
||||
DesktopScreen bin_send(data,covered_child);
|
||||
bin_send.pointer_move(160,239); bin_send.click(10,215);
|
||||
const auto sent_icon=bin_send.click(65,49,true);
|
||||
check(sent_icon.layout_operation==DeskLayoutOperation::send_to_folder &&
|
||||
bin_send.take_sound_ids()==std::vector<uint8_t>{12},"bin-mode send emits only unlink ID12");
|
||||
auto closed_cover=child_desk;
|
||||
closed_cover.items.push_back(DeskItem{48,48,48,14,14,63,0,0,false,false});
|
||||
DesktopScreen stacked_closed_drawer(data,closed_cover);
|
||||
check(stacked_closed_drawer.click(50,49).kind==DeskRequestKind::none&&!stacked_closed_drawer.pending(),
|
||||
"a closed drawer blocks hits inside its Source dimensions minus eight");
|
||||
DesktopScreen outside_closed_drawer(data,closed_cover);
|
||||
check(outside_closed_drawer.click(55,49).item_id==3,
|
||||
"the eight-pixel closed drawer inset allows hits on the exposed lower folder child");
|
||||
const auto menu_test_dir = std::filesystem::temp_directory_path() /
|
||||
("openbmh-menu-layout-picker-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
std::filesystem::create_directories(menu_test_dir / "load");
|
||||
std::filesystem::create_directories(menu_test_dir / "save");
|
||||
{ std::ofstream(menu_test_dir / "load" / "LAYOUT.MEN") << "fixture";
|
||||
std::ofstream(menu_test_dir / "load" / "NOTGAME.FBM") << "fixture"; }
|
||||
SaveLoadScreen menu_load_picker(data, menu_test_dir / "load", SaveLoadMode::load, 0, 6,
|
||||
menu_bar.render(), true, SaveLoadFileKind::menu_layout, 52);
|
||||
check(menu_load_picker.entries().size() == 1 &&
|
||||
menu_load_picker.entries()[0].path.extension() == ".MEN" &&
|
||||
!menu_load_picker.info_press(60,45),
|
||||
"menu-layout picker filters to MEN and never interprets a layout as an FBM information header");
|
||||
menu_load_picker.click(60,45); menu_load_picker.click(60,45);
|
||||
check(menu_load_picker.pending() && menu_load_picker.pending()->file_kind == SaveLoadFileKind::menu_layout &&
|
||||
menu_load_picker.pending()->origin_item_id == 52 &&
|
||||
menu_load_picker.pending()->path.extension() == ".MEN",
|
||||
"MEN load request retains its typed file kind and source drawer identity");
|
||||
SaveLoadScreen menu_save_picker(data, menu_test_dir / "save", SaveLoadMode::save, 0, 6,
|
||||
menu_bar.render(), true, SaveLoadFileKind::menu_layout, 52);
|
||||
menu_save_picker.click(120,214); menu_save_picker.text("LAYOUT"); menu_save_picker.key("ENTER");
|
||||
check(menu_save_picker.pending() && menu_save_picker.pending()->file_kind == SaveLoadFileKind::menu_layout &&
|
||||
menu_save_picker.pending()->path.filename() == "LAYOUT.MEN" &&
|
||||
save_load_request_json(*menu_save_picker.pending()).find("\"file_kind\":\"menu_layout\"") != std::string::npos,
|
||||
"MEN save request uses the native extension and an explicit JSON file-kind discriminator");
|
||||
std::filesystem::remove_all(menu_test_dir);
|
||||
folder_pointer_input_tests(data,exe);
|
||||
TextDb desk_texts = load_textd(asset_path(data,"TEXTD.BLK"));
|
||||
auto match_game = g; match_game.texts = &desk_texts;
|
||||
match_game.club_names.assign(32,0);
|
||||
@@ -1009,12 +1129,19 @@ int main(int argc, char** argv) {
|
||||
auto special=desk_from_game(special_game,exe,10,&prepared,34);
|
||||
check(special.next_competition_label==desk_texts[(::bmh::layout::DeskState_FormatError_RuntimeField4-::bmh::layout::TextPointerTable)/4],
|
||||
"Source calendar entry 4006 selects the special competition title");
|
||||
MatchGroup fallback_badge_group=cup_fixture;fallback_badge_group.fixtures={12,100};
|
||||
// OpenBMH shows a club badge for every league club; only the cup-only teams keep the computer portrait.
|
||||
MatchGroup fallback_badge_group=cup_fixture;fallback_badge_group.fixtures={12,200};
|
||||
std::vector<MatchGroup> fallback_badge_groups{fallback_badge_group};
|
||||
auto fallback_badge=desk_from_game(match_game,exe,10,&fallback_badge_groups,34);
|
||||
check(fallback_badge.next_opponent==100&&fallback_badge.next_opponent_badge_fallback&&
|
||||
check(fallback_badge.next_opponent==200&&fallback_badge.next_opponent_badge_fallback&&
|
||||
!fallback_badge.next_opponent_badge,
|
||||
"legacy routine special team range uses its computer-portrait fallback");
|
||||
"a cup-only team uses its computer-portrait fallback");
|
||||
fallback_badge_group.fixtures={12,100};
|
||||
fallback_badge_groups={fallback_badge_group};
|
||||
auto foreign_badge=desk_from_game(match_game,exe,10,&fallback_badge_groups,34);
|
||||
check(foreign_badge.next_opponent==100&&!foreign_badge.next_opponent_badge_fallback&&
|
||||
foreign_badge.next_opponent_badge,
|
||||
"a foreign league club shows its badge");
|
||||
prepared.clear();
|
||||
auto other_fixture = league_fixture; other_fixture.fixtures={13,14}; prepared.push_back(other_fixture);
|
||||
auto unmatched = desk_from_game(match_game,exe,10,&prepared,34);
|
||||
@@ -1106,28 +1233,8 @@ int main(int argc, char** argv) {
|
||||
auto wrong = d.options; wrong.managers = 5; rejected([&]{ validate_desk_profile(wrong); });
|
||||
wrong = d.options; wrong.world = false; wrong.league = false; rejected([&]{ validate_desk_profile(wrong); });
|
||||
|
||||
d = desk_from_game(g,exe,10); DesktopScreen desk(data,d);
|
||||
const auto pixels = desk.render().pixels;
|
||||
check(desk.render().pixels == pixels,"repeat render is deterministic");
|
||||
check(desk.click(5,23).kind == DeskRequestKind::none,"calendar handle must not advance a turn");
|
||||
auto action = desk.click(50,125);
|
||||
check(action.kind == DeskRequestKind::open_menu && action.menu_kind == 3 && action.manager_slot == 0 && action.revision == 10,"lineup request");
|
||||
check(desk.click(20,40).kind == DeskRequestKind::none,"pending command blocks another turn");
|
||||
rejected([&]{ desk.acknowledge(d); });
|
||||
++d.revision; desk.acknowledge(d);
|
||||
check(desk.click(20,40).kind == DeskRequestKind::advance_turn,"open calendar advances");
|
||||
check(desk.click(20,40).kind == DeskRequestKind::none,"no duplicate advance request");
|
||||
++d.revision; desk.acknowledge(d);
|
||||
check(desk.click(165,125).kind == DeskRequestKind::advance_turn,"kickoff icon advances");
|
||||
check(desk.render().pixels == pixels,"commands cannot mutate the saved game view");
|
||||
desk.reject_action("unsupported_menu");
|
||||
check(!desk.pending() && desk.render().pixels == pixels,"rejected command preserves state");
|
||||
check(desk.key("A").menu_kind == 3,"original A hotkey opens lineup");
|
||||
desk.reject_action("not_implemented");
|
||||
check(desk.key("D").menu_kind == 18,"original D hotkey opens tactics");
|
||||
desk.reject_action("not_implemented");
|
||||
check(desk.key("I").menu_kind == 16 && desk_menu_name(16)=="training" && desk_menu_name(15)=="training_camp",
|
||||
"original I and dispatch distinguish training from training camp");
|
||||
d = desk_from_game(g,exe,10);
|
||||
desktop_control_input_tests(data,d);
|
||||
|
||||
StartupFlow flow(data); begin(flow);
|
||||
auto result = CareerInitializationResult{d,{{0,0,12}}};
|
||||
|
||||
@@ -157,6 +157,8 @@ EnvironmentScreen::EnvironmentScreen(const std::filesystem::path& data, Environm
|
||||
background_.height != 240 || tiles_.width != 306 || tiles_.height != 111 ||
|
||||
panel_.width <= 0 || texts_.strings.size() != TEXT_COUNT)
|
||||
throw FormatError("environment: unsupported owner or Original assets");
|
||||
for(int item=0;item<kEnvironmentItems;++item){const int x=exe_.u8(layout::Environment_FormatError_RuntimeField+item),y=exe_.u8(layout::Environment_FormatError_RuntimeField2+item);
|
||||
if(x<9||x+0x36>=320||y<10||y+0x31+(item<3?6:0)>=240)throw FormatError("environment: tile geometry outside Original screen");}
|
||||
}
|
||||
|
||||
void EnvironmentScreen::text(Image& out, int x, int baseline, std::string_view value,
|
||||
|
||||
+3
-2
@@ -30,6 +30,7 @@ FlowResult StartupFlow::move_action(int x, int y) {
|
||||
if (friendly_match_) return {friendly_match_->move(x,y)};
|
||||
if(league_pairings_)return {league_pairings_->move(x,y)};
|
||||
if(stadium_)return {stadium_->pointer_move(x,y)};
|
||||
if(advertising_)return {advertising_->move(x,y)};
|
||||
if(environment_)return {};
|
||||
if (outgoing_transfer_) return {};
|
||||
if (transfer_market_ && !player_card_) {
|
||||
@@ -45,7 +46,7 @@ FlowResult StartupFlow::move_action(int x, int y) {
|
||||
: contracts_ && !player_card_ ? contracts_->move(x, y)
|
||||
: matchday_results_ || in_readonly_view() || friendly_match_ ? false
|
||||
: player_card_ ? false : pitch_ ? pitch_->move(x, y)
|
||||
: lineup_ ? lineup_->move(x, y) : training_camp_ ? training_camp_->move(x, y)
|
||||
: lineup_ ? lineup_->move(x, y) : training_ ? training_->move(x, y) : training_camp_ ? training_camp_->move(x, y)
|
||||
: toto_ ? toto_->move(x, y)
|
||||
: bank_ || stadium_ ? false
|
||||
: !desktop_ && manager_ && !pending_ && !awaiting_context_ && manager_->move(x, y);
|
||||
@@ -446,7 +447,7 @@ FlowResult StartupFlow::click(int x, int y, bool right, bool double_click) {
|
||||
}
|
||||
if (save_load_) {
|
||||
const auto before = state_json();
|
||||
const bool changed = save_load_->click(x, y, right);
|
||||
const bool changed = save_load_->click(x, y, right, double_click);
|
||||
return finish_file_input(changed || before != state_json());
|
||||
}
|
||||
if (in_preparation_menu()) {
|
||||
|
||||
@@ -103,6 +103,9 @@ public:
|
||||
FlowResult expire_stadium_tip();
|
||||
bool in_stadium() const { return bool(stadium_); }
|
||||
bool in_pitch() const { return bool(pitch_); }
|
||||
std::optional<std::array<uint32_t,121>> pitch_pointer_cursor(const Palette& palette) const {
|
||||
return pitch_ && screen_name() == "pitch" ? pitch_->pointer_cursor(palette) : std::nullopt;
|
||||
}
|
||||
std::optional<Image> pitch_formation_save_feedback(bool restored) const;
|
||||
FlowResult pitch_held_left(int x, int y, uint64_t source_ticks);
|
||||
void consume_orphaned_pitch_release(){pitch_release_barrier_=false;}
|
||||
|
||||
@@ -461,7 +461,10 @@ Image IncomingTransferScreen::render_at_elapsed(uint64_t elapsed_ms) const {
|
||||
std::string(text_at(texts_, ::bmh::layout::IncomingTransfer_RenderAtElapsed_TextPointer14)) + source_number(state_.quoted_years, 1, false) +
|
||||
std::string(text_at(texts_, ::bmh::layout::Contracts_Out_ExecutableField15)) + (state_.quoted_years == 1 ? "" : exe_.cstring(::bmh::layout::Fltd_Layout_TextPointer3)) +
|
||||
exe_.cstring(::bmh::layout::IncomingTransfer_RenderAtElapsed_TextPointer);
|
||||
centered(0, 319, 32, quote, 0x6a);
|
||||
// Early listing review has no newly rolled quote. Explain its input instead
|
||||
// of presenting a fabricated zero-year, zero-price valuation.
|
||||
centered(0, 319, 32, state_.quoted_years ? quote :
|
||||
"Angebot anklicken. Rechtsklick: zurueck.", 0x6a);
|
||||
shadow_text(7, 123, std::string(text_at(texts_, ::bmh::layout::IncomingTransfer_RenderAtElapsed_TextPointer10)) +
|
||||
source_money(state_.asking_fee, 7, state_.currency_numerator, state_.currency_denominator), 0x6a);
|
||||
shadow_text(170, 123, std::string(text_at(texts_, ::bmh::layout::IncomingTransfer_RenderAtElapsed_TextPointer11)) +
|
||||
@@ -527,6 +530,17 @@ bool IncomingTransferScreen::dismiss_notice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void IncomingTransferScreen::pointer_down(bool right) {
|
||||
pointer_buttons_ |= right ? 2 : 1;
|
||||
}
|
||||
|
||||
std::optional<int> IncomingTransferScreen::pointer_up(int x, int y, bool right, uint64_t elapsed_ms) {
|
||||
const uint8_t button = right ? 2 : 1;
|
||||
if (!(pointer_buttons_ & button)) return std::nullopt;
|
||||
pointer_buttons_ &= uint8_t(~button);
|
||||
return click(x, y, right, elapsed_ms);
|
||||
}
|
||||
|
||||
std::optional<int> IncomingTransferScreen::click(int x, int y, bool right, uint64_t elapsed_ms) {
|
||||
if (confirmation_mode_) {
|
||||
if (!right && x >= 95 && x <= 220 && y >= 166 && y <= 176)
|
||||
|
||||
@@ -142,6 +142,10 @@ public:
|
||||
void show_confirmation(uint32_t original_text_address, const Image& backdrop);
|
||||
bool confirmation_dismissed() const { return confirmation_dismissed_; }
|
||||
bool outcome_dismissed() const { return outcome_dismissed_; }
|
||||
// Raw release-driven presenters must own a press in this visible modal.
|
||||
// Semantic Source DOWN actions can continue to use click directly.
|
||||
void pointer_down(bool right = false);
|
||||
std::optional<int> pointer_up(int x, int y, bool right = false, uint64_t elapsed_ms = 0);
|
||||
std::optional<int> click(int x, int y, bool right = false, uint64_t elapsed_ms = 0);
|
||||
std::optional<int> key(std::string_view name);
|
||||
bool dismiss_notice();
|
||||
@@ -159,6 +163,7 @@ private:
|
||||
Image background_, negotiation_;
|
||||
bool gradient_text_ = true;
|
||||
std::optional<int> answer_;
|
||||
uint8_t pointer_buttons_ = 0;
|
||||
bool notice_active_ = false;
|
||||
int outcome_row_count_ = -1;
|
||||
int outcome_accepted_bid_index_ = -1;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/incoming_transfer.hpp"
|
||||
#include "ui/source_notice_test_helpers.hpp"
|
||||
#include "ui/setup.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
@@ -93,6 +94,24 @@ int main(int argc, char** argv) {
|
||||
"raw Source 0xfff pool seller resolves without indexing a club or national-team token");
|
||||
|
||||
auto state = fixture();
|
||||
IncomingTransferScreen release_owner(argv[1], state);
|
||||
const auto undecided_pixels = release_owner.render().pixels;
|
||||
check(!release_owner.pointer_up(310,230,true) &&
|
||||
!release_owner.pointer_up(309,229,true) && !release_owner.answer() &&
|
||||
release_owner.render().pixels == undecided_pixels,
|
||||
"late/repeated table releases cannot decline the following transfer");
|
||||
release_owner.pointer_down();
|
||||
release_owner.pointer_down(); // Repeated DOWN still owns a single left gesture.
|
||||
check(!release_owner.pointer_up(310,230,true) && !release_owner.answer(),
|
||||
"an orphan right release does not consume an owned left press");
|
||||
check(release_owner.pointer_up(10,150) == 0 &&
|
||||
!release_owner.pointer_up(10,150) && release_owner.answer() == 0,
|
||||
"fresh left gesture selects its raw offer once despite repeated DOWN/UP");
|
||||
IncomingTransferScreen right_owner(argv[1], state);
|
||||
right_owner.pointer_down(true);right_owner.pointer_down(true);
|
||||
check(right_owner.pointer_up(309,229,true) == -1 &&
|
||||
!right_owner.pointer_up(309,229,true) && right_owner.answer() == -1,
|
||||
"fresh moved right gesture still declines exactly once");
|
||||
IncomingTransferScreen screen(argv[1], state);
|
||||
const auto frame = screen.render();
|
||||
check(frame.width == 320 && frame.height == 240 && frame.pixels.size() == 320u * 240u,
|
||||
@@ -155,20 +174,42 @@ int main(int argc, char** argv) {
|
||||
check(monitor_ink, "KB0 monitor crop has visible pixels");
|
||||
check(pool_tile_exact, "pool TV crop matches KB0 with Source transparency");
|
||||
check(frame_exact, "pool TV fallback has Source legacy routine border colors and bounds");
|
||||
auto neutral_badge_state = state;
|
||||
neutral_badge_state.seller = 100;
|
||||
neutral_badge_state.seller_team_token = 100;
|
||||
neutral_badge_state.seller_badge_sprite = 0; // The raw Source fallback precedes selector lookup.
|
||||
IncomingTransferScreen neutral_badge(argv[1], neutral_badge_state);
|
||||
const auto neutral_frame = neutral_badge.render();
|
||||
check(neutral_frame.pixels[size_t(50) * 320 + 101] == 0x46 &&
|
||||
neutral_frame.pixels[size_t(89) * 320 + 140] == 0x40,
|
||||
"Source seller tokens 90..137 use legacy routine's framed neutral fallback before badge lookup");
|
||||
auto unused_selector_state = neutral_badge_state;
|
||||
unused_selector_state.seller_badge_sprite = 511;
|
||||
IncomingTransferScreen unused_selector(argv[1], unused_selector_state);
|
||||
check(unused_selector.render().pixels == neutral_frame.pixels,
|
||||
"neutral raw seller fallback does not consult or load its unused ba378 selector");
|
||||
// The supplied executable decides whether tokens 90..137 use individual
|
||||
// crests. Read its verified instruction rather than the UI's policy.
|
||||
const auto source_exe = bmh::load_le(asset_path(argv[1], "BMH.exe"));
|
||||
constexpr auto gate = ::bmh::layout::ForeignBadgeGateInstruction;
|
||||
check(source_exe.u8(gate) == 0x66 && source_exe.u8(gate + 1) == 0x81 &&
|
||||
source_exe.u8(gate + 2) == 0xfb && source_exe.u8(gate + 5) == 0x7c &&
|
||||
source_exe.u8(gate + 6) == 7 &&
|
||||
(source_exe.u16(gate + 3) == 90 || source_exe.u16(gate + 3) == 138),
|
||||
"foreign crest fixture uses a verified Original executable drawing gate");
|
||||
auto profile_badge_state = state;
|
||||
profile_badge_state.seller = 100;
|
||||
profile_badge_state.seller_team_token = 100;
|
||||
profile_badge_state.seller_badge_sprite = 0;
|
||||
IncomingTransferScreen profile_badge(argv[1], profile_badge_state);
|
||||
const auto profile_frame = profile_badge.render();
|
||||
if (source_exe.u16(gate + 3) == 138) {
|
||||
check(profile_frame.pixels[size_t(50) * 320 + 101] == 0x46 &&
|
||||
profile_frame.pixels[size_t(89) * 320 + 140] == 0x40,
|
||||
"CD foreign seller uses the framed neutral fallback before badge lookup");
|
||||
auto unused_selector_state = profile_badge_state;
|
||||
unused_selector_state.seller_badge_sprite = 511;
|
||||
IncomingTransferScreen unused_selector(argv[1], unused_selector_state);
|
||||
check(unused_selector.render().pixels == profile_frame.pixels,
|
||||
"neutral raw seller fallback does not consult or load its unused ba378 selector");
|
||||
} else {
|
||||
const auto foreign_atlas = bmh::load_vga(asset_path(std::filesystem::path(argv[1]) / "W", "0.VGA"));
|
||||
bool foreign_pixels_match = true;
|
||||
size_t foreign_ink = 0;
|
||||
for (int y = 0; y < 38; ++y) for (int x = 0; x < 38; ++x) {
|
||||
const auto pixel = foreign_atlas.pixels.at(size_t(y) * foreign_atlas.width + size_t(x));
|
||||
foreign_ink += pixel != 0;
|
||||
foreign_pixels_match &= profile_frame.pixels[size_t(y + 51) * 320 + size_t(x + 102)] == pixel;
|
||||
}
|
||||
check(foreign_ink > 0 && foreign_pixels_match,
|
||||
"individual foreign crest profile draws seller100's valid W0 selector instead of a neutral tile");
|
||||
}
|
||||
auto selector_state = state;
|
||||
selector_state.seller = 20;
|
||||
selector_state.seller_team_token = 20;
|
||||
@@ -247,6 +288,13 @@ int main(int argc, char** argv) {
|
||||
"only a left click inside KLICK can acknowledge the confirmation");
|
||||
check(!confirm.click(95,166) && confirm.confirmation_dismissed() && !confirm.answer(),
|
||||
"KLICK acknowledges without submitting a new transfer decision");
|
||||
IncomingTransferScreen confirmation_owner(argv[1],confirm_state);
|
||||
confirmation_owner.show_confirmation(::bmh::layout::PendingOffer_FormatError_ExecutableField2,settled_image);
|
||||
check(!confirmation_owner.pointer_up(150,170) && !confirmation_owner.confirmation_dismissed(),
|
||||
"an inherited left release cannot acknowledge the next confirmation");
|
||||
confirmation_owner.pointer_down();
|
||||
check(!confirmation_owner.pointer_up(150,170) && confirmation_owner.confirmation_dismissed(),
|
||||
"a fresh complete left gesture acknowledges its owned confirmation");
|
||||
IncomingTransferScreen confirm_edge(argv[1],confirm_state);
|
||||
confirm_edge.show_confirmation(::bmh::layout::PendingOffer_FormatError_ExecutableField2,settled_image);
|
||||
check(!confirm_edge.click(221,176) && !confirm_edge.confirmation_dismissed(),
|
||||
|
||||
@@ -368,6 +368,9 @@ bool LeaguePairingsScreen::release(int x,int y) {
|
||||
return true;
|
||||
}
|
||||
if(button==5)return true; // Source ellipsis has no action.
|
||||
// OpenBMH deviates from the original: the computer tip is ignored silently once a visible result is known, instead of raising an engine error.
|
||||
if(button==4&&std::any_of(state_.source.rows.begin(),state_.source.rows.end(),
|
||||
[](const auto& row){return row.raw_result!=0xcc;}))return true;
|
||||
post({button==0?LeaguePairingsAction::reset:button==1?LeaguePairingsAction::search:
|
||||
button==2?LeaguePairingsAction::filter_by_club:button==3?LeaguePairingsAction::postponed_list:
|
||||
button==4?LeaguePairingsAction::computer_tip:LeaguePairingsAction::unsupported,button});return true;
|
||||
|
||||
@@ -287,7 +287,12 @@ bool LeagueTableRangeDialog::activate_cell(int index) {
|
||||
|
||||
bool LeagueTableRangeDialog::pointer_down(int px, int py, bool right) {
|
||||
if (outcome_delivered_) return false;
|
||||
if (right) return true; // modal consumes RMB but does not infer Source event 8
|
||||
if (right) {
|
||||
// The right button leaves the calculator as event 8 does (as the Toto calculator); the exit
|
||||
// still waits for its final Present. The modal consumes the press either way.
|
||||
(void)cancel_from_source_event();
|
||||
return true;
|
||||
}
|
||||
if (dragging_) {
|
||||
pointer_x_ = px;
|
||||
pointer_y_ = py;
|
||||
|
||||
+11
-4
@@ -83,7 +83,7 @@ void copy(Image& out, const Image& src, int sx, int sy, int x, int y, int w, int
|
||||
if (c != transparent && x+xx>=0 && x+xx<out.width && y+yy>=0 && y+yy<out.height) out.at(x+xx,y+yy)=c;
|
||||
}
|
||||
}
|
||||
std::string number(int value, int width = 2) {
|
||||
std::string number(uint64_t value, int width = 2) {
|
||||
auto s=std::to_string(value);
|
||||
if (int(s.size())<width) s.insert(0,size_t(width-int(s.size())),'%');
|
||||
return s;
|
||||
@@ -110,11 +110,16 @@ LineupState lineup_from_save(const SaveState& s,const LeImage& exe,uint64_t revi
|
||||
for(size_t at=0;at<w1.size();at+=4) players.push_back({{},le32(w1,at),le32(w2,at),le32(w3,at)});
|
||||
auto out=project(memory,exe,teams,words(block(s,::bmh::layout::SquadSlots)),players,block(s,::bmh::layout::TacticsBoards),block(s,::bmh::layout::ManagerAutomation),
|
||||
words(block(s,::bmh::layout::PlayerCards)),block(s,::bmh::layout::PlayerBonuses),words(block(s,::bmh::layout::PlayerNameOffsets)),s.pool(1),words(block(s,::bmh::layout::ClubIdentities)),s.pool(0),revision);
|
||||
const auto g = GameState::from_save(s);
|
||||
for (auto& p : out.players) if (p.player_id >= 0)
|
||||
p.statistics = player_club_statistics(g, out.runtime_club, p.player_id, p.board);
|
||||
out.source="original_save_read_only"; return out;
|
||||
}
|
||||
LineupState lineup_from_game(const GameState& g,const LeImage& exe,uint64_t revision) {
|
||||
auto out=project(g.memory,exe,g.manager_teams,g.squad_slots,g.players,g.tactics,g.manager_options,
|
||||
g.player_cards,g.player_bonus,g.player_name_offsets,g.player_names,g.club_ids,g.club_names,revision);
|
||||
for (auto& p : out.players) if (p.player_id >= 0)
|
||||
p.statistics = player_club_statistics(g, out.runtime_club, p.player_id, p.board);
|
||||
out.source="engine_projection"; return out;
|
||||
}
|
||||
|
||||
@@ -224,9 +229,9 @@ Image LineupScreen::render() const {
|
||||
} else {
|
||||
text(out,65,baseline,number(a.age())+texts_[(::bmh::layout::ClubInfo_Render_TextPointer5-::bmh::layout::TextPointerTable)/4],0x6c);
|
||||
for(int skill=0;skill<7;++skill)copy(out,atlas_,256+a.skill(Player::Skill(skill))*16,32,87+skill*10,baseline-5,16,5,0);
|
||||
text(out,165,baseline,number(p.bonus&127,3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+number(p.board[7],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+
|
||||
number(p.board[9],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+number(le16(Bytes(p.board.begin(),p.board.end()),0x48),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+
|
||||
number(le16(Bytes(p.board.begin(),p.board.end()),0x4a),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+number(le16(Bytes(p.board.begin(),p.board.end()),0x4c),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField),0x6c);
|
||||
text(out,165,baseline,number(p.bonus&127,3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+number(p.statistics ? p.statistics->appearances[0] : p.board[7],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+
|
||||
number(p.statistics ? p.statistics->appearances[2] : p.board[9],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+number((p.statistics ? p.statistics->total : le16(Bytes(p.board.begin(),p.board.end()),0x48)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+
|
||||
number((p.statistics ? p.statistics->goals : le16(Bytes(p.board.begin(),p.board.end()),0x4a)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+number((p.statistics ? p.statistics->assists : le16(Bytes(p.board.begin(),p.board.end()),0x4c)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField),0x6c);
|
||||
}
|
||||
}
|
||||
button(out,1,215,texts_[(::bmh::layout::Lineup_Render_TextPointer-::bmh::layout::TextPointerTable)/4+(state_.view==LineupView::data_a?1:0)]);
|
||||
@@ -310,6 +315,8 @@ std::string LineupScreen::state_json() const {
|
||||
if(p.player_id>=0)s<<",\"starting\":"<<((p.slot&0x8000)?"true":"false")<<",\"bench\":"<<((p.slot&0x4000)?"true":"false")
|
||||
<<",\"position_type\":"<<p.attributes.position()<<",\"condition\":"<<p.attributes.condition()<<",\"technique\":"<<p.attributes.technique()
|
||||
<<",\"form\":"<<p.attributes.form()<<",\"strength\":"<<p.attributes.strength()<<",\"age\":"<<p.attributes.age()<<",\"exhaustion\":"<<int(p.board[0xf]);
|
||||
if (p.statistics) s << ",\"club_appearances\":[" << p.statistics->appearances[0] << ',' << p.statistics->appearances[1] << ',' << p.statistics->appearances[2]
|
||||
<< "],\"total_appearances\":" << p.statistics->total << ",\"club_goals\":" << p.statistics->goals << ",\"club_assists\":" << p.statistics->assists;
|
||||
s<<'}';}
|
||||
s<<"]}";return s.str();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "formats/font.hpp"
|
||||
#include "game/long_career.hpp"
|
||||
#include "formats/m3d.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
#include "ui/setup.hpp"
|
||||
@@ -22,6 +23,7 @@ struct LineupPlayer {
|
||||
uint16_t cards = 0;
|
||||
uint8_t bonus = 0;
|
||||
std::array<uint8_t, 0x58> board{};
|
||||
std::optional<PlayerClubStatistics> statistics;
|
||||
};
|
||||
struct LineupState {
|
||||
int manager_slot = -1, runtime_club = -1;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -46,6 +47,29 @@ struct LiveMatchdayFrame {
|
||||
LiveMatchdayFrame live_matchday_frame(int minute, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state);
|
||||
|
||||
// The engine commits a chance before its ball/set-piece/shot presentation. Keep
|
||||
// the observed preview scores until the result hook, without delaying simulation.
|
||||
class LiveScoreReveal {
|
||||
public:
|
||||
void observe(LiveChanceStage stage, const LiveMatchdayFrame& frame) {
|
||||
if (stage == LiveChanceStage::preview) preview_ = frame;
|
||||
else preview_.reset();
|
||||
}
|
||||
LiveMatchdayFrame project(LiveMatchdayFrame frame) const {
|
||||
if (!preview_ || preview_->minute != frame.minute) return frame;
|
||||
for (auto& row : frame.matches) for (const auto& before : preview_->matches)
|
||||
if (row.home_team == before.home_team && row.away_team == before.away_team) {
|
||||
row.home_goals = before.home_goals;
|
||||
row.away_goals = before.away_goals;
|
||||
row.score_known = before.score_known;
|
||||
break;
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
private:
|
||||
std::optional<LiveMatchdayFrame> preview_;
|
||||
};
|
||||
|
||||
struct LiveChanceProjection {
|
||||
LiveChanceStage stage = LiveChanceStage::preview;
|
||||
int minute = 0, group = 0, match = 0, side = 0;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/live_matchday.hpp"
|
||||
#include <stdexcept>
|
||||
using namespace bmh::ui;
|
||||
int main() {
|
||||
LiveMatchdayFrame frame;
|
||||
frame.minute=23;
|
||||
LiveMatchRow home;home.home_team=10;home.away_team=11;home.score_known=true;
|
||||
home.home_goals=2;home.away_goals=1;frame.matches.push_back(home);
|
||||
LiveMatchRow other=home;other.home_team=20;other.away_team=21;frame.matches.push_back(other);
|
||||
LiveScoreReveal reveal;
|
||||
if(reveal.project(frame)!=frame)throw std::runtime_error("idle reveal changed scores");
|
||||
for (int side : {0,1}) {
|
||||
reveal.observe(bmh::LiveChanceStage::preview,frame);
|
||||
auto resolved=frame;
|
||||
(side==0?resolved.matches[0].home_goals:resolved.matches[0].away_goals)++;
|
||||
resolved.matches[0].spectators=12500;
|
||||
// Animation frames can be rendered repeatedly without committing scores.
|
||||
for(int animation=0;animation<18;++animation) {
|
||||
const auto shown=reveal.project(resolved);
|
||||
if(shown.matches[0].home_goals!=2 || shown.matches[0].away_goals!=1 ||
|
||||
shown.matches[0].spectators!=12500 || shown.matches[1]!=resolved.matches[1])
|
||||
throw std::runtime_error("animation leaked score or replaced unrelated fields");
|
||||
}
|
||||
reveal.observe(bmh::LiveChanceStage::result,resolved);
|
||||
if(reveal.project(resolved)!=resolved)throw std::runtime_error("result did not reveal goal");
|
||||
}
|
||||
reveal.observe(bmh::LiveChanceStage::preview,frame);
|
||||
if(reveal.project(frame)!=frame)throw std::runtime_error("miss changed score");
|
||||
auto next=frame;next.minute++;
|
||||
if(reveal.project(next)!=next)throw std::runtime_error("old chance held a later minute");
|
||||
// Team identity, rather than row index, survives a reordered board.
|
||||
auto reversed=frame;std::swap(reversed.matches[0],reversed.matches[1]);
|
||||
reversed.matches[1].away_goals++;
|
||||
if(reveal.project(reversed)!=LiveMatchdayFrame{frame.minute,frame.minute_text,frame.gradient_text,
|
||||
{frame.matches[1],frame.matches[0]}})throw std::runtime_error("reordered board used wrong score");
|
||||
}
|
||||
Loaded 100 of 150 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user