Compare commits

...
36 Commits
Author SHA1 Message Date
ClaudeandClaude Sonnet 5.5 2f5303d9bd Prepare Classic 1.0.6 patch release
Prepare verified release / draft (push) Canceled after 0s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 13:06:41 +01:00
ClaudeandClaude Sonnet 5.5 7cc7c3a7ea Fix Other Games and Top Scorers on the national-coach desk
Both screens are identified by the home club in the session; the desktop
check compared against the desk's own runtime club identity after the earlier
Table/Strengths fix, so the national desk was rejected as stale.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 12:27:29 +01:00
ClaudeandClaude Sonnet 5.5 f33b381f18 Hide ANNEHMEN in the advertising offer browser when the offer cannot be accepted
The original shows only ABBRECHEN while a running sponsor contract is not
terminable; the button was always drawn here.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 12:17:30 +01:00
ClaudeandClaude Sonnet 5.5 39de3dc9d4 Allow the national-team desk in the pitch page so the live lineup opens
The live lineup of a national-team match failed with 'pitch: unsupported club'
because the pitch extras only accepted league club ids. The national desk
(runtime club 357, national squad pool) is now accepted under the same
condition as the lineup page, uses badge sheet 0 and its own roster base for
the marking lookup.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 12:05:00 +01:00
ClaudeandClaude Sonnet 5.5 fcd6eb9204 Club information may enter the club on every redraw
The table's club information (TeamInfo) enters the club again on each
redraw: view toggle, statistics, player card. The session required
exactly one entry and discarded the whole visit otherwise, also the
Nein/Radio/Video setting made in it, so a computer match could not be
set to Video. One entry is now the minimum.

Checked with a probe on a real savegame: table, club, two entries and
Video leave the category set.

Refs #75, #77.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 10:25:44 +01:00
ClaudeandClaude Sonnet 5.5 16ae7df7f8 Joined manager sees his next opponent; club detail error names the access
- Joining a manager: the next opponent of every manager is captured per
  day for that day's manager count, so the joined manager's desk showed
  "Spielfrei" until the next day was prepared. It is captured again when
  the join is committed.
- The club player detail's atlas error now names the access and the
  atlas size, so the debug log shows what failed.

Refs #76, #77.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 10:10:34 +01:00
ClaudeandClaude Sonnet 5.5 b8a37353cc Opponent badge follows the day; Table and Stärken at the national desk
- Desktop: the opponent's badge sheet was loaded once when the screen
  was built and kept while the state advanced, so the index of the new
  opponent picked a badge from the old sheet (a foreign club's logo, the
  wrong club for RB Leipzig). It is reloaded with every new state.
- National desk: the desk keeps the home club's key per manager (for
  the hand-back), while Table, Stärken, Other games and the other pages
  carry the identity of the runtime club (the national team). The
  controller and flow compared the two and refused ("invalid Table
  dispatch manager identity", "stale desktop identity"). DeskState now
  gives session_identity_key() and the comparisons use it.

Refs #74.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 09:50:22 +01:00
ClaudeandClaude Sonnet 5.5 7cfc8267b6 Calendar and results-page Stärken work during a running career
Found with the debug log and savegames of a real session:

- Calendar: it read the memory copies of the season origin and day,
  which hold only the day the game was loaded or saved, and refused
  from the first kickoff on ("saved native season cursor disagrees").
  It now uses the live values, as the reschedule code does. This also
  fixes "Spiel verlegen".
- Stärken: the guard of dispatch_strengths required a desk stage, but
  the turn driver marks the running turn as Failed (replay guard) for
  its whole duration, so Stärken could never open from the live
  overview or the end-of-phase results page; the failed handover then
  left the other pages with stale owners and the match stuck. The
  guard now accepts the running turn while a live overview is open.
- Tests: calendar after a kickoff; live overview handovers on the
  phase results page.

Refs #71, #73.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 08:28:45 +01:00
ClaudeandClaude Sonnet 5.5 f12857414e Table range calculator closes with the right button; no frame in the panorama
- The Von/Bis calculator of the league table is left with the right
  mouse button (as the Toto calculator), restoring the backdrop.
- The stadium panorama draws no hover frame (the original draws none);
  the yellow frames stay on the main page (seat blocks, investments).

Refs #64, #66.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 23:02:41 +01:00
ClaudeandClaude Sonnet 5.5 81ae6ad236 Stadium: yellow hover frame over seat blocks, investments and buildings
As on the advertising page, the target under the pointer gets a yellow
frame: a finished seat block and an available investment icon on the
main page, and the hit rectangle of a building in the panorama (next to
its information panel). The frame appears only where a click acts.

Refs #64.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 22:29:36 +01:00
ClaudeandClaude Sonnet 5.5 38f69fa37b Fix save loading at the national desk, calendar colours, pointer size; add -debug
- Loading: a single-manager desk saved with DeskPosition == ManagerCount
  (the completed loop) is read as the first desk again instead of being
  refused as "not a savegame".
- Calendar: text takes the original's six-row colour gradient (the flat
  colours were too dark next to the original).
- Pointer: sized in window points, so it is not doubled on Retina screens.
- Settings: the page names OpenBMH and shows the build version below.
- Desk: the opponent's badge is shown whenever the data has one
  (documented difference); cup-only teams keep the computer portrait.
- Live overview tests: Tabelle/Stärken/Spiele handovers, also with the
  Spiele page opened first.
- New command line option -debug: timestamped log, stderr captured in a
  file, and a savegame after every match day in <saves>/debug.

Refs #63, #65, #67, #68, #71, #73.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 22:22:30 +01:00
ClaudeandClaude Sonnet 5.5 1e7df751a0 Describe original routines in comments instead of naming them
The public-source check rejects decompiler symbol names.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 20:44:58 +01:00
ClaudeandClaude Sonnet 5.5 af634ae8ff Fix settings switches, training skill bars, editor placement and pointer
- Settings: every unlocked switch is stored, as in the original; the
  whitelist of cells with a consumer is gone (J9, O3, ... no longer
  refused). Locks and 0/1 / numeric limits still apply.
- Training: the seven skill bars show the player row under the pointer
  (FUN_00049399).
- Line-up: the field stays editable inside the set-piece editor while no
  taker kind is chosen.
- Pointer: the original 11x11 bitmap is the default pointer on every
  page, not only on the pitch page.

Refs #57, #59, #60, #62.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 19:44:46 +01:00
Codex 04ff3b7656 Prepare Classic 1.0.5 patch release (by Codex)
Prepare verified release / draft (push) Canceled after 0s
2026-11-02 23:38:24 +01:00
Codex f7d20dad9e Name English environment source layout fields (by Codex) 2026-11-02 23:38:24 +01:00
Codex d661ec5eb0 Honor Original visible league counts for fresh Classic managers (by Codex) 2026-11-02 23:28:05 +01:00
Codex 048f617395 Use the common 3.7 environment model and source-language contract tabs (by Codex) 2026-11-02 23:15:49 +01:00
Codex 249bdca1a8 Prepare Classic 1.0.4 patch release (by Codex)
Prepare verified release / draft (push) Canceled after 0s
2026-11-02 21:03:19 +01:00
Codex b8904db92d Document original mouse behavior and verified layout mapping (by Codex) 2026-11-02 18:08:06 +01:00
Codex 9ec136a09f Check effective English translation neighbors (by Codex) 2026-11-02 18:08:02 +01:00
Codex a275ffa1a9 Preserve English overwrite question in translation (by Codex) 2026-11-02 18:03:04 +01:00
Codex fcb6ac14bb Refuse malformed widget formation before desktop projection (by Codex) 2026-11-02 17:47:49 +01:00
Codex acdc7d5c14 Isolate desktop pointer regressions from edition-specific mocks (by Codex) 2026-11-02 17:42:09 +01:00
Codex 0faad16148 Verify incoming transfer crests against installed edition profile (by Codex) 2026-11-02 17:37:26 +01:00
Codex f44de65e22 Handle unframed desktop admission and automation controls (by Codex) 2026-11-02 17:37:26 +01:00
Codex bea5478433 Run focused mouse input regressions in configured test suites (by Codex) 2026-11-02 17:37:26 +01:00
Codex 2d744e380c Align stadium UI fixtures with retained capacity policy (by Codex) 2026-11-02 17:30:07 +01:00
Codex 9140fb4b03 Run synthetic desktop input checks without private inventories (by Codex) 2026-11-02 16:59:52 +01:00
Codex 02f47f7972 Add mouse-operated overwrite confirmation (by Codex) 2026-11-02 16:26:29 +01:00
Codex 564af00d8d Add focused advertising input controller test route (by Codex) 2026-11-02 16:26:29 +01:00
Codex e8ba78e135 Verify folder corner removal and expose desktop input checks (by Codex) 2026-11-02 16:26:29 +01:00
Codex fcbe1ebc13 Refresh advertising hover when modal input returns (by Codex) 2026-11-02 16:23:10 +01:00
Codex 8b1dc16233 Fix unframed desktop date and folder input (by Codex) 2026-11-02 16:14:11 +01:00
Codex 9c10a2bfeb Restore original advertising hover outlines and help (by Codex) 2026-11-02 16:13:01 +01:00
Codex 6f33f9c155 Fix safe save overwrite activation by double-click (by Codex) 2026-11-02 16:13:01 +01:00
Codex 9c82cb16b5 Embed supplied high-resolution Classic start artwork (by Codex) 2026-11-02 02:24:56 +01:00
79 changed files with 10224 additions and 605 deletions

No files matched your search

+1 -1
View File
@@ -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.3/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.6/RELEASE_NOTES.md
+24 -1
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-3.0-only
cmake_minimum_required(VERSION 3.24)
project(OpenBMH VERSION 1.0.3 LANGUAGES CXX C)
project(OpenBMH VERSION 1.0.6 LANGUAGES CXX C)
if(APPLE)
# Enable native languages before dependencies/subdirectories inherit rules.
enable_language(OBJC OBJCXX)
@@ -449,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)
@@ -497,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}")
@@ -945,6 +964,7 @@ 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)
@@ -1130,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)
+6 -2
View File
@@ -1,6 +1,6 @@
# OpenBMH
**Classic-Version: 1.0.3.** Die originalgetreue Linie bleibt in diesem Repository.
**Classic-Version: 1.0.6.** 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.
@@ -28,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.3/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.6/RELEASE_NOTES.md).
## Features and direction
@@ -111,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.
+1
View File
@@ -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) |
+18
View File
@@ -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

+4
View File
@@ -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")
+17 -3
View File
@@ -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,11 +23,18 @@ 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.
@@ -160,3 +167,10 @@ 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.
+5 -1
View File
@@ -6,13 +6,14 @@ 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): show only the static title until a complete left or right click, without the DOS loading animation.
- [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.
@@ -33,8 +34,11 @@ describe deliberate changes; they are not a list of every known compatibility li
- [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_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.
+18
View File
@@ -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.
+51
View File
@@ -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.
+19 -20
View File
@@ -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 |
@@ -1490,19 +1490,19 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
| `Pitch_FormatError_TextPointer2` | `0xaf178` | German-compatible image / runtime field |
| `Pitch_FormatError_TextPointer3` | `0xaf17c` | German-compatible image / runtime field |
| `Pitch_Render_RuntimeField` | `0xa3cbc` | German-compatible image / runtime field |
| `PitchPreferenceDepthBases` | `0xa3cc3` | Four position-depth bases for native pitch feedback |
| `PitchPreferenceRed` | `0xa3cc7` | Ten native pointer red components |
| `PitchPreferenceGreen` | `0xa3cd1` | Ten native pointer green components |
| `OriginalPointerPixels` | `0xa45b4` | Native 11 by 11 indexed pointer bitmap |
| `EnglishPitchPreferenceDepthBases` | `0x6e230` | English position-depth bases |
| `EnglishPitchPreferenceRed` | `0x6e234` | English pointer red components |
| `EnglishPitchPreferenceGreen` | `0x6e240` | English pointer green components |
| `EnglishOriginalPointerPixels` | `0x70554` | English 11 by 11 indexed pointer bitmap |
| `Pitch_Render_TextPointer` | `0xae0e4` | German-compatible image / runtime field |
| `Pitch_Render_TextPointer2` | `0xae0ec` | German-compatible image / runtime field |
| `Pitch_Render_TextPointer3` | `0xae0f0` | German-compatible image / runtime field |
| `Pitch_Render_TextPointer4` | `0xae0f4` | German-compatible image / runtime field |
| `Pitch_Render_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 |
@@ -1578,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 |
@@ -1999,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 |
+2
View File
@@ -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.
+38
View File
@@ -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.
------------------------------------------------------------------------------
+57
View File
@@ -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.
+52
View File
@@ -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.
+54
View File
@@ -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.
+56 -62
View File
@@ -4,6 +4,7 @@
#include "game/calendar.hpp"
#include "formats/executable_layout.hpp"
#include "app/career_session.hpp"
#include "formats/league_visibility.hpp"
#include <stdexcept>
#include <system_error>
@@ -373,8 +374,15 @@ void restore_saved_turn_cursor(TurnDriver& driver, GameState& state, const Datab
const int manager_count = int(state.manager_teams.size());
if (manager_count > 4 || !state.memory.has(::bmh::layout::ActiveManager) || !state.memory.has(::bmh::layout::DeskPosition))
throw std::runtime_error("saved turn cursor: manager continuation fields are missing");
const int position = int(state.memory.u8(::bmh::layout::DeskPosition));
int position = int(state.memory.u8(::bmh::layout::DeskPosition));
const int active = int(state.memory.u8(::bmh::layout::ActiveManager));
// A completed manager loop leaves DeskPosition == ManagerCount (the day's desks are done). A desk
// that was saved in that state is the first desk again for a single manager: nothing else can
// follow it. Reading the byte as 0 lets the day go on instead of refusing the whole save.
if (manager_count == 1 && position == 1 && active == 0) {
position = 0;
state.memory.set8(::bmh::layout::DeskPosition, 0);
}
if (position < 0 || position >= manager_count)
throw std::runtime_error("saved turn cursor: manager position is outside the saved roster");
if (manager_count == 1) {
@@ -728,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);
@@ -757,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);
@@ -807,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) {
@@ -2247,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||
@@ -2335,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_) {
@@ -4529,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;
}
@@ -4583,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;
}
@@ -5626,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;
@@ -5744,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;
@@ -5797,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; }
+21 -3
View File
@@ -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"
@@ -578,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);
@@ -821,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);
});
@@ -938,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);
@@ -1320,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);
@@ -1866,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 {};
+77
View File
@@ -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
+61 -37
View File
@@ -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,7 @@
#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"
@@ -114,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")) {
@@ -138,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) {
@@ -147,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]);
@@ -194,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);
@@ -208,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);
@@ -225,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))
@@ -2669,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) {
@@ -3224,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) {
@@ -3619,42 +3645,40 @@ int main(int argc, char** argv) {
if (expired.request != ui::FlowRequest::none || expired.changed) handle(expired);
}
};
// OpenBMH deviates from the original: show only the static title until
// a complete left or right click, without the DOS loading animation.
const auto title_path = ui::asset_path(data / "KB", "137.VGA");
const auto title_palette = load_optional_embedded_palette(title_path);
const auto title_image = load_vga(title_path);
present_season(title_image, window_title.c_str(),
title_palette ? &*title_palette : nullptr);
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))
present_season(title_image, window_title.c_str(),
title_palette ? &*title_palette : nullptr);
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;
// 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);
}
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_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP);
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
season_backdrop.reset();
dirty = true;
SDL_StartTextInput();
+12 -4
View File
@@ -10,7 +10,9 @@
namespace bmh::app {
// SDL owns pointer position; the UI supplies only the original bitmap/colors.
// 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(); }
@@ -22,10 +24,16 @@ public:
}
pixels_.reset();
}
void show(const std::optional<std::array<uint32_t,121>>& pixels, SDL_Renderer* renderer) {
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;
SDL_GetRendererOutputSize(renderer, &width, &height);
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));
@@ -43,7 +51,7 @@ public:
}
private:
SDL_Cursor* cursor_ = nullptr;
std::optional<std::array<uint32_t,121>> pixels_;
std::optional<std::array<uint32_t,121>> pixels_, default_;
int scale_ = 1;
};
+40
View File
@@ -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_);
}
}
+22
View File
@@ -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;
};
}
+7
View File
@@ -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;
}
+8
View File
@@ -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`.
+7988
View File
File diff suppressed because it is too large. Load diff
+8
View File
@@ -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;
@@ -1559,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;
+14
View File
@@ -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);
}
}
+10 -12
View File
@@ -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) {
+2 -2
View File
@@ -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{};
+8
View File
@@ -3,6 +3,7 @@
#include "launch/fltd.hpp"
#include <algorithm>
#include <array>
#include <cstring>
#include <fstream>
#include <stdexcept>
@@ -26,6 +27,7 @@ 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.
@@ -128,6 +130,12 @@ LeImage translate_fltd(const fs::path& fltd_exe) {
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;
}
+9 -1
View File
@@ -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, {}},
+1 -1
View File
@@ -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 15"; // 15: original pitch affinity tables and pointer bitmap (14: calendar epoch)
constexpr const char* kTranslation = "english translation 17"; // 17: English monthly environment tables (16: overwrite question)
std::string built;
{
std::ifstream in(marker);
+1
View File
@@ -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")
+70 -17
View File
@@ -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");
+8
View File
@@ -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;
+84
View File
@@ -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 -2
View File
@@ -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 {
+11 -6
View File
@@ -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;
}
+1
View File
@@ -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,
+3 -1
View File
@@ -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;
+1 -1
View File
@@ -396,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);}
+17
View File
@@ -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);
+5 -1
View File
@@ -234,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");
@@ -621,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;
+9
View File
@@ -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
View File
@@ -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
View File
@@ -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}}};
+2
View File
@@ -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
View File
@@ -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()) {
+37 -14
View File
@@ -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>
@@ -173,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;
+6 -1
View File
@@ -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;
+2 -1
View File
@@ -185,7 +185,8 @@ int main(int argc, char** argv) {
const bool held=event.button.button==SDL_BUTTON_LEFT&&left_press&&
event.button.x==left_press->x&&event.button.y==left_press->y&&left_press->screen==screen.screen_name()&&SDL_GetTicks()-left_press->time>=2000;
auto result = held ? screen.hold(event.button.x,event.button.y,2000) :
screen.click(event.button.x, event.button.y, event.button.button == SDL_BUTTON_RIGHT);
screen.click(event.button.x, event.button.y, event.button.button == SDL_BUTTON_RIGHT,
event.button.clicks >= 2);
auto input=pointer_input(held ? "hold" : event.button.button == SDL_BUTTON_RIGHT ? "right" : "left",event.button.x,event.button.y);
if(held){input.pop_back();input+=",\"milliseconds\":"+std::to_string(SDL_GetTicks()-left_press->time)+"}";}
left_press.reset();report(screen, result, input);dirty |= result.changed;
+7 -2
View File
@@ -2,6 +2,7 @@
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/manager.hpp"
#include "formats/league_visibility.hpp"
#include <algorithm>
#include <iomanip>
@@ -151,6 +152,7 @@ ManagerScreen::ManagerScreen(const std::filesystem::path& data, int slot, const
if (exe_.u8(::bmh::layout::Manager_FormatError_RuntimeField + i * 2) < 'B') ++text_id;
if (last_[i] - first_[i] >= 20) throw FormatError("manager: league exceeds picker grid");
}
for(int i=player_league_count(exe_);i<5;++i){last_[i]=first_[i]-1;leagues_[i].clear();}
first_[5] = exe_.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField); last_[5] = first_[5] + 19;
first_[6] = first_[5] + 20; last_[6] = first_[5] + exe_.u16(::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6) - 1;
leagues_[5] = texts_[(::bmh::layout::Manager_FormatError_TextPointer - ::bmh::layout::TextPointerTable) / 4]; leagues_[6] = leagues_[5];
@@ -160,6 +162,8 @@ ManagerScreen::ManagerScreen(const std::filesystem::path& data, int slot, const
throw FormatError("manager: unsupported extra-team table");
}
int ManagerScreen::visible_league_count() const {return player_league_count(exe_);}
int ManagerScreen::master_id(int selection_id) const {
return context_.club_order.at(size_t(selection_id));
}
@@ -206,6 +210,7 @@ bool ManagerScreen::click(int x, int y, bool right) {
for (int i = 0; i < 7; ++i) {
int bx = i < 4 ? 64 : 161, by = 175 + (i < 4 ? i : i - 4) * 11;
if (x >= bx && x <= bx + 94 && y >= by && y <= by + 10) {
if(i<5&&i>=visible_league_count())return false;
bool changed = group_ != i; group_ = i; hover_ = hovered_club(x, y); return changed;
}
}
@@ -227,7 +232,7 @@ bool ManagerScreen::click(int x, int y, bool right) {
for (int i = 0; i < 4; ++i) {
if (x < field_x_[i] || x > field_x_[i] + field_width_[i] || y < baseline_[i] - 26 || y > baseline_[i] + 3) continue;
if (i == 0) { choice_.name.clear(); view_ = ManagerView::name_edit; return true; }
if (i == 1) { choice_.start_league = (choice_.start_league + 1) % 5; return true; }
if (i == 1) { choice_.start_league = (choice_.start_league + 1) % visible_league_count(); return true; }
if (i == 2) open_clubs = true;
if (i == 3) { choice_.strength = (choice_.strength + 1) % 3; return true; }
}
@@ -369,7 +374,7 @@ Image ManagerScreen::render() const {
if (choice_.selection_club == id) copy(out, faces_, 228, 0, x + 24, y + 23, 11, 13, true);
}
}
for (int i = 0; i < 7; ++i)
for (int i = 0; i < 7; ++i)if(i>=5||i<visible_league_count())
button(out, i < 4 ? 64 : 161, 175 + (i < 4 ? i : i - 4) * 11, 94, leagues_[i], group_ == i);
// Hover clear uses a new local pattern origin, even when no club is hovered.
pattern(out, 81, 222, 151, 8);
+1
View File
@@ -56,6 +56,7 @@ public:
// builds them from the executable's tables: label (original encoding) and the inclusive
// range of selection indices. Used by the console (openbmh_cli) for ListTeams.
static constexpr int group_count = 7;
int visible_league_count() const;
const std::string& group_label(int group) const { return leagues_.at(size_t(group)); }
int group_first(int group) const { return first_.at(size_t(group)); }
int group_last(int group) const { return last_.at(size_t(group)); }
+6 -1
View File
@@ -18,7 +18,12 @@ int main(int argc, char** argv) {
check(s.choice().master_club == 0 && s.choice().portrait == 0, "default available identity");
check(s.render().pixels.size() == 320 * 240, "original manager framebuffer");
check(!s.click(320, 10, true) && !s.text("ignored"), "invalid point and inactive text input");
for (int i = 0; i < 5; ++i) s.click(30, 140);
for (int i = 0; i < s.visible_league_count(); ++i) s.click(30, 140);
if(s.visible_league_count()==4) {
check(s.group_label(4).empty()&&s.group_last(4)<s.group_first(4),"hidden English domestic group remains selectable");
check(s.click(200,95),"English club picker opens");const auto unchanged=s.choice();
check(!s.click(180,180)&&s.choice()==unchanged,"hidden English group accepted a click");s.click(5,225,true);
}
for (int i = 0; i < 3; ++i) s.click(220, 140);
check(s.choice().start_league == 0 && s.choice().strength == 1, "league and strength wrap");
check(s.click(30, 65) && s.choice().name.empty(), "starting edit clears name like original");
+17 -5
View File
@@ -59,9 +59,16 @@ PitchExtras extras(const StaticMemory& memory,const Bytes& managers,const Bytes&
const int count=memory.u8(::bmh::layout::ManagerCount);
if(count<1||count>4||e.manager_slot>=count||teams.size()!=size_t(count))throw FormatError("pitch: invalid active manager");
e.runtime_club=teams.at(e.manager_slot);
if(e.runtime_club<0||e.runtime_club>=exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField))throw FormatError("pitch: unsupported club");
// The national-team desk has no club of its own (runtime club kNoTeam) and runs on the
// national pool; the lineup page accepts it under the same condition (see lineup.cpp).
const bool national=e.runtime_club==kNoTeam&&e.manager_slot==0&&count==1&&
((memory.u32(::bmh::layout::CompetitionSelection)&2)!=0||
(memory.has(::bmh::layout::CoachActive)&&memory.u8(::bmh::layout::CoachActive)!=0));
if(e.runtime_club<0||(e.runtime_club>=exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField)&&!national))
throw FormatError("pitch: unsupported club");
const size_t m=size_t(e.manager_slot)*0xb0c,f=size_t(e.manager_slot)*0x160;
if(managers.size()<m+0xb0c||formations.size()<f+0x160||badges.size()<size_t(e.runtime_club+1)*2)
if(managers.size()<m+0xb0c||formations.size()<f+0x160||
(!national&&badges.size()<size_t(e.runtime_club+1)*2))
throw FormatError("pitch: truncated manager/formations/badges");
e.formation_mask=managers.at(m+0x218);e.automatic_weights=managers.at(m+0x288);
auto manager_u16=[&](size_t at){return uint16_t(managers.at(m+at)|uint16_t(managers.at(m+at+1))<<8);};
@@ -69,7 +76,8 @@ PitchExtras extras(const StaticMemory& memory,const Bytes& managers,const Bytes&
e.set_piece_signature=manager_u16(0xb0a);
if(memory.has(uint32_t(::bmh::layout::CareerSession_AnyOf_ExecutableField+e.manager_slot*2)))
e.native_display_word=memory.u16(uint32_t(::bmh::layout::CareerSession_AnyOf_ExecutableField+e.manager_slot*2));
e.badge=le16(badges,size_t(e.runtime_club)*2)&0x1ff;
// The national team has no club badge entry; badge sheet 0 is used.
e.badge=national?0:le16(badges,size_t(e.runtime_club)*2)&0x1ff;
e.mode=memory.has(::bmh::layout::GameMode)?memory.u8(::bmh::layout::GameMode):exe.u8(::bmh::layout::GameMode);
std::copy_n(formations.begin()+f,8*22,e.formations.begin());
return e;
@@ -120,7 +128,8 @@ PitchExtras pitch_extras_from_game(const GameState& game,const LeImage& exe,uint
const size_t assignment=own_base+size_t(own)*0x58+0x44;
if(assignment+1>=game.tactics.size())throw FormatError("pitch: truncated own marking rows");
const uint16_t marked=uint16_t(game.tactics[assignment]|uint16_t(game.tactics[assignment+1])<<8);
if(marked==id){const int own_id=game.squad_slots.at(squad_range(e.runtime_club).first+size_t(own))&0x0fff;
if(marked==id){const size_t own_first=e.runtime_club==kNoTeam?size_t(3072):squad_range(e.runtime_club).first;
const int own_id=game.squad_slots.at(own_first+size_t(own))&0x0fff;
if(own_id!=0x0fff)opponent.current_marker_player_id=own_id;break;}
}
e.opponent_players.push_back(std::move(opponent));
@@ -657,8 +666,11 @@ PitchRequest PitchScreen::click(int x,int y,bool right){
r.set_piece_selector=shooter_selection_;r.expected_set_piece_value=extras_.set_piece_takers[size_t(shooter_selection_-2)];
pending_=r;return r;
}
if(!selected_)return {};
}
return {};
// OpenBMH extension: the field stays editable inside the editor. A click picks a taker
// only while a taker kind is chosen; otherwise (or with a player already marked for a
// move) the placement below works as on the normal page.
}
if(extras_.mode!=1&&order_panel_open_&&x>=243&&x<=315&&y>=179&&y<=226){
if(!selected_||*selected_>=11){rejection_="Für Anweisungen muss ein Startspieler markiert sein.";return {};}
+7
View File
@@ -169,6 +169,13 @@ int main(int argc,char**argv){try{
selector_copy.acknowledge(selected_lineup,selected);
check(selector_copy.state_json().find("\"shooter_selection\":1")!=std::string::npos,
"accepted taker write returns the original selector to neutral mode 1");
{
// the field stays editable inside the editor while no taker kind is chosen
const auto neutral_frame=selector_copy.render().pixels;
selector_copy.click(20,31);
check(selector_copy.render().pixels!=neutral_frame,
"inside the editor a click marks a player for placement when no taker kind is chosen");
}
auto automatic=selector_copy.click(260,215);
check(automatic.kind==PitchRequestKind::auto_set_piece_takers&&
automatic.expected_set_piece_values[0]==1&&automatic.expected_display_word==0x018b,
+12 -9
View File
@@ -98,7 +98,7 @@ void validate_strengths_preparation(const StrengthsIdentity& id,const DeskState&
if(next.desktop.revision!=before.revision+1||next.desktop.revision!=id.revision||
id.manager!=before.manager_slot||id.runtime_club!=before.runtime_club||id.day_counter!=before.day_counter||
id.manager<0||size_t(id.manager)>=before.managers.size()||
id.club_identity!=before.managers[size_t(id.manager)].club_identity_key)
id.club_identity!=before.session_identity_key(size_t(id.manager)))
throw FormatError("strengths: mismatched desk acknowledgement");
auto expected=before;expected.revision=id.revision;
if(desk_json(expected)!=desk_json(next.desktop))throw FormatError("strengths: unrelated desk state changed");
@@ -110,7 +110,7 @@ void validate_other_games_preparation(const OtherGamesIdentity& id, const DeskSt
id.manager_slot != before.manager_slot || id.runtime_team != before.runtime_club ||
id.day_counter != before.day_counter || id.manager_slot < 0 ||
size_t(id.manager_slot) >= before.managers.size() ||
id.club_identity != int(before.managers[size_t(id.manager_slot)].club_identity_key))
id.club_identity != int(before.session_identity_key(size_t(id.manager_slot))))
throw FormatError("other games: mismatched desk acknowledgement");
auto expected = before;
expected.revision = id.revision;
@@ -175,7 +175,7 @@ void StartupFlow::show_top_scorers(TopScorersState page,PreparationState prepara
page.identity.runtime_team!=desktop_->state().runtime_club||
page.identity.day_counter!=desktop_->state().day_counter||
page.identity.revision!=desktop_->state().revision+1||page.identity.sequence!=0||!page.identity.scope||
page.identity.club_identity!=int(desktop_->state().managers.at(size_t(owner.manager_slot)).club_identity_key))
page.identity.club_identity!=int(desktop_->state().session_identity_key(size_t(owner.manager_slot))))
throw FormatError("top scorers: mismatched opening acknowledgement");
if(preparation.desktop.revision!=page.identity.revision||preparation.desktop.manager_slot!=owner.manager_slot||
preparation.desktop.runtime_club!=desktop_->state().runtime_club||
@@ -246,7 +246,7 @@ void StartupFlow::show_opportunities(OpportunitiesState page,PreparationState pr
owner.manager_slot!=desktop_->state().manager_slot||owner.revision!=desktop_->state().revision||
page.identity.manager_slot!=owner.manager_slot||page.identity.runtime_team!=desktop_->state().runtime_club||
page.identity.day_counter!=desktop_->state().day_counter||page.identity.revision!=desktop_->state().revision+1||
page.identity.sequence!=0||page.identity.stable_club_identity!=int(desktop_->state().managers.at(size_t(owner.manager_slot)).club_identity_key))
page.identity.sequence!=0||page.identity.stable_club_identity!=int(desktop_->state().session_identity_key(size_t(owner.manager_slot))))
throw FormatError("opportunities: mismatched opening acknowledgement");
if(preparation.desktop.revision!=page.identity.revision||preparation.desktop.manager_slot!=owner.manager_slot||
preparation.desktop.runtime_club!=desktop_->state().runtime_club||preparation.desktop.day_counter!=desktop_->state().day_counter)
@@ -1144,6 +1144,7 @@ FlowResult StartupFlow::pointer_down(int x,int y,bool right) {
return {changed};
}
if (environment_) return {environment_->pointer_down(x,y,right)};
if (advertising_) return {advertising_->move(x,y)};
if(pitch_){
const std::string before=pitch_->state_json();
const auto request=pitch_->pointer_down(x,y,right);
@@ -1166,7 +1167,7 @@ void StartupFlow::show_balance(BalanceState page,const DeskRequest& owner) {
owner.manager_slot!=desktop_->state().manager_slot||owner.revision!=desktop_->state().revision||
page.identity.manager_slot!=owner.manager_slot||page.identity.runtime_club!=desktop_->state().runtime_club||
page.identity.day_counter!=desktop_->state().day_counter||page.identity.revision!=owner.revision||
page.identity.sequence!=0||!page.identity.scope||page.identity.club_identity!=int(desktop_->state().managers.at(size_t(owner.manager_slot)).club_identity_key))
page.identity.sequence!=0||!page.identity.scope||page.identity.club_identity!=int(desktop_->state().session_identity_key(size_t(owner.manager_slot))))
throw FormatError("balance: mismatched opening acknowledgement");
auto screen=std::make_unique<BalanceScreen>(data_,std::move(page));
desktop_->resolve_local_menu();balance_=std::move(screen);
@@ -1179,7 +1180,7 @@ void StartupFlow::acknowledge_balance(BalanceState page) {
page.identity.revision!=pending->identity.revision||page.identity.scope!=pending->identity.scope||
page.identity.revision!=desktop_->state().revision||page.identity.manager_slot!=desktop_->state().manager_slot||
page.identity.runtime_club!=desktop_->state().runtime_club||page.identity.day_counter!=desktop_->state().day_counter||
page.identity.club_identity!=int(desktop_->state().managers.at(size_t(page.identity.manager_slot)).club_identity_key)||
page.identity.club_identity!=int(desktop_->state().session_identity_key(size_t(page.identity.manager_slot)))||
page.identity.sequence!=pending->identity.sequence+1||
(pending->kind==BalanceAction::close)!=page.pending_close)
throw FormatError("balance: mismatched preview acknowledgement");
@@ -1197,7 +1198,7 @@ void StartupFlow::close_balance(BalanceState page,PreparationState preparation)
if(page.identity!=expected||pending->identity.manager_slot!=desktop_->state().manager_slot||
pending->identity.revision!=desktop_->state().revision||pending->identity.runtime_club!=desktop_->state().runtime_club||
pending->identity.day_counter!=desktop_->state().day_counter||
pending->identity.club_identity!=int(desktop_->state().managers.at(size_t(pending->identity.manager_slot)).club_identity_key)||
pending->identity.club_identity!=int(desktop_->state().session_identity_key(size_t(pending->identity.manager_slot)))||
preparation.desktop.revision!=expected.revision||
preparation.desktop.manager_slot!=expected.manager_slot||
preparation.desktop.manager_teams!=desktop_->state().manager_teams||
@@ -1825,7 +1826,7 @@ void StartupFlow::show_family_table_dispatch(std::array<LeagueTableState, 9> tab
throw FormatError("league family: mismatched Table dispatch identity");
if(identity.manager<0||size_t(identity.manager)>=desktop_->state().managers.size()||
identity.manager!=desktop_->state().manager_slot||identity.runtime_club!=desktop_->state().runtime_club||
identity.club_identity!=int(desktop_->state().managers[size_t(identity.manager)].club_identity_key))
identity.club_identity!=int(desktop_->state().session_identity_key(size_t(identity.manager))))
throw FormatError("league family: invalid Table dispatch manager identity");
if(!league_family_identity_&&(!desktop_->pending()||
desktop_->pending()->kind!=DeskRequestKind::open_menu||desktop_->pending()->menu_kind!=(friendly_entry?6:0)||
@@ -2080,7 +2081,7 @@ void StartupFlow::begin_league_family(StrengthsIdentity identity) {
identity.family_id==0)
throw FormatError("league family: invalid desktop entry identity");
if(identity.manager<0||size_t(identity.manager)>=desktop_->state().managers.size()||
identity.club_identity!=int(desktop_->state().managers[size_t(identity.manager)].club_identity_key))
identity.club_identity!=int(desktop_->state().session_identity_key(size_t(identity.manager))))
throw FormatError("league family: invalid manager identity");
league_family_identity_=identity;league_family_child_=0;
}
@@ -2293,6 +2294,8 @@ void StartupFlow::acknowledge_advertising(AdvertisingState state, DeskState desk
// Only contract acceptance resumes the next offer. Spending closes its calculator.
if (request.kind == AdvertisingActionKind::accept_offer)
(void)next_advertising->open_offers(request.offer.display_slot);
if (const auto pointer = advertising_->pointer_position())
(void)next_advertising->move((*pointer)[0], (*pointer)[1]);
desktop_ = std::move(next_desktop);
preparation_ = std::move(next_preparation);
advertising_ = std::move(next_advertising);
+59 -6
View File
@@ -9,6 +9,7 @@
#include <system_error>
#include "ui/manager.hpp"
#include "ui/game_end.hpp"
#include "ui/host_path.hpp"
#include "ui/setup.hpp"
#include "formats/fbm.hpp"
@@ -177,11 +178,24 @@ Image SaveLoadScreen::render() const {
text(out, 212, y, row.league, 0x6b, -1, footer_font_, true);
}
}
if (overwrite_confirmation_open_) {
TaxDialogProjection question;
question.kind = TaxDialogKind::question;
question.source_flags = 0x101; // Original overwrite prompt's Ja/Nein selectors.
question.source_system_identity = true;
question.badge_fallback = true;
question.portrait = 14;
question.body = exe_.string_at_pointer(::bmh::layout::SaveLoad_OverwriteQuestionPointer);
// OpenBMH deviates from the original: the host file picker uses the
// shared dialog's system identity without a live manager portrait projection.
draw_source_dialog(out, {widgets_, widgets_, nullptr, footer_font_, font_, exe_, sprite_font_, texts_},
question, gradient_text_);
}
return out;
}
bool SaveLoadScreen::info_press(int x, int y) {
if (file_kind_ != SaveLoadFileKind::game || pending_ || info_ || x <= 52 || x >= 200 || y <= 40 ||
if (file_kind_ != SaveLoadFileKind::game || pending_ || info_ || overwrite_confirmation_open_ || x <= 52 || x >= 200 || y <= 40 ||
y >= 192 || !select_row(y)) return false;
try {
const auto saved = load_savegame(entries_.at(size_t(selected_)).path);
@@ -316,14 +330,40 @@ void SaveLoadScreen::request_action() {
std::error_code ec;
const bool exists = std::filesystem::exists(path, ec);
if (ec) { feedback_ = "DATEI NICHT PRUEFBAR"; return; }
if (exists && !overwrite_armed_) { overwrite_armed_ = true; feedback_ = "EXISTIERT: ENTER ZUM ERSETZEN"; return; }
if (exists && !overwrite_armed_) {
overwrite_armed_ = true;
overwrite_confirmation_open_ = true;
feedback_.clear();
return;
}
overwrite_confirmation_open_ = false;
pending_ = SaveLoadRequest{SaveLoadAction::save, manager_slot_, revision_, path, exists,
file_kind_, origin_item_id_};
}
bool SaveLoadScreen::click(int x, int y, bool right) {
bool SaveLoadScreen::click(int x, int y, bool right, bool double_click) {
if (info_) { info_.reset(); return true; }
if (pending_) return false;
if (overwrite_confirmation_open_) {
if (right) {
overwrite_confirmation_open_ = overwrite_armed_ = false;
close_requested_ = true;
return true;
}
// Only a separate click on the question's buttons can decide. Further
// releases from a double/triple click in the file list cannot accept it.
if (double_click || y < 166 || y > 176) return false;
if (x >= 62 && x <= 137) {
overwrite_confirmation_open_ = false;
request_action();
return true;
}
if (x >= 175 && x <= 250) {
overwrite_confirmation_open_ = overwrite_armed_ = false;
return true;
}
return false;
}
// OpenBMH deviates from the original: permits cancelling host file dialogs with the right mouse button.
if (right) { close_requested_ = true; return true; }
if (x >= 206 && y >= 60 && y <= 169)
@@ -337,7 +377,11 @@ bool SaveLoadScreen::click(int x, int y, bool right) {
}
if (x >= 53 && x <= 199 && select_row(y)) {
const int row = scroll_ + (y - 40) / 10;
if (mode_ == SaveLoadMode::load && row == last_clicked_row_) { request_action(); return true; }
// Row selection clears overwrite confirmation before activation. Even a
// repeated double-click cannot confirm replacement.
if (double_click || (mode_ == SaveLoadMode::load && row == last_clicked_row_)) {
request_action(); return true;
}
last_clicked_row_ = row;
return true;
}
@@ -351,7 +395,15 @@ bool SaveLoadScreen::click(int x, int y, bool right) {
bool SaveLoadScreen::key(std::string_view value) {
if (info_) return false; // Centered waits for mouse release, not keyboard.
if (pending_) return false;
if (value == "ESC") { close_requested_ = true; return true; }
if (value == "ESC") {
overwrite_confirmation_open_ = overwrite_armed_ = false;
close_requested_ = true;
return true;
}
if (overwrite_confirmation_open_) {
if (value == "ENTER") { request_action(); return true; }
return false;
}
if (mode_ == SaveLoadMode::load && !entries_.empty()) {
if (value == "UP") { if (selected_ > 0) --selected_; if (selected_ < scroll_) scroll_ = selected_; return true; }
if (value == "DOWN") { if (selected_ + 1 < int(entries_.size())) ++selected_; if (selected_ >= scroll_ + 15) scroll_ = selected_ - 14; return true; }
@@ -380,7 +432,7 @@ bool SaveLoadScreen::key(std::string_view value) {
}
bool SaveLoadScreen::text(std::string_view value) {
if (info_ || mode_ != SaveLoadMode::save || !filename_focus_ || pending_ || value.empty()) return false;
if (info_ || overwrite_confirmation_open_ || mode_ != SaveLoadMode::save || !filename_focus_ || pending_ || value.empty()) return false;
const std::string next = (filename_selected_ ? std::string{} : filename_) + std::string(value);
if (!valid_filename(next)) return false;
filename_ = next; filename_selected_ = false;
@@ -418,6 +470,7 @@ std::string SaveLoadScreen::state_json() const {
<< ",\"filename\":" << json_quote(filename_) << ",\"entries\":[";
for (size_t i = 0; i < entries_.size(); ++i) { if (i) out << ','; out << json_quote(path_to_utf8(entries_[i].path.filename())); }
out << "],\"info_open\":" << (info_ ? "true" : "false")
<< ",\"overwrite_confirmation_open\":" << (overwrite_confirmation_open_ ? "true" : "false")
<< ",\"pending_action\":" << (pending_ ? save_load_request_json(*pending_) : "null")
<< ",\"feedback\":" << (feedback_.empty() ? "null" : json_quote(feedback_));
if (file_kind_ == SaveLoadFileKind::menu_layout || file_kind_ == SaveLoadFileKind::settings)
+2 -2
View File
@@ -42,7 +42,7 @@ public:
// InfoPress opens5870f on right DOWN; its popup restores on mouse UP.
bool info_press(int x, int y);
bool info_open() const { return bool(info_); }
bool click(int x, int y, bool right = false);
bool click(int x, int y, bool right = false, bool double_click = false);
bool key(std::string_view key);
bool text(std::string_view value);
const std::optional<SaveLoadRequest>& pending() const { return pending_; }
@@ -72,7 +72,7 @@ private:
int selected_ = 0, scroll_ = 0;
std::string filename_, feedback_;
bool filename_focus_ = false, filename_selected_ = false;
bool overwrite_armed_ = false, close_requested_ = false;
bool overwrite_armed_ = false, overwrite_confirmation_open_ = false, close_requested_ = false;
int last_clicked_row_ = -1;
std::optional<SaveLoadRequest> pending_;
struct InfoRow { std::string manager, club, league; };
+93 -1
View File
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "ui/save_load.hpp"
#include "ui/flow.hpp"
#include <chrono>
#include <fstream>
#include <iostream>
#include <iterator>
#include <stdexcept>
using namespace bmh;
@@ -30,7 +32,90 @@ int main(int argc, char** argv) {
std::pair{SaveLoadFileKind::game, ".FBM"},
std::pair{SaveLoadFileKind::settings, ".EIN"},
std::pair{SaveLoadFileKind::menu_layout, ".MEN"}}) {
std::ofstream(root / (std::string("Existing") + extension)) << "authored filename fixture";
const auto existing = root / (std::string("Existing") + extension);
const std::string fixture = "authored filename fixture";
std::ofstream(existing) << fixture;
const auto unchanged = [&] {
std::ifstream input(existing);
check(std::string(std::istreambuf_iterator<char>(input), {}) == fixture,
"picker interactions never write the selected file");
};
SaveLoadScreen overwrite(argv[1], root, SaveLoadMode::save, 2, 17, backdrop, true, kind, 9);
check(overwrite.click(70, 45) && overwrite.click(70, 45) && !overwrite.pending() &&
overwrite.state_json().find("\"overwrite_confirmation_open\":false") != std::string::npos,
"separate single clicks only select an existing save");
check(overwrite.click(70, 45, false, true) && !overwrite.pending() &&
overwrite.state_json().find("\"overwrite_confirmation_open\":true") != std::string::npos,
"a true double-click asks for overwrite confirmation without submitting a write");
check(!overwrite.click(70, 45, false, true) && !overwrite.pending(),
"repeated double-clicks cannot confirm an overwrite");
unchanged();
check(overwrite.key("ENTER") && overwrite.pending() && overwrite.pending()->overwrite &&
overwrite.pending()->path == existing && overwrite.pending()->manager_slot == 2 &&
overwrite.pending()->revision == 17 && overwrite.pending()->file_kind == kind &&
overwrite.pending()->origin_item_id == 9,
"Enter confirms the exact selected file with its manager, revision and file kind");
const auto request = *overwrite.pending();
check(!overwrite.click(70, 45, false, true) && !overwrite.key("ENTER") &&
*overwrite.pending() == request,
"queued mouse releases and Enter cannot submit a second pending overwrite");
overwrite.acknowledge();
check(overwrite.close_requested() && !overwrite.pending(),
"acknowledgement closes the picker and clears its one request");
unchanged();
SaveLoadScreen mouse(argv[1], root, SaveLoadMode::save, 0, 7, backdrop, true, kind);
const auto list = mouse.render();
mouse.click(70, 45, false, true);
check(mouse.render().pixels != list.pixels && !mouse.text("IGNORED") &&
!mouse.key("BACKSPACE") && !mouse.info_press(70, 45),
"the original overwrite question owns input and renders over the file list");
check(!mouse.click(100, 171, false, true) && !mouse.pending(),
"double-click releases cannot accept even over the question's Yes button");
check(mouse.click(210, 171) && !mouse.pending() && !mouse.close_requested() &&
mouse.render().pixels == list.pixels,
"No dismisses the question and restores the unchanged picker");
mouse.click(70, 45, false, true);
check(mouse.click(100, 171) && mouse.pending() && mouse.pending()->overwrite &&
mouse.pending()->path == existing,
"double-click followed by a separate Yes click submits an entirely mouse-operated overwrite");
const auto mouse_request = *mouse.pending();
check(!mouse.click(100, 171) && *mouse.pending() == mouse_request,
"additional Yes releases preserve one pending write");
unchanged();
for (bool right : {false, true}) {
SaveLoadScreen cancel(argv[1], root, SaveLoadMode::save, 0, 7, backdrop, true, kind);
cancel.click(70, 45, false, true);
check((right ? cancel.click(70, 45, true, true) : cancel.key("ESC")) &&
cancel.close_requested() && !cancel.pending(),
"right-click and Escape cancel an armed overwrite without a write");
}
const auto second = root / (std::string("Second") + extension);
std::ofstream(second) << fixture;
SaveLoadScreen change_row(argv[1], root, SaveLoadMode::save, 0, 7, backdrop, true, kind);
change_row.click(70, 45, false, true);
check(!change_row.click(70, 55) && change_row.selected() == 0,
"the question prevents the file list from changing its target");
change_row.click(210, 171); // Decline before selecting another file.
check(change_row.click(70, 55) && change_row.key("ENTER") && !change_row.pending() &&
change_row.key("ENTER") && change_row.pending() && change_row.pending()->path == second,
"selecting another row cannot reuse the first file's overwrite confirmation");
SaveLoadScreen reset(argv[1], root, SaveLoadMode::save, 0, 7, backdrop, true, kind);
reset.click(70, 45, false, true);
reset.click(210, 171);
reset.click(70, 45);
check(reset.key("ENTER") && !reset.pending() && reset.key("ENTER") && reset.pending(),
"declining and selecting again preserves the existing two-Enter save path");
SaveLoadScreen rename(argv[1], root, SaveLoadMode::save, 0, 7, backdrop, true, kind);
rename.click(70, 45, false, true);
rename.click(210, 171);
check(rename.text("Other") && rename.key("ENTER") && rename.pending() &&
!rename.pending()->overwrite && rename.pending()->path.filename() == std::string("Other") + extension,
"editing an armed overwrite starts an independent new-file save");
SaveLoadScreen activate_load(argv[1], root, SaveLoadMode::load, 0, 7, backdrop, true, kind);
check(activate_load.click(70, 45, false, true) && activate_load.pending() &&
activate_load.pending()->action == SaveLoadAction::load && activate_load.pending()->path == existing,
"an explicit double-click also activates an existing load entry");
unchanged();
SaveLoadScreen load(argv[1], root, SaveLoadMode::load, 0, 7, backdrop, true, kind);
check(load.click(0, 0, true) && load.close_requested() && !load.pending(),
"right-click closes every file picker without submitting a load");
@@ -54,6 +139,13 @@ int main(int argc, char** argv) {
check(edit.pending() && edit.pending()->path.filename() == std::string("Short") + extension,
"editing and UTF-8 deletion preserve the resulting host filename");
}
StartupFlow flow(argv[1], root);
flow.click(214, 215);
check(flow.screen_name() == "save_load", "setup opens its save-list picker");
const auto load = flow.click(70, 45, false, true);
check(load.request == FlowRequest::file_action && load.file_action.action == SaveLoadAction::load &&
load.file_action.path.filename() == "Existing.FBM",
"startup flow forwards a real double-click to its active file picker");
std::cout << "save/load input checks passed\n";
return 0;
} catch (const std::exception& error) {
+12 -1
View File
@@ -51,6 +51,11 @@ std::string number(int value) {
}
}
namespace {
std::string& product_version() { static std::string version; return version; }
}
void set_settings_product_version(std::string version) { product_version() = std::move(version); }
std::array<uint8_t, 180> project_settings_availability(
const std::array<uint8_t, 180>& raw_cells, const SettingsAvailabilityInputs& in,
const LeImage& exe) {
@@ -210,7 +215,13 @@ Image SettingsScreen::render() const {
}
sprite_font_.draw(out, SpriteFont::centered_title_x(sprite_font_.text_width(state_.title)), 13, state_.title);
sprite_font_.draw(out, 5, 235, state_.footer);
text(out, 2, 41, utf8_to_original(state_.version), 0x5f, 58);
// OpenBMH deviates from the original: the settings page names the product and its build version instead of the original's version text.
if (product_version().empty()) {
text(out, 2, 41, utf8_to_original(state_.version), 0x5f, 58);
} else {
text(out, 2, 41, "OpenBMH", 0x5f, 58);
text(out, 2, 49, utf8_to_original(product_version()), 0x5f, 58);
}
for (int col = 0; col < 9; ++col) {
const auto label = std::to_string(col + 1);
// DrawnFirstBy uses x directly when right=-1 and shadow=0x40.
+4
View File
@@ -64,6 +64,10 @@ SettingsState settings_from_game(const GameState&, int manager, uint64_t revisio
std::optional<uint32_t> settings_source_refusal(const GameState& state,
const SettingsWriteRequest& request, uint64_t revision);
// The product line of the settings page: "OpenBMH" and, below it, this build's version. Set once by the
// application (the UI library does not include the generated version); empty keeps the original text.
void set_settings_product_version(std::string version);
class SettingsScreen {
public:
SettingsScreen(const std::filesystem::path& data, SettingsState state, int origin_item_id = -1);
+22 -4
View File
@@ -932,6 +932,7 @@ Image StadiumScreen::render_scene() const {
copy_crop(out, panel_, 219, row_y - 19, 220, row_y + 1, 98, 22);
}
source_border(out, 219, row_y, 318, row_y + 23);
if (pressed_ == Pressed::none && hover_block_ == int(i)) outline(out, 219, row_y, 100, 24, 0x27);
const auto& block = state_.blocks[i];
std::string label = texts_[text_id(::bmh::layout::Stadium_Out_TextPointer)];
if (label.size() > 6) label[6] = char('A' + i);
@@ -997,7 +998,8 @@ Image StadiumScreen::render_scene() const {
text_at(out, x + (0x35 - label_width) / 2, y + 0x1b, tier, 0x5f);
}
}
if (pressed_ == Pressed::investment && pressed_index_ == int(choice))
if ((pressed_ == Pressed::investment && pressed_index_ == int(choice)) ||
(pressed_ == Pressed::none && hover_investment_ == int(choice)))
outline(out, x, y, 0x35, 0x1d, 0x27);
if (future_information_ && row.construction_weeks) {
const std::string weeks = format_number(GameState{}, row.construction_weeks, 0x82) +
@@ -1454,7 +1456,23 @@ bool StadiumScreen::pointer_down(int x, int y, bool right) {
bool StadiumScreen::pointer_move(int x, int y) {
if (calculator_source_waiting()) return false;
if (pressed_ == Pressed::none) {
if (!panorama_ || pending_ || state_.quoted_object || state_.data) return false;
if (pending_ || state_.quoted_object || state_.data) return false;
if (!panorama_) {
// the same targets a click acts on: an available investment icon or a finished seat block
int investment = -1, block = -1;
if (y >= 153 && y <= 211 && x >= 3 && x <= 217) {
const int choice = ((y - 153) / 30) * 4 + (x - 3) / 54;
if (choice >= 0 && choice < 8 && state_.investments_enabled && state_.investments[size_t(choice)].available)
investment = choice;
} else if (x >= 219 && x <= 319 && y >= 22 && y <= 213) {
const int slot = (y - 22) / 24;
if (slot >= 0 && slot < 8 && state_.blocks[size_t(slot)].construction_weeks == 0) block = slot;
}
const bool changed = investment != hover_investment_ || block != hover_block_;
hover_investment_ = investment;
hover_block_ = block;
return changed;
}
const int hover = periphery_object_at(x, y);
if (hover == periphery_hover_) return false;
periphery_hover_ = hover;
@@ -1564,8 +1582,8 @@ StadiumRequest StadiumScreen::release(int x, int y, bool right) {
return emit(request(StadiumRequestKind::set_data_ticket_price, index - 8 + 10));
}
if (pressed == Pressed::scene_button) {
if (index == 0) { panorama_ = !panorama_; future_information_ = false; periphery_hover_ = -1; return {}; }
if (index == 1) { future_information_ = !future_information_; periphery_hover_ = -1; return {}; }
if (index == 0) { panorama_ = !panorama_; future_information_ = false; periphery_hover_ = -1; hover_investment_ = hover_block_ = -1; return {}; }
if (index == 1) { future_information_ = !future_information_; periphery_hover_ = -1; hover_investment_ = hover_block_ = -1; return {}; }
return emit(request(StadiumRequestKind::open_data));
}
if (pressed == Pressed::investment)
+3
View File
@@ -235,6 +235,9 @@ private:
int pressed_x_ = -1, pressed_y_ = -1;
std::optional<GameEndTaxDialog> tip_dialog_, periphery_dialog_;
int periphery_hover_ = -1;
// Yellow frame under the pointer, as on the advertising page: an investment icon or a seat block
// that a click would act on (-1 none).
int hover_investment_ = -1, hover_block_ = -1;
int periphery_object_at(int x, int y) const;
bool periphery_object_contains(int object, int x, int y) const;
void render_panorama(Image&) const;
+28 -1
View File
@@ -250,7 +250,16 @@ Image TrainingScreen::render() const {
}
rect(out, 190, 222, 66, 6, 0x44);
text(out, 190, 220, texts_[(::bmh::layout::Training_Render_TextPointer4 - ::bmh::layout::TextPointerTable) / 4], 0x51, -1, false);
for (int i = 0; i < 7; ++i) copy(out, skill_atlas_, 256, 32, 190 + i * 10, 222, 16, 5, 0);
// The original's skill display: seven bars, one per skill (two bits each of the player's skill word); each
// takes the atlas tile of its level 0-3, all empty while no player's row is under the pointer.
const auto hovered = hovered_row_ ? std::find_if(state_.players.begin(), state_.players.end(),
[&](const auto& p) { return p.row == *hovered_row_; })
: state_.players.end();
for (int i = 0; i < 7; ++i) {
const int level = hovered == state_.players.end() ? 0 : int(hovered->skills >> (2 * i) & 3);
const int sx = 256 + level * 16; // KB/2 is 314 wide: the last tile may be cut short
copy(out, skill_atlas_, sx, 32, 190 + i * 10, 222, std::min(16, skill_atlas_.width - sx), 5, 0);
}
// Int6: four original table-driven groups, transparent index DesktopRuntimeField=0.
for (int group = 0; group < 4; ++group) {
const int count = group == 3 ? int(state_.players.size()) : exe_.u8(::bmh::layout::Training_Click_RuntimeField7 + group);
@@ -347,6 +356,24 @@ TrainingRequest TrainingScreen::click(int x, int y, bool right) {
}
return {};
}
bool TrainingScreen::move(int x, int y) {
if (pending_) return false;
// The player group (3) of the click table: its box selects the row exactly as a click does.
std::optional<int> row;
const int count = int(state_.players.size());
const int bx = exe_.u16(::bmh::layout::Training_Click_RuntimeField + 3 * 2), by = exe_.u8(::bmh::layout::Training_Click_RuntimeField3 + 3);
const int dx = exe_.u8(::bmh::layout::Training_Click_RuntimeField8 + 3), dy = exe_.u8(::bmh::layout::Training_Click_RuntimeField9 + 3);
const int ball_dx = exe_.u8(::bmh::layout::Training_Click_RuntimeField5 + 3), ball_dy = exe_.u8(::bmh::layout::Training_Click_RuntimeField6 + 3);
if (x >= bx - 14 && y >= by && x < bx + count * dx + 3 * ball_dx && y < by + count * dy + 3 * ball_dy) {
const int index = dx ? (x - bx) / dx : (y - by) / dy;
if (index >= 0 && index < count &&
std::any_of(state_.players.begin(), state_.players.end(), [&](const auto& p) { return p.row == index; }))
row = index;
}
const bool changed = row != hovered_row_;
hovered_row_ = row;
return changed;
}
TrainingRequest TrainingScreen::key(std::string_view key) {
if (!pending_ && (key == "ESC" || key == "ESCAPE" || key == "BACKSPACE")) close_requested_ = true;
return {};
+4
View File
@@ -54,6 +54,9 @@ public:
Image render() const;
TrainingRequest click(int x, int y, bool right = false);
TrainingRequest key(std::string_view key);
// The original's skill display: while the pointer rests on a player's row of the training list, the
// seven skill bars (T S S P Z F E) at the bottom show that player's skills; leaving it clears them.
bool move(int x, int y);
// Opening an uninitialized original screen invokes Initialize. This
// explicit request must be serviced by an engine adapter, never by render().
TrainingRequest initialize();
@@ -73,6 +76,7 @@ private:
std::optional<TrainingRequest> pending_;
bool close_requested_ = false;
std::string last_rejection_;
std::optional<int> hovered_row_;
void text(Image&, int x, int baseline, std::string_view, uint8_t color, int right = -1, bool shadow = true) const;
void sprite_text(Image&, int x, int baseline, std::string_view, int font) const;
void button(Image&, int x, int y, int width, int height, std::string_view, bool active) const;
+10
View File
@@ -66,6 +66,16 @@ int main(int argc, char** argv) {
"projection may not change original game tables");
TrainingScreen screen(data, s); const auto frame = screen.render().pixels;
check(frame == screen.render().pixels, "repeat rendering is deterministic and pure");
{
// the seven skill bars follow the player row under the pointer
const int bx = exe.u16(::bmh::layout::Training_Click_RuntimeField + 6), by = exe.u8(::bmh::layout::Training_Click_RuntimeField3 + 3);
const int dy = exe.u8(::bmh::layout::Training_Click_RuntimeField9 + 3);
TrainingScreen hover(data, s);
check(!hover.move(0, 0) && hover.render().pixels == frame, "a pointer off the list changes nothing");
check(hover.move(bx + 1, by + dy + 1) && hover.render().pixels != frame,
"the skill bars show the player row under the pointer");
check(hover.move(0, 0) && hover.render().pixels == frame, "the bars are empty again when the pointer leaves");
}
check(screen.click(175, 26).kind == TrainingRequestKind::none, "condition+technique cannot exceed four balls");
auto r = screen.click(155, 26);
check(r.kind == TrainingRequestKind::set_area && r.index == 0 && r.value == 1 && r.manager_slot == 1 &&
+362 -98
View File
@@ -1,9 +1,11 @@
#include "test_inputs.hpp"
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "formats/league_visibility.hpp"
#include <algorithm>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <filesystem>
#include <fstream>
@@ -1267,6 +1269,18 @@ void check_calendar_readonly_controller(const std::filesystem::path& data) {
check(flow.click(0, 0, true).request == FlowRequest::none, "menu 7 close release is consumed");
check(!flow.calendar() && flow.screen_name() == "desktop",
"right event8 closes menu 7 and returns to the refreshed desk");
// After a kickoff the memory copy of the season day is only the day the game was loaded: the
// calendar follows the live day (it was refused from the first kickoff on).
ui::DeskRequest kickoff;
kickoff.kind = ui::DeskRequestKind::advance_turn;
kickoff.manager_slot = int(game.memory.u8(::bmh::layout::ActiveManager));
kickoff.revision = revision;
std::string kickoff_error;
const auto advanced = session->dispatch_kickoff(kickoff, revision, kickoff_error);
check(advanced.kind != TurnDeskKind::Failed, "the fixture's first kickoff is played");
const auto after_kickoff = ui::calendar_from_game(game, load_le(asset_path(data, "BMH.exe")));
check(after_kickoff.current_day == game.season_day() + after_kickoff.leading_days,
"the calendar after a kickoff shows the live day of the season");
}
void check_readonly_views(const std::filesystem::path& data) {
@@ -1523,6 +1537,18 @@ void check_advertising_controller(const std::filesystem::path& data) {
};
serve(flow.send_key("W"));
check(flow.screen_name() == "advertising", "Original W opens advertising through the controller");
const auto unhovered_pixels = flow.render().pixels;
const auto moved = flow.move_action(40, 30);
check(moved.changed && moved.request == FlowRequest::none &&
flow.state_json().find("\"hovered_target\":") != std::string::npos &&
flow.render().pixels != unhovered_pixels && !flow.pending_advertising_action(),
"production flow routes advertising motion into the original hover and help view");
check(!flow.pointer_down(40, 30).changed && !flow.pending_advertising_action(),
"advertising DOWN does not duplicate the release-owned offer action");
unchanged();
check(flow.move_action(-1, -1).changed && flow.render().pixels == unhovered_pixels,
"production flow restores the advertising view when the pointer leaves");
unchanged();
serve(flow.click(40, 30));
(void)flow.render();
unchanged();
@@ -1606,7 +1632,14 @@ void check_advertising_controller(const std::filesystem::path& data) {
"independent source commit accepts the two-board offer");
const auto expected_bytes = save_stream(expected);
const int32_t cash_before = signed_u32(game.manager_records, record + 0x314);
const auto advertising_exe = load_le(asset_path(data, "BMH.exe"));
check(!flow.move_action(
advertising_exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + 18 * 2) + 2,
advertising_exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + 18 * 2) + 2).changed,
"accepted offer remembers a moved pointer while its pending browser stays frozen");
serve(action);
check(flow.state_json().find("\"hovered_target\":18") != std::string::npos,
"accepted final offer resumes current hover outside its original contract target");
check(save_stream(game) == expected_bytes && revision == original_revision + 1 &&
!flow.pending_advertising_action() && flow.screen_name() == "advertising" &&
flow.desktop()->state().revision == revision &&
@@ -1626,6 +1659,20 @@ void check_advertising_controller(const std::filesystem::path& data) {
"replayed accepted advertisement cannot consume a second revision or another offer");
}
void check_player_league_visibility_controller(const std::filesystem::path& data) {
const auto exe=load_le(asset_path(data,"BMH.exe"));const auto visible=player_league_count(exe);
if(visible==5)return;
app::CareerSession session(data,0x1789abcd);const auto before=save_stream(session.state());
const auto game=session.game();const auto random=session.rand();SetupOptions options;options.world=false;options.league=true;options.managers=1;
const auto context=session.selection_context(0);ManagerChoice choice;choice.master_club=context.club_order[0];choice.name="Visibility";choice.start_league=visible;
std::string error;
check(!session.confirm_manager(options,choice,error)&&!error.empty()&&save_stream(session.state())==before&&session.game().calls()==game.calls()&&session.rand().calls()==random.calls(),"hidden target league changed initial options/state/RNG");
int first=0;for(int league=0;league<visible;++league)first+=exe.u8(::bmh::layout::LeagueSizes+uint32_t(league));
choice.start_league=0;choice.master_club=context.club_order.at(size_t(first));error.clear();
check(!session.confirm_manager(options,choice,error)&&!error.empty()&&save_stream(session.state())==before&&session.game().seed()==game.seed()&&session.rand().seed()==random.seed(),"hidden club entered fresh human management");
choice.master_club=context.club_order[0];error.clear();check(session.confirm_manager(options,choice,error),"valid visible league failed after rejected hidden choices");
}
void check_environment_controller(const std::filesystem::path& data) {
StartupFlow flow(data);
flow.click(150, 215); flow.click(5, 225, true); flow.click(5, 225, true);
@@ -1810,7 +1857,11 @@ void check_advertising_spending_controller(const std::filesystem::path& data) {
const auto before = save_stream(g);
const auto w = session->rand(); const auto gr = session->game();
open(17); flow.text("5000"); (void)flow.render();
serve(flow.send_key("ESC"));
check(!flow.pointer_down(0, 0, true).changed,
"right DOWN records its position while the calculator still owns input");
serve(flow.click(0, 0, true));
check(flow.state_json().find("\"hovered_target\":-1") != std::string::npos,
"calculator right release removes its old outline without a motion event");
check(save_stream(g) == before && session->rand().calls() == w.calls() &&
session->game().calls() == gr.calls(), "calculator input and cancel are read-only");
open(17); flow.text("5000");
@@ -1820,7 +1871,14 @@ void check_advertising_spending_controller(const std::filesystem::path& data) {
check(save_stream(g) == before && !flow.pending_advertising_action(),
"forged monthly request cannot mutate state");
open(17); flow.text("5000"); monthly = submit();
const int resumed_x = exe.u16(::bmh::layout::Advertising_Click_RuntimeField3 + 18 * 2) + 2;
const int resumed_y = exe.u16(::bmh::layout::Advertising_Click_RuntimeField4 + 18 * 2) + 2;
check(!flow.move_action(resumed_x, resumed_y).changed,
"pending calculator keeps its parent frozen while remembering the latest pointer");
serve(monthly);
check(flow.state_json().find("\"hovered_target\":18") != std::string::npos &&
!flow.move_action(resumed_x, resumed_y).changed,
"spending acknowledgement resumes the last pointer over its refreshed parent without new motion");
check(signed_u32(g.manager_records, record + 0x854) == 5000 &&
signed_u32(g.manager_records, record + 0x314) == 500000 &&
session->rand().calls() == w.calls() && session->game().calls() == gr.calls(),
@@ -2371,33 +2429,33 @@ void check_semantic_desk_settings(const std::filesystem::path& data) {
check(session.finish(init,error),"semantic setting fixture reaches a real desk");
revision=init.desktop.revision;
const int manager=game.memory.u8(::bmh::layout::ActiveManager); const size_t rec=size_t(manager)*0xb0c;
const auto default_desk=session.desktop_projection(revision);
check(std::none_of(default_desk.items.begin(),default_desk.items.end(),[](const auto& item) {
return item.kind==64&&item.open&&!item.disabled;
}),"parent failure uses the actual default closed automation drawer");
// Typed settings remain independent of hidden desktop presentation records.
int automation_item=-1,price_item=-1;
for(int i=0;i<54;++i) {
const auto at=::bmh::layout::DesktopsUnsigned+uint32_t(manager)*0x360+uint32_t(i)*16;
const auto kind=game.memory.u8(at+12);
if(kind==64)automation_item=i;
if(kind==64) {
automation_item=i;
game.memory.set16(at,uint16_t(game.memory.u16(at)|0x1000));
}
if(kind==55) {
price_item=i;
game.memory.set8(at+13,uint8_t(game.memory.u8(at+13)&~0x80));
game.memory.set16(at,uint16_t(game.memory.u16(at)|0x1000));
}
}
check(automation_item>=0&&price_item>=0,"Original MEN contains both setting drawers");
DeskRequest legacy{DeskRequestKind::change_option,manager,automation_item,64,1,revision};
reject([&]{return session.dispatch_desk_widget(legacy,revision,error);},
"original SDL dispatcher still rejects default closed automation");
check(error=="stale_or_closed_desk_widget","closed widget fails at the retained SDL item guard");
"SDL dispatcher rejects a hidden automation item");
check(error=="stale_or_closed_desk_widget","hidden widget fails at the retained SDL item guard");
for(int value:{8,25,17}) {
price={identity(),value}; auto expected=game; expected.manager_records[rec+0x26e]=uint8_t(value);
accept([&]{return session.dispatch_ticket_price(price,revision,error);},expected,
"typed price works with a closed drawer and changes only admission, never cash or credit");
"typed price works with a hidden drawer and changes only admission, never cash or credit");
}
reject([&]{return session.dispatch_ticket_price(price,revision,error);},"stale price replay is wholly neutral");
legacy={DeskRequestKind::change_ticket_price,manager,price_item,55,12,revision};
reject([&]{return session.dispatch_desk_widget(legacy,revision,error);},"typed price does not unlock the SDL drawer");
reject([&]{return session.dispatch_desk_widget(legacy,revision,error);},"typed price does not unhide the SDL drawer");
for(int value:{7,26}) {
price={identity(),value};
reject([&]{return session.dispatch_ticket_price(price,revision,error);},"typed price rejects outside Original endpoints");
@@ -2550,7 +2608,8 @@ void check_semantic_desk_settings(const std::filesystem::path& data) {
std::filesystem::remove_all(directory);
}
void check_desk_widgets(const std::filesystem::path& data) {
void check_desk_widgets_for_frame(const std::filesystem::path& data, bool framed) {
const int content_x=20+(framed?4:0);
StartupFlow flow(data);
flow.click(150, 215); flow.click(5, 225, true); flow.click(5, 225, true);
flow.click(90, 169);
@@ -2573,7 +2632,7 @@ void check_desk_widgets(const std::filesystem::path& data) {
game.memory.set8(at + 4, uint8_t(i == 1 ? 36 : 38));
game.memory.set8(at + 5, uint8_t(i == 1 ? 2 : 0));
game.memory.set8(at + 12, uint8_t(i == 1 ? 55 : 64));
game.memory.set8(at + 13, 0x80);
game.memory.set8(at + 13, framed?0x80:0);
}
init.desktop = session->desktop_projection(revision);
init.preparation = session->preparation_projection(revision);
@@ -2598,22 +2657,22 @@ void check_desk_widgets(const std::filesystem::path& data) {
const auto ws = session->rand().seed();
const auto gc = session->game().calls(), wc = session->rand().calls();
const auto rev = revision;
const auto price = flow.click(20 + 4 + 86, 90);
const auto price = flow.click(content_x + 86, 90);
check(price.desk_action.value == 25, "rightmost original price hitbox maps to 25");
check(flow.click(20 + 4 + 35, 90).request == FlowRequest::none, "pending widget blocks a duplicate");
check(flow.click(content_x + 35, 90).request == FlowRequest::none, "pending widget blocks a duplicate");
execute(price);
auto changed_records = records;
changed_records[0x26e] = 25;
check(game.manager_records == changed_records && game.manager_options == options && revision == rev + 1,
"price changes only the active manager's admission byte");
execute(flow.click(20 + 4 + 35, 90));
execute(flow.click(content_x + 35, 90));
check(game.manager_records[0x26e] == 8, "leftmost original price hitbox maps to 8");
check(flow.click(20 + 4 + 34, 90).request == FlowRequest::none &&
flow.click(20 + 4 + 87, 90).request == FlowRequest::none,
check(flow.click(content_x + 34, 90).request == FlowRequest::none &&
flow.click(content_x + 87, 90).request == FlowRequest::none,
"outside price endpoints remain read-only");
for (int index : {1, 2, 3, 4}) {
const auto before = game.manager_options;
execute(flow.click(20 + 4 + index * 33 + 10, 140));
execute(flow.click(content_x + index * 33 + 10, 140));
auto expected = before;
expected[size_t(index)] ^= 1;
check(game.manager_options == expected, "automation toggles only its Original bit including training high flags");
@@ -2623,12 +2682,12 @@ void check_desk_widgets(const std::filesystem::path& data) {
game.manager_records[0x219] = 0x02; // Indoor: only formation 2.
game.manager_options[0] = 0;
for (int value : {3, 8, 0}) {
execute(flow.click(20 + 4 + 10, 140));
execute(flow.click(content_x + 10, 140));
check(game.manager_options[0] == value, "outdoor automation skips unavailable stored formations and wraps to off");
}
game.indoor = true;
for (int value : {2, 0}) {
execute(flow.click(20 + 4 + 10, 140));
execute(flow.click(content_x + 10, 140));
check(game.manager_options[0] == value, "indoor automation uses the separate saved formation mask");
}
game.indoor = false;
@@ -2638,9 +2697,14 @@ void check_desk_widgets(const std::filesystem::path& data) {
const auto before_records = game.manager_records;
const auto before_options = game.manager_options;
const auto before_revision = revision;
const auto before_native = save_stream(game);
const auto before_game = session->game(); const auto before_rand = session->rand();
check(!session->dispatch_desk_widget(request, revision, error) &&
game.manager_records == before_records && game.manager_options == before_options &&
revision == before_revision, "invalid desk widget rejects before all state mutation");
save_stream(game) == before_native && revision == before_revision &&
session->game().seed() == before_game.seed() && session->game().calls() == before_game.calls() &&
session->rand().seed() == before_rand.seed() && session->rand().calls() == before_rand.calls(),
"invalid desk widget rejects before native, revision or RNG mutation");
};
DeskRequest request{DeskRequestKind::change_option, 0, 2, 64, 1, revision};
for (int variant = 0; variant < 7; ++variant) {
@@ -2655,14 +2719,20 @@ void check_desk_widgets(const std::filesystem::path& data) {
unchanged(invalid);
}
for (int value : {7, 26}) unchanged(DeskRequest{DeskRequestKind::change_ticket_price, 0, 1, 55, value, revision});
game.memory.set8(::bmh::layout::Desktops + 2 * 16 + 13, 0);
unchanged(request);
game.memory.set8(::bmh::layout::Desktops + 2 * 16 + 13, 0x80);
game.memory.set16(::bmh::layout::Desktops + 2 * 16, 20 | 0x1000);
unchanged(request);
game.memory.set16(::bmh::layout::Desktops + 2 * 16, 20);
game.manager_options[0] = 9;
request.value = 0; unchanged(request);
for(uint8_t invalid_formation : {uint8_t(9),uint8_t(255)}) {
game.manager_options[0] = invalid_formation;
for(int index : {0,1}) {
request.value = index; unchanged(request);
check(error == "invalid_saved_formation_automation",
"malformed formation returns an explicit refusal before desktop projection");
}
unchanged(DeskRequest{DeskRequestKind::change_ticket_price,0,1,55,10,revision});
check(error == "invalid_saved_formation_automation",
"admission dispatch also refuses an unprojectable saved formation atomically");
}
game.manager_options[0] = 0;
// National coaches keep lineup/attitude/marking automation, while admission
// and training controls are unavailable in legacy routine/legacy routine.
@@ -2675,7 +2745,7 @@ void check_desk_widgets(const std::filesystem::path& data) {
const auto national = session->desktop_projection(revision);
check(national.national_team, "widget fixture projects a national coach");
DesktopScreen national_screen(data, national);
check(national_screen.click(20 + 4 + 35, 90).kind == DeskRequestKind::none,
check(national_screen.click(content_x + 35, 90).kind == DeskRequestKind::none,
"national admission control does not emit a price request");
unchanged(DeskRequest{DeskRequestKind::change_ticket_price, 0, 1, 55, 10, revision});
request.value = 4;
@@ -2691,6 +2761,10 @@ void check_desk_widgets(const std::filesystem::path& data) {
"every drawer action preserves both RNG streams, date, board and squad");
}
void check_desk_widgets(const std::filesystem::path& data) {
for(bool framed : {true,false}) check_desk_widgets_for_frame(data,framed);
}
void check_league_only_national_coach_handoff(const std::filesystem::path& data) {
StartupFlow flow(data);
flow.click(150, 215); // League-only setup; world competition remains disabled.
@@ -3124,28 +3198,46 @@ void check_settings_writer(const std::filesystem::path& data) {
revision == before_revision + 4 && save_stream(game) == save_stream(expected),
"operation mismatch is rejected without changing memory or revision");
const auto unsupported = flow.click(67 + 8 * 24 + 5, 25 + 9 * 10 + 5); // J9, no current Source presentation consumer.
// The original stores every unlocked switch, also one that no OpenBMH consumer reads yet:
// J9 (a number, steps of two) and O3 (a switch) change their byte, one revision per click.
const uint32_t j9_address = ::bmh::layout::LeaguePresentationOptions + 9 * 9 + 8;
const uint8_t j9_old = game.memory.u8(j9_address);
const auto unsupported = flow.click(67 + 8 * 24 + 5, 25 + 9 * 10 + 5); // J9
check(unsupported.request == FlowRequest::settings_action &&
unsupported.settings_action.row == 9 && unsupported.settings_action.operation == SettingsEdit::increment,
"left half maps to one increment action; no implicit held-step loop");
serve(unsupported);
check(!flow.pending_settings() && revision == before_revision + 4 && save_stream(game) == save_stream(expected),
"unconsumed Original numeric field is safely rejected");
const bool j9_stepped = j9_old < 198;
check(!flow.pending_settings() && revision == before_revision + (j9_stepped ? 5 : 4) &&
game.memory.u8(j9_address) == uint8_t(j9_stepped ? j9_old + 2 : j9_old),
"an Original numeric field without a consumer is stored, not refused");
const auto unsupported_minus = flow.click(67 + 8 * 24 + 15, 25 + 9 * 10 + 5);
check(unsupported_minus.request == FlowRequest::settings_action &&
unsupported_minus.settings_action.operation == SettingsEdit::decrement,
"right half maps to one decrement action");
serve(unsupported_minus);
check(revision == before_revision + 4 && save_stream(game) == save_stream(expected),
"unconsumed minus action leaves the exact state unchanged");
check(revision == before_revision + (j9_stepped ? 6 : 4) && game.memory.u8(j9_address) == j9_old,
"the minus action steps the same field back");
const uint32_t o3_address = ::bmh::layout::LeaguePresentationOptions + 14 * 9 + 2;
const auto o3_state = settings_from_game(game, int(game.memory.u8(::bmh::layout::ActiveManager)), revision,
load_le(asset_path(data, "BMH.exe")));
const uint8_t o3_old = game.memory.u8(o3_address);
const bool o3_free = o3_state.display_cells && !((*o3_state.display_cells)[14 * 9 + 2] & 0x80) && o3_old <= 1;
const auto unsupported_o3 = flow.click(67 + 2 * 24 + 5, 25 + 14 * 10 + 5);
check(unsupported_o3.request == FlowRequest::settings_action &&
unsupported_o3.settings_action.row == 14 && unsupported_o3.settings_action.column == 2,
"O3 maps to its exact grid identity");
serve(unsupported_o3);
check(revision == before_revision + 4 && save_stream(game) == save_stream(expected),
"unconsumed middle rows/columns are rejected by the bounded source whitelist");
check(o3_free ? game.memory.u8(o3_address) == uint8_t(o3_old ^ 1)
: game.memory.u8(o3_address) == o3_old,
"an unlocked switch without a consumer toggles; a locked one stays");
if (o3_free) {
serve(flow.click(67 + 2 * 24 + 5, 25 + 14 * 10 + 5));
check(game.memory.u8(o3_address) == o3_old, "O3 toggles back");
}
const uint64_t settled = revision;
check(save_stream(game) == save_stream(expected), "the stepped switches leave the exact state again");
// Exact Q5 date boundary: the Original handler blocks inclusive days 110..230.
for (size_t i = 0; i < 180; ++i) game.memory.set8(::bmh::layout::LeaguePresentationOptions + uint32_t(i), 0);
@@ -3159,13 +3251,13 @@ void check_settings_writer(const std::filesystem::path& data) {
};
auto q5 = q5_request();
const auto q5_before = save_stream(game);
check(!session->dispatch_settings(q5, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(q5, revision, error) && revision == settled &&
save_stream(game) == q5_before && game.date == game.season_start + 110,
"Q5 is rejected on day 110 with no memory/revision/date change");
game.date = game.season_start + 230;
q5 = q5_request();
const auto q5_end_before = save_stream(game);
check(!session->dispatch_settings(q5, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(q5, revision, error) && revision == settled &&
save_stream(game) == q5_end_before,
"Q5 is also rejected on inclusive day 230");
@@ -3175,7 +3267,7 @@ void check_settings_writer(const std::filesystem::path& data) {
for (size_t i = 0; i < locked.expected_raw.size(); ++i) locked.expected_raw[i] = game.memory.u8(::bmh::layout::LeaguePresentationOptions + uint32_t(i));
locked.row = 1; locked.column = 4; locked.operation = SettingsEdit::toggle_binary;
const auto lock_before = save_stream(game);
check(!session->dispatch_settings(locked, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(locked, revision, error) && revision == settled &&
save_stream(game) == lock_before,
"recomputed Original mode lock rejects B5 without a saved write");
@@ -3186,7 +3278,7 @@ void check_settings_writer(const std::filesystem::path& data) {
for (size_t i = 0; i < at_limit.expected_raw.size(); ++i) at_limit.expected_raw[i] = game.memory.u8(::bmh::layout::LeaguePresentationOptions + uint32_t(i));
at_limit.row = 1; at_limit.column = 7; at_limit.operation = SettingsEdit::increment;
const auto limit_before = save_stream(game);
check(!session->dispatch_settings(at_limit, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(at_limit, revision, error) && revision == settled &&
save_stream(game) == limit_before,
"source table upper bound is a no-op, with no write or revision bump");
@@ -3197,7 +3289,7 @@ void check_settings_writer(const std::filesystem::path& data) {
stale_lock.expected_raw[i] = game.memory.u8(::bmh::layout::LeaguePresentationOptions + uint32_t(i));
stale_lock.row = 10; stale_lock.column = 4; stale_lock.operation = SettingsEdit::toggle_binary;
const auto stale_lock_before = save_stream(game);
check(!session->dispatch_settings(stale_lock, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(stale_lock, revision, error) && revision == settled &&
save_stream(game) == stale_lock_before,
"recomputed unlocked display does not authorize writing a raw cell still >=2");
@@ -3253,8 +3345,9 @@ void check_settings_writer(const std::filesystem::path& data) {
other_column9.row = 9;
for (size_t i = 0; i < other_column9.expected_raw.size(); ++i)
other_column9.expected_raw[i] = i9_game.memory.u8(::bmh::layout::LeaguePresentationOptions + uint32_t(i));
check(!i9_session.dispatch_settings(other_column9, i9_revision, error) && i9_revision == 3,
"other ninth-column cells remain unavailable until their consumer is ported");
const uint8_t j9_raw = i9_game.memory.u8(::bmh::layout::LeaguePresentationOptions + 9 * 9 + 8);
check(i9_session.dispatch_settings(other_column9, i9_revision, error) == (j9_raw < 198),
"other ninth-column cells are stored too, without waiting for a consumer");
}
void check_live_delay_settings_writer(const std::filesystem::path& data,const std::filesystem::path& save_path) {
@@ -4141,7 +4234,7 @@ void check_loaded_lineup(const std::filesystem::path& data, const std::filesyste
check(session.game().calls() == game_calls && session.rand().calls() == random_calls,
"pre-kickoff swap consumes no RNG");
bool saw_fixture = false, order_preserved = false, live_overview_roundtrip = false;
bool saw_fixture = false, order_preserved = false, live_overview_roundtrip = false, pairings_first_roundtrip = false;
session.set_live_minute([&](int minute, MatchEngine& engine, std::vector<MatchGroup>& groups, GameState& state) {
if (!live_overview_roundtrip && minute >= 3 && !groups.empty() && groups[0].desc.size() > 0xcf &&
groups[0].desc[0] == 0 && std::any_of(groups.begin(),groups.end(),[&](const MatchGroup& group) {
@@ -4156,8 +4249,24 @@ void check_loaded_lineup(const std::filesystem::path& data, const std::filesyste
if(!opened)throw std::runtime_error("actual WEEK196 live G key failed to open: "+error);
check(opened->kind==app::CareerSession::LiveOverviewKind::league_table && opened->table.has_value(),
"real kickoff observer opens the Source G table for the first league descriptor");
// The family's children as the buttons reach them: Tabelle -> Stärken -> Tabelle ->
// Spiele -> Tabelle, each handoff accepted while the minute is held.
const auto hop=[&](ui::StrengthsIdentity from,int from_child,int target_child,const char* what) {
ui::LeagueFamilyRequest nav;
nav.identity=from; nav.kind=ui::LeagueFamilyRequestKind::navigate;
nav.from_child=from_child; nav.target_child=target_child;
auto page=session.dispatch_live_overview(app::CareerSession::LiveOverviewAction{nav},engine,revision,error);
if(!page)throw std::runtime_error(std::string("live overview ")+what+" failed: "+error);
return *page;
};
auto strengths=hop(opened->family_identity,1,3,"Tabelle -> Stärken");
check(strengths.kind==app::CareerSession::LiveOverviewKind::league_strengths,"the live family opens Stärken");
auto table_again=hop(strengths.family_identity,3,1,"Stärken -> Tabelle");
auto pairings=hop(table_again.family_identity,1,2,"Tabelle -> Spiele");
check(pairings.kind==app::CareerSession::LiveOverviewKind::league_pairings,"the live family opens Spiele");
auto table_last=hop(pairings.family_identity,2,1,"Spiele -> Tabelle");
ui::LeagueFamilyRequest close;
close.identity=opened->family_identity; close.kind=ui::LeagueFamilyRequestKind::close;
close.identity=table_last.family_identity; close.kind=ui::LeagueFamilyRequestKind::close;
close.from_child=1; close.target_child=0;
auto closed=session.dispatch_live_overview(app::CareerSession::LiveOverviewAction{close},engine,revision,error);
if(!closed)throw std::runtime_error("actual WEEK196 live G key failed to close: "+error);
@@ -4165,6 +4274,41 @@ void check_loaded_lineup(const std::filesystem::path& data, const std::filesyste
"real kickoff observer closes the Source G family and resumes the same minute");
live_overview_roundtrip=true;
}
// The Spiele page opened first (key slot 1, as at the end of a phase): its Tabelle and
// Stärken buttons hand over to the other children and back.
if (live_overview_roundtrip && !pairings_first_roundtrip && minute >= 5 && !groups.empty() &&
groups[0].desc.size() > 0xcf && groups[0].desc[0] == 0) {
pairings_first_roundtrip = true;
app::CareerSession::LiveOverviewRequest live;
live.key_slot=1; live.minute=minute; live.group_index=0;
live.manager_slot=manager; live.runtime_team=team; live.revision=revision;
live.sequence=0xfeee;
auto opened=session.open_live_overview(live,engine,revision,Image{},error);
if(!opened)throw std::runtime_error("live Spiele page failed to open: "+error);
check(opened->kind==app::CareerSession::LiveOverviewKind::league_pairings,"key slot 1 opens the Spiele page");
const auto hop2=[&](ui::StrengthsIdentity from,int from_child,int target_child,const char* what) {
ui::LeagueFamilyRequest nav;
nav.identity=from; nav.kind=ui::LeagueFamilyRequestKind::navigate;
nav.from_child=from_child; nav.target_child=target_child;
auto page=session.dispatch_live_overview(app::CareerSession::LiveOverviewAction{nav},engine,revision,error);
if(!page)throw std::runtime_error(std::string("live overview ")+what+" failed: "+error);
return *page;
};
// the buttons of the Spiele page itself: Stärken directly, and back
auto direct=hop2(opened->family_identity,2,3,"Spiele -> Stärken");
check(direct.kind==app::CareerSession::LiveOverviewKind::league_strengths,"Spiele hands over to Stärken");
auto again=hop2(direct.family_identity,3,2,"Stärken -> Spiele");
auto table=hop2(again.family_identity,2,1,"Spiele -> Tabelle");
check(table.kind==app::CareerSession::LiveOverviewKind::league_table,"Spiele hands over to Tabelle");
auto strengths=hop2(table.family_identity,1,3,"Tabelle -> Stärken");
auto pairings=hop2(strengths.family_identity,3,2,"Stärken -> Spiele");
ui::LeagueFamilyRequest close;
close.identity=pairings.family_identity; close.kind=ui::LeagueFamilyRequestKind::close;
close.from_child=2; close.target_child=0;
auto closed=session.dispatch_live_overview(app::CareerSession::LiveOverviewAction{close},engine,revision,error);
if(!closed)throw std::runtime_error("live Spiele page failed to close: "+error);
check(closed->closed,"the Spiele page closes and resumes the minute");
}
if (saw_fixture) return;
for (const auto& group : groups) {
if (std::find(group.fixtures.begin(), group.fixtures.end(), team) == group.fixtures.end()) continue;
@@ -4174,6 +4318,36 @@ void check_loaded_lineup(const std::filesystem::path& data, const std::filesyste
(state.squad_slots.at(squad.first + 11) & 0x0fff) == (first & 0x0fff);
}
});
// The end-of-phase results page (key slot 1 at the Source phase boundary) is the viewer the
// players meet after every match: Spiele -> Stärken -> Spiele -> Tabelle -> close must not strand it.
int phase_pages = 0;
session.set_phase_results([&](const PhaseResultRequest&, const std::vector<MatchGroup>&, const GameState&) {
if (phase_pages >= 2) return;
std::string phase_error;
auto opened = session.open_phase_results(revision, Image{}, phase_error);
if (!opened) return; // a phase of another group or competition: nothing to view here
++phase_pages;
const auto hop = [&](ui::StrengthsIdentity from, int from_child, int target_child, const char* what) {
ui::LeagueFamilyRequest nav;
nav.identity = from; nav.kind = ui::LeagueFamilyRequestKind::navigate;
nav.from_child = from_child; nav.target_child = target_child;
auto page = session.dispatch_phase_results(app::CareerSession::LiveOverviewAction{nav}, revision, phase_error);
if (!page) throw std::runtime_error(std::string("phase results ") + what + " failed: " + phase_error);
return *page;
};
ui::StrengthsIdentity at = opened->family_identity;
int child = opened->kind == app::CareerSession::LiveOverviewKind::league_table ? 1 : 2;
const int path[] = {3, 2, 1, 3, 1, 2};
for (const int next : path) {
auto page = hop(at, child, next, "handover");
at = page.family_identity; child = next;
}
ui::LeagueFamilyRequest close;
close.identity = at; close.kind = ui::LeagueFamilyRequestKind::close;
close.from_child = child; close.target_child = 0;
auto closed = session.dispatch_phase_results(app::CareerSession::LiveOverviewAction{close}, revision, phase_error);
if (!closed || !closed->closed) throw std::runtime_error("phase results page did not close: " + phase_error);
});
int turns = 0;
for (; turns < 8 && (!saw_fixture || turns < 2); ++turns) {
ui::DeskRequest request;
@@ -6804,6 +6978,64 @@ void check_stadium_investment_controller(const std::filesystem::path& data) {
std::filesystem::remove_all(saves);
}
void check_date_widget_controller(const std::filesystem::path& data) {
for(bool framed : {true,false}) {
StartupFlow flow(data);
flow.click(150,215); flow.click(5,225,true); flow.click(5,225,true);
flow.click(90,169);
check(flow.pending_career()!=nullptr,"date fixture requests a new career");
std::unique_ptr<app::CareerSession> session=std::make_unique<app::CareerSession>(data,0x44415445);
std::string error;
const auto request=*flow.pending_career();
for(const auto& manager : request.managers)
check(session->confirm_manager(request.options,manager,error),"date fixture confirms its manager");
CareerInitializationResult initialized;
check(session->finish(initialized,error),"date fixture reaches an actual turn-driver desk");
uint64_t revision=initialized.desktop.revision;
const auto date=std::find_if(initialized.desktop.items.begin(),initialized.desktop.items.end(),
[](const DeskItem& item){return item.kind==58;});
check(date!=initialized.desktop.items.end(),"date fixture exposes the desktop date widget");
const auto at=layout::DesktopsUnsigned+uint32_t(initialized.desktop.manager_slot)*0x360u+uint32_t(date->id)*16u+13u;
auto& memory=session->state().memory;
memory.set8(at,uint8_t((memory.u8(at)&0x7f)|(framed?0x80:0)));
const int x=date->x+20,y=date->y+20;
initialized.desktop=session->desktop_projection(revision);
initialized.preparation=session->preparation_projection(revision);
auto preparation=initialized.preparation;
flow.attach_initialized_career(std::move(initialized));
flow.attach_preparation_context(std::move(preparation));
check(flow.pointer_down(x,y).request==FlowRequest::none,"date press waits for its release");
const auto advance=flow.click(x,y);
check(advance.request==FlowRequest::kickoff && advance.desk_action.menu_kind==58,
"framed and unframed date releases route through the shared kickoff action");
openbmh::audio::Playback playback;
std::optional<uint64_t> audio_session;
const auto serve=[&](const FlowResult& action) {
const auto failure=app::serve_flow_request(flow,action,session,data,data,0x44415445,
revision,playback,audio_session,false);
if(!failure.empty()) throw std::runtime_error("date widget dispatch failed: "+failure);
};
const auto before=save_stream(session->state());
const auto before_revision=revision;
const auto before_game=session->game(); const auto before_rand=session->rand();
auto stale=advance; ++stale.desk_action.revision;
serve(stale);
check(save_stream(session->state())==before && revision==before_revision &&
session->game().seed()==before_game.seed() && session->game().calls()==before_game.calls() &&
session->rand().seed()==before_rand.seed() && session->rand().calls()==before_rand.calls(),
"stale date request leaves the pending owner, native state and both RNG streams unchanged");
const auto before_date=session->state().date;
serve(advance);
check(session->state().date>before_date && revision>before_revision &&
flow.screen_name()=="desktop" && !flow.desktop()->pending(),
"date widget completes a real calendar event and acknowledges the next desk");
const auto after=save_stream(session->state()); const auto after_revision=revision;
serve(advance);
check(save_stream(session->state())==after && revision==after_revision,
"consumed date action cannot advance the calendar twice");
}
}
void check_menu_layout_session_io(const std::filesystem::path& data) {
StartupFlow flow(data);
flow.click(150, 215); flow.click(5, 225, true); flow.click(5, 225, true);
@@ -6930,70 +7162,94 @@ void check_menu_layout_session_io(const std::filesystem::path& data) {
session->rand().seed()==move_rand.seed()&&session->rand().calls()==move_rand.calls(),
"desktop layout movement preserves both RNG streams");
// Exercise the newly source-backed folder-child return and bin-mode
// Exercise framed and unframed folder-child return and bin-mode
// transfer through the authenticated CareerSession boundary, not only the
// DesktopScreen request projection.
constexpr uint32_t native_layout=::bmh::layout::Desktops;
const uint32_t native_base=native_layout+uint32_t(manager)*0x360u;
for(size_t i=0;i<bytes_count;++i)game.memory.set8(native_base+uint32_t(i),0xff);
auto put=[&](size_t item,size_t offset,uint8_t value){game.memory.set8(native_base+uint32_t(item*16+offset),value);};
put(0,5,49);put(0,6,0);
put(49,0,40);put(49,1,0);put(49,2,40);put(49,3,100);put(49,4,65);
put(49,5,0);put(49,6,0);put(49,12,50);put(49,13,0x80);
put(3,0,0);put(3,1,0);put(3,2,0);put(3,3,32);put(3,4,25);
put(3,5,0xff);put(3,6,0xff);put(3,12,2);put(3,13,0);
auto folder_desk=session->desktop_projection(revision);
DesktopScreen child_return_screen(data,folder_desk);
child_return_screen.pointer_down(50,49,true);
child_return_screen.pointer_move(175,100);
const auto return_request=child_return_screen.pointer_up(175,100,true);
const auto before_return_rng=session->game();const auto before_return_rand=session->rand();
check(return_request.layout_operation==ui::DeskLayoutOperation::return_folder_child&&
session->dispatch_desktop_layout(return_request,revision,error)&&error.empty()&&
game.memory.u8(native_base+3*16+5)==0&&game.memory.u8(native_base+3*16+6)==49&&
game.memory.u8(native_base+49*16+5)==3,
"authenticated folder child return appends to the visible chain");
check(session->game().seed()==before_return_rng.seed()&&session->game().calls()==before_return_rng.calls()&&
session->rand().seed()==before_return_rand.seed()&&session->rand().calls()==before_return_rand.calls(),
"folder child return consumes no RNG");
const auto returned_desk=session->desktop_projection(revision);
const auto returned_child=std::find_if(returned_desk.items.begin(),returned_desk.items.end(),
[](const ui::DeskItem& item){return item.id==3;});
check(returned_child!=returned_desk.items.end(),"returned child is projected as a desk item");
const auto saved_child_x=game.memory.u16(native_base+3*16);
const auto saved_child_y=game.memory.u8(native_base+3*16+2);
auto bin_desk=returned_desk;bin_desk.shortcut_bar_always=true;
DesktopScreen bin_screen(data,bin_desk);
bin_screen.click(2,215); // Source local_50 bin mode toggle.
const auto bin_request=bin_screen.click(returned_child->x+1,returned_child->y+1,true);
const auto before_bin_rng=session->game();const auto before_bin_rand=session->rand();
check(bin_request.layout_operation==ui::DeskLayoutOperation::send_to_folder&&
session->dispatch_desktop_layout(bin_request,revision,error)&&error.empty()&&
game.memory.u8(native_base+3*16+5)==0xff&&game.memory.u8(native_base+3*16+6)==0xff&&
game.memory.u8(native_base+3*16+13)==0,
"bin mode moves the item into its original associated folder without clearing its coordinates");
check(session->game().seed()==before_bin_rng.seed()&&session->game().calls()==before_bin_rng.calls()&&
session->rand().seed()==before_bin_rand.seed()&&session->rand().calls()==before_bin_rand.calls(),
"folder bin transfer consumes no RNG");
auto binned_desk=session->desktop_projection(revision);binned_desk.shortcut_bar_always=true;
DesktopScreen restore_screen(data,binned_desk);
restore_screen.click(2,215);
const int folder_x=std::find_if(binned_desk.items.begin(),binned_desk.items.end(),
[](const ui::DeskItem& item){return item.id==49;})->x;
const int folder_y=std::find_if(binned_desk.items.begin(),binned_desk.items.end(),
[](const ui::DeskItem& item){return item.id==49;})->y;
const auto restore_request=restore_screen.click(folder_x+10,folder_y+9,true);
check(restore_request.layout_operation==ui::DeskLayoutOperation::restore_folder_child&&
session->dispatch_desktop_layout(restore_request,revision,error)&&error.empty()&&
game.memory.u8(native_base+3*16+5)==0&&game.memory.u8(native_base+49*16+5)==3&&
game.memory.u16(native_base+3*16)==saved_child_x&&game.memory.u8(native_base+3*16+2)==saved_child_y,
"right-clicking a folder child in bin mode restores its saved original position");
for(int child_id : {3,13}) for(bool framed : {true,false}) {
for(size_t i=0;i<bytes_count;++i)game.memory.set8(native_base+uint32_t(i),0xff);
auto put=[&](size_t item,size_t offset,uint8_t value){game.memory.set8(native_base+uint32_t(item*16+offset),value);};
put(0,5,49);put(0,6,0);
put(49,0,40);put(49,1,0);put(49,2,40);put(49,3,100);put(49,4,65);
put(49,5,0);put(49,6,0);put(49,12,50);put(49,13,framed?0x80:0);
put(size_t(child_id),0,0);put(size_t(child_id),1,0);put(size_t(child_id),2,0);put(size_t(child_id),3,32);put(size_t(child_id),4,25);
put(size_t(child_id),5,0xff);put(size_t(child_id),6,0xff);put(size_t(child_id),12,uint8_t(child_id-1));put(size_t(child_id),13,0);
auto folder_desk=session->desktop_projection(revision);
DesktopScreen child_return_screen(data,folder_desk);
child_return_screen.pointer_down(50,49,true);
child_return_screen.pointer_move(175,100);
const auto return_request=child_return_screen.pointer_up(175,100,true);
const auto before_return_rng=session->game();const auto before_return_rand=session->rand();
const auto return_revision=revision;
const auto before_return=capture_slot();
auto stale_return=return_request; ++stale_return.revision;
check(!session->dispatch_desktop_layout(stale_return,revision,error) &&
revision==return_revision && capture_slot()==before_return,
"folder extraction rejects a stale revision atomically");
// A linked folder with the native hidden flag owns no visible child input.
put(49,1,0x10);
auto hidden_return=return_request;
hidden_return.layout_before[49*16+1]=hidden_return.layout_after[49*16+1]=0x10;
const auto hidden_before=capture_slot();
check(!session->dispatch_desktop_layout(hidden_return,revision,error) &&
revision==return_revision && capture_slot()==hidden_before,
"folder extraction rejects a hidden owner without modifying its chain");
put(49,1,0);
check(return_request.layout_operation==ui::DeskLayoutOperation::return_folder_child&&
session->dispatch_desktop_layout(return_request,revision,error)&&error.empty()&&
game.memory.u8(native_base+uint32_t(child_id)*16+5)==0&&game.memory.u8(native_base+uint32_t(child_id)*16+6)==49&&
game.memory.u8(native_base+49*16+5)==child_id,
"authenticated folder child return appends to the visible chain");
check(session->game().seed()==before_return_rng.seed()&&session->game().calls()==before_return_rng.calls()&&
session->rand().seed()==before_return_rand.seed()&&session->rand().calls()==before_return_rand.calls(),
"folder child return consumes no RNG");
const auto returned_desk=session->desktop_projection(revision);
const auto returned_child=std::find_if(returned_desk.items.begin(),returned_desk.items.end(),
[&](const ui::DeskItem& item){return item.id==child_id;});
check(returned_child!=returned_desk.items.end(),"returned child is projected as a desk item");
if(child_id==13) continue; // Source excludes the kickoff icon from bin-mode removal.
const auto saved_child_x=game.memory.u16(native_base+uint32_t(child_id)*16);
const auto saved_child_y=game.memory.u8(native_base+uint32_t(child_id)*16+2);
auto bin_desk=returned_desk;bin_desk.shortcut_bar_always=true;
DesktopScreen bin_screen(data,bin_desk);
bin_screen.click(2,215); // Source local_50 bin mode toggle.
const auto bin_request=bin_screen.click(returned_child->x+1,returned_child->y+1,true);
const auto before_bin_rng=session->game();const auto before_bin_rand=session->rand();
check(bin_request.layout_operation==ui::DeskLayoutOperation::send_to_folder&&
session->dispatch_desktop_layout(bin_request,revision,error)&&error.empty()&&
game.memory.u8(native_base+uint32_t(child_id)*16+5)==0xff&&game.memory.u8(native_base+uint32_t(child_id)*16+6)==0xff&&
game.memory.u8(native_base+uint32_t(child_id)*16+13)==0,
"bin mode moves the item into its original associated folder without clearing its coordinates");
check(session->game().seed()==before_bin_rng.seed()&&session->game().calls()==before_bin_rng.calls()&&
session->rand().seed()==before_bin_rand.seed()&&session->rand().calls()==before_bin_rand.calls(),
"folder bin transfer consumes no RNG");
auto binned_desk=session->desktop_projection(revision);binned_desk.shortcut_bar_always=true;
DesktopScreen restore_screen(data,binned_desk);
restore_screen.click(2,215);
const int folder_x=std::find_if(binned_desk.items.begin(),binned_desk.items.end(),
[](const ui::DeskItem& item){return item.id==49;})->x;
const int folder_y=std::find_if(binned_desk.items.begin(),binned_desk.items.end(),
[](const ui::DeskItem& item){return item.id==49;})->y;
const auto restore_request=restore_screen.click(folder_x+10,folder_y+9,true);
check(restore_request.layout_operation==ui::DeskLayoutOperation::restore_folder_child&&
session->dispatch_desktop_layout(restore_request,revision,error)&&error.empty()&&
game.memory.u8(native_base+uint32_t(child_id)*16+5)==0&&game.memory.u8(native_base+49*16+5)==3&&
game.memory.u16(native_base+uint32_t(child_id)*16)==saved_child_x&&game.memory.u8(native_base+uint32_t(child_id)*16+2)==saved_child_y,
"right-clicking a folder child in bin mode restores its saved original position");
}
}
int main(int argc, char** argv) {
try {
if (argc != 2 && argc != 3 && argc != 4) throw std::runtime_error("app_controller_tests requires data directory [optional Original save]");
const std::filesystem::path data = argv[1];
if(argc==3 && std::string_view(argv[2])=="--desktop-input-only") {
check_date_widget_controller(data); check_menu_layout_session_io(data); check_desk_widgets(data); return 0;
}
if(argc==3 && std::string_view(argv[2])=="--selection-visibility-only") {
check_player_league_visibility_controller(data);return 0;
}
if(argc==3 && std::string_view(argv[2])=="--environment-only") {
check_environment_controller(data);return 0;
}
@@ -7013,6 +7269,13 @@ int main(int argc, char** argv) {
if(argc==3 && std::string_view(argv[2])=="--poach-only") {
check_poach_ui_components(data);return 0;
}
if(argc==3 && std::string_view(argv[2])=="--advertising-input-only") {
check_advertising_controller(data);
check_advertising_renewal_controller(data);
check_advertising_spending_controller(data);
std::cout << "Advertising hover, modal return and controller actions passed.\n";
return 0;
}
check_poach_ui_components(data);
check_stadium_investment_controller(data);
check_pairings_timer_controller(data);
@@ -7023,6 +7286,7 @@ int main(int argc, char** argv) {
check_readonly_views(data);
check_desk_records_controller(data);
check_menu_layout_session_io(data);
check_date_widget_controller(data);
check_calendar_readonly_controller(data);
check_indoor_standings_controller(data);
check_strengths_semantic_and_controller(data);
+8
View File
@@ -186,6 +186,14 @@ void test_toto_source_calculator(const std::filesystem::path& data) {
check(cancelled_result && cancelled_result->result == TableRangeDialogResult::cancel,
"Toto calculator cancel has no accepted payment value");
LeagueTableRangeDialog by_mouse(data, backdrop, TotoStakeDialogProfile{TableRangeTextMode::flat});
(void)by_mouse.render(); (void)by_mouse.after_present();
check(by_mouse.pointer_down(10, 10, true), "the right button is consumed by the calculator");
check(by_mouse.render().pixels == backdrop.pixels, "the right button restores the owned backdrop");
const auto by_mouse_result = by_mouse.after_present();
check(by_mouse_result && by_mouse_result->result == TableRangeDialogResult::cancel,
"the right button closes the calculator as a cancel");
TableRangeDialogProfile table_profile;
table_profile.text_mode = TableRangeTextMode::flat;
LeagueTableRangeDialog table(data, backdrop, table_profile);
+26
View File
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include <iostream>
#include <stdexcept>
using namespace bmh;
namespace {void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}}
int main()try {
const std::array<uint8_t,6> source{2,4,5,5,5,5};
auto image=LeImage::from_bytes(layout::EnvironmentBudgetSteps,Bytes(source.begin(),source.end()));
install_environment_rules(image);
check(environment_rules_supported()&&kEnvironmentStep==std::array<int32_t,6>{2000,4000,5000,5000,5000,5000},
"valid source steps require the common model without original instructions");
const auto previous=kEnvironmentStep;
auto missing=LeImage::from_bytes(layout::EnvironmentBudgetSteps,Bytes(source.begin(),source.end()-1));
install_environment_rules(missing);check(!environment_rules_supported()&&kEnvironmentStep==previous,"missing final step partially installed");
auto malformed=image;const uint8_t changed=9;malformed.patch(layout::EnvironmentBudgetSteps,&changed,1);const uint8_t zero=0;malformed.patch(layout::EnvironmentBudgetSteps+3,&zero,1);
install_environment_rules(malformed);check(!environment_rules_supported()&&kEnvironmentStep==previous,"zero step partially installed");
install_environment_rules(image);check(environment_rules_supported()&&kEnvironmentStep==previous,"valid profile could not recover after rejected input");
GameState state;state.memory.add_block(layout::Spending,4*0x24);
state.memory.set32(layout::Spending,12000);state.memory.set32(layout::Spending+4,24000);
check(environment_monthly_cost(state,0,0)==12000&&environment_monthly_cost(state,0,1)==24000,"common profile changed owned monthly budgets");
std::cout<<"Common Diamond3.7 monthly model accepts valid data without instruction provenance and rejects malformed numeric steps atomically\n";
return 0;
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
+6
View File
@@ -2,6 +2,7 @@
#include "fixture_tables.hpp"
#include "formats/executable_layout.hpp"
#include "formats/le.hpp"
#include "formats/league_visibility.hpp"
#include <iostream>
#include <set>
#include <stdexcept>
@@ -19,6 +20,11 @@ void same(const std::vector<Fixture>& a, const std::vector<Fixture>& b) {
check(a[i].home == b[i].home && a[i].away == b[i].away, "fixture ownership changed");
}
void unit() {
const auto address=layout::LeaguePairings_LeaguePairingsConstants_RuntimeField;
check(player_league_count(LeImage::from_bytes(address,Bytes{5,4,9}))==4&&player_league_count(LeImage::from_bytes(address,Bytes{5,5,9}))==5,"player-visible leagues replaced internal catalogue counts");
invalid([&]{player_league_count(LeImage::from_bytes(address,Bytes{5,0,9}));});
invalid([&]{player_league_count(LeImage::from_bytes(address,Bytes{5,6,9}));});
invalid([&]{player_league_count(LeImage::from_bytes(address,Bytes{5}));});
const auto authored = bmh::test::authored_fixture_tables();
set_fixture_tables(authored);
for (const auto& [teams, rows] : authored) {
+50 -1
View File
@@ -1,11 +1,15 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "launch/fltd.hpp"
#include "game/environment.hpp"
#include "formats/league_visibility.hpp"
#include <chrono>
#include <array>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <string>
int main() {
using namespace bmh;
@@ -19,6 +23,27 @@ int main() {
source[0] = 'M'; source[1] = 'Z';
const auto put = [&](uint32_t address, uint8_t value) { source.at(address + 0x496d) = value; };
const auto check = [](bool value, const char* message) { if (!value) throw std::runtime_error(message); };
const auto put_pointer = [&](uint32_t address, uint32_t value) {
for (uint32_t i = 0; i < 4; ++i) put(address + i, uint8_t(value >> (i * 8)));
};
constexpr uint32_t english_overwrite_pointer = 0x6c43c;
constexpr uint32_t authored_question_address = layout::EnDataStart + 0x100;
const std::string authored_question = "Authored overwrite question?";
put_pointer(english_overwrite_pointer, authored_question_address);
for (uint32_t i = 0; i <= authored_question.size(); ++i)
put(authored_question_address + i, i < authored_question.size() ? uint8_t(authored_question[i]) : 0);
// Adjacent English pointers are intentionally distinct from the retained
// empty German slots. An over-wide copy must not import either one.
put_pointer(english_overwrite_pointer - 4, authored_question_address + 1);
put_pointer(english_overwrite_pointer + 4, authored_question_address + 2);
// The analytics label mapping intentionally replaces the final 72 bytes
// of the old empty-pointer range. Give that independent source its own data.
Bytes analytics_labels(72);
for (uint32_t i = 0; i < analytics_labels.size(); ++i) {
analytics_labels[i] = uint8_t(0x31 + i * 3);
put(layout::EnglishLayoutTranslation50 + i, analytics_labels[i]);
}
put(layout::EnglishLayoutTranslation259,5);put(layout::EnglishLayoutTranslation259+1,4);put(layout::EnglishLayoutTranslation259+2,9);
const uint8_t toggle_rows[] = {3, 7, 11, 13, 17, 19};
put(layout::EnglishLayoutTranslation16 - 1, 99); // alignment padding is not a toggle row
for (uint32_t i = 0; i < 6; ++i) put(layout::EnglishLayoutTranslation16 + i, toggle_rows[i]);
@@ -29,9 +54,28 @@ int main() {
put(layout::EnglishDesktopBinSourceY + i, uint8_t(20 + i));
put(layout::EnglishDesktopSocketSourceX + i, uint8_t(30 + i));
}
const std::array<uint8_t,6> environment_x{20,80,140,200,250,20},environment_y{40,40,40,80,80,140},environment_steps{2,4,5,5,5,5};
for(uint32_t i=0;i<6;++i){put(layout::EnglishEnvironmentTileX+i,environment_x[i]);put(layout::EnglishEnvironmentTileY+i,environment_y[i]);put(layout::EnglishEnvironmentBudgetSteps+i,environment_steps[i]);}
const std::array<uint8_t,3> youth_colors{0x41,0x42,0x43};for(uint32_t i=0;i<3;++i)put(layout::EnglishEnvironmentYouthColors+i,youth_colors[i]);
const std::string position_suffix=". / ",cost_suffix=".";
for(uint32_t i=0;i<=position_suffix.size();++i)put(layout::EnglishEnvironmentYouthPositionSuffix+i,i<position_suffix.size()?uint8_t(position_suffix[i]):0);
for(uint32_t i=0;i<=cost_suffix.size();++i)put(layout::EnglishEnvironmentCostSuffix+i,i<cost_suffix.size()?uint8_t(cost_suffix[i]):0);
const auto path = root / "FLTD.EXE";
{ std::ofstream out(path, std::ios::binary); out.write(reinterpret_cast<const char*>(source.data()), std::streamsize(source.size())); }
const auto image = launch::translate_fltd(path);
check(image.u32(layout::SaveLoad_OverwriteQuestionPointer) == authored_question_address,
"overwrite question pointer must select the original English source slot");
check(image.string_at_pointer(layout::SaveLoad_OverwriteQuestionPointer) == authored_question,
"overwrite question must retain its complete source text");
for (uint32_t address = layout::Bank_OriginalToUtf8_RuntimeField;
address < layout::Analytics_FormatError_ExecutableField; address += 4) {
if (address == layout::SaveLoad_OverwriteQuestionPointer) continue;
check(image.u32(address) == layout::EmptyString,
"mapping the overwrite question must preserve all seventeen other empty pointers before analytics");
}
for (uint32_t i = 0; i < analytics_labels.size(); ++i)
check(image.u8(layout::Analytics_FormatError_ExecutableField + i) == analytics_labels[i],
"mapping the overwrite question must preserve the complete independent analytics mapping");
for (uint32_t i = 0; i < 6; ++i)
check(image.u8(layout::Setup_FormatError_RuntimeField8 + i) == toggle_rows[i], "toggle mapping includes alignment padding");
check(image.u8(layout::Desktop_Copy_TextPointer) == 0xfb, "negative balance colour");
@@ -41,8 +85,13 @@ int main() {
check(image.u8(layout::Desktop_Render_RuntimeField2 + i) == 20 + i, "bin source y");
check(image.u8(layout::Desktop_Render_RuntimeField3 + i) == 30 + i, "socket source x");
}
for(uint32_t i=0;i<6;++i)check(image.u8(layout::Environment_FormatError_RuntimeField+i)==environment_x[i]&&image.u8(layout::Environment_FormatError_RuntimeField2+i)==environment_y[i]&&image.u8(layout::EnvironmentBudgetSteps+i)==environment_steps[i],"English environment geometry/steps lost source table alignment");
for(uint32_t i=0;i<3;++i)check(image.u8(layout::EnvironmentYouthColors+i)==youth_colors[i],"English youth colours lost source alignment");
check(image.cstring(layout::EnvironmentYouthPositionSuffix)==position_suffix&&image.cstring(layout::EnvironmentCostSuffix)==cost_suffix,"English environment suffix mapping is incomplete");
install_environment_rules(image);check(environment_rules_supported(),"authored English numeric profile depends on source instructions");
check(player_league_count(image)==4&&image.u8(layout::LeaguePairings_LeaguePairingsConstants_RuntimeField)==5,"English visible league count overwrote internal leagues");
std::filesystem::remove_all(root);
std::cout << "FLTD setup, colour and desktop-control mappings passed\n";
std::cout << "FLTD setup, colour, desktop-control and overwrite-question mappings passed\n";
return 0;
} catch (const std::exception& error) {
if (!root.empty()) { std::error_code ec; std::filesystem::remove_all(root, ec); }
+30 -13
View File
@@ -139,9 +139,10 @@ void assert_key_source_cell(const StadiumScreen& screen, const std::filesystem::
constexpr std::array<uint32_t, 8> kPrices{300000, 375000, 300000, 350000,
300000, 375000, 300000, 350000};
constexpr std::array<uint32_t, 8> kMaxima{8000, 18000, 8000, 14000,
8000, 18000, 8000, 14000};
constexpr std::array<uint8_t, 8> kWeeks{30, 37, 30, 25, 30, 37, 30, 25};
// Match the retained 144k expansion policy and size-aware construction periods.
constexpr std::array<uint32_t, 8> kMaxima{14000, 24000, 14000, 20000,
14000, 24000, 14000, 20000};
constexpr std::array<uint8_t, 8> kWeeks{30, 48, 30, 40, 30, 48, 30, 40};
StadiumBlockExpansionEditor editor_for(uint8_t slot = 1, uint32_t total = 8000,
uint8_t features = 0, uint8_t raw_flags = 0) {
@@ -418,7 +419,7 @@ void source_textd_stadium_caption_tests(const std::filesystem::path& data) {
assert_text_pixels(editor_image, font, 5, 130, text(::bmh::layout::Stadium_RenderBlockExpansion_TextPointer9), 0x6a,
"block editor paints the Original TEXTD total-cost label");
const std::string duration = format_number(GameState{}, 37, 0x82) + text(::bmh::layout::Stadium_FormatError_RuntimeField) +
const std::string duration = format_number(GameState{}, 48, 0x82) + text(::bmh::layout::Stadium_FormatError_RuntimeField) +
exe.cstring(::bmh::layout::Stadium_FormatError_ExecutableField) + exe.cstring(::bmh::layout::CareerSession_FormatNumber_ExecutableField);
const int duration_x = 148 - font.text_width(duration);
assert_text_pixels(editor_image, font, duration_x, 54, duration, 0x6c,
@@ -432,7 +433,7 @@ void source_textd_stadium_caption_tests(const std::filesystem::path& data) {
assert_text_pixels(current_image, font, 221, 29, "Block A", 0x6b,
"A-H overview uses its Source TEXTD block prefix");
assert_text_pixels(current_image, font, 221, 22 + 21, text(::bmh::layout::Stadium_Out_TextPointer5) +
format_number(GameState{}, int32_t(exe.u8(::bmh::layout::CareerSession_Invalid_RuntimeField) * 1000), 5) +
format_number(GameState{}, int32_t(kMaxima[0]), 5) +
exe.cstring(::bmh::layout::Stadium_Out_ExecutableField), 0x51,
"current overview uses the Original TEXTD maximum-capacity label");
@@ -689,7 +690,7 @@ void calculator_tests(const std::filesystem::path& data) {
check(screen.calculator_open(), "host can query calculator visibility without reading or mutating Native");
assert_readout_source_text(screen, data, format_number(GameState{}, 0, 7),
"initial calculator readout matches Original width-seven FNT3 glyphs");
assert_preset_source_cell(screen, data, exe, 7, 18000);
assert_preset_source_cell(screen, data, exe, 7, 24000);
const Image before = screen.render();
check(screen.pointer_down(116, 36), "the calculator header starts a Source drag");
screen.pointer_move(1000, 1000);
@@ -759,7 +760,7 @@ void calculator_tests(const std::filesystem::path& data) {
"preset selection changes the value without the keypad's invented pressed phase");
const auto preset_accept = keyboard_return_after_source_phase(preset);
check(preset_accept.kind == StadiumRequestKind::expansion_set_total &&
preset_accept.block_total_places == 18000,
preset_accept.block_total_places == 24000,
"a preset value remains usable through the timed Source J action");
StadiumScreen low_total(data, detail_state());
@@ -774,7 +775,7 @@ void calculator_tests(const std::filesystem::path& data) {
high_total.click(50, 80);
check(high_total.text("999999"), "large typed input is accepted and clamped to Source maximum");
const auto maximum = keyboard_return_after_source_phase(high_total);
check(maximum.kind == StadiumRequestKind::expansion_set_total && maximum.block_total_places == 18000,
check(maximum.kind == StadiumRequestKind::expansion_set_total && maximum.block_total_places == 24000,
"calculator input never exceeds the slot-B maximum");
StadiumScreen reopened(data, detail_state(1, 15333, 1));
@@ -782,7 +783,7 @@ void calculator_tests(const std::filesystem::path& data) {
check(reopened.text("1"), "reopened calculator accepts another appended digit");
const auto appended = keyboard_return_after_source_phase(reopened);
check(appended.kind == StadiumRequestKind::expansion_set_total &&
appended.block_total_places == 18000,
appended.block_total_places == 24000,
"reopening starts from D=7333 and appends instead of replacing it with the first digit");
StadiumScreen zeroes(data, detail_state());
@@ -903,12 +904,12 @@ void offer_ack_tests(const std::filesystem::path& data) {
auto no_build = no_screen.state(); next_identity(no_build);
const auto no_quote = no_build.block_expansion->quote;
no_build.block_expansion.reset(); no_build.construction_tip_dialog.reset();
no_build.blocks[1].construction_weeks = 37;
no_build.blocks[1].construction_weeks = 48;
no_build.blocks[1].flags = uint8_t(no_build.blocks[1].flags | 0x10);
no_build.blocks[1].capacity = 15;
no_build.balance -= int32_t(no_quote.base_price);
no_screen.acknowledge(no_build);
check(!no_screen.pending() && no_screen.state().blocks[1].construction_weeks == 37,
check(!no_screen.pending() && no_screen.state().blocks[1].construction_weeks == 48,
"a valid NO decision constructs at the original base price and full duration");
auto poor = initial;
@@ -1034,7 +1035,7 @@ void source_compensation_ack_tests(const std::filesystem::path& data) {
"negative-week compensation path can take the ordinary NO construction");
const auto no_offer = *negative_weeks.state().block_expansion->offer;
const int32_t negative_compensation = -66000; // 11,000 * (17-20) * rate 2.
negative_weeks.acknowledge(completed_build_state(negative_weeks, 37,
negative_weeks.acknowledge(completed_build_state(negative_weeks, 48,
late.balance - int32_t(no_offer.base_price) - negative_compensation, 14000));
check(negative_weeks.state().balance == late.balance - int32_t(no_offer.base_price) + 66000,
"negative Source weeks credit the account while the ticket cap still applies");
@@ -1046,7 +1047,7 @@ void source_compensation_ack_tests(const std::filesystem::path& data) {
check(!no_account_booking.click(210, 171).accept_tip,
"level-zero Source path can accept a normal NO construction");
const auto level_zero_offer = *no_account_booking.state().block_expansion->offer;
no_account_booking.acknowledge(completed_build_state(no_account_booking, 37,
no_account_booking.acknowledge(completed_build_state(no_account_booking, 48,
level_zero.balance, 14000));
check(no_account_booking.state().balance == level_zero.balance &&
no_account_booking.state().season_tickets == 14000 &&
@@ -1120,6 +1121,22 @@ namespace {
void source_stadium_data_controls(const std::filesystem::path& data) {
const auto exe = load_le(asset_path(data, "BMH.exe"));
auto state = overview_state();
{
// the yellow hover frame of the advertising page: over a seat block and over an investment icon
StadiumScreen scene(data, state);
const auto plain = scene.render().pixels;
if (state.blocks[0].construction_weeks == 0) {
check(scene.pointer_move(250, 30) && scene.render().pixels != plain, "a seat block is framed under the pointer");
check(scene.pointer_move(100, 100) && scene.render().pixels == plain, "and the frame is gone when the pointer leaves");
}
for (int choice = 0; choice < 8 && state.investments_enabled; ++choice) {
if (!state.investments[size_t(choice)].available) continue;
check(scene.pointer_move(8 + (choice % 4) * 54, 158 + (choice / 4) * 30) && scene.render().pixels != plain,
"an available investment icon is framed under the pointer");
check(scene.pointer_move(100, 100) && scene.render().pixels == plain, "and the frame is gone when the pointer leaves");
break;
}
}
StadiumScreen overview(data, state);
check(overview.pointer_down(265, 220), "Original stadium data button binds on DOWN");
const auto held_overview=overview.state_json();
+53
View File
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "app/start_screen.hpp"
#include <SDL.h>
#include <array>
#include <cmath>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <vector>
namespace {
void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}
void frame(int width,int height,const std::filesystem::path& output) {
const std::unique_ptr<SDL_Surface,decltype(&SDL_FreeSurface)> surface(
SDL_CreateRGBSurfaceWithFormat(0,width,height,32,SDL_PIXELFORMAT_RGBA32),SDL_FreeSurface);
check(bool(surface),SDL_GetError());
const std::unique_ptr<SDL_Renderer,decltype(&SDL_DestroyRenderer)> renderer(SDL_CreateSoftwareRenderer(surface.get()),SDL_DestroyRenderer);
check(bool(renderer),SDL_GetError());SDL_RenderSetLogicalSize(renderer.get(),320,240);SDL_SetRenderDrawColor(renderer.get(),12,34,56,255);
{
bmh::app::StartScreen title(renderer.get());
check(title.width()==1448&&title.height()==1086,"start artwork was reduced to the game canvas");title.present();
int logical_width=0,logical_height=0;SDL_RenderGetLogicalSize(renderer.get(),&logical_width,&logical_height);
check(logical_width==1448&&logical_height==1086,"start screen uses the low-resolution logical size");
float sx=0,sy=0;SDL_RenderGetScale(renderer.get(),&sx,&sy);
check(sx>0&&sy>0&&std::abs(sx-sy)<0.001f,"start artwork aspect ratio was stretched");
std::vector<unsigned char> pixels(size_t(width)*height*4);
check(SDL_LockSurface(surface.get())==0,SDL_GetError());
for(int y=0;y<height;++y)std::memcpy(pixels.data()+size_t(y)*width*4,
static_cast<const unsigned char*>(surface->pixels)+size_t(y)*surface->pitch,size_t(width)*4);
SDL_UnlockSurface(surface.get());
const auto center=(size_t(height/2)*width+width/2)*4;
check(pixels[center]+pixels[center+1]+pixels[center+2]>20,"embedded start artwork was not painted");
if(width*3>height*4){const auto side=size_t(height/2)*width*4;check(pixels[side]==0&&pixels[side+1]==0&&pixels[side+2]==0,"wide display has no clean side bars");}
Uint8 r=0,g=0,b=0,a=0;SDL_GetRenderDrawColor(renderer.get(),&r,&g,&b,&a);
check(r==12&&g==34&&b==56&&a==255,"start screen leaked its draw color into the game");
if(!output.empty()) {
std::filesystem::create_directories(output);std::ofstream file(output/(std::to_string(width)+"x"+std::to_string(height)+".ppm"),std::ios::binary);
file<<"P6\n"<<width<<' '<<height<<"\n255\n";for(size_t i=0;i<pixels.size();i+=4)file.write(reinterpret_cast<const char*>(pixels.data()+i),3);
}
title.present(); // Expose/resize redraw retains the same decoded texture.
}
int w=0,h=0;SDL_RenderGetLogicalSize(renderer.get(),&w,&h);
check(w==320&&h==240,"start screen did not restore the game and input coordinate system");
}
}
int main(int argc,char** argv)try {
SDL_setenv("SDL_VIDEODRIVER","dummy",0);check(SDL_Init(SDL_INIT_VIDEO)==0,SDL_GetError());
const std::filesystem::path output=argc>1?argv[1]:"";
for(const auto size:std::array<std::array<int,2>,4>{{{1448,1086},{1920,1080},{3840,2160},{3440,1440}}})frame(size[0],size[1],output);
SDL_Quit();std::cout<<"Embedded native artwork, 1080p/4K/ultrawide aspect fit, redraw and game/input restoration passed\n";
}catch(const std::exception& error){std::cerr<<error.what()<<'\n';SDL_Quit();return 1;}
+1 -1
View File
@@ -14,7 +14,7 @@ def validate(directory, windows):
documents = {'README.md', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md'}
licenses = {'README.md', 'LGPL-2.1.txt', 'Nuked-OPL3-notices.txt', 'LZMA-SDK.txt', 'SDL2-HIDAPI-BSD.txt',
'SDL2-HIDAPI-options.txt', 'SDL2-HIDAPI-original.txt', 'SDL2-yuv2rgb.txt',
'SDL2.txt', 'miniz-source-notices.txt', 'miniz.txt', 'nativefiledialog-extended.txt'}
'SDL2.txt', 'miniz-source-notices.txt', 'miniz.txt', 'nativefiledialog-extended.txt', 'stb_image.txt'}
present = set()
for file in directory.rglob('*'):
if not file.is_file():
+10
View File
@@ -8,6 +8,7 @@ from __future__ import annotations
import argparse
import dataclasses
import json
import hashlib
from pathlib import Path, PurePosixPath
import re
import shutil
@@ -28,6 +29,10 @@ ASSET_SUFFIXES = {
".avi", ".mov", ".mp4", ".png", ".jpg", ".jpeg", ".bmp", ".gif",
".bin", ".zip", ".7z", ".dmg", ".tar", ".gz", ".pdf",
}
# Newly supplied project artwork and an unchanged MIT/public-domain decoder.
# Exact hashes keep this exception from admitting original-game asset dumps.
REVIEWED_BINARY_FILES = {"assets/start-screen.jpg": "28df5a72cd7b6951c9eebf30532ea9557007a46f0a73614ba22401c403e379dc"}
REVIEWED_UPSTREAM_FILES = {"src/app/third_party/stb_image.h": "594c2fe35d49488b4382dbfaec8f98366defca819d916ac95becf3e75f4200b3"}
PRIVATE_PREFIXES = (
("data", "original"), ("docs", "manuals"), ("docs", "analyses"),
("docs", "agents"), ("src", "ui", "validation"),
@@ -166,6 +171,11 @@ def path_findings(name: str) -> list[Finding]:
def scan_blob(name: str, blob: bytes) -> list[Finding]:
reviewed = REVIEWED_BINARY_FILES | REVIEWED_UPSTREAM_FILES
if name in reviewed:
if hashlib.sha256(blob).hexdigest() == reviewed[name]:
return []
return [Finding(name, 0, "modified-reviewed-project-file")]
result = path_findings(name)
if len(blob) > 2_000_000:
result.append(Finding(name, 0, "oversized-source-file"))
+11
View File
@@ -5,6 +5,7 @@
import contextlib
import io
import hashlib
import json
from pathlib import Path
import shutil
@@ -17,6 +18,16 @@ import check_public_tree as guard
class BlobChecks(unittest.TestCase):
def test_only_exact_reviewed_artwork_and_decoder_are_admitted(self):
for name, table in (("assets/start-screen.jpg",guard.REVIEWED_BINARY_FILES),
("src/app/third_party/stb_image.h",guard.REVIEWED_UPSTREAM_FILES)):
content=b"synthetic reviewed input\0"
with mock.patch.dict(table,{name:hashlib.sha256(content).hexdigest()}):
self.assertEqual(guard.scan_blob(name,content),[])
self.assertEqual({finding.rule for finding in guard.scan_blob(name,content+b"changed")},
{"modified-reviewed-project-file"})
self.assertIn("binary-or-game-asset",{finding.rule for finding in guard.scan_blob("assets/other.jpg",b"synthetic\0")})
def rules(self, name, text):
return {finding.rule for finding in guard.scan_blob(name, text.encode())}