Compare commits
No files matched your search
@@ -1,2 +1,3 @@
|
||||
* text=auto eol=lf
|
||||
*.bat text eol=crlf
|
||||
third_party/** -text
|
||||
@@ -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.6/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.12/RELEASE_NOTES.md
|
||||
+22
-8
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 1.0.6 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 1.0.12 LANGUAGES CXX C)
|
||||
if(APPLE)
|
||||
# Enable native languages before dependencies/subdirectories inherit rules.
|
||||
enable_language(OBJC OBJCXX)
|
||||
@@ -213,6 +213,7 @@ add_library(bmhcore STATIC
|
||||
src/formats/textd.cpp
|
||||
src/formats/fbm.cpp
|
||||
src/formats/le.cpp
|
||||
src/formats/diamond_image.cpp
|
||||
src/formats/m3d.cpp
|
||||
src/formats/savestate.cpp
|
||||
src/game/schedule.cpp
|
||||
@@ -240,6 +241,7 @@ add_library(bmhcore STATIC
|
||||
src/game/matchday_setup.cpp
|
||||
src/game/prediction.cpp
|
||||
src/game/month.cpp
|
||||
src/game/search_profile.cpp
|
||||
src/game/desk.cpp
|
||||
src/game/cup.cpp
|
||||
src/game/club_info.cpp
|
||||
@@ -283,12 +285,9 @@ if(MSVC)
|
||||
endif()
|
||||
|
||||
# --- Game data launcher (src/launch): find, unpack and check the original game data ---------
|
||||
# ZIP: miniz (MIT), 7z: the C decoder of the LZMA SDK (public domain), file dialog:
|
||||
# ZIP: miniz 3.0.2 (MIT, vendored in third_party/miniz), 7z: the C decoder of the LZMA SDK (public domain), file dialog:
|
||||
# nativefiledialog-extended (zlib). All pinned; fetched like SDL2.
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(miniz
|
||||
URL https://github.com/richgel999/miniz/releases/download/3.0.2/miniz-3.0.2.zip
|
||||
URL_HASH SHA256=ada38db0b703a56d3dd6d57bf84a9c5d664921d870d8fea4db153979fb5332c5)
|
||||
FetchContent_Declare(lzma_sdk
|
||||
GIT_REPOSITORY https://github.com/ip7z/7zip.git
|
||||
GIT_TAG 24.09
|
||||
@@ -300,8 +299,9 @@ FetchContent_Declare(nfd
|
||||
GIT_REPOSITORY https://github.com/btzy/nativefiledialog-extended.git
|
||||
GIT_TAG v1.2.1
|
||||
GIT_SHALLOW TRUE)
|
||||
FetchContent_MakeAvailable(miniz lzma_sdk nfd)
|
||||
FetchContent_MakeAvailable(lzma_sdk nfd)
|
||||
|
||||
set(miniz_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/miniz") # vendored: no download that can fail
|
||||
add_library(bmh_miniz STATIC ${miniz_SOURCE_DIR}/miniz.c)
|
||||
target_include_directories(bmh_miniz PUBLIC ${miniz_SOURCE_DIR})
|
||||
set(BMH_LZMA_C ${lzma_sdk_SOURCE_DIR}/C)
|
||||
@@ -1087,9 +1087,16 @@ set(BMH_TEST_SPORTSCHAU_APP_TESTS_INPUT_1 "" CACHE PATH "External input 1 for sp
|
||||
bmh_add_data_test(NAME sportschau_app_tests REQUIRED_OPTIONS BMH_TEST_SPORTSCHAU_APP_TESTS_INPUT_1 COMMAND sportschau_app_tests "${BMH_DATA}"
|
||||
"${BMH_TEST_SPORTSCHAU_APP_TESTS_INPUT_1}")
|
||||
|
||||
# The runtime component deliberately contains only the two products and notices.
|
||||
# openbmh.dat (the game texts of the original executables, tools/diamond_constants) ships next to the programs and is copied
|
||||
# next to the built programs as well, where the game looks for it.
|
||||
foreach(product IN ITEMS openbmh_play openbmh_cli)
|
||||
add_custom_command(TARGET ${product} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/data/openbmh.dat" "$<TARGET_FILE_DIR:${product}>")
|
||||
endforeach()
|
||||
|
||||
# The runtime component deliberately contains only the two products, openbmh.dat and notices.
|
||||
install(TARGETS openbmh_play openbmh_cli RUNTIME DESTINATION . COMPONENT Runtime)
|
||||
install(FILES README.md LICENSE THIRD_PARTY_NOTICES.md ACKNOWLEDGEMENTS.md CONTRIBUTING.md
|
||||
install(FILES README.md LICENSE THIRD_PARTY_NOTICES.md ACKNOWLEDGEMENTS.md CONTRIBUTING.md data/openbmh.dat
|
||||
DESTINATION . COMPONENT Runtime)
|
||||
install(DIRECTORY docs/ DESTINATION docs COMPONENT Runtime)
|
||||
if(MSVC)
|
||||
@@ -1192,6 +1199,13 @@ add_test(NAME daily_interest_unit_tests COMMAND daily_interest_unit_tests)
|
||||
add_executable(transfer_seller_actions_tests tests/transfer_seller_actions_tests.cpp)
|
||||
target_link_libraries(transfer_seller_actions_tests PRIVATE bmhcore)
|
||||
add_test(NAME transfer_seller_actions_tests COMMAND transfer_seller_actions_tests)
|
||||
add_executable(diamond_image_tests tests/diamond_image_tests.cpp)
|
||||
target_link_libraries(diamond_image_tests PRIVATE bmhcore)
|
||||
add_test(NAME diamond_image_tests COMMAND diamond_image_tests - "${CMAKE_CURRENT_SOURCE_DIR}/data/openbmh.dat")
|
||||
bmh_add_data_test(NAME diamond_image_data_tests COMMAND diamond_image_tests "${BMH_DATA}" "${CMAKE_CURRENT_SOURCE_DIR}/data/openbmh.dat")
|
||||
add_executable(search_profile_tests tests/search_profile_tests.cpp)
|
||||
target_link_libraries(search_profile_tests PRIVATE bmhcore)
|
||||
add_test(NAME search_profile_tests COMMAND search_profile_tests)
|
||||
|
||||
add_executable(transfer_seller_app_tests tests/transfer_seller_app_tests.cpp ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(transfer_seller_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# OpenBMH
|
||||
|
||||
**Classic-Version: 1.0.6.** Die originalgetreue Linie bleibt in diesem Repository.
|
||||
**Classic-Version: 1.0.12.** Die originalgetreue Linie bleibt in diesem Repository.
|
||||
Erweiterte Ligen, die gemeinsame deutsche/englische Karriere und der Dateneditor
|
||||
werden separat als **[OpenBMH-Extended 1.0 Beta](https://github.com/Weyoune/OpenBMH-extended)** entwickelt.
|
||||
|
||||
|
||||
A faithful, standalone community reconstruction of *Bundesliga Manager Hattrick*, using the player's original installation and SDL2 interface.
|
||||
|
||||
OpenBMH 1.0 builds on v0.1.2 with reviewed bug fixes and starts directly with the original game data. Original game files, graphics, audio and manuals are not distributed. German CD-compatible BMH and verified Diamond editions are the primary release targets. Football Limited remains experimental; the older floppy executable is not supported.
|
||||
OpenBMH 1.0 builds on v0.1.2 with reviewed bug fixes and starts directly with the original game data. Original game files, graphics, audio, texts and manuals are not distributed. German CD-compatible BMH and verified Diamond editions are the primary release targets. Football Limited remains experimental; the older floppy executable is not supported.
|
||||
|
||||
This is an independent community project, with no affiliation with or endorsement by the original rights holders, the DFL or the Bundesliga. It is an engine implementation, not an official source release or a remaster.
|
||||
|
||||
@@ -15,9 +15,9 @@ This is an independent community project, with no affiliation with or endorsemen
|
||||
|
||||
Check the [releases page](https://github.com/Weyoune/openbmh/releases) for available packages and their platform notes. A Windows package uses the name `OpenBMH-<version>-windows-x64.zip`. Availability and native validation are stated for each release; source build instructions do not establish platform support on their own.
|
||||
|
||||
1. Have your own supported game installation available.
|
||||
1. Have your own supported game installation available. OpenBMH needs its asset files (texts, master database, pictures, fonts, sounds) and **either** `BMH.EXE` (`FLTD.EXE` for the English game) **or** `openbmh.dat`, which ships next to the programs in the release package and holds the game texts of the original executables; the numbers of those executables are built into OpenBMH. If both are there, the executable is used. If neither is there, OpenBMH asks for the game directory or for `BMH.EXE`.
|
||||
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
|
||||
3. Start `OpenBMH` (`OpenBMH.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
3. Start `OpenBMH` (`OpenBMH.exe` on Windows). Select the game directory (or `BMH.EXE`) when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
|
||||
From a terminal in the extracted package on Linux or macOS:
|
||||
|
||||
@@ -30,7 +30,7 @@ In Windows PowerShell, use `.\OpenBMH.exe` and `.\openbmh_cli.exe` instead.
|
||||
|
||||
To report a problem, start the game with `-debug`. It then writes `openbmh-debug.log` (timestamped events, errors and refused actions) and `openbmh-stderr.log` into the `debug` sub folder of the save directory, and saves the game there after every match day (`DBG00001.FBM`, `DBG00002.FBM`, ...). Attach the log and the last save to the report.
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0.6/RELEASE_NOTES.md).
|
||||
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.12/RELEASE_NOTES.md).
|
||||
|
||||
## Features and direction
|
||||
|
||||
@@ -104,7 +104,7 @@ Reports with reproducible steps, documentation corrections and focused patches a
|
||||
|
||||
## How the project was developed
|
||||
|
||||
The implementation grew from study of file formats and behaviour of a legally obtained game installation. The public repository contains independently written implementation and format documentation. It does not contain the proprietary implementation or its extracted resources.
|
||||
The implementation grew from study of file formats and behaviour of a legally obtained game installation. The public repository contains independently written implementation and format documentation. It also contains the numeric tables and constants of the Diamond edition 3.7 executable (rates, positions, prices; `src/formats/diamond_constants.inc`, generated by `tools/diamond_constants`) so that the game runs from its asset files alone. It does not contain the executable's program code or any original game text, graphics, audio or master data.
|
||||
|
||||
## License and thanks
|
||||
|
||||
|
||||
Binary file not shown.
@@ -146,7 +146,9 @@ This index includes registered and reserved names. `ListOptions` and `Help` from
|
||||
| `BuyPlayer` | player:Player | VER-KAUFEN on a market player: the offer editor |
|
||||
| `HirePlayer` | player:Player, months:int(12\|24) | VER-LEIHEN on a market player: the loan offer |
|
||||
| `OpenOffers` | player:Player | Open Offers. See current Help for behaviour and bounds. |
|
||||
| `OpenSearch` | – | Open Search. See current Help for behaviour and bounds. |
|
||||
| `ShowSearchProfile` | – | SUCHEN: your search profile as 18 values (positions, age, strength, attributes, sides, price classes) |
|
||||
| `SuggestSearchProfile` | [whole:bool], [apply:bool] | VORSCHLAG: the profile your squad asks for; `apply` stores it and lists the matching players |
|
||||
| `SetSearchProfile` | values:[18 numbers], [apply:bool] | SUCHEN: store the profile; all values 0 or all 1 count as no search; `apply` lists the players on the transfer list that fit (the original's "Spieler ... ist interessant!" boxes) |
|
||||
| `OpenPoach` | – | ABWERBEN: pick a player of another club (Transfer.Poach) |
|
||||
| `ShowTransferNews` | [count:int] | Show Transfer News. See current Help for behaviour and bounds. |
|
||||
| `ShowTeamInfo` | – | Show Team Info. See current Help for behaviour and bounds. |
|
||||
|
||||
@@ -209,7 +209,9 @@
|
||||
"Transfer";"BuyPlayer";"player:Player";"VER-KAUFEN on a market player: the offer editor";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"HirePlayer";"player:Player, months:int(12|24)";"VER-LEIHEN on a market player: the loan offer";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Transfer";"OpenOffers";"player:Player";"Open Offers. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"OpenSearch";"–";"Open Search. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"ShowSearchProfile";"–";"SUCHEN: your search profile as 18 values";"";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"SuggestSearchProfile";"[whole:bool], [apply:bool]";"VORSCHLAG: the profile your squad asks for; apply stores it and lists the matches";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"SetSearchProfile";"values:[18 numbers], [apply:bool]";"SUCHEN: store the search profile; apply lists the matching players";"E_BAD_ARGUMENT";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"OpenPoach";"–";"ABWERBEN: pick a player of another club (Transfer.Poach)";"—";"";"";"ready";"06-verein.md"
|
||||
"Transfer";"ShowTransferNews";"[count:int]";"Show Transfer News. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"ShowTeamInfo";"–";"Show Team Info. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
|
||||
|
+1
-3
@@ -20,11 +20,8 @@ describe deliberate changes; they are not a list of every known compatibility li
|
||||
- [src/game/match_engine.cpp](../src/game/match_engine.cpp): supports designated set-piece takers, the enhanced injury tables, and the extended suspension fields.
|
||||
- [src/game/month.cpp](../src/game/month.cpp): keep the price product in 64 bits until division, retaining per-unit truncation and recipient policy.
|
||||
- [src/game/national.cpp](../src/game/national.cpp): a new arrival must not inherit the previous occupant's retirement/refusal/month-processing flags.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): age/retire each player once, even when a temporary offer row references his club slot or regeneration moves him to a later free-agent slot.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): includes transfer-market players in retirement so the five-bit age cannot wrap to 16.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): initializes the empty EM qualifier seeds with national teams, preventing club zero from entering the EM.
|
||||
- [src/game/season.hpp](../src/game/season.hpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/stadium_blocks.cpp](../src/game/stadium_blocks.cpp): allow 144,000 standard places and size-aware construction times while retaining edition-owned unit prices.
|
||||
- [src/game/state.hpp](../src/game/state.hpp): retains designated set-piece selections in the supported manager-record extension.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): widen products before annual-rate division so valid native account amounts do not overflow intermediate sums.
|
||||
@@ -35,6 +32,7 @@ describe deliberate changes; they are not a list of every known compatibility li
|
||||
- [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.
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
# Measurement against Diamond 3.7: matchdays, weekly processing, month change, season end
|
||||
|
||||
OpenBMH Classic follows the game and match engine of BMH 2026-27 DIAMOND Edition 3.7. Besides the routine-by-routine
|
||||
comparisons (see the 1.0.9 release notes) the engine is checked against **recordings of the real 3.7** running in an
|
||||
emulator (DOSBox-X). A recorder reads the emulator's memory without touching the game: at every match minute, at every
|
||||
change of the calendar day and at every pause it stores the random number states (game and C library generator) and all
|
||||
tables the engine reads (squads, player words, team flags, cards, managers, stock market, transfer list, mailbox, ...).
|
||||
The port replays the same turn from the save game that precedes it and is compared at every one of these checkpoints.
|
||||
|
||||
The recorder and the automation that operates the original are not part of this repository (they need the original
|
||||
program); the checker is `tests/week_check.cpp`.
|
||||
|
||||
## Scope of the November 2026 series
|
||||
|
||||
- 73 recorded "Weiter" turns of one career, from the first Saturday in August 2026 (game day 38) through the whole
|
||||
first season, the season end on 1 July 2027 (day 365) and most of the second season up to April 2028 (day 645).
|
||||
The human manager's club played every matchday (league, cup and the indoor tournament). Incoming transfer offers
|
||||
were declined.
|
||||
- **Match phase:** 7,642 recorded match minutes, every one inside the interval of random draws that the port passes
|
||||
through, none outside. Final whistle, stoppage time and the first extra-time pass match in every turn, in the second
|
||||
season as well.
|
||||
- **Weekly processing:** 70 runs of the routine ported from the original (days 43 to 645). At the desk after each turn
|
||||
the random states and **all tables are identical** to the recording.
|
||||
- **Month change:** 17 runs (1 September 2026 to 1 April 2028, among them the change of the year and the summer break).
|
||||
Identical at the desk afterwards.
|
||||
- **Season end:** one run (day 365 with the last weekly processing and the month change, from the last matchday of the
|
||||
season on 8 May 2027 to the desk of 1 July 2027). Identical, all tables.
|
||||
- **Indoor tournament:** eleven rounds (see below).
|
||||
- Training, the stock market, the matchday preparation and the kick-off of the next matchday are part of the same turns
|
||||
and match as well (the match groups built by the port equal the first minute snapshot of the next matchday).
|
||||
|
||||
Of the 73 evaluated turns 71 are identical at the desk (random states and all tables; the transfer list is shown
|
||||
separately, see below). The other two are explained:
|
||||
|
||||
- One differs in a single lineup flag of one player slot that the original clears when the manager's lineup page is
|
||||
shown (a routine of the user interface, not of the engine); the recording passed through that page.
|
||||
- The last round of the indoor tournament ends with the tournament processing of the original (prizes, next
|
||||
fixtures); the checker replays only the playing part of an indoor round, so that part is not compared.
|
||||
|
||||
## Indoor tournament
|
||||
|
||||
All eleven recorded rounds play their 40 minutes with the same random draws as the original. At the kick-off, however,
|
||||
the six strength values of the side records differ by 1 to 4 points in about half of the rounds (the port is mostly
|
||||
higher); ordinary matches show no such difference. This is tracked as issue 82. The desk after the round is identical in
|
||||
ten of eleven rounds (the eleventh is the tournament end above).
|
||||
|
||||
## How to read the "DIFF" lines of the checker
|
||||
|
||||
The recorder takes a day snapshot when the date changes, i.e. **inside** the original's processing of that day; the
|
||||
port's state belongs to the end of the processing. The checker therefore prints such checkpoints as "late snapshot ...
|
||||
draws ahead of the port's state, not counted". They are not differences of the engine: the checkpoint after them (and the
|
||||
desk at the end of the turn) is identical in every counted turn. The transfer list is compared but not counted (the
|
||||
amounts of new bids depend on stale data in the original, documented in the source); a few desks show a handful of
|
||||
bytes there and the line says so.
|
||||
|
||||
## Recordings that were not used
|
||||
|
||||
Four turns of the series were dropped, none because of a difference of the engine: two were disturbed by the operation
|
||||
of the original (a mouse click that listed two players for transfer; a turn that clicked through several matchdays
|
||||
and did not keep the recorder running), two belong to the start of the second season before the first matchday
|
||||
(the season start screens with the Super Cup; no minutes were recorded). A first recording of the season end failed
|
||||
because the recorder gave up after 60 s of the long end-of-season processing; recorded again with a longer wait it
|
||||
matches.
|
||||
|
||||
## Not covered
|
||||
|
||||
- Only one career and one human manager. Contract expiry on 1 July and the other manager decisions at the season end
|
||||
were not driven by a human in this series.
|
||||
- The start of the second season between the desk of 1 July and the first matchday (Super Cup, season start screens)
|
||||
was played without recording.
|
||||
- Offers made by the weekly processing to the human manager (new transfer bids): the amounts depend on a stale stack
|
||||
value in the original and are not reproduced (documented in the source).
|
||||
- Foul and card chances are derived from the constants of the 3.7 code and show no difference in the recorded
|
||||
minutes, but a deliberate comparison of the single routine was not made.
|
||||
- A second season end and later seasons; the end of the indoor tournament.
|
||||
@@ -0,0 +1,61 @@
|
||||
# OpenBMH Classic 1.0.10
|
||||
|
||||
This release adds the transfer market search dialog, fixes the "Angebot" button
|
||||
of the poaching dialog and corrects the asking price shown in the market. 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.9
|
||||
|
||||
- **Suchen and Vorschlag in the transfer market.** Both buttons did nothing.
|
||||
They now open the search profile dialog of the original (positions, age,
|
||||
strength, attributes, sides, price classes). "Suchen" opens the stored
|
||||
profile, "Vorschlag" the profile your squad asks for. Closing with the
|
||||
confirm button stores the profile and announces the listed players that
|
||||
fit, one message box each; the right mouse button or Esc closes it and
|
||||
switches the search off. The rules (closing rule, matching, suggestion) were
|
||||
compared with the Diamond 3.7 routines on ten savegames without a
|
||||
difference. The console has the same steps: `ShowSearchProfile`,
|
||||
`SuggestSearchProfile`, `SetSearchProfile`.
|
||||
- **Abwerben: "Angebot" button.** Two causes. The engine asks the selling
|
||||
manager and the buyer a yes/no question when a poaching offer is decided;
|
||||
the graphical client did not provide the question dialog. And the agreement
|
||||
of the poached player ("Ihr erstes Angebot wird angenommen!") had no message
|
||||
dialog, which refused the whole offer. Both exist now. A refused offer or
|
||||
transfer action also shows its reason (and writes it to the debug log)
|
||||
instead of a dead button.
|
||||
- **Verkaufen on a listed player.** Clicking a player who is already on the transfer
|
||||
list and then VERKAUFEN did nothing when no offer had arrived yet. It now asks
|
||||
the question of the original, "Wollen Sie ... vom Transfermarkt holen?": yes takes
|
||||
the player off the list (he stays in the squad), no leads on to the offers.
|
||||
- **Pressed buttons.** Suchen, Vorschlag, Abwerben and the other buttons of
|
||||
the market are drawn pressed while the mouse button is held.
|
||||
- **Scouting message.** Confirming the search dialog first shows the message
|
||||
of the scouting department, then one box per fitting listing.
|
||||
- **Asking price in the market list.** The list showed the asking fee scaled
|
||||
by 1.25, the factor of an older Diamond build. Diamond 3.7 rounds to whole
|
||||
10,000 (the offer editor and the weekly processing already did).
|
||||
- **Tests.** The controller tests now drive the whole route of reviewing and
|
||||
accepting offers on an own listing, of relisting a player after a declined
|
||||
listing and of the search dialog.
|
||||
|
||||
## Open points
|
||||
|
||||
- **"Angebote prüfen" / listing again after a declined offer.** Reported by the
|
||||
Diamond author. The console and the controller tests show the expected
|
||||
behaviour (offers can be reviewed and accepted before expiry; a player who
|
||||
left the list after a decline can be listed again). It could not be
|
||||
reproduced, so a debug log (`-debug`) or exact steps are still needed.
|
||||
- **Measurement against Diamond 3.7.** The match engine (minute, duels, shots)
|
||||
and the whole weekly processing with the bid amounts are not yet compared
|
||||
with the real 3.7. The bid amounts of new offers depend on stale data in the
|
||||
original and cannot be reproduced exactly (documented in the source).
|
||||
- Earlier open points remain: "player card: original atlas bounds" (#77), sporadic
|
||||
double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,87 @@
|
||||
# OpenBMH Classic 1.0.11
|
||||
|
||||
This release lets the game run from the asset files alone, adds the transfer
|
||||
market search dialog, fixes the "Angebot" button of the poaching dialog and the
|
||||
selling of a listed player, and corrects the asking price shown in the market.
|
||||
Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## BMH.EXE or openbmh.dat
|
||||
|
||||
- A game needs its asset files and **either** the executable (`BMH.EXE`, or
|
||||
`FLTD.EXE` for the English game) **or** the file **openbmh.dat**. If both are
|
||||
there, the executable is used as before. If neither is there, OpenBMH asks for
|
||||
a game directory or for `BMH.EXE`.
|
||||
- The numbers of the Diamond 3.7 executable (tables, rates, positions, prices) and
|
||||
of the English Football Limited are built into the program. `openbmh.dat` holds
|
||||
the game texts of those executables (live commentary, messages). It ships next
|
||||
to `OpenBMH` and `openbmh_cli` in the release package and is found in the
|
||||
game folder, in the program folder and in the current folder (or where
|
||||
`OPENBMH_DAT` points to). A folder, ZIP or 7z with only the asset files
|
||||
(`TEXTD.BLK` and `M3D.MAN`, or `TEXTE.BLK` and `M3E.MAN`, plus the
|
||||
picture, font and sound folders) is a complete game when `openbmh.dat` is
|
||||
found.
|
||||
- The default manager name is "OpenBMH" instead of "Nobody".
|
||||
- A recorded session gives the same output as with the real `BMH.EXE`.
|
||||
## Changes since 1.0.9 (1.0.10 was never published; its changes are part of this release)
|
||||
|
||||
- **Suchen and Vorschlag in the transfer market.** Both buttons did nothing.
|
||||
They now open the search profile dialog of the original (positions, age,
|
||||
strength, attributes, sides, price classes). "Suchen" opens the stored
|
||||
profile, "Vorschlag" the profile your squad asks for. Closing with the
|
||||
confirm button stores the profile and announces the listed players that
|
||||
fit, one message box each; the right mouse button or Esc closes it and
|
||||
switches the search off. The rules (closing rule, matching, suggestion) were
|
||||
compared with the Diamond 3.7 routines on ten savegames without a
|
||||
difference. The console has the same steps: `ShowSearchProfile`,
|
||||
`SuggestSearchProfile`, `SetSearchProfile`.
|
||||
- **Abwerben: "Angebot" button.** Two causes. The engine asks the selling
|
||||
manager and the buyer a yes/no question when a poaching offer is decided;
|
||||
the graphical client did not provide the question dialog. And the agreement
|
||||
of the poached player ("Ihr erstes Angebot wird angenommen!") had no message
|
||||
dialog, which refused the whole offer. Both exist now. A refused offer or
|
||||
transfer action also shows its reason (and writes it to the debug log)
|
||||
instead of a dead button.
|
||||
- **Verkaufen on a listed player.** Clicking a player who is already on the transfer
|
||||
list and then VERKAUFEN did nothing when no offer had arrived yet. It now asks
|
||||
the question of the original, "Wollen Sie ... vom Transfermarkt holen?": yes takes
|
||||
the player off the list (he stays in the squad), no leads on to the offers.
|
||||
- **Pressed buttons.** Suchen, Vorschlag, Abwerben and the other buttons of
|
||||
the market are drawn pressed while the mouse button is held.
|
||||
- **Scouting message.** Confirming the search dialog first shows the message
|
||||
of the scouting department, then one box per fitting listing.
|
||||
- **Asking price in the market list.** The list showed the asking fee scaled
|
||||
by 1.25, the factor of an older Diamond build. Diamond 3.7 rounds to whole
|
||||
10,000 (the offer editor and the weekly processing already did).
|
||||
- **Tests.** The controller tests now drive the whole route of reviewing and
|
||||
accepting offers on an own listing, of relisting a player after a declined
|
||||
listing and of the search dialog.
|
||||
|
||||
## Measurement against Diamond 3.7
|
||||
|
||||
- The match engine of a recorded matchday in the real 3.7 (DOSBox-X) matches the
|
||||
port in all 94 minutes, with the random number state at kick-off, in every
|
||||
minute, at the final whistle and at the next desk.
|
||||
- Two apparent deviations (from minute 10, and on the days after the match) were
|
||||
errors of the comparison tool, not of the engine, and are fixed or explained there.
|
||||
|
||||
## Open points
|
||||
|
||||
- **"Angebote prüfen" / listing again after a declined offer.** Reported by the
|
||||
Diamond author. The console and the controller tests show the expected
|
||||
behaviour. It could not be reproduced, so a debug log (`-debug`) or exact
|
||||
steps are still needed.
|
||||
- The bid amounts of new offers in the weekly processing depend on stale data in
|
||||
the original and cannot be reproduced exactly (documented in the source).
|
||||
- Only one matchday and the days after it were recorded from the real 3.7; the
|
||||
weekly processing, month changes and transfers are not yet compared.
|
||||
- The graphical client has not yet been tried with `openbmh.dat` and asset files only.
|
||||
- Earlier open points remain: "player card: original atlas bounds" (#77), sporadic
|
||||
double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,83 @@
|
||||
# OpenBMH Classic 1.0.12
|
||||
|
||||
This release makes the buttons of the dialogs behave like the original: a button
|
||||
without a lasting state is drawn pressed while the mouse button is held. It also
|
||||
carries everything of [1.0.11](../1.0.11/RELEASE_NOTES.md) (the game from asset
|
||||
files plus `openbmh.dat`, the transfer market search, the poaching and selling
|
||||
fixes). Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Pressed buttons
|
||||
|
||||
Many dialogs drew their buttons raised at all times, the original shows them
|
||||
pressed for as long as the mouse button is down (the friendly match question
|
||||
already did). Now pressed while held:
|
||||
|
||||
- **Bank:** the two buttons of stocks, property, savings and credit, the OK of
|
||||
its notices, Ja/Nein of the credit fee question and the keys of its calculator.
|
||||
- **Spieler kaufen (offer editor):** Team-Info, Spieler-Info, Angebot, Abbruch and
|
||||
the calculator keys.
|
||||
- **Aufstellung:** Daten A/B and Spielfeld; **Spielfeld page:** Daten and Kurz
|
||||
(the action starts after a short moment, as the pressed look has to be seen).
|
||||
- **Contracts:** the buttons under the offer and the team premium panels
|
||||
(Team-Prämien), OK of the answer and the calculator keys.
|
||||
- **Advertising:** Abbrechen/Annehmen of an offer, OK of its notices and the keys of
|
||||
its calculator.
|
||||
- **Player card:** Schließen, Statistik and Zurück; **training camp:** the booking
|
||||
button and OK; **file dialog:** Ja/Nein of the overwrite question and the page
|
||||
button of a long list; **manager confirmation:** JA and NEIN; **transfer
|
||||
decision:** OK of the confirmation.
|
||||
- **Start menu (game setup):** the minus and plus buttons show the original's
|
||||
darker pressed picture while the mouse button is held (also in the joining
|
||||
manager's setup). It is a different picture (36x36 pixels, drawn two pixels right
|
||||
and down of the raised button on the plain background), not a shifted copy of the
|
||||
button, and was compared pixel for pixel with a recording of the real game.
|
||||
- The notices that wait for any click (Sportschau, cup draw, game end screens) have
|
||||
no button and are unchanged. Toggles that stay on (training, filters) keep their
|
||||
lasting state.
|
||||
|
||||
## Transfer market
|
||||
|
||||
- **Verkaufen on a listed player chosen in the market list.** Choosing an own listed
|
||||
player in the right-hand list and pressing VERKAUFEN gave "Noch keine Angebote"
|
||||
(or went straight to the offers) instead of the question of the original,
|
||||
"Wollen Sie ... vom Transfermarkt holen?". It now asks first, as it already did for
|
||||
a player chosen in the squad list: yes takes him off the list, no leads on to the
|
||||
offers.
|
||||
|
||||
- **No status text in the footer.** The transfer market replaced the club name in the
|
||||
bottom row with status texts (rejections, hints). The original has no such line; the
|
||||
club name now always stays there.
|
||||
|
||||
- **League table: club names in full.** Names were cut after about 17 characters
|
||||
("EINTRACHT FRANKFU"); the original shows them completely ("EINTRACHT FRANKFURT",
|
||||
"TSG 1899 HOFFENHEIM") and lets the games column cover what reaches into it.
|
||||
|
||||
## Internal
|
||||
|
||||
- The drawing of the wide push button, of the calculator window (panel and keys) and
|
||||
of the dialog frame is now shared (`ui/button_frame.hpp`,
|
||||
`ui/calculator_widgets.hpp`, `ui/dialog_frame.hpp`) instead of being copied in
|
||||
about twenty dialogs. A test compares the shared drawing pixel for pixel with the
|
||||
former one. A few buttons whose former drawing differs by one pixel (statistics
|
||||
rankings, team statistics, opportunities, analytics) were left as they are.
|
||||
|
||||
## Open points
|
||||
|
||||
- The pressed look was checked by tests and by reading the drawing code, not yet
|
||||
against a recording of the real Diamond 3.7; the exact timing of the short press on
|
||||
the Spielfeld page is an estimate.
|
||||
- **"Angebote prüfen" / listing again after a declined offer.** Could not be
|
||||
reproduced; a debug log (`-debug`) or exact steps are still needed.
|
||||
- The graphical client has not yet been tried with `openbmh.dat` and asset files only.
|
||||
- The weekly processing, month changes and transfers are not yet compared with the
|
||||
real 3.7 (only one matchday and the days after it were).
|
||||
- Earlier open points remain: "player card: original atlas bounds" (#77), sporadic
|
||||
double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,35 @@
|
||||
# OpenBMH Classic 1.0.7
|
||||
|
||||
This patch fixes national-team desk screens and two small interface details
|
||||
reported by testers. It requires the player's own game installation. Extended
|
||||
development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.6
|
||||
|
||||
- **National-team desk.** Other Games and Top Scorers open again; both screens
|
||||
are identified by the home club, so the desk is no longer rejected as stale
|
||||
or as a mismatched acknowledgement.
|
||||
- **Computer tip.** After the results of a round are known the button is only
|
||||
pressed and released, as in the original, instead of raising an engine error.
|
||||
- **Manager selection.** JA of the confirmation question is shown pushed in
|
||||
briefly after it is clicked.
|
||||
|
||||
## Validation and human QA
|
||||
|
||||
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
|
||||
builds, configured tests, product-version checks and package/source verification
|
||||
for the exact tagged revision. Downloads include checksums, a platform test
|
||||
report and corresponding source with pinned open-source dependencies.
|
||||
|
||||
The fixes were checked with the desktop, controller and manager tests; native
|
||||
Windows/macOS gameplay acceptance is not established by CI builds. Open points
|
||||
from 1.0.6 remain: the "player card: original atlas bounds" error (#77),
|
||||
sporadic double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,43 @@
|
||||
# OpenBMH Classic 1.0.8
|
||||
|
||||
This patch makes the bank credit annuity identical on every platform. It
|
||||
requires the player's own game installation. Extended development remains
|
||||
separate in [OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.7
|
||||
|
||||
- **Bank credit annuity.** The original computes the monthly payment with
|
||||
x87 floating point (64-bit mantissa at every step, one final store to a
|
||||
double). The host `long double` is only 64 bits wide on Windows (MSVC) and
|
||||
on Apple silicon, so the payment differed by 1 for roughly 0.2 % of loans of
|
||||
one to sixty million. The chain is now evaluated with integer arithmetic and
|
||||
gives the original's result on every platform.
|
||||
|
||||
## Validation and human QA
|
||||
|
||||
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
|
||||
builds, configured tests, product-version checks and package/source verification
|
||||
for the exact tagged revision. Downloads include checksums, a platform test
|
||||
report and corresponding source with pinned open-source dependencies.
|
||||
|
||||
This release follows a quality pass that ran single routines of the original
|
||||
programme in an emulator and compared them with the engine on whole savegames,
|
||||
with boundary values and a deliberately wrong result per rule that must fail.
|
||||
Compared without a difference: the random generator, market value and salary,
|
||||
the willingness of clubs to sell, the rating of transfer bids, club mood and
|
||||
flags at the end of a season, the order of national cup ties, weekly advertising
|
||||
offers, facility ageing and damage, offers to managers, weekly statistics,
|
||||
familiarity decay, squad training and daily interest. The one difference found
|
||||
is the annuity fixed above. Rules that depend on screens, dialogs or the master
|
||||
database were not part of this pass.
|
||||
|
||||
Native Windows/macOS gameplay acceptance is not established by CI builds. Open
|
||||
points from earlier releases remain: the "player card: original atlas bounds"
|
||||
error (#77), sporadic double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,65 @@
|
||||
# OpenBMH Classic 1.0.9
|
||||
|
||||
This release aligns the engine's hard-coded rules with BMH 2026-27 DIAMOND
|
||||
Edition 3.7. It requires the player's own game installation. Extended
|
||||
development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Why
|
||||
|
||||
The engine had been checked against an older Diamond build whose executable
|
||||
differs from 3.7 in about 2,700 bytes (50 code ranges, the Diamond patch area
|
||||
and 64 data bytes). Rules from v2.24, an older Diamond and 3.7 were therefore
|
||||
mixed. The routines of the real 3.7 executable were run in an emulator and
|
||||
compared with the engine; every difference found was ported and documented.
|
||||
|
||||
## Changes since 1.0.8
|
||||
|
||||
- **Injuries and cards.** New injury tables (thresholds and durations), the
|
||||
injury history factor 1.25, doctor and insurance caps, and the foul, booking
|
||||
and red-card chances of 3.7.
|
||||
- **Economy.** Credit limit 8,000,000, transfer fee base, DFB fee, advertising
|
||||
base, start capital, bankruptcy limit, championship and cup premiums,
|
||||
periphery prices, contract talk limit and training injury range.
|
||||
- **Weekly processing.** Retirement chance, side rating rhythm for human and
|
||||
computer managers, facility values, per-visitor income and the season
|
||||
ticket price.
|
||||
- **Youth academy.** 3.7 generation with its monthly budget gate. An age check
|
||||
was inverted in the port (older players were recycled the wrong way round);
|
||||
this is fixed.
|
||||
- **Season end.** Retirement and leave rules for the player slots.
|
||||
- **Live match statistics.** The chance counters at the bottom of the live
|
||||
matchday screen counted a chance as soon as the engine logged it, before the
|
||||
presentation started. They are now held back like the score and appear with
|
||||
the result of the chance.
|
||||
|
||||
## What was measured, what was derived
|
||||
|
||||
Compared with the 3.7 executable without any difference (boundary values and a
|
||||
deliberately wrong result per rule that must fail): random generator, market
|
||||
value, bank annuity, club mood and flags, cup tie order, advertising offers,
|
||||
bid rating, poaching, facility ageing and damage, manager offers, weekly
|
||||
statistics, familiarity decay, squad training, daily interest, youth academy,
|
||||
month change, new transfer list entries, and injuries including doctor and
|
||||
insurance (932 runs).
|
||||
|
||||
Derived from the constants of the 3.7 code but **not** measured in the
|
||||
emulator: foul and card chances in a match, and several economy numbers.
|
||||
Not covered: the complete weekly processing routine, and the amounts of newly
|
||||
created transfer bids (the original reads a stale stack value there; documented
|
||||
in the source as a known gap).
|
||||
|
||||
## Open points
|
||||
|
||||
Reported by the Diamond author and not changed here: the bug in "fetch player
|
||||
from transfer market / check offers" (exact steps still to be reproduced).
|
||||
Earlier open points remain: the
|
||||
"player card: original atlas bounds" error (#77), sporadic double clicks (#58)
|
||||
and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// All-or-nothing wrapper for one UI window action on a CareerSession (used by
|
||||
// desktop_actions.cpp and window_actions.cpp). It snapshots the game state, the RNG and the
|
||||
// revision counter, runs the action and, if the action returns false or throws, restores
|
||||
// all three, so a rejected action leaves no half-applied change behind.
|
||||
// apply_native() is the variant for owners that keep their state in CareerSession::state().
|
||||
// Header-only; owns no state of its own.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Glue between the original-audio engine (src/audio/playback.hpp) and the app: builds the
|
||||
// asset set from the game's sound containers and the frequency/operator tables read from the
|
||||
// executable, derives the music/click/match-sound options from the saved settings bytes of
|
||||
// the GameState, and sends sound commands only when the original sound path is ready.
|
||||
// OriginalMouseSound is an SDL event watch that plays the click sound on each real mouse
|
||||
// button press; it touches only the Playback object, never the GameState, because the
|
||||
// watch can run on SDL's event thread. Header-only.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#pragma once
|
||||
|
||||
|
||||
+647
-1
File diff suppressed because it is too large.
Load diff
@@ -38,6 +38,7 @@
|
||||
#include "game/pending_offer.hpp"
|
||||
#include "game/poach.hpp"
|
||||
#include "game/human_buyer_sale.hpp"
|
||||
#include "game/search_profile.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
#include "ui/flow.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
@@ -178,6 +179,21 @@ public:
|
||||
uint64_t& revision, std::string& error,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
|
||||
|
||||
// The search profile of a human manager (transfer market buttons "Suchen" and "Vorschlag", game/search_profile.hpp).
|
||||
// `search_profile` is the stored profile, `suggest_search_profile` the one the squad asks for (nothing is stored).
|
||||
// `dispatch_search_profile` stores an edited profile the way the closing dialog does (`cancelled` = left by right
|
||||
// click, which switches the profile off) and, with `apply`, lists the transfer-list entries that fit it right now.
|
||||
// The revision rises only when the stored profile changed.
|
||||
SearchProfile search_profile(int manager) const;
|
||||
SearchProfile suggest_search_profile(int manager, bool whole_squad) const;
|
||||
struct SearchProfileDispatch {
|
||||
SearchProfile profile{};
|
||||
bool active = false;
|
||||
std::vector<SearchProfileHit> hits;
|
||||
};
|
||||
std::optional<SearchProfileDispatch> dispatch_search_profile(int manager, const SearchProfile& profile, bool cancelled,
|
||||
bool apply, uint64_t& revision, std::string& error);
|
||||
|
||||
struct TransferMarketPreviewDispatch {
|
||||
ui::PreparationState preparation;
|
||||
ui::TransferMarketPreview quote;
|
||||
|
||||
+366
-5
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The controller: the one synchronous boundary between the UI flow (ui::StartupFlow) and
|
||||
// the engine session (CareerSession). The flow turns a click or key into a ui::FlowResult
|
||||
// that carries a request; serve_flow_request() validates it against the current revision,
|
||||
// calls the session, and acknowledges the outcome back to the flow. Everything the engine
|
||||
// needs from the front end (dialogs, live match presentation, notices) is passed in as
|
||||
// std::function "presenter" hooks, so tests can drive the same code without a window.
|
||||
// Pairs with controller.cpp; the real hooks are supplied by main.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Debug mode (command line -debug): a process-wide, mutex-protected log file plus numbered
|
||||
// automatic savegames, both kept in one folder. State is a function-local static; every
|
||||
// function is a no-op until init() has succeeded, so callers may log unconditionally.
|
||||
// init() also redirects stderr into the same folder. Header-only.
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the desk-level action facades declared in desktop_actions.hpp. Each
|
||||
// method checkpoints the relevant session owner, runs the request through CareerSession,
|
||||
// lets the accept callback acknowledge the result to the UI, and rolls everything back via
|
||||
// detail::apply_window if the callback returns false or throws. Errors are returned through
|
||||
// the std::string& error parameter. The request/acknowledge flow as a whole is described
|
||||
// at the top of controller.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/desktop_actions.hpp"
|
||||
#include "app/action_transaction.hpp"
|
||||
@@ -7,6 +13,8 @@
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
// Builds the desk request that opens menu `kind` for the observed manager; the item id is
|
||||
// taken from the desk item of that kind.
|
||||
ui::DeskRequest DesktopActions::menu(const ui::DeskState& observed, int kind) {
|
||||
ui::DeskRequest request;
|
||||
request.kind = ui::DeskRequestKind::open_menu;
|
||||
@@ -18,6 +26,8 @@ ui::DeskRequest DesktopActions::menu(const ui::DeskState& observed, int kind) {
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction on the desk settings owner; the checkpoint is restored
|
||||
// if the action fails.
|
||||
bool DeskSettingsActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.desk_settings_checkpoint(revision),
|
||||
[&](CareerSession::DeskSettingsCheckpoint before) {
|
||||
@@ -25,6 +35,7 @@ bool DeskSettingsActions::apply(uint64_t& revision, const std::function<bool()>&
|
||||
}, action);
|
||||
}
|
||||
|
||||
// Opens the desk settings screen; `acknowledge` receives the projection on success.
|
||||
std::optional<CareerSession::DeskSettingsProjection> DeskSettingsActions::open(
|
||||
const ui::DeskRequest& request, uint64_t& revision, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<CareerSession::DeskSettingsProjection> result;
|
||||
@@ -37,6 +48,7 @@ std::optional<CareerSession::DeskSettingsProjection> DeskSettingsActions::open(
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends any settings action (write, file, close) to the session in one transaction.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::dispatch(
|
||||
const CareerSession::DeskSettingsAction& request, uint64_t& revision, std::string& error,
|
||||
const Accept& acknowledge) {
|
||||
@@ -50,16 +62,19 @@ std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::dispatch
|
||||
return result;
|
||||
}
|
||||
|
||||
// Dispatches a settings write for the owner identified by `sequence`.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::write(uint64_t sequence,
|
||||
const ui::SettingsWriteRequest& request, uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
return dispatch(CareerSession::DeskSettingsWrite{sequence, request}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
// Dispatches a settings file (save/load) request for the owner `sequence`.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::file(uint64_t sequence,
|
||||
const ui::SaveLoadRequest& request, uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
return dispatch(CareerSession::DeskSettingsFile{sequence, request}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
// Dispatches the close of the settings owner, built from the observed desk request.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::close(uint64_t sequence,
|
||||
uint64_t owner_revision, const ui::DeskRequest& observed, uint64_t& revision, std::string& error,
|
||||
const Accept& acknowledge) {
|
||||
@@ -67,6 +82,8 @@ std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::close(ui
|
||||
return dispatch(CareerSession::DeskSettingsClose{owner}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
// Applies one edit (row, column, operation) to the settings cells; the request carries
|
||||
// the observed cells so that a stale view is detected.
|
||||
bool DeskSettingsActions::edit(const ui::SettingsState& observed, int row, int column, ui::SettingsEdit operation,
|
||||
uint64_t& revision, std::string& error) {
|
||||
ui::SettingsWriteRequest request;
|
||||
@@ -79,11 +96,13 @@ bool DeskSettingsActions::edit(const ui::SettingsState& observed, int row, int c
|
||||
return apply(revision, [&] { return session_.dispatch_settings(request, revision, error); });
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the balance checkpoint on failure.
|
||||
bool BalanceActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.balance_checkpoint(),
|
||||
[&](CareerSession::BalanceCheckpoint before) { session_.restore_balance_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the balance (finance plan) screen over `underlay`.
|
||||
std::optional<ui::BalanceState> BalanceActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::BalanceState> result;
|
||||
@@ -96,6 +115,7 @@ std::optional<ui::BalanceState> BalanceActions::open(const ui::DeskRequest& requ
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends a balance screen request to the session in one transaction.
|
||||
std::optional<CareerSession::BalanceDispatch> BalanceActions::dispatch(const ui::BalanceRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::BalanceDispatch> result;
|
||||
@@ -108,13 +128,20 @@ std::optional<CareerSession::BalanceDispatch> BalanceActions::dispatch(const ui:
|
||||
return result;
|
||||
}
|
||||
|
||||
// Draft helpers for the console balance plan (thin wrappers around the game functions):
|
||||
// open a draft for a manager,
|
||||
BalancePlanDraft BalanceActions::open_draft(int manager) const { return bmh::open_balance_plan(session_.state(), manager); }
|
||||
// switch its view,
|
||||
void BalanceActions::cycle_draft(BalancePlanDraft& draft) const { cycle_balance_view(session_.state(), draft); }
|
||||
// reset it,
|
||||
void BalanceActions::reset_draft(BalancePlanDraft& draft) const { reset_balance_plan(session_.state(), draft); }
|
||||
// and edit one row.
|
||||
BalanceEditStatus BalanceActions::edit_draft(BalancePlanDraft& draft, int row, int32_t value) const {
|
||||
return edit_balance_plan(session_.state(), draft, row, value);
|
||||
}
|
||||
|
||||
// Closes the draft inside a transaction and always increases the revision. Returns the
|
||||
// warning flag reported by the close.
|
||||
bool BalanceActions::close_draft(const BalancePlanDraft& draft, uint64_t& revision) {
|
||||
bool warning = false;
|
||||
apply(revision, [&] {
|
||||
@@ -125,11 +152,13 @@ bool BalanceActions::close_draft(const BalancePlanDraft& draft, uint64_t& revisi
|
||||
return warning;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the other-games checkpoint on failure.
|
||||
bool OtherGamesActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.other_games_checkpoint(),
|
||||
[&](CareerSession::OtherGamesCheckpoint before) { session_.restore_other_games_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the other-games screen over `underlay`.
|
||||
std::optional<ui::OtherGamesState> OtherGamesActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::OtherGamesState> result;
|
||||
@@ -142,6 +171,8 @@ std::optional<ui::OtherGamesState> OtherGamesActions::open(const ui::DeskRequest
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends an other-games request to the session; `team_info` presents club information
|
||||
// when the screen asks for it.
|
||||
std::optional<CareerSession::OtherGamesDispatch> OtherGamesActions::dispatch(const ui::OtherGamesRequest& request,
|
||||
uint64_t& revision, std::string& error, const TransferOfferTeamInfoPresenter& team_info, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::OtherGamesDispatch> result;
|
||||
@@ -154,11 +185,13 @@ std::optional<CareerSession::OtherGamesDispatch> OtherGamesActions::dispatch(con
|
||||
return result;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the top scorers checkpoint on failure.
|
||||
bool TopScorersActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.top_scorers_checkpoint(),
|
||||
[&](CareerSession::TopScorersCheckpoint before) { session_.restore_top_scorers_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the top scorers screen over `underlay`; the revision is increased on opening.
|
||||
std::optional<ui::TopScorersState> TopScorersActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::TopScorersState> result;
|
||||
@@ -172,6 +205,7 @@ std::optional<ui::TopScorersState> TopScorersActions::open(const ui::DeskRequest
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends a top scorers request to the session in one transaction.
|
||||
std::optional<CareerSession::TopScorersDispatch> TopScorersActions::dispatch(const ui::TopScorersRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::TopScorersDispatch> result;
|
||||
@@ -184,11 +218,13 @@ std::optional<CareerSession::TopScorersDispatch> TopScorersActions::dispatch(con
|
||||
return result;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the opportunities checkpoint on failure.
|
||||
bool OpportunitiesActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.opportunities_checkpoint(),
|
||||
[&](CareerSession::OpportunitiesCheckpoint before) { session_.restore_opportunities_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the opportunities screen over `underlay`; the revision is increased on opening.
|
||||
std::optional<ui::OpportunitiesState> OpportunitiesActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, bool national_source_case,
|
||||
int stable_identity, const OpenAccept& acknowledge) {
|
||||
@@ -203,6 +239,7 @@ std::optional<ui::OpportunitiesState> OpportunitiesActions::open(const ui::DeskR
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends an opportunities request to the session in one transaction.
|
||||
std::optional<CareerSession::OpportunitiesDispatch> OpportunitiesActions::dispatch(const ui::OpportunitiesRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::OpportunitiesDispatch> result;
|
||||
@@ -215,6 +252,8 @@ std::optional<CareerSession::OpportunitiesDispatch> OpportunitiesActions::dispat
|
||||
return result;
|
||||
}
|
||||
|
||||
// Stores a changed statistics display preference (expected flags to target flags) and
|
||||
// increases the revision; throws if the revision counter is exhausted.
|
||||
bool OpportunitiesActions::preference(const ui::AnalyticsRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -227,15 +266,18 @@ bool OpportunitiesActions::preference(const ui::AnalyticsRequest& request, uint6
|
||||
});
|
||||
}
|
||||
|
||||
// Builds the request that closes the observed opportunities screen.
|
||||
ui::OpportunitiesRequest OpportunitiesActions::close_request(const ui::OpportunitiesState& observed) {
|
||||
return {observed.identity, ui::OpportunitiesAction::close, observed.mode};
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the manager join checkpoint on failure.
|
||||
bool ManagerJoinActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.manager_join_checkpoint(),
|
||||
[&](CareerSession::ManagerJoinCheckpoint before) { session_.restore_manager_join_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Commits a new manager joining the career; `acknowledge` receives the initialization result.
|
||||
bool ManagerJoinActions::commit(uint64_t& revision, std::string& error,
|
||||
const std::function<void(ui::CareerInitializationResult&)>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -246,6 +288,7 @@ bool ManagerJoinActions::commit(uint64_t& revision, std::string& error,
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a mailbox action (via the native transaction wrapper) and acknowledges it.
|
||||
bool MailboxActions::dispatch(const ui::MailboxActionRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
@@ -255,6 +298,7 @@ bool MailboxActions::dispatch(const ui::MailboxActionRequest& request, uint64_t&
|
||||
});
|
||||
}
|
||||
|
||||
// Acknowledges the closing of the mailbox.
|
||||
bool MailboxActions::close(const ui::MailboxCloseRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
@@ -264,6 +308,7 @@ bool MailboxActions::close(const ui::MailboxCloseRequest& request, uint64_t& rev
|
||||
});
|
||||
}
|
||||
|
||||
// Builds a mailbox action request for the observed message (entry index and raw entry).
|
||||
ui::MailboxActionRequest MailboxActions::request(int manager, uint64_t revision,
|
||||
ui::MailboxActionKind kind, const ui::MailboxMessage& observed) {
|
||||
ui::MailboxActionRequest request;
|
||||
@@ -275,6 +320,7 @@ ui::MailboxActionRequest MailboxActions::request(int manager, uint64_t revision,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Sends a menu layout save/load request and acknowledges it.
|
||||
bool MenuLayoutActions::dispatch(const ui::SaveLoadRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
@@ -284,16 +330,22 @@ bool MenuLayoutActions::dispatch(const ui::SaveLoadRequest& request, uint64_t& r
|
||||
});
|
||||
}
|
||||
|
||||
// Sets one environment item through set_impl (normal UI path).
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set(const ui::EnvironmentRequest& request,
|
||||
uint64_t& revision, std::string& error, const Notice& notice, const std::function<void(bool)>& acknowledge) {
|
||||
return set_impl(request, revision, error, notice, acknowledge, false);
|
||||
}
|
||||
|
||||
// Console variant of set(): the staged state is published even if nothing changed.
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set_console(const ui::EnvironmentView& observed,
|
||||
int item, int level, uint64_t& revision, std::string& error, const Notice& notice) {
|
||||
return set_impl(request(observed, item, level), revision, error, notice, {}, true);
|
||||
}
|
||||
|
||||
// Shared implementation. The request must match the current revision, manager slot
|
||||
// (0..3), active manager and club, otherwise error is "stale_environment_owner". The change
|
||||
// is made on a staged copy; a notice callback may abort it. The revision increases only
|
||||
// when something changed. Returns nothing if the transaction was not accepted.
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set_impl(const ui::EnvironmentRequest& request,
|
||||
uint64_t& revision, std::string& error, const Notice& notice, const std::function<void(bool)>& acknowledge,
|
||||
bool publish_console_result) {
|
||||
@@ -333,6 +385,7 @@ std::optional<EnvironmentResult> EnvironmentActions::set_impl(const ui::Environm
|
||||
return result;
|
||||
}
|
||||
|
||||
// Builds a set_item request for `item` and `level` bound to the observed view.
|
||||
ui::EnvironmentRequest EnvironmentActions::request(const ui::EnvironmentView& observed, int item, int level) {
|
||||
ui::EnvironmentRequest request;
|
||||
request.kind = ui::EnvironmentRequestKind::set_item;
|
||||
@@ -345,10 +398,12 @@ ui::EnvironmentRequest EnvironmentActions::request(const ui::EnvironmentView& ob
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` through the native transaction wrapper.
|
||||
bool RescheduleActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_native(session_, revision, action);
|
||||
}
|
||||
|
||||
// Moves a league match to `day` or undoes a move; any other combination is invalid.
|
||||
RescheduleStatus RescheduleActions::change(GameState& state, int manager, const LeagueMatchRef& match,
|
||||
int day, ui::RescheduleActionKind kind) {
|
||||
if (kind == ui::RescheduleActionKind::move) return reschedule_league_match(state, manager, match, day);
|
||||
@@ -356,6 +411,9 @@ RescheduleStatus RescheduleActions::change(GameState& state, int manager, const
|
||||
return RescheduleStatus::invalid_match;
|
||||
}
|
||||
|
||||
// Handles a UI reschedule action: the owner must be the open menu 7 for the current
|
||||
// revision and active manager, and the match must be among the eligible (or already moved)
|
||||
// matches. The state changes only when the move succeeds.
|
||||
RescheduleStatus RescheduleActions::dispatch(const ui::RescheduleAction& request, uint64_t& revision,
|
||||
const std::function<void()>& acknowledge) {
|
||||
auto status = RescheduleStatus::invalid_match;
|
||||
@@ -379,6 +437,7 @@ RescheduleStatus RescheduleActions::dispatch(const ui::RescheduleAction& request
|
||||
return status;
|
||||
}
|
||||
|
||||
// Moves a match directly (console path); the revision increases on success.
|
||||
RescheduleStatus RescheduleActions::move(int manager, const LeagueMatchRef& match, int day, uint64_t& revision) {
|
||||
auto status = RescheduleStatus::invalid_match;
|
||||
apply(revision, [&] {
|
||||
@@ -390,6 +449,7 @@ RescheduleStatus RescheduleActions::move(int manager, const LeagueMatchRef& matc
|
||||
return status;
|
||||
}
|
||||
|
||||
// Console undo; the revision always increases, whatever the result of the undo.
|
||||
void RescheduleActions::undo_console(int manager, int day, uint64_t& revision) {
|
||||
apply(revision, [&] {
|
||||
// Keep the Console's existing accepted-command revision after its own
|
||||
@@ -400,6 +460,8 @@ void RescheduleActions::undo_console(int manager, int day, uint64_t& revision) {
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a contract request to the session. If an exception follows an accepted request,
|
||||
// the pending contract quote is cleared before rethrowing.
|
||||
bool ContractActions::dispatch(const ui::ContractRequest& request, uint64_t& revision,
|
||||
ui::ContractActionResult& result, std::string& error, const std::function<void()>& acknowledge) {
|
||||
bool accepted = false;
|
||||
@@ -417,6 +479,7 @@ bool ContractActions::dispatch(const ui::ContractRequest& request, uint64_t& rev
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a contract request of `kind` bound to the observed manager, club and revision.
|
||||
ui::ContractRequest ContractActions::bind(const ui::ContractsState& observed,
|
||||
ui::ContractActionKind kind, uint64_t request_id) {
|
||||
ui::ContractRequest request;
|
||||
@@ -428,6 +491,7 @@ ui::ContractRequest ContractActions::bind(const ui::ContractsState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for a player's contract demands (row and player id).
|
||||
ui::ContractRequest ContractActions::demands(const ui::ContractsState& observed,
|
||||
const ui::ContractPlayer& player, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::request_demands, request_id);
|
||||
@@ -436,6 +500,7 @@ ui::ContractRequest ContractActions::demands(const ui::ContractsState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request that sets team bonus `index` to `percent`, keeping the other proposed premiums.
|
||||
ui::ContractRequest ContractActions::team_bonus(const ui::ContractsState& observed,
|
||||
int index, uint8_t percent, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::submit_bonuses, request_id);
|
||||
@@ -444,6 +509,7 @@ ui::ContractRequest ContractActions::team_bonus(const ui::ContractsState& observ
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request to insure a player (quote, insurance form in the term column, months).
|
||||
ui::ContractRequest ContractActions::insurance(const ui::ContractsState& observed, int row,
|
||||
int player, uint64_t quote, uint8_t form, uint8_t months, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::insure_player, request_id);
|
||||
@@ -452,6 +518,8 @@ ui::ContractRequest ContractActions::insurance(const ui::ContractsState& observe
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for a contract offer. With years > 0 it is an offer for that term (salary and
|
||||
// the matching demand); with 0 years only the bonuses are submitted.
|
||||
ui::ContractRequest ContractActions::offer(const ui::ContractsState& observed, int row,
|
||||
int player, uint64_t quote, const std::array<uint8_t,7>& bonuses, int years, uint32_t salary,
|
||||
const std::array<uint32_t,4>& demands, uint64_t request_id) {
|
||||
@@ -466,10 +534,12 @@ ui::ContractRequest ContractActions::offer(const ui::ContractsState& observed, i
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` through the native transaction wrapper.
|
||||
bool FriendlyActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_native(session_, revision, action);
|
||||
}
|
||||
|
||||
// Converts the UI's friendly match request into the engine's booking request.
|
||||
FriendlyBookingRequest FriendlyActions::booking_request(const ui::FriendlyMatchRequest& observed) {
|
||||
FriendlyBookingQuote quote;
|
||||
quote.status = FriendlyQuoteStatus::quoted;
|
||||
@@ -487,6 +557,7 @@ FriendlyBookingRequest FriendlyActions::booking_request(const ui::FriendlyMatchR
|
||||
observed.accept_cost, observed.approving_manager};
|
||||
}
|
||||
|
||||
// Builds the acknowledgement for the UI from the booking outcome and the new revision.
|
||||
ui::FriendlyBookingAck FriendlyActions::acknowledgement(const ui::FriendlyMatchRequest& request,
|
||||
const FriendlyBookingResult& outcome, uint64_t revision) const {
|
||||
ui::FriendlyBookingAck ack;
|
||||
@@ -499,6 +570,9 @@ ui::FriendlyBookingAck FriendlyActions::acknowledgement(const ui::FriendlyMatchR
|
||||
return ack;
|
||||
}
|
||||
|
||||
// Books a friendly match (club or national). The request must be a book request for the
|
||||
// current revision, otherwise the quote is stale. After booking, the planner count must
|
||||
// have grown by 2, else the booking is rolled back and planner_mismatch is set.
|
||||
FriendlyActions::Booking FriendlyActions::book(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, bool national, const Accept& acknowledge) {
|
||||
Booking result;
|
||||
@@ -526,11 +600,14 @@ FriendlyActions::Booking FriendlyActions::book(const ui::FriendlyMatchRequest& r
|
||||
return result;
|
||||
}
|
||||
|
||||
// Books a club friendly.
|
||||
FriendlyActions::Booking FriendlyActions::book_club(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, const Accept& acknowledge) { return book(request, revision, false, acknowledge); }
|
||||
// Books a national team friendly.
|
||||
FriendlyActions::Booking FriendlyActions::book_national(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, const Accept& acknowledge) { return book(request, revision, true, acknowledge); }
|
||||
|
||||
// Console booking from an existing quote; the revision increases when it was booked.
|
||||
FriendlyBookingResult FriendlyActions::book_console(const FriendlyBookingQuote& quote, uint16_t day,
|
||||
bool accept_opponent, int consenting_manager, bool accept_cost, int approving_manager, uint64_t& revision) {
|
||||
FriendlyBookingResult result;
|
||||
@@ -544,19 +621,25 @@ FriendlyBookingResult FriendlyActions::book_console(const FriendlyBookingQuote&
|
||||
return result;
|
||||
}
|
||||
|
||||
// Quote functions (thin wrappers over the game functions): club friendly quote,
|
||||
FriendlyBookingQuote FriendlyActions::quote(int manager, int opponent, bool home) const {
|
||||
return quote_friendly_match(session_.state(), manager, opponent, home);
|
||||
}
|
||||
// national friendly quote (uses the random generator),
|
||||
NationalFriendlyQuote FriendlyActions::national_quote(const NationalFriendlyOwner& owner, int opponent, bool home) {
|
||||
return quote_national_friendly_match(session_.state(), owner, opponent, home, session_.rand());
|
||||
}
|
||||
// whether a club friendly can be played on a day,
|
||||
FriendlyDateStatus FriendlyActions::date_status(const FriendlyBookingQuote& quote, uint16_t day) const {
|
||||
return friendly_match_date_status(session_.state(), quote, day);
|
||||
}
|
||||
// the same for a national friendly,
|
||||
FriendlyDateStatus FriendlyActions::national_date_status(const NationalFriendlyQuote& quote,
|
||||
const NationalFriendlyOwner& owner, uint16_t day) const {
|
||||
return national_friendly_match_date_status(session_.state(), quote, owner, session_.rand(), day);
|
||||
}
|
||||
// and the owner identity of a national friendly built from the request (the last two
|
||||
// fields are fixed constants).
|
||||
NationalFriendlyOwner FriendlyActions::national_owner(const ui::FriendlyMatchRequest& request) {
|
||||
return {request.quote_id, request.revision, request.manager_slot, 0x165, 6};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Application-boundary facades for desk-level windows: one small class per owner (desk
|
||||
// settings, balance plan, other games, top scorers, opportunities, manager join, mailbox,
|
||||
// menu layout, environment, reschedule, contracts, friendly matches). Each wraps a
|
||||
// CareerSession reference; its apply() runs an action under a rollback transaction (see
|
||||
// action_transaction.hpp), and open()/dispatch() take the UI request plus the shared
|
||||
// revision counter and an optional "accept" callback that carries the front end's
|
||||
// acknowledgement. Implemented in desktop_actions.cpp; window_actions.hpp holds the club windows.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// SDL event helpers for the live match-day presentation, which runs while the engine is
|
||||
// synchronously paused in its observer hook. live_matchday_board_side() turns a mouse press
|
||||
// into a side (0 or 1) of the board only at the allowed minutes and screen intervals;
|
||||
// pump_live_matchday_events() drains the SDL queue, reports a quit request and an ESC skip
|
||||
// through its return value / out-parameter, and re-queues only non-interactive system events.
|
||||
// Header-only; owns no state.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
+459
-5
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Mouse pointer for the pitch page. SDL owns the pointer position; the UI only hands over
|
||||
// the original 11x11 pixel bitmap (121 ARGB values). PitchPointer builds an SDL colour
|
||||
// cursor from it, enlarged by an integer scale derived from the window size in points, and
|
||||
// caches it until the pixels or the scale change. set_default() sets the bitmap used on all
|
||||
// other pages. Header-only; the cursor is freed in clear() / the destructor.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Quit confirmation (a deliberate deviation from the original): a native message box in
|
||||
// German or English whose default button is "Cancel". poll() and peep() wrap
|
||||
// SDL_PollEvent / SDL_PeepEvents and drop SDL_QUIT events the user does not confirm. The
|
||||
// dialog is shown from the UI thread only, and a dialog that fails to open counts as "not
|
||||
// confirmed". The presenter is injectable (defaults to SDL_ShowMessageBox). Header-only.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of StartScreen (start_screen.hpp): decodes the embedded JPEG
|
||||
// (start_screen_data.hpp) with stb_image into an RGB24 texture, switches the renderer's
|
||||
// logical size to the image size while presenting and restores the previous logical size in
|
||||
// the destructor. Errors are reported as std::runtime_error; the stb_image implementation
|
||||
// is compiled into this file only (JPEG decoding, no stdio).
|
||||
#include "app/start_screen.hpp"
|
||||
#include "app/start_screen_data.hpp"
|
||||
#include <SDL.h>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Start screen shown before the game data is loaded: one embedded picture drawn with its
|
||||
// own renderer logical size, independent of the indexed game canvas. Owns the SDL
|
||||
// texture; non-copyable. Implemented in start_screen.cpp, the image bytes come from
|
||||
// start_screen_data.hpp.
|
||||
#pragma once
|
||||
struct SDL_Renderer;
|
||||
struct SDL_Texture;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Declares the embedded start screen artwork (JPEG bytes and their size); the definitions
|
||||
// live in a separate data translation unit. Consumed only by start_screen.cpp.
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
namespace bmh::app {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// RAII guard for SDL video: SDL_Init(SDL_INIT_VIDEO) in the constructor (throws
|
||||
// std::runtime_error on failure) and SDL_Quit in the destructor. It must exist before any
|
||||
// native file picker is opened (see the comment on the class). Non-copyable, header-only.
|
||||
#pragma once
|
||||
#include <SDL.h>
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the club and league window facades declared in window_actions.hpp. Each
|
||||
// method validates the UI request against the session state, runs it on the CareerSession
|
||||
// inside an apply() transaction (state, RNG and revision are restored on rejection or an
|
||||
// exception) and hands the result to the front end's acknowledgement callback. Errors come
|
||||
// back through the std::string& error parameter; see controller.cpp for the overall model.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/window_actions.hpp"
|
||||
#include "app/action_transaction.hpp"
|
||||
@@ -11,6 +16,9 @@
|
||||
namespace bmh::app {
|
||||
using detail::apply_window;
|
||||
|
||||
// Runs `action` as a transaction on the league family state. Returns true if the action
|
||||
// succeeded; if it returns false or throws, the checkpoint and the revision are restored
|
||||
// (an exception is rethrown).
|
||||
bool LeagueFamilyActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
auto before = session_.league_family_checkpoint();
|
||||
const auto old_revision = revision;
|
||||
@@ -26,6 +34,8 @@ bool LeagueFamilyActions::apply(uint64_t& revision, const std::function<bool()>&
|
||||
return false;
|
||||
}
|
||||
|
||||
// Opens the league pairings screen from the desk (menu kind 1, using the desk item of
|
||||
// kind 1). Returns its state, or nothing with `error` set if the session refused.
|
||||
std::optional<ui::LeaguePairingsState> LeagueFamilyActions::open_pairings(
|
||||
const ui::DeskState& observed, uint64_t& revision, std::string& error) {
|
||||
ui::DeskRequest request;
|
||||
@@ -43,6 +53,7 @@ std::optional<ui::LeaguePairingsState> LeagueFamilyActions::open_pairings(
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends one pairings screen event (kind and value) to the session inside a transaction.
|
||||
std::optional<CareerSession::LeaguePairingsDispatch> LeagueFamilyActions::pairings(
|
||||
const ui::LeaguePairingsIdentity& observed, LeaguePairingsAction kind, int value,
|
||||
uint64_t& revision, std::string& error) {
|
||||
@@ -58,16 +69,19 @@ std::optional<CareerSession::LeaguePairingsDispatch> LeagueFamilyActions::pairin
|
||||
return result;
|
||||
}
|
||||
|
||||
// Builds the desk request that opens menu 1 (pairings) for the manager of `identity`.
|
||||
ui::DeskRequest LeagueFamilyActions::pairings_entry(const ui::StrengthsIdentity& identity,
|
||||
uint64_t revision) {
|
||||
return {ui::DeskRequestKind::open_menu, identity.manager, 0, 1, -1, revision};
|
||||
}
|
||||
|
||||
// Builds the pairings request that selects `league`.
|
||||
ui::LeaguePairingsRequest LeagueFamilyActions::pairings_selection(
|
||||
const ui::LeaguePairingsIdentity& identity, int league) {
|
||||
return {identity, {LeaguePairingsAction::select_league, league, -1}};
|
||||
}
|
||||
|
||||
// Turns a fresh strengths request into an `open` request bound to `identity`.
|
||||
ui::StrengthsRequest LeagueFamilyActions::strengths_entry(const ui::StrengthsRequest& fresh,
|
||||
const ui::StrengthsIdentity& identity) {
|
||||
auto request = fresh;
|
||||
@@ -76,6 +90,9 @@ ui::StrengthsRequest LeagueFamilyActions::strengths_entry(const ui::StrengthsReq
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction on the transfer state. Before it, the game state, random
|
||||
// generators, offer editor, poach state, club modal runtime and revision are copied; they
|
||||
// are all restored if the action returns false or throws (then rethrown).
|
||||
bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
auto state = session_.g_;
|
||||
const auto game = session_.game_;
|
||||
@@ -85,6 +102,7 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
|
||||
const auto owner_revision = session_.transfer_offer_revision_;
|
||||
auto runtime = session_.club_modal_runtime_;
|
||||
const auto old_revision = revision;
|
||||
// Puts every saved piece back into the session.
|
||||
const auto restore = [&] {
|
||||
session_.g_ = std::move(state);
|
||||
session_.game_ = game;
|
||||
@@ -105,12 +123,17 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
|
||||
return false;
|
||||
}
|
||||
|
||||
// Handles a transfer market request. In the normal interactive policy the session does
|
||||
// the work (with the sale hooks and the review callback). The other policy is an older
|
||||
// path that only allows listing a player and submitting a bid; it bumps the revision
|
||||
// only if the state or random stream really changed. `acknowledge` is called on success.
|
||||
std::optional<TransferActions::MarketDispatch> TransferActions::market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, HumanBuyerMarketEntryPolicy policy,
|
||||
const MarketAccept& acknowledge,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
|
||||
std::optional<MarketDispatch> result;
|
||||
// Body of the transaction; returning false rolls everything back.
|
||||
apply(revision, [&] {
|
||||
const auto old_revision = revision;
|
||||
if (policy == HumanBuyerMarketEntryPolicy::normal_interactive) {
|
||||
@@ -151,6 +174,9 @@ std::optional<TransferActions::MarketDispatch> TransferActions::market(
|
||||
return result;
|
||||
}
|
||||
|
||||
// Checks a market request against the current state. Returns a German error text if the
|
||||
// request is stale or invalid, or an empty string if it may proceed. Bonus values may be
|
||||
// at most 255 (interactive policy) or 100 (legacy policy).
|
||||
std::string TransferActions::rejection(const ui::TransferMarketRequest& request,
|
||||
uint64_t revision, HumanBuyerMarketEntryPolicy policy) const {
|
||||
const auto& state = session_.state();
|
||||
@@ -176,11 +202,13 @@ std::string TransferActions::rejection(const ui::TransferMarketRequest& request,
|
||||
} else if (request.kind != ui::TransferMarketRequestKind::open_offer &&
|
||||
request.kind != ui::TransferMarketRequestKind::preview_quote &&
|
||||
request.kind != ui::TransferMarketRequestKind::open_poach &&
|
||||
request.kind != ui::TransferMarketRequestKind::review_offers)
|
||||
request.kind != ui::TransferMarketRequestKind::review_offers &&
|
||||
request.kind != ui::TransferMarketRequestKind::store_search_profile)
|
||||
return "Diese Transferaktion ist nicht verfügbar.";
|
||||
return {};
|
||||
}
|
||||
|
||||
// Opens the transfer offer editor for a market request (one transaction).
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::open_offer(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error,
|
||||
const OfferAccept& acknowledge) {
|
||||
@@ -194,6 +222,7 @@ std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::open_
|
||||
return result;
|
||||
}
|
||||
|
||||
// Asks the session for a preview (quote) of a market request without committing it.
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> TransferActions::preview(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error,
|
||||
const PreviewAccept& acknowledge) {
|
||||
@@ -207,6 +236,8 @@ std::optional<CareerSession::TransferMarketPreviewDispatch> TransferActions::pre
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends an action of the outgoing offer editor to the session; the team and player
|
||||
// information presenters are used when it opens those screens.
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::offer(
|
||||
const ui::OutgoingTransferRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, const TransferOfferTeamInfoPresenter& team_info,
|
||||
@@ -221,6 +252,7 @@ std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::offer
|
||||
return result;
|
||||
}
|
||||
|
||||
// Starts a poaching attempt for the given manager and squad slot.
|
||||
std::optional<CareerSession::PoachDispatch> TransferActions::poach(int manager, int slot,
|
||||
uint64_t& revision, std::string& error) {
|
||||
std::optional<CareerSession::PoachDispatch> result;
|
||||
@@ -231,6 +263,8 @@ std::optional<CareerSession::PoachDispatch> TransferActions::poach(int manager,
|
||||
return result;
|
||||
}
|
||||
|
||||
// Builds the request to list the squad player `item` on the market (as a loan if `loan`),
|
||||
// bound to the observed state's manager, club and revision.
|
||||
ui::TransferMarketRequest TransferActions::listing(const ui::TransferMarketState& observed,
|
||||
const ui::TransferMarketSquadItem& item, bool loan) {
|
||||
ui::TransferMarketRequest request;
|
||||
@@ -246,6 +280,8 @@ ui::TransferMarketRequest TransferActions::listing(const ui::TransferMarketState
|
||||
return request;
|
||||
}
|
||||
|
||||
// Builds the request to open an offer for the market entry `item`; an existing own bid
|
||||
// is used as the starting point.
|
||||
ui::TransferMarketRequest TransferActions::opening(const ui::TransferMarketState& observed,
|
||||
const ui::TransferMarketItem& item, bool loan) {
|
||||
ui::TransferMarketRequest request;
|
||||
@@ -263,6 +299,7 @@ ui::TransferMarketRequest TransferActions::opening(const ui::TransferMarketState
|
||||
return request;
|
||||
}
|
||||
|
||||
// Builds a request from the offer editor's current state plus the changed field and value.
|
||||
ui::OutgoingTransferRequest TransferActions::editor(const ui::OutgoingTransferEditorState& observed,
|
||||
ui::OutgoingTransferRequestKind kind, ui::OutgoingTransferField field, uint32_t value) {
|
||||
ui::OutgoingTransferRequest request;
|
||||
@@ -282,11 +319,13 @@ ui::OutgoingTransferRequest TransferActions::editor(const ui::OutgoingTransferEd
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the bank checkpoint on failure.
|
||||
bool BankActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.bank_checkpoint(),
|
||||
[&](CareerSession::BankCheckpoint before) { session_.restore_bank_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Sends a bank request to the session; `acknowledge` is called when it was accepted.
|
||||
bool BankActions::dispatch(const ui::BankRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -296,6 +335,7 @@ bool BankActions::dispatch(const ui::BankRequest& request, uint64_t& revision, s
|
||||
});
|
||||
}
|
||||
|
||||
// Creates a bank request of `kind` bound to the observed manager, club and revision.
|
||||
ui::BankRequest BankActions::bind(const ui::BankState& observed, ui::BankRequestKind kind) {
|
||||
ui::BankRequest request;
|
||||
request.kind = kind;
|
||||
@@ -305,12 +345,14 @@ ui::BankRequest BankActions::bind(const ui::BankState& observed, ui::BankRequest
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request to move `amount` to the deposit account.
|
||||
ui::BankRequest BankActions::savings(const ui::BankState& observed, int32_t amount) {
|
||||
auto request = bind(observed, ui::BankRequestKind::move_to_deposit);
|
||||
request.amount = amount;
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for an investment action on asset index `asset` with `count` units.
|
||||
ui::BankRequest BankActions::investment(const ui::BankState& observed, ui::BankRequestKind kind,
|
||||
int asset, int count) {
|
||||
auto request = bind(observed, kind);
|
||||
@@ -319,6 +361,8 @@ ui::BankRequest BankActions::investment(const ui::BankState& observed, ui::BankR
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for a bank credit: carries the saved credit, the player's edits, whether the
|
||||
// fees are accepted and the counterparty.
|
||||
ui::BankRequest BankActions::credit(const ui::BankState& observed, const BankCreditContext& context,
|
||||
const BankCreditDraft& draft, bool accept_fees, int counterparty) {
|
||||
auto request = bind(observed, ui::BankRequestKind::bank_credit);
|
||||
@@ -329,11 +373,14 @@ ui::BankRequest BankActions::credit(const ui::BankState& observed, const BankCre
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the stadium checkpoint on failure.
|
||||
bool StadiumActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.stadium_checkpoint(),
|
||||
[&](CareerSession::StadiumCheckpoint before) { session_.restore_stadium_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Sends a stadium request to the session with the notice hooks; `acknowledge` is called
|
||||
// when it was accepted.
|
||||
bool StadiumActions::dispatch(const ui::StadiumRequest& request, uint64_t& revision, std::string& error,
|
||||
const ConstructionNoticeHook& construction, const SeasonTicketCompensationNoticeHook& compensation,
|
||||
const std::function<void()>& acknowledge) {
|
||||
@@ -344,6 +391,7 @@ bool StadiumActions::dispatch(const ui::StadiumRequest& request, uint64_t& revis
|
||||
});
|
||||
}
|
||||
|
||||
// Creates a stadium request bound to the observed club, revision, scope and sequence.
|
||||
ui::StadiumRequest StadiumActions::request(const ui::StadiumState& observed, ui::StadiumRequestKind kind,
|
||||
int object, int option, int32_t price, bool accept_tip) {
|
||||
ui::StadiumRequest request;
|
||||
@@ -361,6 +409,8 @@ ui::StadiumRequest StadiumActions::request(const ui::StadiumState& observed, ui:
|
||||
return request;
|
||||
}
|
||||
|
||||
// Sets the ticket price for the observed desk's club; the stable club identity is filled
|
||||
// in when the club index is valid.
|
||||
bool DeskActions::ticket_price(const ui::DeskState& observed, int price,
|
||||
uint64_t& revision, std::string& error) {
|
||||
TicketPriceRequest request;
|
||||
@@ -373,11 +423,13 @@ bool DeskActions::ticket_price(const ui::DeskState& observed, int price,
|
||||
return session_.dispatch_ticket_price(request, revision, error);
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the lineup checkpoint on failure.
|
||||
bool LineupActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.lineup_checkpoint(),
|
||||
[&](CareerSession::LineupCheckpoint before) { session_.restore_lineup_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Sends a lineup request to the session; `acknowledge` is called when accepted.
|
||||
bool LineupActions::lineup(const ui::LineupRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -387,6 +439,7 @@ bool LineupActions::lineup(const ui::LineupRequest& request, uint64_t& revision,
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a pitch request to the session; `acknowledge` is called when accepted.
|
||||
bool LineupActions::pitch(const ui::PitchRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -396,10 +449,13 @@ bool LineupActions::pitch(const ui::PitchRequest& request, uint64_t& revision, s
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a pitch swap request to the session as one transaction.
|
||||
bool LineupActions::pitch_swap(const ui::PitchRequest& request, uint64_t& revision, std::string& error) {
|
||||
return apply(revision, [&] { return session_.dispatch_pitch_swap(request, revision, error); });
|
||||
}
|
||||
|
||||
// Changes one order value (`aspect`) of a player. Only valid for the observed revision;
|
||||
// on success the revision is increased.
|
||||
bool LineupActions::order(const ui::LineupState& observed, const ui::LineupPlayer& player,
|
||||
int aspect, int value, uint64_t& revision) {
|
||||
return apply(revision, [&] {
|
||||
@@ -410,6 +466,9 @@ bool LineupActions::order(const ui::LineupState& observed, const ui::LineupPlaye
|
||||
});
|
||||
}
|
||||
|
||||
// Tries the requested pitch move on a copy of the state and tells whether the player ends
|
||||
// up paired with `second_row` (requested), with another player (other_pair) or whether the
|
||||
// move is invalid.
|
||||
LineupActions::PairTarget LineupActions::pair_target(const ui::PitchRequest& request, int second_row) const {
|
||||
auto preview = session_.state();
|
||||
if (!move_pitch_player_source(preview, request.manager_slot, request.runtime_club,
|
||||
@@ -421,6 +480,7 @@ LineupActions::PairTarget LineupActions::pair_target(const ui::PitchRequest& req
|
||||
? PairTarget::requested : PairTarget::other_pair;
|
||||
}
|
||||
|
||||
// Creates a lineup request that prepares the lineup of the observed state.
|
||||
ui::LineupRequest LineupActions::prepare(const ui::LineupState& observed) {
|
||||
ui::LineupRequest request;
|
||||
request.kind = ui::LineupRequestKind::prepare_lineup;
|
||||
@@ -430,6 +490,7 @@ ui::LineupRequest LineupActions::prepare(const ui::LineupState& observed) {
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to swap two players of the lineup.
|
||||
ui::LineupRequest LineupActions::swap(const ui::LineupState& observed,
|
||||
const ui::LineupPlayer& first, const ui::LineupPlayer& second) {
|
||||
auto request = prepare(observed);
|
||||
@@ -440,6 +501,8 @@ ui::LineupRequest LineupActions::swap(const ui::LineupState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a pitch request of `kind` bound to the observed lineup. The observed live mode
|
||||
// must be known, otherwise a FormatError is thrown.
|
||||
ui::PitchRequest LineupActions::bind_pitch(const ui::PreparationState& observed, ui::PitchRequestKind kind) {
|
||||
if (!observed.pitch || !observed.pitch->indoor.has_value())
|
||||
throw FormatError("pitch: missing observed live mode");
|
||||
@@ -452,6 +515,7 @@ ui::PitchRequest LineupActions::bind_pitch(const ui::PreparationState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to swap two players on the pitch (including their current positions).
|
||||
ui::PitchRequest LineupActions::swap_pitch(const ui::PreparationState& observed,
|
||||
const ui::LineupPlayer& first, const ui::LineupPlayer& second) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::swap_players);
|
||||
@@ -461,6 +525,7 @@ ui::PitchRequest LineupActions::swap_pitch(const ui::PreparationState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to switch the pitch page (toggles the 0x000c bits of the display word).
|
||||
ui::PitchRequest LineupActions::page(const ui::PreparationState& observed) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::select_pitch_page);
|
||||
request.expected_mode = uint8_t(observed.pitch->mode);
|
||||
@@ -472,6 +537,8 @@ ui::PitchRequest LineupActions::page(const ui::PreparationState& observed) {
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to load or save a formation in `slot`; saving copies the position
|
||||
// bytes of the 11 players on the pitch.
|
||||
ui::PitchRequest LineupActions::formation(const ui::PreparationState& observed,
|
||||
ui::PitchRequestKind kind, int slot) {
|
||||
auto request = bind_pitch(observed, kind);
|
||||
@@ -487,6 +554,7 @@ ui::PitchRequest LineupActions::formation(const ui::PreparationState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to move a player to the given depth and lane.
|
||||
ui::PitchRequest LineupActions::move(const ui::PreparationState& observed, const ui::LineupPlayer& player,
|
||||
int depth, int lane) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::move_player);
|
||||
@@ -497,6 +565,8 @@ ui::PitchRequest LineupActions::move(const ui::PreparationState& observed, const
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request that advances one of the three automatic weights (index 0..2) by one
|
||||
// step; each weight is a 2-bit value that wraps around after 3.
|
||||
ui::PitchRequest LineupActions::weight(const ui::PreparationState& observed, int index) {
|
||||
if (index < 0 || index > 2) throw FormatError("pitch: invalid automatic weight index");
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::set_automatic_weight);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Application-boundary facades for the club and league windows: league table/pairings/
|
||||
// strengths, transfer market and offers, bank, stadium, desk actions and lineup. Same pattern
|
||||
// as desktop_actions.hpp: a class per owner that wraps a CareerSession, offers apply() as a
|
||||
// rollback transaction and takes the shared revision counter plus an acknowledgement
|
||||
// callback from the front end. Implemented in window_actions.cpp, called from controller.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of container.hpp: parse_container() checks the FORM/ALPTRAUM header and
|
||||
// walks the adjacent little-endian chunks (no alignment byte) with bounds checks, filling
|
||||
// a Container of offsets; decode_sample() and decode_original_cue() convert the bounded
|
||||
// sample data to PCM. Pure functions on byte spans, no state; failures are reported through
|
||||
// the std::string& error argument and a false result.
|
||||
#include "container.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Reader for the original sound container (a FORM/ALPTRAUM chunk wrapper) and for the PCM
|
||||
// samples inside it. A Container only lists chunk ids and payload offsets; the payload bytes
|
||||
// stay in the caller's buffer, which must outlive any use of the offsets. decode_sample()
|
||||
// turns unsigned 8-bit samples into signed 16-bit mono PCM; decode_original_cue() resolves
|
||||
// only the PCM-backed effects (original ids 17..22). Pairs with container.cpp; the PCM types
|
||||
// are shared by mixer, playback, semantic cues and the music fallback.
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of Mixer (mixer.hpp). Incoming PCM is resampled to the output rate with
|
||||
// range and overflow checks and a total/per-voice byte ceiling (2 MiB overall, an eighth of
|
||||
// that per voice); mix_block() sums music and active voices into the output block, applies
|
||||
// the volume and advances the cursors (the music loops).
|
||||
#include "mixer.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Small PCM mixer used by the software (non-original) playback path: one looping music
|
||||
// buffer plus up to 8 one-shot voices, all converted to the output rate when added.
|
||||
// start_music_loop()/add_voice() may allocate; mix_block() only reads the prepared buffers
|
||||
// and writes into caller-owned storage, so it is safe to call from the audio path. Owned
|
||||
// by Playback (playback.hpp); the byte limits are in mixer.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the synthetic matchday loop (music_fallback.hpp): a fixed 22050 Hz,
|
||||
// 108 bpm, 8-bar sequence of bass, chord and lead notes defined by constant MIDI tables,
|
||||
// rendered to mono PCM16. No game state or randomness is involved, so the output is the
|
||||
// same on every run.
|
||||
#include "music_fallback.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Synthetic fallback matchday music: a deterministic 8-bar loop generated in code. It is
|
||||
// presentation filler, not decoded original music and not tied to any original sound id.
|
||||
// The result is a PcmSample that Playback::start_music_loop() can play; implemented in
|
||||
// music_fallback.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of OriginalSynth (original.hpp). The hidden State holds the parsed
|
||||
// songs, tracks, channels, sample banks and the Nuked-OPL3 chip core (src/audio/third_party);
|
||||
// tick() runs one sequencer step of the original timer interrupt, render() produces output
|
||||
// samples from the chip and the PCM channel. load() validates every input and fails
|
||||
// cleanly on malformed data; the register and sample observers exist only for offline
|
||||
// validation (original_validation.cpp, sound_driver.cpp).
|
||||
#include "original.hpp"
|
||||
#include "container.hpp"
|
||||
#include "third_party/nuked-opl3/opl3.h"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Emulation of the original game's sound system (MIDI-style sequencer, OPL FM instruments
|
||||
// and one Sound Blaster PCM channel) as OriginalSynth. The application reads the sound
|
||||
// containers (S/2000..2003) and the frequency/operator tables from the user's executable
|
||||
// and hands them in as OriginalAssets; this module knows nothing about game state, file
|
||||
// layout, the simulation clock or random generators. command() takes the original sound ids
|
||||
// (0 title, 1 desk, 2 intro, 3 crowd, 8 stop, 10..22 effects); render() fills PCM blocks
|
||||
// without allocating. Implemented in original.cpp, driven by Playback and the audio tools.
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Validation executable for the original-sound emulation (original.hpp, playback.hpp). It
|
||||
// needs the user's game data directory as its single argument, loads the executable tables
|
||||
// and sound containers from it, and runs oracle checks on song/effect output, transitions,
|
||||
// malformed input, option and mute handling, effect priorities and the audio callback
|
||||
// lifecycle. With an empty argument it prints SKIP and exits with 77 (test skipped).
|
||||
// Contains no game assets itself.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "original.hpp"
|
||||
#include "playback.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of Playback (playback.hpp): opens the SDL audio device, feeds either the
|
||||
// OriginalSynth from the SDL callback (original mode) or bounded blocks from the Mixer via
|
||||
// pump() (software mode), and maps original ids and semantic cues to sound played on the
|
||||
// device. Duplicate or out-of-order event ids are rejected before anything is played;
|
||||
// shutdown() releases the device.
|
||||
#include "playback.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Audio output device wrapper (SDL) and the single audio object the application uses.
|
||||
// Playback owns the SDL device, a software Mixer (PCM effects, optional music loop) and the
|
||||
// OriginalSynth (the full original driver, streamed from SDL's audio callback so modal
|
||||
// windows cannot starve it). Cue requests carry a session id and an increasing event id
|
||||
// chosen by the controller; submit() consumes each event once and returns a CueStatus.
|
||||
// Mute and volume apply to both paths. Pairs with playback.cpp and app/audio.hpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of synthesize_semantic_cue() (semantic_cues.hpp): builds each cue in code
|
||||
// (the whistles from frequency sweeps with attack and release shaping) at 22050 Hz and
|
||||
// clamps the result to 16-bit PCM. Pure and deterministic.
|
||||
#include "semantic_cues.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Semantic sound cues (kickoff whistle, goal, full-time whistle) synthesized in code for
|
||||
// use when no verified original effect is available. They are labels of intent, never
|
||||
// original sound ids. The generator is deterministic mono PCM16 at 22050 Hz and has no
|
||||
// dependency on game state, randomness or rendering; implemented in semantic_cues.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Command line tool openbmh_sound for the audio module. It works either on one sound
|
||||
// container file (play or export a sample, a test tone, or an original effect id as WAV) or,
|
||||
// with --original DATA_DIR, on the user's game data through OriginalSynth (export a song or
|
||||
// effect to WAV, or play ids through the real device). It also plays or exports the
|
||||
// synthetic semantic cues and the fallback music loop. Own state only: parsed arguments.
|
||||
// Bounds on seconds, loops and ids are checked before anything runs.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "container.hpp"
|
||||
#include "music_fallback.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Self-contained checks for the audio module that need no game data: container parsing
|
||||
// against authored fixtures, sample and cue decoding, the mixer, the playback request
|
||||
// rules and the synthetic music fallback. The fixtures are built in code and are not
|
||||
// copied from any game asset. Returns non-zero on the first failed CHECK; companion of
|
||||
// original_validation.cpp, which covers the original-driver emulation.
|
||||
#include "container.hpp"
|
||||
#include "music_fallback.hpp"
|
||||
#include "playback.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the console line parser (parser.hpp): trimming, top-level splitting of
|
||||
// the argument list (commas inside quotes or brackets do not split), parsing of one
|
||||
// argument (positional or name=value), canonical name comparison that ignores case, '.' and
|
||||
// '_', line classification, and the integer/bool converters for arguments. Pure functions;
|
||||
// no console state. The console (console.cpp, windows_*.cpp) checks the argument types.
|
||||
#include "cli/console/parser.hpp"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "cli/console/detail.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
#include "game/human_buyer_sale.hpp"
|
||||
#include "game/messages.hpp"
|
||||
#include "game/poach.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "ui/club_info.hpp"
|
||||
@@ -516,8 +517,76 @@ void Console::register_transfer_commands() {
|
||||
show_offer();
|
||||
});
|
||||
|
||||
// --- the search profile (buttons Suchen / Vorschlag of the market, game/search_profile.hpp) ---------------
|
||||
// The 18 values of the profile in the order of the original dialog; the console shows and takes them as a list.
|
||||
static const char* const kProfileLabels[18] = {
|
||||
"Goalkeeper", "Defender", "Midfielder", "Forward", "AgeMin(16+)", "AgeMax(16+)", "StrengthMin", "StrengthMax",
|
||||
"AttrCondition", "AttrTechnique", "AttrForm", "Side1", "Side2", "Side3", "Side4", "PriceLow", "PriceMid", "PriceHigh"};
|
||||
auto show_profile = [this](const SearchProfile& p, const char* heading) {
|
||||
std::vector<std::vector<std::string>> rows;
|
||||
for (size_t i = 0; i < p.size(); ++i)
|
||||
rows.push_back({kProfileLabels[i], std::to_string(i == 0 ? p[i] & ~kSearchProfileOff : p[i])});
|
||||
emit_table({heading, "Value"}, rows);
|
||||
std::string list;
|
||||
for (size_t i = 0; i < p.size(); ++i) list += (i ? "," : "") + std::to_string(i == 0 ? p[i] & ~kSearchProfileOff : p[i]);
|
||||
emit('i', std::string("profile ") + (p[0] & kSearchProfileOff ? "OFF" : "active") + "; as SetSearchProfile([" + list + "])");
|
||||
};
|
||||
auto manager_slot = [market] { return market().manager_slot; };
|
||||
add({"Transfer", "ShowSearchProfile", {}, "SUCHEN: your search profile (18 values; positions, age, strength, attributes, sides, price classes)", false},
|
||||
[this, manager_slot, show_profile](const Values&) { show_profile(session_->search_profile(manager_slot()), "Search profile"); });
|
||||
add({"Transfer", "SuggestSearchProfile", {boolean("whole", true), boolean("apply", true)},
|
||||
"VORSCHLAG: the profile your squad asks for (whole = count the substitutes); apply = store it and list the matches", false},
|
||||
[this, manager_slot, show_profile, flush_notices](const Values& v) {
|
||||
const int manager = manager_slot();
|
||||
const auto suggestion = session_->suggest_search_profile(manager, v.boolean("whole", false));
|
||||
show_profile(suggestion, "Suggestion");
|
||||
if (v.boolean("apply", false)) {
|
||||
std::string error;
|
||||
const auto result = session_->dispatch_search_profile(manager, suggestion, false, true, revision_, error);
|
||||
if (!result) require_engine(false, "search profile", error);
|
||||
emit('i', utf8(message_text(session_->state(), ::bmh::layout::Month_SearchProfileNews_TextPointer4)));
|
||||
emit('+', std::to_string(result->hits.size()) + " listed player(s) fit the profile");
|
||||
for (const auto& hit : result->hits) emit('i', utf8(hit.message));
|
||||
}
|
||||
});
|
||||
Param profile_values = detail::text("values");
|
||||
profile_values.display = "values:[18 numbers] (see ShowSearchProfile)";
|
||||
add({"Transfer", "SetSearchProfile", {profile_values, boolean("apply", true)},
|
||||
"SUCHEN: store the search profile (the 18 values of ShowSearchProfile, switches 0/1, age 0..24 = 16..40, strength 0..99); apply = list the matches now", false},
|
||||
[this, manager_slot, show_profile](const Values& v) {
|
||||
std::string list = v.text("values");
|
||||
if (list.size() >= 2 && list.front() == '[' && list.back() == ']') list = list.substr(1, list.size() - 2);
|
||||
SearchProfile profile{};
|
||||
size_t count = 0, start = 0;
|
||||
while (start <= list.size()) {
|
||||
const size_t comma = list.find(',', start);
|
||||
std::string item = list.substr(start, comma == std::string::npos ? std::string::npos : comma - start);
|
||||
item.erase(0, item.find_first_not_of(' '));
|
||||
item.erase(item.find_last_not_of(' ') + 1);
|
||||
if (item.empty() || item.find_first_not_of("0123456789") != std::string::npos || item.size() > 3)
|
||||
fail("E_BAD_ARGUMENT", "the profile values are numbers separated by commas");
|
||||
if (count >= profile.size()) fail("E_BAD_ARGUMENT", "the profile has 18 values");
|
||||
profile[count++] = uint8_t(std::min(255, std::stoi(item)));
|
||||
if (comma == std::string::npos) break;
|
||||
start = comma + 1;
|
||||
}
|
||||
if (count != profile.size()) fail("E_BAD_ARGUMENT", "the profile has 18 values, not " + std::to_string(count));
|
||||
if (!search_profile_valid(profile))
|
||||
fail("E_BAD_ARGUMENT", "switches are 0 or 1, the age values 0..24 and the strength values 0..99");
|
||||
std::string error;
|
||||
const auto result = session_->dispatch_search_profile(manager_slot(), profile, false, v.boolean("apply", true), revision_, error);
|
||||
if (!result) require_engine(false, "search profile", error);
|
||||
emit('+', result->active ? "search profile stored"
|
||||
: "search profile stored but switched off (all values 0 or all 1 count as no search)");
|
||||
if (v.boolean("apply", true)) {
|
||||
emit('i', utf8(message_text(session_->state(), ::bmh::layout::Month_SearchProfileNews_TextPointer4)));
|
||||
emit('+', std::to_string(result->hits.size()) + " listed player(s) fit the profile");
|
||||
for (const auto& hit : result->hits) emit('i', utf8(hit.message));
|
||||
}
|
||||
});
|
||||
|
||||
// the rest of the market (06-verein 5): later steps of stage 3 or engine gaps
|
||||
for (const char* name : {"SetSquadView", "SetSquadSheet", "SetMarketVisible", "ShowPlayer", "OpenOffers", "OpenSearch",
|
||||
for (const char* name : {"SetSquadView", "SetSquadSheet", "SetMarketVisible", "ShowPlayer", "OpenOffers",
|
||||
"ShowTransferNews", "ShowTeamInfo"})
|
||||
add({"Transfer", name, {}, "not in the console yet", false},
|
||||
[name](const Values&) { fail("E_ENGINE_GAP", std::string(name) + " is not in the console yet"); });
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of parse_json()/dump_json() (json.hpp): a small recursive-descent Parser
|
||||
// over a string_view that reports the byte position in JsonError messages, UTF-8 handling
|
||||
// for string escapes, and a serializer for the Json variant. No state beyond the parser's
|
||||
// position in the input.
|
||||
#include "cli/json.hpp"
|
||||
|
||||
#include <charconv>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Minimal JSON value type for the CLI protocol (no external library). A Json holds null,
|
||||
// bool, a 64-bit integer, string, array or object (std::map) in one std::variant; the
|
||||
// accessors return null pointers when the type does not match, so callers must check.
|
||||
// Numbers are integers only. parse_json() throws JsonError on bad input; dump_json() writes
|
||||
// compact text. Used by protocol.*, seat_hub.cpp and main.cpp; implemented in json.cpp.
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Entry point of openbmh_cli, the headless front end without a window. Besides parsing the
|
||||
// command line (Arguments) it offers several modes on top of the same engine: the JSON
|
||||
// protocol on stdin/stdout (protocol.hpp) with --log/--replay, the console language
|
||||
// (docs/CLI_CONCEPT) as plain session, replay, mailbox server (--serve), multi-seat server
|
||||
// (--seats, SeatHub), TCP listener on 127.0.0.1 (--listen), and --send to hand one block to
|
||||
// a running mailbox session. --data may be a game directory, the game's EXE or an archive
|
||||
// (src/launch resolves it). All game logic stays in the engine; this file only moves lines.
|
||||
#include "cli/protocol.hpp"
|
||||
#include "cli/console/console.hpp"
|
||||
#include "cli/seat_hub.hpp"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the JSON protocol (protocol.hpp). Protocol::handle() validates the
|
||||
// request keys per command (check_keys / check_command_keys), then calls the CareerSession
|
||||
// and the same projection functions the SDL front end uses (desk, table, mail, tactics,
|
||||
// training, camp, bank, stadium, kickoff, save/load, ...), and wraps the result with the
|
||||
// current revision. Errors are returned as {"ok": false, "error": ...}, never thrown to the
|
||||
// caller. The "replay" flag lets a logged session be played again (saves may overwrite).
|
||||
// text_request()/text_response() implement the one-line text form of the protocol.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "cli/protocol.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The JSON line protocol of openbmh_cli (the non-console mode): one request object with a
|
||||
// "cmd" field in, one response object ("ok", "revision", result or error) out. Protocol owns
|
||||
// one app::CareerSession (created by "new" or "load") and the revision counter that every
|
||||
// state-changing command must echo back, so stale requests are refused like in the UI
|
||||
// flow. text_request()/text_response() translate a simple one-line text form to and from the
|
||||
// same JSON. Implemented in protocol.cpp; Protocol::help() lists the commands.
|
||||
#pragma once
|
||||
|
||||
#include "cli/json.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of SeatHub (seat_hub.hpp): routes the blocks of several clients into one
|
||||
// console::Console. It runs a block as the seat's manager ("@k"), classifies each output
|
||||
// line with Console::LineInfo, queues lines that concern other seats as their "meanwhile"
|
||||
// feed, holds WaitTurn blocks until they can be answered, and holds the Run/Step of a live
|
||||
// match until every seat has sent one. State per seat is a small Seat record; the game
|
||||
// itself lives in the console.
|
||||
#include "cli/seat_hub.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Decides which club badge tokens the original draws as a fallback instead of an individual
|
||||
// crest. The cut-off for foreign clubs differs between game editions, so it is read from one
|
||||
// instruction in the loaded executable (layout::ForeignBadgeGateInstruction) and stored in the
|
||||
// process-wide original_foreign_badge_end by install_original_badge_policy(). An executable
|
||||
// that does not match the verified pattern falls back to 138. Header-only; the club
|
||||
// selectors themselves stay in the database and savegame data.
|
||||
#pragma once
|
||||
|
||||
#include "formats/executable_layout.hpp"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the basic file helpers declared in binary.hpp: read_file() loads a whole
|
||||
// file into a Bytes vector (FormatError if it cannot be opened) and iso646de_to_utf8()
|
||||
// converts the game's ISO 646-DE strings ([ \ ] { | } ~ stand for the umlauts and the sharp s)
|
||||
// to UTF-8. No state.
|
||||
#include "formats/binary.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,169 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of diamond_image.hpp: the images built from the embedded numbers of the generated .inc files plus the
|
||||
// texts of openbmh.dat.
|
||||
#include "formats/diamond_image.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <system_error>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#elif defined(__APPLE__)
|
||||
#include <mach-o/dyld.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace bmh {
|
||||
|
||||
namespace {
|
||||
|
||||
struct Chunk { uint32_t address; uint32_t size; const uint8_t* bytes; };
|
||||
struct Range { uint32_t address; uint32_t length; };
|
||||
|
||||
namespace german {
|
||||
#include "formats/diamond_constants.inc"
|
||||
} // namespace german
|
||||
namespace english {
|
||||
#include "formats/fltd_constants.inc"
|
||||
} // namespace english
|
||||
|
||||
constexpr char kMagic[12] = "OPENBMH-DAT"; // 11 characters and the NUL
|
||||
constexpr char kFileName[] = "openbmh.dat";
|
||||
|
||||
std::string lower(std::string s) {
|
||||
for (char& c : s) c = char(std::tolower(static_cast<unsigned char>(c)));
|
||||
return s;
|
||||
}
|
||||
|
||||
uint32_t word(const Bytes& b, size_t at) {
|
||||
if (at + 4 > b.size()) throw FormatError("openbmh.dat: truncated");
|
||||
return uint32_t(b[at]) | uint32_t(b[at + 1]) << 8 | uint32_t(b[at + 2]) << 16 | uint32_t(b[at + 3]) << 24;
|
||||
}
|
||||
|
||||
LeImage build(uint32_t base, uint32_t size, const Chunk* first, const Chunk* last) {
|
||||
Bytes bytes(size, 0);
|
||||
for (const Chunk* chunk = first; chunk != last; ++chunk)
|
||||
std::copy(chunk->bytes, chunk->bytes + chunk->size, bytes.begin() + (chunk->address - base));
|
||||
return LeImage::from_bytes(base, std::move(bytes));
|
||||
}
|
||||
|
||||
std::filesystem::path executable_directory() {
|
||||
std::error_code ec;
|
||||
#ifdef _WIN32
|
||||
wchar_t buffer[32768];
|
||||
const DWORD n = GetModuleFileNameW(nullptr, buffer, DWORD(std::size(buffer)));
|
||||
if (n == 0 || n >= std::size(buffer)) return {};
|
||||
return std::filesystem::path(buffer).parent_path();
|
||||
#elif defined(__APPLE__)
|
||||
char buffer[4096];
|
||||
uint32_t size = sizeof buffer;
|
||||
if (_NSGetExecutablePath(buffer, &size) != 0) return {};
|
||||
return std::filesystem::weakly_canonical(buffer, ec).parent_path();
|
||||
#else
|
||||
char buffer[4096];
|
||||
const ssize_t n = readlink("/proc/self/exe", buffer, sizeof buffer - 1);
|
||||
if (n <= 0) return {};
|
||||
buffer[n] = 0;
|
||||
return std::filesystem::path(buffer).parent_path();
|
||||
#endif
|
||||
}
|
||||
|
||||
std::filesystem::path file_in(const std::filesystem::path& directory) {
|
||||
if (directory.empty()) return {};
|
||||
std::error_code ec;
|
||||
for (const auto& entry : std::filesystem::directory_iterator(directory, ec))
|
||||
if (entry.is_regular_file(ec) && lower(entry.path().filename().string()) == kFileName) return entry.path();
|
||||
return {};
|
||||
}
|
||||
|
||||
void add_texts(LeImage& image, int edition, const std::filesystem::path& game_directory) {
|
||||
const auto file = find_texts_file(game_directory);
|
||||
if (file.empty()) return;
|
||||
try {
|
||||
apply_texts(image, edition, read_file(file));
|
||||
} catch (const std::exception&) {
|
||||
// a damaged texts file leaves the texts empty; the game itself still runs
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::filesystem::path find_texts_file(const std::filesystem::path& game_directory) {
|
||||
if (const char* env = std::getenv("OPENBMH_DAT"); env && *env) {
|
||||
if (std::string_view(env) == "-") return {}; // "no texts file at all" (tests of the launcher)
|
||||
std::error_code ec;
|
||||
if (std::filesystem::is_regular_file(env, ec)) return env;
|
||||
}
|
||||
for (const auto& directory : {game_directory, executable_directory(), std::filesystem::path(".")})
|
||||
if (auto file = file_in(directory); !file.empty()) return file;
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string texts_signature(const std::filesystem::path& game_directory) {
|
||||
const auto file = find_texts_file(game_directory);
|
||||
if (file.empty()) return {};
|
||||
try {
|
||||
const Bytes data = read_file(file);
|
||||
uint64_t hash = 1469598103934665603ull; // FNV-1a
|
||||
for (uint8_t b : data) hash = (hash ^ b) * 1099511628211ull;
|
||||
return std::to_string(data.size()) + "-" + std::to_string(hash);
|
||||
} catch (const std::exception&) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
bool apply_texts(LeImage& image, int edition, const Bytes& file) {
|
||||
if (file.size() < sizeof kMagic + 4 || !std::equal(kMagic, kMagic + sizeof kMagic, file.begin()))
|
||||
throw FormatError("openbmh.dat: not an OpenBMH data file");
|
||||
const Range* known = edition == 1 ? std::begin(german::kTextRanges) : std::begin(english::kTextRanges);
|
||||
const Range* known_end = edition == 1 ? std::end(german::kTextRanges) : std::end(english::kTextRanges);
|
||||
const uint32_t sets = word(file, sizeof kMagic);
|
||||
if (sets > 16) throw FormatError("openbmh.dat: too many sets");
|
||||
size_t at = sizeof kMagic + 4;
|
||||
bool found = false;
|
||||
for (uint32_t s = 0; s < sets; ++s) {
|
||||
const uint32_t id = word(file, at), count = word(file, at + 4);
|
||||
if (count > 65536) throw FormatError("openbmh.dat: too many ranges");
|
||||
const size_t table = at + 8;
|
||||
size_t data = table + size_t(count) * 8;
|
||||
for (uint32_t n = 0; n < count; ++n) {
|
||||
const uint32_t address = word(file, table + n * 8ull), length = word(file, table + n * 8ull + 4);
|
||||
if (data + length > file.size()) throw FormatError("openbmh.dat: truncated");
|
||||
if (int(id) == edition) {
|
||||
const bool allowed = std::any_of(known, known_end,
|
||||
[&](const Range& r) { return r.address == address && length <= r.length; });
|
||||
if (!allowed) throw FormatError("openbmh.dat: a range is not a text of the game");
|
||||
image.patch(address, file.data() + data, length);
|
||||
found = true;
|
||||
}
|
||||
data += length;
|
||||
}
|
||||
at = data;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
LeImage diamond_constants_image(const std::filesystem::path& game_directory) {
|
||||
LeImage image = build(german::kImageBase, german::kImageSize, std::begin(german::kChunks), std::end(german::kChunks));
|
||||
add_texts(image, 1, game_directory);
|
||||
return image;
|
||||
}
|
||||
|
||||
LeImage english_constants_image(const std::filesystem::path& game_directory) {
|
||||
LeImage image = build(english::kImageBase, english::kImageSize, std::begin(english::kChunks), std::end(english::kChunks));
|
||||
add_texts(image, 2, game_directory);
|
||||
return image;
|
||||
}
|
||||
|
||||
bool is_executable_name(const std::filesystem::path& file_name) { return lower(file_name.string()) == "bmh.exe"; }
|
||||
|
||||
} // namespace bmh
|
||||
@@ -0,0 +1,48 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The game without BMH.exe and FLTD.EXE: OpenBMH carries the numbers of the Diamond 3.7 executable (tables, rates,
|
||||
// positions, prices; the generated formats/diamond_constants.inc) and of the English Football Limited
|
||||
// (formats/fltd_constants.inc) and needs only the asset files of the game. The game texts that live in the executables
|
||||
// (live commentary, messages) are not part of the source: they are in the data file openbmh.dat, which ships with the
|
||||
// release next to the programs (tools/diamond_constants/generate.py makes it). Without that file those texts are empty.
|
||||
//
|
||||
// load_le() returns diamond_constants_image() for a BMH.exe that does not exist, so every reader of the executable image
|
||||
// works unchanged. A BMH.exe that is there is used as before (it carries its own edition's numbers and texts). For an
|
||||
// English installation the launcher (launch/fltd.cpp) writes english_constants_image() as the image of the game
|
||||
// directory when FLTD.EXE is missing.
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
// openbmh.dat: "OPENBMH-DAT" NUL, u32 set count, then per set u32 edition (1 German, 2 English), u32 range count, count
|
||||
// times (u32 address, u32 length), then the bytes of all ranges. A range must be one of the edition's text ranges, so
|
||||
// the file can never change a number of the image.
|
||||
//
|
||||
// The file is looked for in: the environment variable OPENBMH_DAT ("-" = none at all), the folder of the game data, the folder of the
|
||||
// running program, the current folder. Returns an empty path when there is none.
|
||||
std::filesystem::path find_texts_file(const std::filesystem::path& game_directory);
|
||||
|
||||
// A short text that changes when the texts file changes (empty without a file): used to rebuild cached English games.
|
||||
std::string texts_signature(const std::filesystem::path& game_directory);
|
||||
|
||||
// The German (Diamond 3.7) image built from the embedded numbers plus the texts of openbmh.dat (found for
|
||||
// `game_directory`).
|
||||
LeImage diamond_constants_image(const std::filesystem::path& game_directory = {});
|
||||
|
||||
// The English Football Limited image in the German address space (what launch::translate_fltd() makes from
|
||||
// FLTD.EXE), built from the embedded numbers plus the texts of openbmh.dat.
|
||||
LeImage english_constants_image(const std::filesystem::path& game_directory = {});
|
||||
|
||||
// Puts the texts of an openbmh.dat file (edition 1 or 2) into `image`. Throws FormatError for malformed data or for a
|
||||
// range that is not a text range of that edition. Returns false when the file has no set of that edition.
|
||||
bool apply_texts(LeImage& image, int edition, const Bytes& file);
|
||||
|
||||
// Whether `file_name` is the name of the executable (BMH.exe in any case).
|
||||
bool is_executable_name(const std::filesystem::path& file_name);
|
||||
|
||||
} // namespace bmh
|
||||
@@ -1415,6 +1415,10 @@ inline constexpr auto Month_ReturnLoans_TextPointer7 = 0xaee44;
|
||||
inline constexpr auto Month_ReturnLoans_TextPointer8 = 0xaee48;
|
||||
inline constexpr auto Month_SearchProfileNews_TextPointer = 0xaedd8;
|
||||
inline constexpr auto Month_SearchProfileNews_TextPointer2 = 0xaf254;
|
||||
inline constexpr auto Month_SearchProfileNews_TextPointer3 = 0xaf258; // ending of the message box after "Suchen"
|
||||
inline constexpr auto Month_SearchProfileNews_TextPointer4 = 0xaf25c; // "Ihre Scouting-Abteilung ...": shown first when the dialog is confirmed
|
||||
inline constexpr auto TransferMarket_WithdrawQuestion_TextPointer = 0xaf2a4; // "Wollen Sie " (+ player name)
|
||||
inline constexpr auto TransferMarket_WithdrawQuestion_TextPointer2 = 0xaf2a8; // " vom Transfermarkt holen?"
|
||||
inline constexpr auto NationalFriendlyPayerPrefixText = 0xa000f;
|
||||
inline constexpr auto NextDeskManager = 0xbd6cc;
|
||||
inline constexpr auto NoClubText = 0xaec74;
|
||||
@@ -1915,6 +1919,10 @@ inline constexpr auto TransferMarket_Rect_TextPointer2 = 0xa0045;
|
||||
inline constexpr auto TransferMarket_Rect_TextPointer3 = 0xae148;
|
||||
inline constexpr auto TransferMarket_Rect_TextPointer4 = 0xae14c;
|
||||
inline constexpr auto TransferMarket_Rect_TextPointer5 = 0xae150;
|
||||
// Search dialog (buttons Suchen / Vorschlag): seven 5-byte rows (y, step in px, cells, slider flag, profile offset)
|
||||
// and the text pointer of its confirm button.
|
||||
inline constexpr auto TransferMarket_SearchRows_RuntimeField = 0xa20fb;
|
||||
inline constexpr auto TransferMarket_SearchButton_TextPointer = 0xae144;
|
||||
inline constexpr auto TransferMarket_Rect_TextPointer6 = 0xaecac;
|
||||
inline constexpr auto TransferMarket_Rect_TextPointer7 = 0xaf250;
|
||||
inline constexpr auto TransferMarket_Render_TextPointer = 0xaf264;
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the .FBM savegame container (fbm.hpp): fbm_encrypt()/fbm_decrypt() are the
|
||||
// stream cipher whose key changes by 0x29 per byte, and load_savegame() finds the "KRON_FBM"
|
||||
// magic, splits the plain header from the encrypted stream, decrypts it and verifies the
|
||||
// one-byte checksum, which is reported in Savegame::checksum_ok (not thrown). The decrypted
|
||||
// stream is interpreted by savestate.cpp. Pure functions, no state.
|
||||
#include "formats/fbm.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the .FNT bitmap font loader and renderer (font.hpp): load_font() reads
|
||||
// the header, the 1-bit glyph bitmap and the per-character location (and spacing) tables and
|
||||
// checks that the file size matches exactly; Font::glyph(), text_width() and draw() look up
|
||||
// glyphs (out-of-range characters use the last glyph) and draw them into an indexed Image.
|
||||
// No state beyond the Font object.
|
||||
#include "formats/font.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
+71
-1
@@ -1,7 +1,16 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the executable image loader (le.hpp): load_le() reads the original
|
||||
// DOS/4GW LE executable, places its objects at their link addresses and applies the internal
|
||||
// fixups (FormatError for other files or external fixups). It also accepts the OpenBMH image
|
||||
// format written by save_image(), so a translated image can replace the executable.
|
||||
// LeImage::cstring() reads NUL-terminated strings from the image. No global state.
|
||||
#include "formats/le.hpp"
|
||||
|
||||
#include "formats/diamond_image.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
@@ -17,10 +26,63 @@ struct Object {
|
||||
|
||||
std::string LeImage::cstring(uint32_t address) const {
|
||||
std::string s;
|
||||
while (contains(address) && u8(address) != 0) s.push_back(char(u8(address++)));
|
||||
const uint32_t first = address;
|
||||
while (contains(address) && bytes_[address - base_] != 0) s.push_back(char(bytes_[address++ - base_]));
|
||||
if (le_trace::hook) le_trace::hook(first, uint32_t(s.size()) + 1, 't');
|
||||
return s;
|
||||
}
|
||||
|
||||
namespace le_trace {
|
||||
void (*hook)(uint32_t, uint32_t, char) = nullptr;
|
||||
|
||||
namespace {
|
||||
// One flag byte per image address: 1 number read, 2 string read, 4 start of a bulk read.
|
||||
std::vector<uint8_t>& marks() {
|
||||
static std::vector<uint8_t> value(0x100000, 0);
|
||||
return value;
|
||||
}
|
||||
std::string& trace_path() {
|
||||
static std::string value;
|
||||
return value;
|
||||
}
|
||||
void record(uint32_t address, uint32_t length, char kind) {
|
||||
auto& m = marks();
|
||||
const uint8_t flag = kind == 'n' ? 1 : kind == 't' ? 2 : 4;
|
||||
if (address < 0x10000 || address - 0x10000 >= m.size()) return;
|
||||
if (length == 0) length = 1;
|
||||
for (uint32_t i = 0; i < length && address - 0x10000 + i < m.size(); ++i) m[address - 0x10000 + i] |= flag;
|
||||
}
|
||||
// Appends the marked ranges ("<flag> <start> <length>" in hex, one per line) to the trace file.
|
||||
void flush() {
|
||||
if (trace_path().empty()) return;
|
||||
std::ofstream out(trace_path(), std::ios::app);
|
||||
const auto& m = marks();
|
||||
for (uint8_t flag : {uint8_t(1), uint8_t(2), uint8_t(4)}) {
|
||||
size_t i = 0;
|
||||
while (i < m.size()) {
|
||||
if (!(m[i] & flag)) { ++i; continue; }
|
||||
size_t j = i;
|
||||
while (j < m.size() && (m[j] & flag)) ++j;
|
||||
out << std::hex << unsigned(flag) << ' ' << (i + 0x10000) << ' ' << (j - i) << '\n';
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void enable_from_environment() {
|
||||
static bool done = false;
|
||||
if (done) return;
|
||||
done = true;
|
||||
if (const char* path = std::getenv("OPENBMH_LE_TRACE"); path && *path) {
|
||||
trace_path() = path;
|
||||
(void)marks(); // constructed before atexit(flush) is registered, so it is destroyed after flush has run
|
||||
hook = record;
|
||||
std::atexit(flush);
|
||||
}
|
||||
}
|
||||
} // namespace le_trace
|
||||
|
||||
namespace {
|
||||
constexpr char kImageMagic[14] = "OPENBMH-IMAGE"; // 13 characters and the NUL
|
||||
}
|
||||
@@ -36,6 +98,14 @@ void save_image(const LeImage& image, const std::filesystem::path& path) {
|
||||
}
|
||||
|
||||
LeImage load_le(const std::filesystem::path& path) {
|
||||
le_trace::enable_from_environment();
|
||||
// The game runs from its asset files alone: for a BMH.exe that is not there the embedded numbers of the Diamond 3.7 executable
|
||||
// and the texts of openbmh.dat stand in for it.
|
||||
{
|
||||
std::error_code ec;
|
||||
if (is_executable_name(path.filename()) && !std::filesystem::exists(path, ec))
|
||||
return diamond_constants_image(path.has_parent_path() ? path.parent_path() : std::filesystem::path("."));
|
||||
}
|
||||
const Bytes raw = read_file(path);
|
||||
if (raw.size() >= sizeof kImageMagic + 8 && std::equal(kImageMagic, kImageMagic + sizeof kImageMagic, raw.begin())) {
|
||||
const auto word = [&](size_t at) { return uint32_t(raw[at] | raw[at + 1] << 8 | raw[at + 2] << 16) | uint32_t(raw[at + 3]) << 24; };
|
||||
|
||||
+16
-2
@@ -16,19 +16,33 @@
|
||||
|
||||
namespace bmh {
|
||||
|
||||
// Read recording for building the embedded constants (formats/diamond_constants.inc): when the environment variable
|
||||
// OPENBMH_LE_TRACE names a file, every image read is noted (numbers, strings, bulk pointers) and appended to that
|
||||
// file when the program ends. Without the variable the hook is a null pointer and costs one branch per read.
|
||||
namespace le_trace {
|
||||
extern void (*hook)(uint32_t address, uint32_t length, char kind); // kind: 'n' number, 't' string, 'b' bulk pointer
|
||||
void enable_from_environment();
|
||||
} // namespace le_trace
|
||||
|
||||
class LeImage {
|
||||
public:
|
||||
uint32_t base() const { return base_; }
|
||||
uint32_t size() const { return uint32_t(bytes_.size()); }
|
||||
bool contains(uint32_t address) const { return address >= base_ && address - base_ < bytes_.size(); }
|
||||
uint8_t u8(uint32_t address) const { return bytes_.at(address - base_); }
|
||||
uint8_t u8(uint32_t address) const {
|
||||
if (le_trace::hook) le_trace::hook(address, 1, 'n');
|
||||
return bytes_.at(address - base_);
|
||||
}
|
||||
uint16_t u16(uint32_t address) const { return uint16_t(u8(address) | u8(address + 1) << 8); }
|
||||
uint32_t u32(uint32_t address) const { return uint32_t(u16(address)) | uint32_t(u16(address + 2)) << 16; }
|
||||
// A NUL terminated string at `address` (ISO 646-DE bytes, see textd.hpp).
|
||||
std::string cstring(uint32_t address) const;
|
||||
// The string a pointer variable at `address` points to (e.g. Weekly_AdvertisingOffers_TextPointer).
|
||||
std::string string_at_pointer(uint32_t address) const { return cstring(u32(address)); }
|
||||
const uint8_t* data(uint32_t address) const { return bytes_.data() + (address - base_); }
|
||||
const uint8_t* data(uint32_t address) const {
|
||||
if (le_trace::hook) le_trace::hook(address, 0, 'b');
|
||||
return bytes_.data() + (address - base_);
|
||||
}
|
||||
// Overwrites bytes inside a prepared image for verified address translation.
|
||||
void patch(uint32_t address, const uint8_t* bytes, size_t count) {
|
||||
for (size_t i = 0; i < count; ++i) bytes_.at(address - base_ + i) = bytes[i];
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Reads from the loaded executable how many league levels a player can see; the original
|
||||
// separates internal domestic league slots from these visible levels. Throws
|
||||
// std::invalid_argument when the stored constants fail the sanity check. Header-only,
|
||||
// stateless; the address comes from executable_layout.hpp and the image from le.hpp.
|
||||
#pragma once
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the M3D.MAN master database loader (m3d.hpp). load_database() reads the
|
||||
// file sequentially with a bounds-checked Reader: first the lengths of the four string pools
|
||||
// (clubs, players, referees, stadiums), then the pools, the name offset tables and the raw
|
||||
// record blocks, whose sizes depend on the DbCounts passed in. Several blocks are kept as raw
|
||||
// bytes in the Database (raw_* fields). Throws FormatError on a truncated file.
|
||||
#include "formats/m3d.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Accepted savegame version markers for the native (original-layout) save format. The FBM
|
||||
// container (fbm.hpp) carries a version string; V2.24 and V3.7 share the same block order,
|
||||
// while expanded careers use their own marker (O1.1) and layout. require_native_savegame()
|
||||
// throws FormatError on a bad checksum or an unsupported marker; callers still validate the
|
||||
// full state layout afterwards (savestate.hpp). Header-only.
|
||||
#pragma once
|
||||
#include "formats/fbm.hpp"
|
||||
#include <string_view>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the palette loader (palette.hpp). load_palette() reads a 256-entry,
|
||||
// 6 bits per channel RGB file and converts it to 32-bit ARGB via vga_dac_rgb8();
|
||||
// load_optional_embedded_palette() reads the palette that may follow the RLE data of a VGA
|
||||
// image file (std::nullopt if there is none); Palette::nearest() returns the index of the
|
||||
// closest colour by squared RGB distance. FormatError on short or inconsistent files.
|
||||
#include "formats/palette.hpp"
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the savegame stream layout (savestate.hpp). save_layout() lists the
|
||||
// blocks in the exact order the original wrote them, with sizes that are constants or depend
|
||||
// on DbCounts; the SaveState constructor splits a decrypted stream along that list, reads
|
||||
// the four string-pool trailer blocks and the optional OpenBMH extension, and throws
|
||||
// FormatError if the sizes do not add up. append_save_extension() writes that extension.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/savestate.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the TEXTD.BLK loader (textd.hpp): skips the 7-byte header, keeps the whole
|
||||
// blob and splits it into NUL-terminated strings, recording each string's offset. Exactly
|
||||
// TEXT_COUNT strings must be found, otherwise FormatError. No state.
|
||||
#include "formats/textd.hpp"
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the .VGA image support (vga.hpp): Image::blit() copies one indexed image
|
||||
// into another with clipping, decode_vga() unpacks the run-length data (a byte of 0x80 or
|
||||
// more is a run, below that a literal block) and checks the length fields and the single
|
||||
// trailing byte, and load_vga() reads a file and decodes it. FormatError on malformed data.
|
||||
#include "formats/vga.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Business plan (balance plan) screen of a human manager: builds a draft of the plan rows
|
||||
// (income, running costs, shares and loans, catering, ticket price), checks per-row maxima when
|
||||
// the player edits a row and writes the accepted plan back on close.
|
||||
// Reads and writes the manager records in GameState (manager_records); reads schedule, table and
|
||||
// prediction data for the forecast. Draws no random numbers.
|
||||
// Interface in balance_plan.hpp; monthly bookings of similar figures live in month.cpp / week.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/balance_plan.hpp"
|
||||
@@ -30,7 +36,7 @@ constexpr uint16_t kFacilityCost[22] = {2000, 3000, 3000, 8000, 4000, 3000, 2500
|
||||
// BalancePlanRuntimeField6: monthly income of the first six facilities (FacilityIncome)
|
||||
constexpr uint16_t kFacilityIncome[6] = {0, 5000, 5000, 4800, 2400, 8000};
|
||||
// BalancePlanRuntimeField7: catering income per visitor of the facilities 0-13 (BookMoney)
|
||||
constexpr uint8_t kPerVisitor[14] = {0, 10, 10, 3, 5, 15, 3, 3, 3, 3, 2, 2, 2, 2};
|
||||
constexpr uint8_t kPerVisitor[14] = {0, 10, 15, 3, 5, 10, 3, 3, 3, 3, 2, 2, 2, 2}; // Diamond 3.7 (entries 2 and 5 were 10 and 15)
|
||||
// Rec32: price units of the six funds (BMH.exe+MonthRuntimeField10)
|
||||
constexpr int32_t kShareUnits[6] = {15, 18, 21, 24, 27, 30};
|
||||
|
||||
|
||||
+109
-11
@@ -1,7 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Bank credit dialog: loans from the bank or from another manager, held in the per-manager loan
|
||||
// matrix of the manager records. Implements the amount/fee/monthly-payment arithmetic (with the
|
||||
// original's extended-precision rounding emulated in integers), draft editing with bounds, and
|
||||
// the interest-rate change. Reads the manager records and executable tables via BankCreditContext;
|
||||
// only change_bank_credit_interest writes GameState here. Draws no random numbers.
|
||||
// Types are declared in bank_credit.hpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/bank_credit.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
@@ -29,6 +36,102 @@ uint32_t read_record(const GameState& g, size_t at) {
|
||||
for (int i = 0; i < 4; ++i) v |= uint32_t(g.manager_records.at(at + i)) << (i * 8);
|
||||
return v;
|
||||
}
|
||||
// The original evaluates ((base / 100) * den) / 100 on the x87 stack: every step is rounded to a
|
||||
// 64-bit mantissa (round to nearest even), only the final store rounds to a 53-bit double. The
|
||||
// host's long double is not that format (64 bits on MSVC and on Apple silicon), which changed the
|
||||
// result by 1 for loans of about a million and more. This evaluates the same chain exactly with
|
||||
// integers, so the result is the same on every platform. Returns the value truncated toward zero.
|
||||
struct Wide { // 128-bit unsigned, little-endian 32-bit limbs
|
||||
std::array<uint32_t, 4> l{};
|
||||
unsigned bit_length() const {
|
||||
for (int i = 3; i >= 0; --i)
|
||||
if (l[size_t(i)]) return unsigned(i) * 32 + unsigned(32 - std::countl_zero(l[size_t(i)]));
|
||||
return 0;
|
||||
}
|
||||
bool bit(unsigned n) const { return n < 128 && (l[n / 32] >> (n % 32)) & 1u; }
|
||||
bool any_below(unsigned n) const { // any bit below position n set
|
||||
for (unsigned i = 0; i < n && i < 128; ++i) if (bit(i)) return true;
|
||||
return false;
|
||||
}
|
||||
static Wide from(uint64_t v) { Wide w; w.l[0] = uint32_t(v); w.l[1] = uint32_t(v >> 32); return w; }
|
||||
uint64_t window(unsigned lo) const { // the 64 bits starting at bit `lo`
|
||||
uint64_t v = 0;
|
||||
for (unsigned i = 0; i < 64; ++i) if (bit(lo + i)) v |= uint64_t(1) << i;
|
||||
return v;
|
||||
}
|
||||
};
|
||||
struct Extended { uint64_t m = 0; int e = 0; }; // value = m * 2^e, m has 64 bits (or is zero)
|
||||
// Round `w` (plus a "something was dropped" flag) to 64 bits, nearest even; value = w * 2^exp.
|
||||
Extended round_to_64(const Wide& w, bool sticky, int exp) {
|
||||
const unsigned len = w.bit_length();
|
||||
Extended r;
|
||||
if (len == 0) return r;
|
||||
if (len <= 64) {
|
||||
const unsigned up = 64 - len;
|
||||
r.m = w.window(0) << up;
|
||||
r.e = exp - int(up);
|
||||
return r;
|
||||
}
|
||||
const unsigned s = len - 64;
|
||||
r.m = w.window(s);
|
||||
const bool guard = w.bit(s - 1), rest = sticky || w.any_below(s - 1);
|
||||
r.e = exp + int(s);
|
||||
if (guard && (rest || (r.m & 1))) {
|
||||
if (++r.m == 0) { r.m = uint64_t(1) << 63; ++r.e; }
|
||||
}
|
||||
return r;
|
||||
}
|
||||
Extended x87_divide_small(const Extended& a, uint32_t d) {
|
||||
Wide n; // a.m * 2^64, divided limb by limb
|
||||
n.l[2] = uint32_t(a.m); n.l[3] = uint32_t(a.m >> 32);
|
||||
uint64_t rem = 0;
|
||||
Wide q;
|
||||
for (int i = 3; i >= 0; --i) {
|
||||
const uint64_t cur = (rem << 32) | n.l[size_t(i)];
|
||||
q.l[size_t(i)] = uint32_t(cur / d);
|
||||
rem = cur % d;
|
||||
}
|
||||
return round_to_64(q, rem != 0, a.e - 64);
|
||||
}
|
||||
Extended x87_multiply_small(const Extended& a, uint32_t b) {
|
||||
Wide p;
|
||||
uint64_t carry = 0;
|
||||
const uint32_t limb[2] = {uint32_t(a.m), uint32_t(a.m >> 32)};
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
const uint64_t cur = uint64_t(limb[i]) * b + carry;
|
||||
p.l[size_t(i)] = uint32_t(cur);
|
||||
carry = cur >> 32;
|
||||
}
|
||||
p.l[2] = uint32_t(carry);
|
||||
return round_to_64(p, false, a.e);
|
||||
}
|
||||
// ((base / 100) * den) / 100 stored as a double and truncated toward zero. `zero` reports an exact
|
||||
// zero before truncation (the original's "exact zero becomes 1" rule looks at the stored double).
|
||||
int64_t x87_amount_chain(int32_t base, uint32_t den, bool& zero) {
|
||||
zero = base == 0 || den == 0;
|
||||
if (zero) return 0;
|
||||
const bool negative = base < 0;
|
||||
const uint64_t magnitude = negative ? uint64_t(-int64_t(base)) : uint64_t(base);
|
||||
Extended v = round_to_64(Wide::from(magnitude), false, 0);
|
||||
v = x87_divide_small(v, 100);
|
||||
v = x87_multiply_small(v, den);
|
||||
v = x87_divide_small(v, 100);
|
||||
// store as double: 53-bit mantissa, nearest even
|
||||
uint64_t m53 = v.m >> 11;
|
||||
int e = v.e + 11;
|
||||
const bool guard = (v.m >> 10) & 1, rest = (v.m & 0x3ff) != 0;
|
||||
if (guard && (rest || (m53 & 1))) ++m53; // a carry to 2^53 is still exact
|
||||
uint64_t whole;
|
||||
if (e >= 0) {
|
||||
if (e > 10) throw std::invalid_argument("invalid native credit amount");
|
||||
whole = m53 << e;
|
||||
} else {
|
||||
whole = -e >= 64 ? 0 : m53 >> unsigned(-e);
|
||||
}
|
||||
if (whole > uint64_t(std::numeric_limits<int32_t>::max()) + (negative ? 1u : 0u))
|
||||
throw std::invalid_argument("invalid native credit amount");
|
||||
return negative ? -int64_t(whole) : int64_t(whole);
|
||||
}
|
||||
// Amount: signed IMUL/IDIV, x87 intermediate, QWORD store,
|
||||
// exact-zero floor, then Amount2's explicit rounding toward zero.
|
||||
int32_t amount(const BankCreditContext& c, uint32_t months, int32_t principal) {
|
||||
@@ -37,15 +140,10 @@ int32_t amount(const BankCreditContext& c, uint32_t months, int32_t principal) {
|
||||
const int32_t factor = c.rate_table[months];
|
||||
const int32_t base = divide(mul(principal, factor), 100);
|
||||
const int32_t den = divide(10000, factor - 100);
|
||||
const long double intermediate = (static_cast<long double>(base) / c.divisor)
|
||||
* den / c.divisor;
|
||||
double raw = static_cast<double>(intermediate);
|
||||
if (raw == 0 && principal != 0) raw = 1;
|
||||
raw = std::trunc(raw);
|
||||
if (!std::isfinite(raw) || raw < std::numeric_limits<int32_t>::min()
|
||||
|| raw > std::numeric_limits<int32_t>::max())
|
||||
throw std::invalid_argument("invalid native credit amount");
|
||||
return static_cast<int32_t>(raw);
|
||||
bool zero = false;
|
||||
int64_t result = x87_amount_chain(base, uint32_t(den), zero);
|
||||
if (zero && principal != 0) result = 1;
|
||||
return static_cast<int32_t>(result);
|
||||
}
|
||||
void balance(const BankCreditContext& c, BankCreditDraft& d) {
|
||||
int32_t result = add(c.cash, signed_word(d.values[0]));
|
||||
@@ -136,7 +234,7 @@ BankCreditBounds bank_credit_bounds(const BankCreditContext& c, const BankCredit
|
||||
int32_t lo = 0, hi = 0;
|
||||
if (field == 0) {
|
||||
lo = 1000;
|
||||
hi = sub(12000000, accrued);
|
||||
hi = sub(8000000, accrued); // Diamond 3.7: credit limit 8 million (12 million before)
|
||||
// case 5: no more than the lender can pay out (balance + credit line)
|
||||
if (c.counterparty && c.lender_liquidity < hi) hi = sub(c.lender_liquidity, accrued);
|
||||
}
|
||||
@@ -158,7 +256,7 @@ BankCreditBounds bank_credit_bounds(const BankCreditContext& c, const BankCredit
|
||||
if (field == 6) { hi = liquidity < accrued ? liquidity : signed_word(v[0]); }
|
||||
// Source checks availability before overriding the principal bounds.
|
||||
if (lo >= hi) return {};
|
||||
if (field == 0 && lo < signed_word(c.saved[0])) { lo = signed_word(c.saved[0]); hi = 12000000; }
|
||||
if (field == 0 && lo < signed_word(c.saved[0])) { lo = signed_word(c.saved[0]); hi = 8000000; }
|
||||
if (lo < 0 || hi < 0 || lo >= hi) return {};
|
||||
return {word(lo), word(hi), word(lo - (lo == 1)), true};
|
||||
} catch (const std::invalid_argument&) { return {}; }
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface of the bank credit dialog: context (rate table, liquidity, saved loan row), draft,
|
||||
// edit and bounds types plus the projection/edit functions implemented in bank_credit.cpp.
|
||||
// Case "bank" and case "another manager lends" share these types; projection and draft editing
|
||||
// are read-only with respect to GameState. No random numbers are drawn.
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Per-manager guard against repeated bank robbery events: one blocked month key per manager,
|
||||
// stored in an OpenBMH-owned extension block of the static memory in GameState (not in the
|
||||
// original save fields). The month key function is implemented in week.cpp.
|
||||
// Header-only accessors; no random numbers are drawn.
|
||||
#pragma once
|
||||
#include "game/state.hpp"
|
||||
#include <limits>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Calendar epoch (start year and weekday of the season calendar), read from the date setup code
|
||||
// of the loaded executable image. Unknown or unverified setups are rejected with FormatError.
|
||||
// Holds one process-wide installed epoch; reads no GameState and draws no random numbers.
|
||||
// Declared in calendar.hpp.
|
||||
#include "game/calendar.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface for the calendar epoch (start year and weekday) used for date calculations.
|
||||
// calendar_epoch_from_executable validates the loaded executable, install_calendar_rules makes it
|
||||
// active, calendar_epoch returns it (a synthetic default for isolated test states).
|
||||
// Implemented in calendar.cpp; no GameState access and no random numbers.
|
||||
#pragma once
|
||||
namespace bmh {
|
||||
class LeImage;
|
||||
|
||||
+9
-2
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Start of a new career: league strength ranges read from the executable, generation of players
|
||||
// (startup squads, the extra and market players), initial club moods and markets, the starting
|
||||
// state built from the data files, plus new-manager setup (stadium, sponsors, competition blocks).
|
||||
// Writes most of GameState (players, squad_slots, memory, manager records).
|
||||
// Draws from both generators: WatcomRandom for attributes and levels, GameRandom for the
|
||||
// reseeding done by stir_random and the mood reset.
|
||||
// Interface in career.hpp; the season-wide steps follow in season.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/career.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
@@ -403,7 +410,7 @@ void starting_sponsors(GameState& g, int m) {
|
||||
const size_t rec = size_t(m) * kRecord;
|
||||
int league = g.manager_records.at(rec + 0x210);
|
||||
if (league > 2) league--;
|
||||
const int v = (((league * -20 + 80) * 60000 + 1000000) / 12 * (mem.u8(::bmh::layout::Difficulty) * -5 + 0xaa)) / 3000000 * 10000;
|
||||
const int v = (((league * -20 + 80) * 60000 + 1000000) / 12 * (mem.u8(::bmh::layout::Difficulty) * -5 + 0x7d)) / 3000000 * 10000;
|
||||
for (size_t o : {size_t(0xae8), size_t(0xadc), size_t(0xa34)}) put32(g.manager_records, rec + o, uint32_t(v));
|
||||
for (size_t o : {size_t(0xaed), size_t(0xae1), size_t(0xa39)}) g.manager_records.at(rec + o) = 1;
|
||||
}
|
||||
@@ -560,7 +567,7 @@ bool career_add_manager(GameState& g, const LeImage& exe, int m, const CareerMan
|
||||
}
|
||||
for (size_t i = 0; i < 0x690; i++) g.manager_results.at(size_t(m) * 0x690 + i) = 0xff;
|
||||
const uint8_t level = mem.u8(::bmh::layout::Difficulty);
|
||||
const uint32_t money = level == 0 ? 50000000u : 4000000u - level * 200000u;
|
||||
const uint32_t money = level == 0 ? 50000000u : 3000000u - level * 200000u; // Diamond 3.7: 3 million start capital step base (4 million before)
|
||||
put32(r, rec + 0x314, money);
|
||||
put32(r, rec + 0x324, money);
|
||||
r.at(rec + 0x219) = r.at(rec + 0x218) = 0xf;
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Club information screen preparation: sets the line-up markers (first eleven / bench) in the
|
||||
// club's squad_slots, clears markers of injured players and applies the chosen player category.
|
||||
// Reads players and squad ranges, writes squad_slots in GameState. Draws no random numbers.
|
||||
// Interface in club_info.hpp; line-up rules themselves are in lineup.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/club_info.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Player detail screen opened from a club squad or the market pool: resolves the selection to a
|
||||
// squad slot, builds the context (loans, national nomination mode, pending offers) and runs the
|
||||
// actions the screen offers (market value, add to national squad, offers).
|
||||
// Reads and writes players, squad_slots and manager data in GameState.
|
||||
// Draws from WatcomRandom (market value, adding to a squad) and reseeds both generators via
|
||||
// stir_random. Interface in club_player_detail.hpp; related code in national.cpp and weekly.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/club_player_detail.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface of the player detail screen: selection and context types (squad vs market pool row,
|
||||
// loan data, national mode) and the functions implemented in club_player_detail.cpp.
|
||||
// Context building is read-only; actions take both generators (GameRandom, WatcomRandom) and
|
||||
// a MinuteReport, as documented at each declaration below.
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Cup competitions: Masters qualification, replay lists, group tables and qualifiers, friendly
|
||||
// preparation, national tournament end and the draw/advance step advance_cup for each round.
|
||||
// Works on the cup entries in the static memory of GameState and on MatchGroup results.
|
||||
// Draws from WatcomRandom (tie ordering) and GameRandom (shuffling the Masters field).
|
||||
// Interface in cup.hpp; matchday_setup.cpp creates the matches, driver.cpp and season.cpp are neighbours.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/cup.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Entering a human manager's desk: desk button table per game mode, the random stir, the table
|
||||
// prediction messages, the autosave hook and the manager's prestige (weighted sum of ratings and
|
||||
// money). Reads and writes manager records and the mailbox in GameState.
|
||||
// Draws from WatcomRandom (the four save draws) and reseeds both generators via stir_random.
|
||||
// Interface in desk.hpp; called from turn.cpp before each desk.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/desk.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface for entering a human manager's desk (the part before the desk screen appears):
|
||||
// enter_desk, the draws made when saving, and the prestige update.
|
||||
// Implemented in desk.cpp; uses both generators (GameRandom, WatcomRandom) as documented below.
|
||||
#pragma once
|
||||
// Entering a human manager's desk (DeskDate, the part before the desk screen).
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Actions a human manager can take at the desk: friendly match quotes and booking (including
|
||||
// the national team variant), training camp configuration, and the transfer offer editor
|
||||
// with bids and market previews.
|
||||
// Reads and writes manager records, memory (friendly plan, calendar), players and squad_slots.
|
||||
// Quotes draw from WatcomRandom on a staged copy that is committed only when accepted; booking
|
||||
// also handles GameRandom. Interface in desk_actions.hpp; bids are settled in weekly.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
|
||||
@@ -613,7 +619,7 @@ TransferActionResult submit_transfer_bid_impl(GameState& g, const TransferBidReq
|
||||
out.status = TransferActionStatus::blocked_by_board;
|
||||
return out;
|
||||
}
|
||||
const uint32_t fee_base = (g.memory.u32(entry + 0x2c) / 10000) * 0x30d4;
|
||||
const uint32_t fee_base = (g.memory.u32(entry + 0x2c) / 10000) * 10000; // Diamond 3.7: base 10000 per 10000 of value (12500 before)
|
||||
const uint32_t salary_base = ((uint32_t((request.contract_years - 1) * 20 + 100) * g.memory.u32(entry + 0x30)) / 10000) * 100;
|
||||
if (fee_base == 0 || salary_base == 0) {
|
||||
out.status = TransferActionStatus::offer_too_low;
|
||||
@@ -935,11 +941,11 @@ TransferActionResult submit_transfer_bid_source_impl(GameState& g, const Transfe
|
||||
bool dfb_fee = false;
|
||||
if (uint32_t(rand.range(92, request.poach ? 98 : 150)) >= fee_pct) {
|
||||
if (request.poach) {
|
||||
// The club refuses; as the player agreed, the DFB sets the fee to 188 % of his
|
||||
// market value (AddToSquad with 0xbc) and the buyer may pay it (PresentManagerDialog).
|
||||
// The club refuses; as the player agreed, the DFB sets the fee to 150 % of his
|
||||
// market value (AddToSquad with 0x96, Diamond 3.7; 188 % = 0xbc before) and the buyer may pay it (PresentManagerDialog).
|
||||
uint32_t fee = 0, salary = 0;
|
||||
const bool loan = (g.memory.u8(list + 0x34 + uint32_t(bid_slot)) & 0x80) != 0;
|
||||
market_value(g, request.source_slot, loan ? 1 : 0, 0xbc, fee, salary, 1, 0, rand);
|
||||
market_value(g, request.source_slot, loan ? 1 : 0, 0x96, fee, salary, 1, 0, rand);
|
||||
g.memory.set32(list + 0x1c + uint32_t(bid_slot) * 4, fee);
|
||||
const std::string question = message_text(g, ::bmh::layout::DeskActions_Unsupported_TextPointer4) + format_amount(g, std::bit_cast<int32_t>(fee)) +
|
||||
message_text(g, ::bmh::layout::DeskActions_Unsupported_TextPointer5);
|
||||
@@ -1228,7 +1234,7 @@ void editor_project(const GameState& g,TransferOfferEditorState& state) {
|
||||
} else {state.years=1;state.term=0;state.fee=0;state.salary=0;state.bonuses.fill(0);}
|
||||
// RateTransferBidSource: explicit byte years and Source32 unsigned products.
|
||||
const uint8_t year_index=state.editable?uint8_t((int(state.term&127)-1)/12):uint8_t(1);
|
||||
state.asking_fee=(g.memory.u32(list+0x2c)/10000u)*12500u;
|
||||
state.asking_fee=(g.memory.u32(list+0x2c)/10000u)*10000u;
|
||||
if(state.editable&&(state.term&128))state.asking_fee>>=2;
|
||||
state.asking_salary=((uint32_t(year_index)*20u+100u)*g.memory.u32(list+0x30)/10000u)*100u;
|
||||
state.money_profiles[0]=editor_profile(0,state.asking_fee*2u|0x40000000u,0xffffffffu,10000,0,state.asking_fee,::bmh::layout::DeskActions_EditorProject_RuntimeField);
|
||||
@@ -1594,7 +1600,7 @@ namespace bmh {
|
||||
namespace {
|
||||
|
||||
// StadiumPriceTable: base price of the 14 periphery objects.
|
||||
constexpr int32_t kPeripheryPrice[14] = {2500000, 1700000, 2200000, 1000000, 1100000, 1500000, 280000,
|
||||
constexpr int32_t kPeripheryPrice[14] = {2200000, 1700000, 2000000, 1000000, 1100000, 1800000, 280000,
|
||||
280000, 280000, 280000, 350000, 350000, 350000, 350000};
|
||||
// CareerSession_DispatchStadium_RuntimeField2[object * 5]: construction time in days.
|
||||
constexpr uint8_t kPeripheryDays[14] = {45, 30, 28, 40, 30, 20, 6, 6, 6, 6, 5, 5, 5, 5};
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Match day driver: plays the minutes of all match groups of a matchday in phases (first half,
|
||||
// second half, extra phases), shows or hides screens per button table and handles the phase end
|
||||
// (cup tie decisions, results, reseeding via stir_random).
|
||||
// Works on MatchGroup lists, GameState and the MatchEngine of match_engine.cpp.
|
||||
// Passes both generators on to the engine; itself only reseeds them at phase end.
|
||||
// Interface in driver.hpp; neighbours are matchday_setup.cpp and season.cpp.
|
||||
#include "game/driver.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Club environment budgets of a human manager (youth teams, academy, co-trainer, doctor,
|
||||
// physiotherapist): monthly cost per level, setting a level, and the youth team results and
|
||||
// season handover. Reads and writes the budget and youth blocks in the static memory of GameState.
|
||||
// advance_youth_teams draws from WatcomRandom; setting levels draws nothing.
|
||||
// Interface in environment.hpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface for the club environment budgets (youth teams, academy, co-trainer, doctor,
|
||||
// physiotherapist): item enum, monthly cost steps, state view and the functions implemented in
|
||||
// environment.cpp. Setting a level draws no random number; youth match results use WatcomRandom.
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// High-score table of the game: computes a manager's score from his record (assets, history,
|
||||
// titles), builds projections of the ranked table and reads/writes the five-row score file bytes.
|
||||
// Reads manager records in GameState; the file images are passed in and out as bytes.
|
||||
// Draws no random numbers. Interface in highscore.hpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/highscore.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface of the high-score table: row/table/projection types and the scoring and file
|
||||
// functions implemented in highscore.cpp. Names keep the original text encoding.
|
||||
// Reads GameState only; no random numbers are drawn.
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Types for completing the sale of a player to a human buyer (allocator gate, direct mode,
|
||||
// result status). The unsaved observations named here are supplied by the caller; missing
|
||||
// evidence means "unsupported", never an implicit default.
|
||||
// The matching settle_human_buyer_sale function is implemented in weekly.cpp and takes WatcomRandom.
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// League pairings screen: the fixture view of a league round (filtered, postponed and per team),
|
||||
// paging preferences and the computer tip (predicted results) for the shown round.
|
||||
// Reads and writes GameState (memory preferences, squad data) through the screen owner struct.
|
||||
// Computer tips use the game generator; closing the screen reseeds both generators via
|
||||
// stir_random. Interface in league_pairings.hpp; the tip arithmetic is shared with source_tip.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/league_pairings.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface of the league pairings screen: constants, owner state, tip result and view types
|
||||
// and the open/move/close functions implemented in league_pairings.cpp. No mutator here calls a
|
||||
// presenter, advances a day or saves; generators are passed in by the caller where needed.
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Line-up rules: position types per formation depth, player suitability values, automatic
|
||||
// line-up for computer teams and the optimizer for human boards, plus preparing the line-up
|
||||
// entry of a team. Reads players, formations and tactics boards; writes squad_slots and boards.
|
||||
// Draws from WatcomRandom in two places of the automatic selection (see the rand calls below).
|
||||
// Interface in lineup.hpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Long-career extension: per-club player statistics (appearances, goals, assists) and title
|
||||
// history archives kept in an OpenBMH extension block outside the original save fields, with
|
||||
// encoding to and decoding from bytes for saving.
|
||||
// Reads and writes GameState (memory extension, manager records). Draws no random numbers.
|
||||
// Interface in long_career.hpp.
|
||||
#include "game/long_career.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Interface of the long-career extension block (extension id, statistics and title history
|
||||
// archive types, record/reset/swap functions and encode/decode) implemented in long_career.cpp.
|
||||
// No random numbers are drawn.
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
Loaded 100 of 377 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user