Compare commits

...
17 Commits
Author SHA1 Message Date
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
38 changed files with 639 additions and 116 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.5/RELEASE_NOTES.md
gh release create "$RELEASE_TAG" dist/*.zip dist/SHA256SUMS dist/QA-REPORT.json --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/1.0.7/RELEASE_NOTES.md
+1 -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.5 LANGUAGES CXX C)
project(OpenBMH VERSION 1.0.7 LANGUAGES CXX C)
if(APPLE)
# Enable native languages before dependencies/subdirectories inherit rules.
enable_language(OBJC OBJCXX)
+4 -2
View File
@@ -1,6 +1,6 @@
# OpenBMH
**Classic-Version: 1.0.5.** Die originalgetreue Linie bleibt in diesem Repository.
**Classic-Version: 1.0.7.** Die originalgetreue Linie bleibt in diesem Repository.
Erweiterte Ligen, die gemeinsame deutsche/englische Karriere und der Dateneditor
werden separat als **[OpenBMH-Extended 1.0 Beta](https://github.com/Weyoune/OpenBMH-extended)** entwickelt.
@@ -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.5/RELEASE_NOTES.md).
To report a problem, start the game with `-debug`. It then writes `openbmh-debug.log` (timestamped events, errors and refused actions) and `openbmh-stderr.log` into the `debug` sub folder of the save directory, and saves the game there after every match day (`DBG00001.FBM`, `DBG00002.FBM`, ...). Attach the log and the last save to the report.
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0.7/RELEASE_NOTES.md).
## Features and direction
+3
View File
@@ -34,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.
+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.
+27 -50
View File
@@ -374,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) {
@@ -761,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);
@@ -2257,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||
@@ -2345,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_) {
@@ -4539,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;
}
@@ -4593,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;
};
+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;
+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);
+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;
+3 -1
View File
@@ -392,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;
+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 &&
+128 -16
View File
@@ -1269,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) {
@@ -3186,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);
@@ -3221,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");
@@ -3237,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");
@@ -3248,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");
@@ -3259,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");
@@ -3315,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) {
@@ -4203,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) {
@@ -4218,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);
@@ -4227,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;
@@ -4236,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;
+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);
+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();