Compare commits

...
23 Commits
Author SHA1 Message Date
ClaudeandClaude Sonnet 5.5 aa6ec96305 Prepare Classic 1.0.8 patch release
Prepare verified release / draft (push) Waiting to run
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 22:05:19 +01:00
ClaudeandClaude Sonnet 5.5 e337c3c6b2 Bank credit annuity: evaluate the original's x87 rounding chain exactly
The original computes ((base / 100) * den) / 100 with 64-bit-mantissa x87
steps and one final store to a double. The host long double is only 64 bits
wide on MSVC and Apple silicon, so the annuity differed by 1 for roughly 0.2 %
of realistic loans (1-60 million) there. The chain is now evaluated with
integers, identical on every platform. Verified against the original routine
in an emulator: 5684 term/principal combinations, no difference.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 21:40:20 +01:00
ClaudeandClaude Sonnet 5.5 6cccbb01d3 Prepare Classic 1.0.7 patch release
Prepare verified release / draft (push) Waiting to run
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 21:12:49 +01:00
ClaudeandClaude Sonnet 5.5 8780d7b5a5 Show JA pushed in briefly when the manager selection is confirmed
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 21:11:01 +01:00
ClaudeandClaude Sonnet 5.5 a279bfb6df Ignore the computer tip button once a visible result is known
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 21:04:00 +01:00
ClaudeandClaude Sonnet 5.5 0535764834 Other Games and Top Scorers acknowledgement uses the home-club identity at the national desk
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 21:02:19 +01:00
ClaudeandClaude Sonnet 5.5 2f5303d9bd Prepare Classic 1.0.6 patch release
Prepare verified release / draft (push) Waiting to run
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) Waiting to run
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
56 changed files with 1000 additions and 147 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.4/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.8/RELEASE_NOTES.md
+5 -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.4 LANGUAGES CXX C)
project(OpenBMH VERSION 1.0.8 LANGUAGES CXX C)
if(APPLE)
# Enable native languages before dependencies/subdirectories inherit rules.
enable_language(OBJC OBJCXX)
@@ -964,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)
@@ -1149,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)
+4 -2
View File
@@ -1,6 +1,6 @@
# OpenBMH
**Classic-Version: 1.0.4.** Die originalgetreue Linie bleibt in diesem Repository.
**Classic-Version: 1.0.8.** 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.4/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.8/RELEASE_NOTES.md).
## Features and direction
+10 -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.
+4
View File
@@ -13,6 +13,7 @@ describe deliberate changes; they are not a list of every known compatibility li
- [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,9 +34,12 @@ 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_pairings.cpp](../src/ui/league_pairings.cpp): the computer tip is ignored silently once a visible result is known, instead of raising an engine error.
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): omits DOS drive and delete buttons in the directory-confined save/load view.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): the host file picker uses the shared dialog's system identity without a live manager portrait projection.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): permits cancelling host file dialogs with the right mouse button.
- [src/ui/settings.cpp](../src/ui/settings.cpp): the settings page names the product and its build version instead of the original's version text.
+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.
+35
View File
@@ -0,0 +1,35 @@
# OpenBMH Classic 1.0.7
This patch fixes national-team desk screens and two small interface details
reported by testers. It requires the player's own game installation. Extended
development remains separate in
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
## Changes since 1.0.6
- **National-team desk.** Other Games and Top Scorers open again; both screens
are identified by the home club, so the desk is no longer rejected as stale
or as a mismatched acknowledgement.
- **Computer tip.** After the results of a round are known the button is only
pressed and released, as in the original, instead of raising an engine error.
- **Manager selection.** JA of the confirmation question is shown pushed in
briefly after it is clicked.
## Validation and human QA
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
builds, configured tests, product-version checks and package/source verification
for the exact tagged revision. Downloads include checksums, a platform test
report and corresponding source with pinned open-source dependencies.
The fixes were checked with the desktop, controller and manager tests; native
Windows/macOS gameplay acceptance is not established by CI builds. Open points
from 1.0.6 remain: the "player card: original atlas bounds" error (#77),
sporadic double clicks (#58) and the macOS match scene speed (#70).
## Known limits
The compatibility and long-career limits documented for
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
its original V2.20 save layout remains unsupported. Keep backups of saves.
macOS packages are unsigned terminal executables, not notarised app bundles.
+43
View File
@@ -0,0 +1,43 @@
# OpenBMH Classic 1.0.8
This patch makes the bank credit annuity identical on every platform. It
requires the player's own game installation. Extended development remains
separate in [OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
## Changes since 1.0.7
- **Bank credit annuity.** The original computes the monthly payment with
x87 floating point (64-bit mantissa at every step, one final store to a
double). The host `long double` is only 64 bits wide on Windows (MSVC) and
on Apple silicon, so the payment differed by 1 for roughly 0.2 % of loans of
one to sixty million. The chain is now evaluated with integer arithmetic and
gives the original's result on every platform.
## Validation and human QA
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
builds, configured tests, product-version checks and package/source verification
for the exact tagged revision. Downloads include checksums, a platform test
report and corresponding source with pinned open-source dependencies.
This release follows a quality pass that ran single routines of the original
programme in an emulator and compared them with the engine on whole savegames,
with boundary values and a deliberately wrong result per rule that must fail.
Compared without a difference: the random generator, market value and salary,
the willingness of clubs to sell, the rating of transfer bids, club mood and
flags at the end of a season, the order of national cup ties, weekly advertising
offers, facility ageing and damage, offers to managers, weekly statistics,
familiarity decay, squad training and daily interest. The one difference found
is the annuity fixed above. Rules that depend on screens, dialogs or the master
database were not part of this pass.
Native Windows/macOS gameplay acceptance is not established by CI builds. Open
points from earlier releases remain: the "player card: original atlas bounds"
error (#77), sporadic double clicks (#58) and the macOS match scene speed (#70).
## Known limits
The compatibility and long-career limits documented for
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
its original V2.20 save layout remains unsupported. Keep backups of saves.
macOS packages are unsigned terminal executables, not notarised app bundles.
+37 -50
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;
}
+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
+32 -2
View File
@@ -34,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"
@@ -115,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")) {
@@ -139,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) {
@@ -148,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]);
@@ -195,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);
@@ -226,8 +236,21 @@ int main(int argc, char** argv) {
ui::SportschauEleven sportschau_eleven(data);
ui::SportschauTeamInfo sportschau_team_info(data);
ui::CompetitionWinnerScreen competition_winner(data);
ui::set_settings_product_version(bmh::kOpenBmhVersion);
const auto season_exe = load_le(ui::asset_path(data, "BMH.exe"));
english_game = english_game || season_exe.u8(layout::LeagueSizes) == 20;
{
// The pointer of the original is its default 11x11 bitmap (index 0 transparent, hot spot
// top left, set when a window object is created); the pitch page draws the same bitmap
// with its own fill colour. The edition's own bitmap is used for the English version.
std::array<uint32_t, 121> bitmap{};
for (uint32_t i = 0; i < bitmap.size(); ++i) {
const auto index = season_exe.u8(layout::OriginalPointerPixels + i);
bitmap[i] = index == 0 ? 0 : palette.argb[index];
}
pitch_pointer.set_default(bitmap);
pitch_pointer.show({}, renderer);
}
app::QuitConfirmation quit_confirmation(window, english_game);
try {
if (!playback.initialize_original(app::original_audio_assets(data, season_exe), audio_error))
@@ -3226,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) {
@@ -3845,6 +3869,12 @@ int main(int argc, char** argv) {
const auto released = held ? flow.hold(e.button.x, e.button.y, 2000)
: flow.click(e.button.x, e.button.y, e.button.button == SDL_BUTTON_RIGHT, e.button.clicks >= 2);
present_formation_save_feedback();
// JA of the manager confirmation is shown pushed in briefly before the
// (possibly slow) next step starts, as in the original.
if (flow.screen_name() == "manager_accepted") {
present_season(flow.render(), "OpenBMH - manager_accepted");
SDL_Delay(150);
}
handle(released);
present_desk_record_points();
press.reset();
+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;
};
+7
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;
+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);
}
}
+101 -9
View File
@@ -2,6 +2,7 @@
#include "formats/executable_layout.hpp"
#include "game/bank_credit.hpp"
#include <array>
#include <bit>
#include <cmath>
#include <cstring>
@@ -29,6 +30,102 @@ uint32_t read_record(const GameState& g, size_t at) {
for (int i = 0; i < 4; ++i) v |= uint32_t(g.manager_records.at(at + i)) << (i * 8);
return v;
}
// The original evaluates ((base / 100) * den) / 100 on the x87 stack: every step is rounded to a
// 64-bit mantissa (round to nearest even), only the final store rounds to a 53-bit double. The
// host's long double is not that format (64 bits on MSVC and on Apple silicon), which changed the
// result by 1 for loans of about a million and more. This evaluates the same chain exactly with
// integers, so the result is the same on every platform. Returns the value truncated toward zero.
struct Wide { // 128-bit unsigned, little-endian 32-bit limbs
std::array<uint32_t, 4> l{};
unsigned bit_length() const {
for (int i = 3; i >= 0; --i)
if (l[size_t(i)]) return unsigned(i) * 32 + unsigned(32 - std::countl_zero(l[size_t(i)]));
return 0;
}
bool bit(unsigned n) const { return n < 128 && (l[n / 32] >> (n % 32)) & 1u; }
bool any_below(unsigned n) const { // any bit below position n set
for (unsigned i = 0; i < n && i < 128; ++i) if (bit(i)) return true;
return false;
}
static Wide from(uint64_t v) { Wide w; w.l[0] = uint32_t(v); w.l[1] = uint32_t(v >> 32); return w; }
uint64_t window(unsigned lo) const { // the 64 bits starting at bit `lo`
uint64_t v = 0;
for (unsigned i = 0; i < 64; ++i) if (bit(lo + i)) v |= uint64_t(1) << i;
return v;
}
};
struct Extended { uint64_t m = 0; int e = 0; }; // value = m * 2^e, m has 64 bits (or is zero)
// Round `w` (plus a "something was dropped" flag) to 64 bits, nearest even; value = w * 2^exp.
Extended round_to_64(const Wide& w, bool sticky, int exp) {
const unsigned len = w.bit_length();
Extended r;
if (len == 0) return r;
if (len <= 64) {
const unsigned up = 64 - len;
r.m = w.window(0) << up;
r.e = exp - int(up);
return r;
}
const unsigned s = len - 64;
r.m = w.window(s);
const bool guard = w.bit(s - 1), rest = sticky || w.any_below(s - 1);
r.e = exp + int(s);
if (guard && (rest || (r.m & 1))) {
if (++r.m == 0) { r.m = uint64_t(1) << 63; ++r.e; }
}
return r;
}
Extended x87_divide_small(const Extended& a, uint32_t d) {
Wide n; // a.m * 2^64, divided limb by limb
n.l[2] = uint32_t(a.m); n.l[3] = uint32_t(a.m >> 32);
uint64_t rem = 0;
Wide q;
for (int i = 3; i >= 0; --i) {
const uint64_t cur = (rem << 32) | n.l[size_t(i)];
q.l[size_t(i)] = uint32_t(cur / d);
rem = cur % d;
}
return round_to_64(q, rem != 0, a.e - 64);
}
Extended x87_multiply_small(const Extended& a, uint32_t b) {
Wide p;
uint64_t carry = 0;
const uint32_t limb[2] = {uint32_t(a.m), uint32_t(a.m >> 32)};
for (int i = 0; i < 2; ++i) {
const uint64_t cur = uint64_t(limb[i]) * b + carry;
p.l[size_t(i)] = uint32_t(cur);
carry = cur >> 32;
}
p.l[2] = uint32_t(carry);
return round_to_64(p, false, a.e);
}
// ((base / 100) * den) / 100 stored as a double and truncated toward zero. `zero` reports an exact
// zero before truncation (the original's "exact zero becomes 1" rule looks at the stored double).
int64_t x87_amount_chain(int32_t base, uint32_t den, bool& zero) {
zero = base == 0 || den == 0;
if (zero) return 0;
const bool negative = base < 0;
const uint64_t magnitude = negative ? uint64_t(-int64_t(base)) : uint64_t(base);
Extended v = round_to_64(Wide::from(magnitude), false, 0);
v = x87_divide_small(v, 100);
v = x87_multiply_small(v, den);
v = x87_divide_small(v, 100);
// store as double: 53-bit mantissa, nearest even
uint64_t m53 = v.m >> 11;
int e = v.e + 11;
const bool guard = (v.m >> 10) & 1, rest = (v.m & 0x3ff) != 0;
if (guard && (rest || (m53 & 1))) ++m53; // a carry to 2^53 is still exact
uint64_t whole;
if (e >= 0) {
if (e > 10) throw std::invalid_argument("invalid native credit amount");
whole = m53 << e;
} else {
whole = -e >= 64 ? 0 : m53 >> unsigned(-e);
}
if (whole > uint64_t(std::numeric_limits<int32_t>::max()) + (negative ? 1u : 0u))
throw std::invalid_argument("invalid native credit amount");
return negative ? -int64_t(whole) : int64_t(whole);
}
// Amount: signed IMUL/IDIV, x87 intermediate, QWORD store,
// exact-zero floor, then Amount2's explicit rounding toward zero.
int32_t amount(const BankCreditContext& c, uint32_t months, int32_t principal) {
@@ -37,15 +134,10 @@ int32_t amount(const BankCreditContext& c, uint32_t months, int32_t principal) {
const int32_t factor = c.rate_table[months];
const int32_t base = divide(mul(principal, factor), 100);
const int32_t den = divide(10000, factor - 100);
const long double intermediate = (static_cast<long double>(base) / c.divisor)
* den / c.divisor;
double raw = static_cast<double>(intermediate);
if (raw == 0 && principal != 0) raw = 1;
raw = std::trunc(raw);
if (!std::isfinite(raw) || raw < std::numeric_limits<int32_t>::min()
|| raw > std::numeric_limits<int32_t>::max())
throw std::invalid_argument("invalid native credit amount");
return static_cast<int32_t>(raw);
bool zero = false;
int64_t result = x87_amount_chain(base, uint32_t(den), zero);
if (zero && principal != 0) result = 1;
return static_cast<int32_t>(result);
}
void balance(const BankCreditContext& c, BankCreditDraft& d) {
int32_t result = add(c.cash, signed_word(d.values[0]));
+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{};
+7
View File
@@ -3,6 +3,7 @@
#include "launch/fltd.hpp"
#include <algorithm>
#include <array>
#include <cstring>
#include <fstream>
#include <stdexcept>
@@ -129,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;
}
+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 16"; // 16: overwrite question pointer (15: original pitch affinity tables and pointer bitmap)
constexpr const char* kTranslation = "english translation 17"; // 17: English monthly environment tables (16: overwrite question)
std::string built;
{
std::ifstream in(marker);
+12 -1
View File
@@ -756,7 +756,10 @@ 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 (hovered_target_ >= 0) {
@@ -970,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;
+2
View File
@@ -158,6 +158,8 @@ 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();
+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;
+9
View File
@@ -739,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) {
+17 -4
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); });
@@ -1123,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);
+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,
+1 -1
View File
@@ -46,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);
+3
View File
@@ -368,6 +368,9 @@ bool LeaguePairingsScreen::release(int x,int y) {
return true;
}
if(button==5)return true; // Source ellipsis has no action.
// OpenBMH deviates from the original: the computer tip is ignored silently once a visible result is known, instead of raising an engine error.
if(button==4&&std::any_of(state_.source.rows.begin(),state_.source.rows.end(),
[](const auto& row){return row.raw_result!=0xcc;}))return true;
post({button==0?LeaguePairingsAction::reset:button==1?LeaguePairingsAction::search:
button==2?LeaguePairingsAction::filter_by_club:button==3?LeaguePairingsAction::postponed_list:
button==4?LeaguePairingsAction::computer_tip:LeaguePairingsAction::unsupported,button});return true;
+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;
+10 -3
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);
@@ -387,7 +392,9 @@ Image ManagerScreen::render() const {
badge(out, 54, 89, choice_.master_club); portrait(out, 221, 89, choice_.portrait);
const auto& prompt = texts_[(::bmh::layout::Manager_SmallText_TextPointer - ::bmh::layout::TextPointerTable) / 4];
small_text(out, 73 + 170 / 2 - small_.text_width(prompt) / 2, 140, prompt);
button(out, 62, 166, 75, texts_[(::bmh::layout::GameEnd_Copy_TextPointer - ::bmh::layout::TextPointerTable) / 4], false);
// The original shows JA pushed in for a moment after it is clicked.
button(out, 62, 166, 75, texts_[(::bmh::layout::GameEnd_Copy_TextPointer - ::bmh::layout::TextPointerTable) / 4],
view_ == ManagerView::accepted);
button(out, 175, 166, 75, texts_[(::bmh::layout::GameEnd_Copy_TextPointer2 - ::bmh::layout::TextPointerTable) / 4], false);
}
return out;
+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,
+8 -8
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");
@@ -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().managers[size_t(owner.manager_slot)].club_identity_key))
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)
@@ -1167,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);
@@ -1180,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");
@@ -1198,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||
@@ -1826,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)||
@@ -2081,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;
}
+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 &&
+146 -16
View File
@@ -1,6 +1,7 @@
#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>
@@ -1268,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) {
@@ -1646,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);
@@ -3171,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);
@@ -3206,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");
@@ -3222,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");
@@ -3233,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");
@@ -3244,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");
@@ -3300,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) {
@@ -4188,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) {
@@ -4203,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);
@@ -4212,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;
@@ -4221,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;
@@ -7120,6 +7247,9 @@ int main(int argc, char** argv) {
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;
}
+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) {
+15
View File
@@ -1,8 +1,11 @@
// 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>
@@ -40,6 +43,7 @@ int main() {
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]);
@@ -50,6 +54,12 @@ 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);
@@ -75,6 +85,11 @@ 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, desktop-control and overwrite-question mappings passed\n";
return 0;
+16
View File
@@ -1121,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();