Compare commits
23
Commits
v1.1.0-beta.2
...
v1.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bfa705ec5 | ||
|
|
c6341aa4f9 | ||
|
|
8862bd4f89 | ||
|
|
a5aa4c6a08 | ||
|
|
2a2fd17d07 | ||
|
|
0e8cfe5cd9 | ||
|
|
feb6ca2717 | ||
|
|
5caf23c452 | ||
|
|
30843fc9f3 | ||
|
|
8e2f491d5e | ||
|
|
4a93d9fd88 | ||
|
|
540178b264 | ||
|
|
86e2bfd32a | ||
|
|
8baf80564a | ||
|
|
d57b6b5a96 | ||
|
|
70082ef825 | ||
|
|
f87d927c8d | ||
|
|
777039832d | ||
|
|
fc07e45bbc | ||
|
|
7482697248 | ||
|
|
7b5cd6988e | ||
|
|
c8ae7a31d2 | ||
|
|
db56c323aa |
No files matched your search
@@ -62,4 +62,4 @@ jobs:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
gh release create "$RELEASE_TAG" dist/*.zip dist/SHA256SUMS dist/QA-REPORT.json --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/1.0/RELEASE_NOTES.md
|
||||
gh release create "$RELEASE_TAG" dist/*.zip dist/SHA256SUMS dist/QA-REPORT.json --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/1.0.3/RELEASE_NOTES.md
|
||||
+47
-1
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 1.0.2 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 1.0.3 LANGUAGES CXX C)
|
||||
if(APPLE)
|
||||
# Enable native languages before dependencies/subdirectories inherit rules.
|
||||
enable_language(OBJC OBJCXX)
|
||||
@@ -232,6 +232,7 @@ add_library(bmhcore STATIC
|
||||
src/game/reality_ball.cpp
|
||||
src/game/reality_duel.cpp
|
||||
src/game/reality_reporter.cpp
|
||||
src/game/long_career.cpp
|
||||
src/game/matchday.cpp
|
||||
src/game/sportschau_replay.cpp
|
||||
src/game/sportschau_rating.cpp
|
||||
@@ -340,6 +341,10 @@ bmh_add_data_test(NAME format_tests REQUIRED_OPTIONS BMH_TEST_INPUTS
|
||||
REQUIRED_FILES expected-text.tsv format-players.tsv format-start.fbm
|
||||
COMMAND format_tests "${BMH_DATA}" "${BMH_REFERENCE}")
|
||||
|
||||
add_executable(stadium_extended_limits_tests tests/stadium_extended_limits_tests.cpp)
|
||||
target_link_libraries(stadium_extended_limits_tests PRIVATE bmhcore)
|
||||
add_test(NAME stadium_extended_limits_tests COMMAND stadium_extended_limits_tests)
|
||||
|
||||
add_executable(stand_block_actions_tests tests/stand_block_actions_tests.cpp)
|
||||
target_link_libraries(stand_block_actions_tests PRIVATE bmhcore)
|
||||
add_test(NAME stand_block_actions_tests COMMAND stand_block_actions_tests)
|
||||
@@ -512,6 +517,10 @@ add_executable(national_friendly_actions_tests tests/national_friendly_actions_t
|
||||
target_link_libraries(national_friendly_actions_tests PRIVATE bmhcore)
|
||||
add_test(NAME national_friendly_actions_tests COMMAND national_friendly_actions_tests)
|
||||
|
||||
add_executable(edition_startup_app_tests tests/edition_startup_app_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(edition_startup_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
bmh_add_data_test(NAME edition_startup_app_tests COMMAND edition_startup_app_tests "${BMH_DATA}")
|
||||
|
||||
add_executable(manager_join_app_tests tests/manager_join_app_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(manager_join_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
if(MSVC)
|
||||
@@ -936,6 +945,7 @@ bmh_add_data_test(NAME league_views_data_tests COMMAND league_views_data_tests "
|
||||
# FLTD is translated by launch_check/the launcher first. Do not point these
|
||||
# tests at the raw DOS directory: the shared UI consumes the prepared image.
|
||||
set(BMH_ENGLISH_DATA "" CACHE PATH "Prepared Football Limited game-data directory")
|
||||
bmh_add_data_test(NAME english_edition_startup_app_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND edition_startup_app_tests "${BMH_ENGLISH_DATA}")
|
||||
bmh_add_data_test(NAME english_pairings_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_pairings_data_tests "${BMH_ENGLISH_DATA}")
|
||||
bmh_add_data_test(NAME english_desktop_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND desktop_data_tests "${BMH_ENGLISH_DATA}" --english)
|
||||
bmh_add_data_test(NAME english_league_views_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_views_data_tests "${BMH_ENGLISH_DATA}")
|
||||
@@ -1152,3 +1162,39 @@ endif()
|
||||
add_executable(desktop_feedback_tests tests/desktop_feedback_tests.cpp)
|
||||
target_link_libraries(desktop_feedback_tests PRIVATE bmhui)
|
||||
bmh_add_data_test(NAME desktop_feedback_tests COMMAND desktop_feedback_tests "${BMH_DATA}")
|
||||
|
||||
add_executable(daily_interest_unit_tests tests/daily_interest_unit_tests.cpp)
|
||||
target_link_libraries(daily_interest_unit_tests PRIVATE bmhcore)
|
||||
add_test(NAME daily_interest_unit_tests COMMAND daily_interest_unit_tests)
|
||||
add_executable(transfer_seller_actions_tests tests/transfer_seller_actions_tests.cpp)
|
||||
target_link_libraries(transfer_seller_actions_tests PRIVATE bmhcore)
|
||||
add_test(NAME transfer_seller_actions_tests COMMAND transfer_seller_actions_tests)
|
||||
|
||||
add_executable(transfer_seller_app_tests tests/transfer_seller_app_tests.cpp ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(transfer_seller_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
set(BMH_TEST_TRANSFER_SELLER_APP_SAVE "" CACHE FILEPATH "External career for seller-offer integration; not distributed")
|
||||
bmh_add_data_test(NAME transfer_seller_app_tests REQUIRED_OPTIONS BMH_TEST_TRANSFER_SELLER_APP_SAVE
|
||||
COMMAND transfer_seller_app_tests "${BMH_DATA}" "${BMH_TEST_TRANSFER_SELLER_APP_SAVE}")
|
||||
|
||||
add_executable(wide_number_unit_tests tests/wide_number_unit_tests.cpp)
|
||||
target_link_libraries(wide_number_unit_tests PRIVATE bmhcore)
|
||||
add_test(NAME wide_number_unit_tests COMMAND wide_number_unit_tests)
|
||||
add_executable(long_career_tests tests/long_career_tests.cpp)
|
||||
target_link_libraries(long_career_tests PRIVATE bmhcore)
|
||||
add_test(NAME long_career_tests COMMAND long_career_tests)
|
||||
|
||||
add_executable(bank_robbery_month_tests tests/bank_robbery_month_tests.cpp)
|
||||
target_link_libraries(bank_robbery_month_tests PRIVATE bmhcore)
|
||||
add_test(NAME bank_robbery_month_tests COMMAND bank_robbery_month_tests)
|
||||
add_executable(monthly_dividend_tests tests/monthly_dividend_tests.cpp)
|
||||
target_link_libraries(monthly_dividend_tests PRIVATE bmhui)
|
||||
add_test(NAME monthly_dividend_tests COMMAND monthly_dividend_tests)
|
||||
|
||||
add_executable(native_save_version_tests tests/native_save_version_tests.cpp)
|
||||
target_link_libraries(native_save_version_tests PRIVATE bmhcore)
|
||||
add_test(NAME native_save_version_tests COMMAND native_save_version_tests)
|
||||
add_executable(native_save_import_tests tests/native_save_import_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(native_save_import_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
set(BMH_TEST_NATIVE_SAVE_IMPORT_INPUT "" CACHE FILEPATH "External native save for import compatibility; not distributed")
|
||||
bmh_add_data_test(NAME native_save_import_tests REQUIRED_OPTIONS BMH_TEST_NATIVE_SAVE_IMPORT_INPUT
|
||||
COMMAND native_save_import_tests "${BMH_DATA}" "${BMH_TEST_NATIVE_SAVE_IMPORT_INPUT}")
|
||||
@@ -1,5 +1,10 @@
|
||||
# OpenBMH
|
||||
|
||||
**Classic-Version: 1.0.3.** Die originalgetreue Linie bleibt in diesem Repository.
|
||||
Erweiterte Ligen, die gemeinsame deutsche/englische Karriere und der Dateneditor
|
||||
werden separat als **[OpenBMH-Extended 1.0 Beta](https://github.com/Weyoune/OpenBMH-extended)** entwickelt.
|
||||
|
||||
|
||||
A faithful, standalone community reconstruction of *Bundesliga Manager Hattrick*, using the player's original installation and SDL2 interface.
|
||||
|
||||
OpenBMH 1.0 builds on v0.1.2 with reviewed bug fixes and starts directly with the original game data. Original game files, graphics, audio and manuals are not distributed. German CD-compatible BMH and verified Diamond editions are the primary release targets. Football Limited remains experimental; the older floppy executable is not supported.
|
||||
@@ -23,7 +28,7 @@ From a terminal in the extracted package on Linux or macOS:
|
||||
|
||||
In Windows PowerShell, use `.\OpenBMH.exe` and `.\openbmh_cli.exe` instead.
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0/RELEASE_NOTES.md).
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0.3/RELEASE_NOTES.md).
|
||||
|
||||
## Features and direction
|
||||
|
||||
|
||||
@@ -139,6 +139,8 @@ This index includes registered and reserved names. `ListOptions` and `Help` from
|
||||
| `SetSquadSheet` | sheet:enum(A,B) | Set Squad Sheet. See current Help for behaviour and bounds. |
|
||||
| `SetMarketVisible` | on:bool | Set Market Visible. See current Help for behaviour and bounds. |
|
||||
| `ShowPlayer` | player:Player | Show Player. See current Help for behaviour and bounds. |
|
||||
| `ShowOffers` | player:Player | existing bids for an owned listing; raw bid slots 0..3 |
|
||||
| `AcceptOffer` | player:Player, bid:int(0..3) | accept an existing bid before weekly expiry |
|
||||
| `SellPlayer` | player:Player | VER-KAUFEN: put an own player on the list |
|
||||
| `LoanOutPlayer` | player:Player, months:int(12\|24) | VER-LEIHEN: offer an own player for loan |
|
||||
| `BuyPlayer` | player:Player | VER-KAUFEN on a market player: the offer editor |
|
||||
|
||||
@@ -31,6 +31,18 @@ The six-budget monthly environment implementation has been checked against the p
|
||||
|
||||
Release acceptance of individual editions is recorded separately from their recognition. Source compatibility and automated tests do not establish full original-game or platform validation.
|
||||
|
||||
OpenBMH deviates from the original: graphical startup shows the supplied static
|
||||
137.VGA title with its embedded palette, without the DOS loading animation.
|
||||
It waits for a complete left or right mouse click before the game options.
|
||||
The title does not advance on a timer; its confirming press and release are
|
||||
consumed so they cannot also change a setup option.
|
||||
|
||||
Setup restores ordinary scene-backed manager dialogs before a career is created
|
||||
or loaded. The executable's boot-only black dialog mode is process state and is
|
||||
not restored from native save files. Football Limited's translated data includes
|
||||
its own verified calendar year and weekday operands; German epochs are not used
|
||||
as a substitute for the English edition.
|
||||
|
||||
## Diamond 3.7 foreign crests
|
||||
|
||||
The supplied edition controls whether foreign league clubs use individual
|
||||
@@ -41,3 +53,110 @@ Older drawing gates retain their own behaviour; no external crest pack is needed
|
||||
The automatic lineup installs the supplied foreign-player rule switch alongside the career tables. Where enabled, it restores the original three/two-player limit, reserve swaps with board-coordinate preservation and the short-lineup outcome when domestic reserves are unavailable. This does not consume additional random draws.
|
||||
|
||||
New careers correct the original all-zero EM qualification placeholders to the original national-team placeholders. Supplied nonzero seeds and restored savegame state are not rewritten by this initialization.
|
||||
|
||||
## Stadium extension in1.0.3
|
||||
|
||||
The user-requested stadium extension raises standard A–H maxima to14/24/14/20/
|
||||
14/24/14/20thousand places (144,000total), keeping larger supplied custom limits
|
||||
where the saved byte fields can represent them. Original unit prices remain
|
||||
edition-owned. Each stand's base build period is at least two weeks per1,000
|
||||
places of its expanded maximum and never shorter than the edition's original
|
||||
period. Contractor shortening remains unchanged.
|
||||
|
||||
The original Diamond3.6/3.7 table's14k stands really used25weeks versus30weeks
|
||||
for8k and37weeks for18k. That was original data, not a mistaken timer. Expanded
|
||||
limits/time policy is an intentional improvement. The UI now validates quotes
|
||||
against the actual edition and this shared policy rather than hardcoded Diamond
|
||||
prices and sizes. Existing eight capacity/construction bytes and saves are retained.
|
||||
## Daily interest at large native balances
|
||||
|
||||
OpenBMH deviates from the original: daily debt and deposit interest uses 64-bit
|
||||
intermediate arithmetic before the original integer divisions. The balance-plan
|
||||
preview uses the same calculation. Original rates, division order and random
|
||||
consumption remain unchanged. Account balances and accumulated statistics retain
|
||||
the native 32-bit save representation; this change does not add unlimited account
|
||||
balances or change the original high-cash deduction policy.
|
||||
OpenBMH deviates from the original: the legacy transfer market allows an owned
|
||||
listing to open incoming offers before its weekly expiry. Select the player and
|
||||
use the sale action (or Enter). Cancel keeps the listing and offers unchanged;
|
||||
acceptance uses the existing buyer eligibility, player salary qualification and
|
||||
transaction rules. Human-buyer loans still require their separate consent and
|
||||
allocator context and are unavailable in this early review. Viewing/canceling
|
||||
consumes no RNG. The weekly auction remains unchanged.
|
||||
|
||||
The transfer overview processes one selected player per action and renders action
|
||||
feedback in its footer. A cleared unsuccessful listing can be listed again
|
||||
immediately; there is no additional cooldown. The manager listing action refuses a full ordinary market
|
||||
without allocating a reserved special-offer row. These are explicit
|
||||
application outcomes instead of the Original's destructive overflow/dialog paths.
|
||||
|
||||
OpenBMH deviates from the original: a newly initialized squad board entry clears
|
||||
retirement, refused-negotiation and month-processing flags left by its previous
|
||||
occupant. The Original leaves that byte intact when reusing the row, so purchases
|
||||
and academy arrivals can inherit a refusal to renew. Existing players' genuine
|
||||
retirement/refusal flags remain effective. The initial academy contract remains
|
||||
two years; a young arrival can immediately negotiate any supported renewal term.
|
||||
This corrects the reused-row mechanism; it does not establish a fixed 200–300
|
||||
season threshold or repair ambiguous refusal flags in existing saved careers.
|
||||
|
||||
Bank finance-overview totals and gains use 64-bit read-only projections and
|
||||
currency formatting, including values beyond a signed native account word.
|
||||
Saved cash, deposits, loan fields and holdings retain their original widths.
|
||||
This prevents a positive combined portfolio from appearing negative; it does
|
||||
not recover amounts that have already overflowed inside a native saved field.
|
||||
|
||||
Live ball, set-piece and shot animations retain
|
||||
visible scoreboard digits at the chance-preview value until the result view.
|
||||
The simulation still commits goals, statistics and random draws at their existing
|
||||
boundaries. Post-match overview dismissal owns its full mouse gesture, including
|
||||
release after pointer movement, before the following calendar decision can open.
|
||||
The pitch uses each edition's original position-distance tables, atlas swatches
|
||||
and pointer bitmap for placement feedback; this display state is not serialized.
|
||||
OpenBMH deviates from the original: cumulative human-club appearances, goals and
|
||||
assists have optional 64-bit counters. Original byte/word fields keep their
|
||||
modulo representation for gameplay/layout compatibility; roster projections use
|
||||
the wider values. Tracking begins with the surviving legacy values, so high bits
|
||||
already lost in an imported save cannot be recovered. A new arrival clears the
|
||||
previous squad occupant's totals. Club promotion remaps counter ownership.
|
||||
|
||||
Title-holder and cup-winner lists retain all observed seasons in the same optional
|
||||
OpenBMH save extension. The Original nine-by-fifty table remains a rolling window.
|
||||
The archive captures that window before it shifts, and the title list can page
|
||||
through the archived rows. Late legacy imports start with their surviving fifty
|
||||
seasons; earlier winners are unknown and are not fabricated. Stored winner names
|
||||
are historical snapshots, so later renaming and promotion cannot change them.
|
||||
The separate manager-achievements graph retains its Original fifty-season view.
|
||||
|
||||
These records use a versioned `OBMHEXT1` extension after the Original name pools;
|
||||
see [save format](formats/LONG_CAREER.md). Original programs and older OpenBMH
|
||||
writers do not preserve this archive. Keep an OpenBMH backup when exchanging
|
||||
careers with those writers. The native calendar still has its existing signed
|
||||
16-bit season limit; this patch does not claim an unlimited calendar.
|
||||
## Monthly high-cash loss limit
|
||||
|
||||
OpenBMH deviates from the original: the high-cash bank robbery can occur at most
|
||||
once per manager and calendar month. The original threshold above 100 million
|
||||
and random loss of 10–20 million remain. A blocked repeat consumes no random
|
||||
draw. Month boundaries follow the same source calendar used by daily processing,
|
||||
and the guard is stored in the optional BRM1 section of OBMHEXT1 saves.
|
||||
|
||||
An older save has no record of past robberies. Its first qualifying high-cash month
|
||||
receives a grace period without a loss or random draw; subsequent saves retain
|
||||
that guard. The next calendar month can trigger the ordinary loss. Import cannot
|
||||
infer whether an event already occurred before this feature. Fresh histories
|
||||
receive the same initial grace month.
|
||||
|
||||
|
||||
OpenBMH deviates from the original: monthly fund/property dividends multiply
|
||||
unit price by the dividend factor in 64 bits before the existing integer division.
|
||||
The monthly and annual previews and weekly offers use the same widened product.
|
||||
Per-unit rounding and the selected legacy/typed recipient policy are unchanged.
|
||||
This corrects intermediate overflow for representable dividends; account,
|
||||
deposit, property book value and monthly totals still use their native 32-bit
|
||||
storage and can overflow. It is not a complete large-balance finance fix.
|
||||
|
||||
|
||||
Release-driven incoming-transfer presenters require a matching press observed
|
||||
inside that modal. An orphan or repeated release from the preceding result table
|
||||
cannot decline an offer or dismiss its confirmation. Repeated presses while a
|
||||
button is held still form one gesture; fresh left/right clicks keep their actions.
|
||||
@@ -6,25 +6,33 @@ See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These en
|
||||
describe deliberate changes; they are not a list of every known compatibility limit.
|
||||
|
||||
- [src/app/career_session.cpp](../src/app/career_session.cpp): supports designated set-piece record initialization and validation.
|
||||
- [src/app/main.cpp](../src/app/main.cpp): show only the static title until a complete left or right click, without the DOS loading animation.
|
||||
- [src/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
|
||||
- [src/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
||||
- [src/game/career.hpp](../src/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
- [src/game/desk_actions.cpp](../src/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): supports designated set-piece records and the supported transfer-editor rules.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): a seller may accept an existing bid before expiry.
|
||||
- [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image.
|
||||
- [src/game/lineup.hpp](../src/game/lineup.hpp): supports owner-bound designated set-piece selection.
|
||||
- [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules.
|
||||
- [src/game/match_engine.cpp](../src/game/match_engine.cpp): supports designated set-piece takers, the enhanced injury tables, and the extended suspension fields.
|
||||
- [src/game/month.cpp](../src/game/month.cpp): keep the price product in 64 bits until division, retaining per-unit truncation and recipient policy.
|
||||
- [src/game/national.cpp](../src/game/national.cpp): a new arrival must not inherit the previous occupant's retirement/refusal/month-processing flags.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): age/retire each player once, even when a temporary offer row references his club slot or regeneration moves him to a later free-agent slot.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): includes transfer-market players in retirement so the five-bit age cannot wrap to 16.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): initializes the empty EM qualifier seeds with national teams, preventing club zero from entering the EM.
|
||||
- [src/game/season.hpp](../src/game/season.hpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/stadium_blocks.cpp](../src/game/stadium_blocks.cpp): allow 144,000 standard places and size-aware construction times while retaining edition-owned unit prices.
|
||||
- [src/game/state.hpp](../src/game/state.hpp): retains designated set-piece selections in the supported manager-record extension.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): widen products before annual-rate division so valid native account amounts do not overflow intermediate sums.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): an unknown history receives a grace month; later losses occur at most once per source month.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): uses the enhanced training rules: focus strength is at least five below its target, and completed skills rotate to another focus.
|
||||
- [src/game/week.hpp](../src/game/week.hpp): uses the enhanced assistant-training rules, retaining the selected skill until it reaches its maximum.
|
||||
- [src/game/weekly.cpp](../src/game/weekly.cpp): uses the supported weekly-event configuration, with its rule switch disabled.
|
||||
- [src/game/weekly.hpp](../src/game/weekly.hpp): uses the supported weekly processing and transfer rule profile.
|
||||
- [src/ui/bank.cpp](../src/ui/bank.cpp): read-only totals use wide arithmetic; individual saved account, price, holding and paid fields are unchanged.
|
||||
- [src/ui/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.
|
||||
|
||||
@@ -1490,6 +1490,14 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `Pitch_FormatError_TextPointer2` | `0xaf178` | German-compatible image / runtime field |
|
||||
| `Pitch_FormatError_TextPointer3` | `0xaf17c` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_RuntimeField` | `0xa3cbc` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceDepthBases` | `0xa3cc3` | Four position-depth bases for native pitch feedback |
|
||||
| `PitchPreferenceRed` | `0xa3cc7` | Ten native pointer red components |
|
||||
| `PitchPreferenceGreen` | `0xa3cd1` | Ten native pointer green components |
|
||||
| `OriginalPointerPixels` | `0xa45b4` | Native 11 by 11 indexed pointer bitmap |
|
||||
| `EnglishPitchPreferenceDepthBases` | `0x6e230` | English position-depth bases |
|
||||
| `EnglishPitchPreferenceRed` | `0x6e234` | English pointer red components |
|
||||
| `EnglishPitchPreferenceGreen` | `0x6e240` | English pointer green components |
|
||||
| `EnglishOriginalPointerPixels` | `0x70554` | English 11 by 11 indexed pointer bitmap |
|
||||
| `Pitch_Render_TextPointer` | `0xae0e4` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer2` | `0xae0ec` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer3` | `0xae0f0` | German-compatible image / runtime field |
|
||||
|
||||
+37
-1
@@ -9,7 +9,7 @@
|
||||
| Plain header | Variable | Manager/date information for the load list |
|
||||
| Signature area | 10 bytes | Eight-byte `KRON_FBM` signature and two following bytes |
|
||||
| First ID | u32 | Container identifier |
|
||||
| Version | 6 bytes | NUL-terminated version field, normally `V2.24` for the supported state layout |
|
||||
| Version | 6 bytes | NUL-terminated version field, `V2.24` or the verified Diamond `V3.7` marker for this state layout |
|
||||
| Second ID | u32 | Save identifier |
|
||||
| Random byte | u8 | Header value |
|
||||
| Initial key | u8 | Rolling-cipher seed |
|
||||
@@ -26,8 +26,44 @@ The supported layout contains a fixed ordered block table, followed by four name
|
||||
|
||||
Each name pool has a u16 byte length followed by that many bytes, in club, player, referee and stadium order. These pools preserve renamed entities. The splitter rejects missing/truncated blocks or pools and requires exact stream consumption. See [STATE](STATE.md) for interpreted records and [M3D](M3D.md) for pool references.
|
||||
|
||||
## Optional OpenBMH state
|
||||
|
||||
After the four name pools, OpenBMH can append `OBMHEXT1`, a u16 block count,
|
||||
then each block as a u32 identifier, u32 byte length and payload. There is at
|
||||
most one such container and the decoder requires exact consumption of it.
|
||||
Original saves have no container. The entire extension is included in the outer
|
||||
rolling cipher and checksum.
|
||||
|
||||
Known OpenBMH-owned sections include:
|
||||
|
||||
| Identifier | Payload | Purpose |
|
||||
|---|---|---|
|
||||
| `OBLC` (`0x4f424c43`) | Versioned variable-length archive | [Long-career player counters and title winners](LONG_CAREER.md) |
|
||||
| `BRM1` (`0x314d5242`) | Four little-endian u32 month-start keys (16 bytes) | Per-manager monthly high-cash robbery guard |
|
||||
|
||||
A robbery key is the absolute first day of the last blocked source-calendar
|
||||
month. `UINT32_MAX` means unknown. An unknown high-cash history receives a
|
||||
first qualifying grace month; later deductions can occur at most once per
|
||||
calendar month. Managers have independent keys. A truncated or duplicate BRM1
|
||||
section is rejected before game state is published.
|
||||
|
||||
These identifiers describe OpenBMH-owned payloads, not original executable
|
||||
addresses. The container can also hold explicitly supported compatibility blocks,
|
||||
such as edition-specific cup state. Unrecognized payloads are not a general
|
||||
persistence API. Original programs and older OpenBMH writers may reject or
|
||||
discard optional information: keep a backup before opening a new save with them.
|
||||
|
||||
## Edition compatibility
|
||||
|
||||
Diamond 3.7 uses the `V3.7` container label with the verified German V2.24 state
|
||||
layout. Career loading, saved-desktop/preparation import and browser information
|
||||
accept that exact label as well as `V2.24`. The checksum, full block/pool structure
|
||||
and installed edition's database dimensions are still required. An accepted
|
||||
version label cannot make a malformed or mismatched state valid. Ordinary
|
||||
OpenBMH native saves continue to use the canonical `V2.24` output marker.
|
||||
Unknown labels are rejected separately from checksum failures.
|
||||
|
||||
|
||||
Original Football Limited V2.20 saves use a different state block list despite sharing the signature and rolling cipher. They are not interchangeable with the V2.24 layout. Reading an English installation and importing its original saves are separate features; do not edit a version string to bypass the distinction. OpenBMH's own English careers use the session's supported save representation.
|
||||
|
||||
Keep a backup before using a save with another engine version. Unknown bytes retained for compatibility are not safe targets for direct client manipulation.
|
||||
@@ -0,0 +1,34 @@
|
||||
# Optional long-career statistics and title archive
|
||||
|
||||
The existing `OBMHEXT1` container can contain block `0x4f424c43` (OpenBMH-owned,
|
||||
not a guest memory address). Original state blocks and all four name pools retain
|
||||
their sizes and ordering. No extension is emitted until an archive is needed.
|
||||
Payload integers use little-endian encoding:
|
||||
|
||||
| Field | Encoding |
|
||||
|---|---|
|
||||
| Payload version | u32, currently 1 |
|
||||
| Player/club record count | u32 |
|
||||
| Known season record count | u32 |
|
||||
| Each player/club record | u32 key, then six u64 counters |
|
||||
| Each season record | u32 absolute zero-based season, then nine names |
|
||||
| Each name | u16 byte length followed by Original-encoding bytes |
|
||||
|
||||
The player key is `(runtime_club << 12) | player_id`. The six counters are league,
|
||||
national-cup and European-cup appearances, total appearances, goals and assists.
|
||||
Club swaps remap keys; fresh squad entry initialization resets the new player's
|
||||
club record. The Original byte/word fields continue to update normally.
|
||||
|
||||
Season names follow the nine Original title categories. An empty name is a known
|
||||
season with no holder for that category. Missing season records are unknown,
|
||||
not an assertion that no competition was held. Names are owned snapshots at the
|
||||
award/capture time, independent of future club-number and name-pool changes.
|
||||
A legacy import contributes only its surviving window; no earlier information
|
||||
is inferred. The title list uses the earliest known absolute season when paging
|
||||
and compensates for the native rolling-window year offset.
|
||||
|
||||
The decoder rejects unknown versions, truncated payloads, invalid/duplicate
|
||||
identities and seasons, duplicate blocks and trailing bytes before publishing
|
||||
archive state. Season records remain within the native signed 16-bit calendar
|
||||
range. The surrounding FBM checksum covers the extension. Older writers may
|
||||
discard extensions; Original-game roundtrip preservation is not promised.
|
||||
@@ -0,0 +1,71 @@
|
||||
# OpenBMH 1.0.3
|
||||
|
||||
This Classic maintenance release fixes startup, dialog and match presentation,
|
||||
transfer handling and several long-career limits. It uses the player's own
|
||||
supported game installation. Extended development lives separately in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes
|
||||
|
||||
- Football Limited startup reads its own calendar epoch and prepared-image
|
||||
tables. Original CD assets are located without assuming filename case.
|
||||
- Original Diamond 3.7 saves with the verified `V3.7` container marker load in
|
||||
the career, browser information and preparation paths. Unknown versions and
|
||||
checksum failures are reported separately; layout checks remain strict.
|
||||
- The original title remains visible until a complete left or right mouse click,
|
||||
without loading balls or automatic advancement.
|
||||
- Career dialogs retain their scene background instead of inheriting the
|
||||
executable's black boot-dialog mode.
|
||||
- Goal scenes retain the previous visible score until the result is revealed.
|
||||
- Closing a table or pairings overview owns the complete right-button gesture.
|
||||
- Pitch placement again uses the edition's preferred-position colors and
|
||||
original colored cursor.
|
||||
- Select an owned transfer listing and use the sale action or Enter to inspect
|
||||
existing offers before expiry. Cancel preserves the listing. Cleared listings
|
||||
can be offered again; refusals receive visible feedback.
|
||||
- A fresh squad arrival clears negotiation flags left by the previous occupant
|
||||
of its row. This prevents inherited refusal of contract renewal.
|
||||
- Optional saved archives preserve cumulative player counters and observed
|
||||
title winners beyond the original byte/word and fifty-season windows.
|
||||
- Daily interest and property/fund dividend products use wider intermediate
|
||||
arithmetic; Bank portfolio totals use wide display values.
|
||||
- The high-cash bank robbery remains, at most once per manager and calendar
|
||||
month. Saving and loading preserves the limit. An older save with unknown
|
||||
history receives a first qualifying month of grace.
|
||||
- Standard stadium blocks now allow 144,000 places in total. Unit prices come
|
||||
from the loaded edition; build periods increase with expanded block size.
|
||||
|
||||
## Validation
|
||||
|
||||
The release workflow requires successful builds, configured synthetic tests and
|
||||
package checks for Windows x64, macOS ARM64 and Linux x64 at the tagged revision.
|
||||
Reports and checksums accompany the downloads. Missing external-data tests are
|
||||
reported as skipped, rather than counted as successful game tests.
|
||||
|
||||
Additional private Linux checks use Original CD, Diamond and Football Limited
|
||||
assets for startup and setup, scene-backed dialogs, calendar/rescheduling,
|
||||
transfer decisions, preferred-position feedback and score reveal. A 144,000-place
|
||||
stadium was rendered after encrypted native save/load. These checks do not
|
||||
constitute manual gameplay validation on Windows or macOS, or a full
|
||||
200–300-season simulation.
|
||||
|
||||
## Known limits
|
||||
|
||||
- Individual native cash, deposit and financial-history fields remain 32-bit and
|
||||
can still overflow. Wider calculations and aggregate display do not solve
|
||||
multi-billion single-account storage; that issue remains open.
|
||||
- Calendar and rescheduling opened in the checked Classic datasets; the reported
|
||||
failure remains open because it could not be reproduced.
|
||||
- Football Limited remains experimental. Its original V2.20 save layout is
|
||||
different and is not enabled by the Diamond 3.7 import correction.
|
||||
- Already lost counters and earlier title winners cannot be reconstructed. The
|
||||
separate manager-achievements graph retains its original fifty-season window.
|
||||
Original programs and older OpenBMH writers can discard optional archive and
|
||||
monthly-robbery extensions; keep backups before exchanging saves.
|
||||
- The row-initialization correction does not clear genuine retirement/refusal
|
||||
flags in an existing career or establish a fixed 200–300-season threshold.
|
||||
- Early acceptance of a human-buyer loan still needs its separate consent flow
|
||||
and is unavailable from the early offer preview.
|
||||
|
||||
The public downloads contain implementation, corresponding source and notices;
|
||||
original game content is not included.
|
||||
+41
-16
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
@@ -549,9 +550,9 @@ static void install_league_sizes(const LeImage& exe) {
|
||||
}
|
||||
|
||||
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed)
|
||||
: data_directory_(data), exe_(load_le(data / "BMH.exe")),
|
||||
db_(load_database(data / "M3D.MAN")),
|
||||
texts_(load_textd(data / "TEXTD.BLK")),
|
||||
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))),
|
||||
db_(load_database(ui::asset_path(data, "M3D.MAN"))),
|
||||
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))),
|
||||
rand_(watcom_seed) {
|
||||
install_league_sizes(exe_);
|
||||
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
|
||||
@@ -560,7 +561,7 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
? TransferAllocatorContext::zero : TransferAllocatorContext::blocked;
|
||||
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
|
||||
initialize_club_modal_runtime();
|
||||
g_ = startup_state(exe_, db_, read_file(data / "M3.MEN"), read_file(data / "M3.DAT"));
|
||||
g_ = startup_state(exe_, db_, read_file(ui::asset_path(data, "M3.MEN")), read_file(ui::asset_path(data, "M3.DAT")));
|
||||
g_.texts = &texts_;
|
||||
g_.currency_suffix = exe_.cstring(::bmh::layout::CurrencySuffixText); // CurrencySuffixText
|
||||
configure_training_camp_data(g_, exe_);
|
||||
@@ -576,8 +577,8 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
|
||||
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed,
|
||||
const std::filesystem::path& save_path)
|
||||
: data_directory_(data), exe_(load_le(data / "BMH.exe")), db_(load_database(data / "M3D.MAN")),
|
||||
texts_(load_textd(data / "TEXTD.BLK")), rand_(watcom_seed) {
|
||||
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))), db_(load_database(ui::asset_path(data, "M3D.MAN"))),
|
||||
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))), rand_(watcom_seed) {
|
||||
install_league_sizes(exe_);
|
||||
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
|
||||
turn_driver_.disable_match_events = exe_.u8(::bmh::layout::MatchEventsDisabled) != 0;
|
||||
@@ -586,7 +587,7 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
|
||||
initialize_club_modal_runtime();
|
||||
const Savegame file = load_savegame(save_path);
|
||||
if (!file.checksum_ok || file.version != "V2.24") throw std::runtime_error("savegame: unsupported or damaged FBM");
|
||||
require_native_savegame(file);
|
||||
const DbCounts counts{exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe_.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
const SaveState save(file.stream, counts);
|
||||
g_ = GameState::from_save(save, counts);
|
||||
@@ -926,6 +927,9 @@ std::optional<PendingOfferResult> CareerSession::dispatch_club_player_pending_of
|
||||
}
|
||||
|
||||
void CareerSession::initialize_club_modal_runtime() {
|
||||
// Setup clears the boot-only dialog mode before either creating or loading
|
||||
// a career. This process flag is deliberately absent from native saves.
|
||||
club_modal_runtime_.emplace(layout::CompactDialogFrame, 0);
|
||||
// LE object4 has bb cdd/de/e1 in its zero-initialized virtual tail;
|
||||
// CareerSession_InitializeClubModalRuntime_ExecutableField is file-backed zero. These are explicit process-start values,
|
||||
// carried by this runtime owner across modal entry/return, not FBM bytes.
|
||||
@@ -3982,7 +3986,8 @@ std::optional<CareerSession::TransferMarketPreviewDispatch> CareerSession::previ
|
||||
|
||||
std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& presenters,
|
||||
uint64_t& revision, std::string& error) {
|
||||
uint64_t& revision, std::string& error,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
@@ -3995,7 +4000,18 @@ std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
error = "transfer market: stale or nested request";
|
||||
return std::nullopt;
|
||||
}
|
||||
if (request.kind == ui::TransferMarketRequestKind::submit_bid) {
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
if (!review || request.bid.manager != request.manager_slot || request.bid.list_entry < 0 ||
|
||||
request.bid.list_entry >= 40 || request.bid.source_slot != 0xb70 + request.bid.list_entry ||
|
||||
request.squad_row != -1 || !request.selected_players.empty()) {
|
||||
error = "transfer market: invalid offer review"; return std::nullopt;
|
||||
}
|
||||
const auto view = project_transfer_offer_list(g_, request.bid.list_entry);
|
||||
if (!view.valid || view.player != request.bid.player || view.seller != request.runtime_club ||
|
||||
view.seller_manager != request.manager_slot) {
|
||||
error = "transfer market: stale seller listing"; return std::nullopt;
|
||||
}
|
||||
} else if (request.kind == ui::TransferMarketRequestKind::submit_bid) {
|
||||
if (request.bid.manager != request.manager_slot || request.squad_row != -1 ||
|
||||
request.expected_player != -1 ||
|
||||
std::any_of(request.bid.bonuses.begin(), request.bid.bonuses.end(),
|
||||
@@ -4061,7 +4077,21 @@ std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
try {
|
||||
const auto before = save_stream(g_);
|
||||
TransferActionResult result;
|
||||
if (request.kind == ui::TransferMarketRequestKind::list_player)
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
const auto view = project_transfer_offer_list(next_state, request.bid.list_entry);
|
||||
const int selected = view.offer_count ? review(next_state, view) : -1;
|
||||
result.player = view.player; result.list_entry = view.list_entry;
|
||||
result.status = TransferActionStatus::pending;
|
||||
if (selected != -1) {
|
||||
auto allocator = TransferAllocatorContext::unsupported;
|
||||
if (turn_driver_.transfer_allocator_context == PendingOfferAllocatorGate::zero)
|
||||
allocator = TransferAllocatorContext::zero;
|
||||
else if (turn_driver_.transfer_allocator_context == PendingOfferAllocatorGate::blocked)
|
||||
allocator = TransferAllocatorContext::blocked;
|
||||
result = accept_manager_transfer_offer(next_state, request.manager_slot,
|
||||
view.list_entry, view.player, selected, next_rand, report, allocator);
|
||||
}
|
||||
} else if (request.kind == ui::TransferMarketRequestKind::list_player)
|
||||
result = list_manager_player(next_state, request.manager_slot, request.squad_row, next_rand, report);
|
||||
else
|
||||
result = submit_transfer_bid_source_human_buyer(next_state, request.bid, next_rand, hooks, report);
|
||||
@@ -8102,12 +8132,7 @@ bool CareerSession::dispatch_stadium(const ui::StadiumRequest& supplied_request,
|
||||
if (request.object != -1 || request.option != -1 || request.price != 0 ||
|
||||
(request.kind != ui::StadiumRequestKind::expansion_answer_tip && request.accept_tip))
|
||||
return invalid("invalid_block_expansion_envelope");
|
||||
StadiumBlockExpansionConstants block_constants;
|
||||
for (unsigned i = 0; i < 8; ++i) {
|
||||
block_constants.price_per_1000[i] = exe_.u32(::bmh::layout::CareerSession_DispatchStadium_RuntimeField + (i + 8) * 4);
|
||||
block_constants.weeks[i] = exe_.u8(::bmh::layout::CareerSession_DispatchStadium_RuntimeField2 + (i + 22) * 5);
|
||||
block_constants.max_places[i] = uint32_t(exe_.u8(::bmh::layout::CareerSession_Invalid_RuntimeField + i)) * 1000;
|
||||
}
|
||||
const auto block_constants=stadium_block_expansion_constants(exe_);
|
||||
const auto quote_block = [&](StadiumBlockSlot slot, uint32_t total, uint8_t features) {
|
||||
return quote_stadium_block_expansion(g_, active, slot, total, features,
|
||||
stadium_.price_percent, block_constants);
|
||||
|
||||
@@ -175,7 +175,8 @@ public:
|
||||
// result with valid dependent projections becomes the live state.
|
||||
std::optional<TransferActionResult> dispatch_transfer_market(
|
||||
const ui::TransferMarketRequest&, const HumanBuyerSaleHooks&,
|
||||
uint64_t& revision, std::string& error);
|
||||
uint64_t& revision, std::string& error,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
|
||||
|
||||
struct TransferMarketPreviewDispatch {
|
||||
ui::PreparationState preparation;
|
||||
|
||||
+19
-7
@@ -370,9 +370,11 @@ std::string transfer_status_message(TransferActionStatus status, ui::TransferMar
|
||||
case TransferActionStatus::accepted:
|
||||
return kind == ui::TransferMarketRequestKind::list_player
|
||||
? "Der Spieler steht jetzt auf der Transferliste." : "Der Spieler hat das Angebot angenommen.";
|
||||
case TransferActionStatus::pending: return "Der Spieler entscheidet sich nächste Woche.";
|
||||
case TransferActionStatus::pending: return kind == ui::TransferMarketRequestKind::list_player
|
||||
? "Der Spieler steht bereits auf der Transferliste." : "Der Spieler entscheidet sich nächste Woche.";
|
||||
case TransferActionStatus::offer_too_low: return "Das Angebot ist zu niedrig.";
|
||||
case TransferActionStatus::blocked_by_board: return "Der Vorstand genehmigt diesen Transfer nicht.";
|
||||
case TransferActionStatus::blocked_by_board: return kind == ui::TransferMarketRequestKind::list_player
|
||||
? "Transferliste voll oder Spieler nicht verfügbar." : "Der Vorstand genehmigt diesen Transfer nicht.";
|
||||
case TransferActionStatus::insufficient_funds: return "Das Geld reicht für diesen Transfer nicht aus.";
|
||||
case TransferActionStatus::no_squad_room: return "Im Kader ist kein Platz für diesen Spieler.";
|
||||
case TransferActionStatus::rejected: return "Der Spieler hat das Angebot abgelehnt.";
|
||||
@@ -384,7 +386,8 @@ void serve_transfer_action(ui::StartupFlow& flow, CareerSession& session,
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision,
|
||||
const HumanBuyerSaleHooks& presenters,
|
||||
HumanBuyerMarketEntryPolicy entry_policy,
|
||||
const CareerSession::PoachPlayerSelector& poach_selector, const PoachNoticePresenter& poach_notice) {
|
||||
const CareerSession::PoachPlayerSelector& poach_selector, const PoachNoticePresenter& poach_notice,
|
||||
const TransferOfferPresenter& review) {
|
||||
const auto* pending = flow.pending_transfer_market();
|
||||
// JSON covers every offer field except its redundant nested manager identity.
|
||||
// Check that identity too, before an engine helper can consume a random draw.
|
||||
@@ -473,13 +476,22 @@ void serve_transfer_action(ui::StartupFlow& flow, CareerSession& session,
|
||||
const auto outcome = TransferActions(session).market(request, hooks, revision, error, entry_policy,
|
||||
[&](const TransferActions::MarketDispatch& applied) {
|
||||
// Preserve the Source caller's existing notice/ACK sequence.
|
||||
const bool source_finished = entry_policy == HumanBuyerMarketEntryPolicy::normal_interactive &&
|
||||
(source_notice_presented || applied.action.status == TransferActionStatus::pending);
|
||||
const bool source_finished = request.kind != ui::TransferMarketRequestKind::review_offers &&
|
||||
entry_policy == HumanBuyerMarketEntryPolicy::normal_interactive &&
|
||||
(source_notice_presented || (request.kind == ui::TransferMarketRequestKind::submit_bid &&
|
||||
applied.action.status == TransferActionStatus::pending));
|
||||
auto notice = source_finished ? std::string{} : transfer_status_message(applied.action.status, request.kind);
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
notice = applied.action.status == TransferActionStatus::accepted
|
||||
? "Das Angebot wurde angenommen."
|
||||
: applied.action.status == TransferActionStatus::pending
|
||||
? "Spieler bleibt auf der Transferliste."
|
||||
: "Angebot abgelehnt; Transferliste unverändert.";
|
||||
}
|
||||
if (!applied.changed && source_finished) flow.acknowledge_unchanged_transfer_market();
|
||||
else if (!applied.changed) flow.reject_preparation_action(std::move(notice));
|
||||
else flow.acknowledge_preparation(session.preparation_projection(revision), std::move(notice));
|
||||
});
|
||||
}, review);
|
||||
if (!outcome) throw FormatError(error);
|
||||
} catch (const std::exception&) {
|
||||
flow.reject_preparation_action("Diese Transferaktion konnte nicht übernommen werden.");
|
||||
@@ -1533,7 +1545,7 @@ std::string serve_flow_request(ui::StartupFlow& flow, const ui::FlowResult& resu
|
||||
} else if (result.request == ui::FlowRequest::submenu_action && session &&
|
||||
std::holds_alternative<ui::TransferMarketRequest>(result.submenu_action)) {
|
||||
serve_transfer_action(flow, *session, std::get<ui::TransferMarketRequest>(result.submenu_action), revision,
|
||||
market_sale_presenter, market_entry_policy, poach_player_selector, poach_notice_presenter);
|
||||
market_sale_presenter, market_entry_policy, poach_player_selector, poach_notice_presenter, transfer_presenter);
|
||||
} else if (result.request == ui::FlowRequest::submenu_action && session &&
|
||||
std::holds_alternative<ui::OutgoingTransferRequest>(result.submenu_action)) {
|
||||
serve_transfer_offer(flow, *session, std::get<ui::OutgoingTransferRequest>(result.submenu_action), revision,
|
||||
|
||||
+74
-14
@@ -33,6 +33,7 @@
|
||||
#include "version.hpp"
|
||||
#include "app/video_session.hpp"
|
||||
#include "app/live_matchday_events.hpp"
|
||||
#include "app/pitch_pointer.hpp"
|
||||
#include "audio/playback.hpp"
|
||||
#include "app/audio.hpp"
|
||||
#include "formats/palette.hpp"
|
||||
@@ -215,6 +216,7 @@ int main(int argc, char** argv) {
|
||||
SDL_RenderSetLogicalSize(renderer, 320, 240);
|
||||
SDL_Texture* texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 320, 240);
|
||||
if (!texture) throw FormatError(SDL_GetError());
|
||||
app::PitchPointer pitch_pointer;
|
||||
std::vector<uint32_t> pixels(320 * 240);
|
||||
ui::LiveMatchdayScreen live_screen(data);
|
||||
ui::RealityReporterPanel reality_reporter(data);
|
||||
@@ -1702,6 +1704,7 @@ int main(int argc, char** argv) {
|
||||
std::optional<Uint64> timed_notice_presented_at;
|
||||
std::optional<Uint8> timed_notice_release;
|
||||
auto handle = [&](const ui::FlowResult& r) {
|
||||
pitch_pointer.show({}, renderer);
|
||||
if (r.request == ui::FlowRequest::end_session && !quit_confirmation.confirm()) {
|
||||
flow.reject_desk_action(english_game ? "Quit cancelled." : "Beenden abgebrochen.");
|
||||
dirty = true;
|
||||
@@ -1781,6 +1784,7 @@ int main(int argc, char** argv) {
|
||||
bool closed = false;
|
||||
const auto apply_live_pitch = [&](const ui::PitchRequest& action) {
|
||||
if (action.kind == ui::PitchRequestKind::none) return;
|
||||
pitch_pointer.show({}, renderer);
|
||||
if (action.kind == ui::PitchRequestKind::open_player_info) {
|
||||
try {
|
||||
if (action.row < 0 || size_t(action.row) >= screen.state().players.size() ||
|
||||
@@ -1820,6 +1824,7 @@ int main(int argc, char** argv) {
|
||||
};
|
||||
bool left_held = false, left_release_consumed = false, right_held = false;
|
||||
while (running && !closed) {
|
||||
pitch_pointer.show(screen.pointer_cursor(palette), renderer);
|
||||
const Image image = screen.render();
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
pixels[i] = palette.argb[image.pixels[i]];
|
||||
@@ -1880,8 +1885,10 @@ int main(int argc, char** argv) {
|
||||
scope_finished = true;
|
||||
completed = true;
|
||||
}
|
||||
pitch_pointer.show({}, renderer);
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_matchday");
|
||||
} catch (const std::exception& e) {
|
||||
pitch_pointer.show({}, renderer);
|
||||
if (scope_started && !scope_finished)
|
||||
dispatch_scope(app::LiveInterventionBoundary::abort, 2,
|
||||
selected_manager, selected_team, scope_error);
|
||||
@@ -2096,11 +2103,16 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
};
|
||||
SDL_FlushEvent(SDL_KEYUP);
|
||||
while (running && !closed) {
|
||||
while (running && (!closed || down)) {
|
||||
SDL_Event input;
|
||||
bool redrawn = false;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; break; }
|
||||
if (closed) {
|
||||
if (input.type == SDL_MOUSEBUTTONUP && down &&
|
||||
input.button.button == down->button) { down.reset(); break; }
|
||||
continue;
|
||||
}
|
||||
if (input.type == SDL_MOUSEMOTION) {
|
||||
const bool changed = table_screen ? table_screen->move(input.motion.x, input.motion.y)
|
||||
: pairings_screen ? pairings_screen->move(input.motion.x, input.motion.y)
|
||||
@@ -2119,8 +2131,7 @@ int main(int argc, char** argv) {
|
||||
else cup_screen->pointer_down(input.button.x, input.button.y,
|
||||
input.button.button == SDL_BUTTON_RIGHT);
|
||||
} else if (input.type == SDL_MOUSEBUTTONUP && down &&
|
||||
input.button.button == down->button && input.button.x == down->x &&
|
||||
input.button.y == down->y) {
|
||||
input.button.button == down->button) {
|
||||
down.reset();
|
||||
if (table_screen) table_screen->click(input.button.x, input.button.y,
|
||||
input.button.button == SDL_BUTTON_RIGHT);
|
||||
@@ -2141,19 +2152,21 @@ int main(int argc, char** argv) {
|
||||
else if (cup_screen && cup_screen->pending())
|
||||
action = *cup_screen->pending();
|
||||
if (action) { dispatch_action(*action); redrawn = true; }
|
||||
if (closed || !running) break;
|
||||
if ((closed && !down) || !running) break;
|
||||
}
|
||||
if (!running || closed) break;
|
||||
if (!running || (closed && !down)) break;
|
||||
if (closed) { SDL_Delay(8); continue; }
|
||||
if (pairings_screen && pairings_screen->tick_source_seconds(overview_source_seconds())) {
|
||||
if (pairings_screen->pending())
|
||||
dispatch_action(app::CareerSession::LiveOverviewAction{*pairings_screen->pending()});
|
||||
redrawn = true;
|
||||
}
|
||||
if (closed || !running) break;
|
||||
if ((closed && !down) || !running) break;
|
||||
if (!redrawn) SDL_Delay(8);
|
||||
}
|
||||
return running && closed;
|
||||
};
|
||||
ui::LiveScoreReveal live_score_reveal;
|
||||
std::optional<ui::LiveChanceProjection> live_chance_context;
|
||||
std::unique_ptr<ui::RealityFieldScreen> reality_field;
|
||||
ui::RealityReporterLayoutState reality_layout;
|
||||
@@ -2212,10 +2225,13 @@ int main(int argc, char** argv) {
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return -1; }
|
||||
std::optional<int> answer;
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
answer = offer_screen.click(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT);
|
||||
offer_screen.pointer_down(event.button.button == SDL_BUTTON_RIGHT);
|
||||
} else if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
answer = offer_screen.pointer_up(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT);
|
||||
offer_dirty = true;
|
||||
} else if (event.type == SDL_KEYDOWN) {
|
||||
if (offer_screen.notice_active()) {
|
||||
@@ -2280,9 +2296,12 @@ int main(int argc, char** argv) {
|
||||
SDL_Event event;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))
|
||||
(void)decision_screen.click(event.button.x, event.button.y,
|
||||
decision_screen.pointer_down(event.button.button == SDL_BUTTON_RIGHT);
|
||||
else if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))
|
||||
(void)decision_screen.pointer_up(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT, elapsed);
|
||||
}
|
||||
if (confirmation ? decision_screen.confirmation_dismissed() : decision_screen.outcome_dismissed()) return;
|
||||
@@ -2911,7 +2930,7 @@ int main(int argc, char** argv) {
|
||||
}, [&](const LiveBallEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
const auto frame = live_score_reveal.project(ui::live_matchday_frame(event.minute, groups, state));
|
||||
if (frame.matches.empty()) return;
|
||||
const auto present = [&](const Image& image) {
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]];
|
||||
@@ -2958,6 +2977,7 @@ int main(int argc, char** argv) {
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
live_score_reveal.observe(event.stage, frame);
|
||||
if (frame.matches.empty()) return;
|
||||
const auto chance = ui::live_chance_projection(event, groups, state, season_exe);
|
||||
if (event.stage == LiveChanceStage::preview) live_chance_context = chance;
|
||||
@@ -2990,7 +3010,7 @@ int main(int argc, char** argv) {
|
||||
}, [&](const LiveShotEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
const auto frame = live_score_reveal.project(ui::live_matchday_frame(event.minute, groups, state));
|
||||
if (frame.matches.empty()) return;
|
||||
const auto frames = live_screen.render_shot(frame, event);
|
||||
const auto shot_colors = live_screen.shot_palette(palette, event, groups, state);
|
||||
@@ -3048,7 +3068,7 @@ int main(int argc, char** argv) {
|
||||
}, [&](const LiveSetPieceEvent& event, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state) {
|
||||
if (!running || live_skipped) return;
|
||||
const auto frame=ui::live_matchday_frame(event.minute,groups,state);
|
||||
const auto frame=live_score_reveal.project(ui::live_matchday_frame(event.minute,groups,state));
|
||||
if (frame.matches.empty()) return;
|
||||
const auto images=live_screen.render_set_piece(frame,event);
|
||||
LiveShotEvent palette_event;
|
||||
@@ -3599,6 +3619,44 @@ int main(int argc, char** argv) {
|
||||
if (expired.request != ui::FlowRequest::none || expired.changed) handle(expired);
|
||||
}
|
||||
};
|
||||
// OpenBMH deviates from the original: show only the static title until
|
||||
// a complete left or right click, without the DOS loading animation.
|
||||
const auto title_path = ui::asset_path(data / "KB", "137.VGA");
|
||||
const auto title_palette = load_optional_embedded_palette(title_path);
|
||||
const auto title_image = load_vga(title_path);
|
||||
present_season(title_image, window_title.c_str(),
|
||||
title_palette ? &*title_palette : nullptr);
|
||||
bool opening_confirmed = false;
|
||||
std::optional<Uint8> opening_press;
|
||||
while (running && !opening_confirmed) {
|
||||
SDL_Event opening_event;
|
||||
while (quit_confirmation.poll(&opening_event)) {
|
||||
if (opening_event.type == SDL_QUIT) running = false;
|
||||
if (opening_event.type == SDL_KEYDOWN && opening_event.key.keysym.sym == SDLK_ESCAPE &&
|
||||
quit_confirmation.confirm()) running = false;
|
||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||
(opening_event.window.event == SDL_WINDOWEVENT_EXPOSED ||
|
||||
opening_event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED))
|
||||
present_season(title_image, window_title.c_str(),
|
||||
title_palette ? &*title_palette : nullptr);
|
||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||
opening_event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
opening_press.reset();
|
||||
if (opening_event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(opening_event.button.button == SDL_BUTTON_LEFT ||
|
||||
opening_event.button.button == SDL_BUTTON_RIGHT))
|
||||
opening_press = opening_event.button.button;
|
||||
if (opening_event.type == SDL_MOUSEBUTTONUP && opening_press &&
|
||||
opening_event.button.button == *opening_press)
|
||||
opening_confirmed = true;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
// Opening input must not also change an option on the first setup frame.
|
||||
SDL_FlushEvents(SDL_KEYDOWN, SDL_KEYUP);
|
||||
SDL_FlushEvents(SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP);
|
||||
season_backdrop.reset();
|
||||
dirty = true;
|
||||
SDL_StartTextInput();
|
||||
bool filename_input_active = false;
|
||||
std::array<bool, 2> setup_button_down{};
|
||||
@@ -3877,6 +3935,7 @@ int main(int argc, char** argv) {
|
||||
throw std::runtime_error(std::string("Source modal texture: ") + SDL_GetError());
|
||||
dirty = false;
|
||||
}
|
||||
pitch_pointer.show(flow.pitch_pointer_cursor(palette), renderer);
|
||||
const int cleared = SDL_RenderClear(renderer);
|
||||
const int copied = SDL_RenderCopy(renderer, texture, nullptr, nullptr);
|
||||
if (source_modal_redraw && (cleared != 0 || copied != 0))
|
||||
@@ -3901,6 +3960,7 @@ int main(int argc, char** argv) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
SDL_StopTextInput();
|
||||
pitch_pointer.clear();
|
||||
SDL_DestroyTexture(texture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
// SDL owns pointer position; the UI supplies only the original bitmap/colors.
|
||||
class PitchPointer {
|
||||
public:
|
||||
~PitchPointer() { clear(); }
|
||||
void clear() {
|
||||
if (cursor_) {
|
||||
SDL_SetCursor(SDL_GetDefaultCursor());
|
||||
SDL_FreeCursor(cursor_);
|
||||
cursor_ = nullptr;
|
||||
}
|
||||
pixels_.reset();
|
||||
}
|
||||
void show(const std::optional<std::array<uint32_t,121>>& pixels, SDL_Renderer* renderer) {
|
||||
if (!pixels) { SDL_SetCursor(SDL_GetDefaultCursor()); return; }
|
||||
int width = 320, height = 240;
|
||||
SDL_GetRendererOutputSize(renderer, &width, &height);
|
||||
const int scale = std::max(1, std::min(width / 320, height / 240));
|
||||
if (!cursor_ || pixels != pixels_ || scale != scale_) {
|
||||
std::vector<uint32_t> enlarged(size_t(11 * scale) * size_t(11 * scale));
|
||||
for (int y = 0; y < 11 * scale; ++y) for (int x = 0; x < 11 * scale; ++x)
|
||||
enlarged[size_t(y) * size_t(11 * scale) + size_t(x)] =
|
||||
pixels->at(size_t(y / scale) * 11 + size_t(x / scale));
|
||||
SDL_Surface* surface = SDL_CreateRGBSurfaceWithFormatFrom(enlarged.data(),
|
||||
11 * scale, 11 * scale, 32, 11 * scale * 4, SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_Cursor* next = surface ? SDL_CreateColorCursor(surface, 0, 0) : nullptr;
|
||||
if (surface) SDL_FreeSurface(surface);
|
||||
if (!next) return; // A headless SDL driver may not support host cursors.
|
||||
clear(); cursor_ = next; pixels_ = pixels; scale_ = scale;
|
||||
}
|
||||
SDL_SetCursor(cursor_);
|
||||
}
|
||||
private:
|
||||
SDL_Cursor* cursor_ = nullptr;
|
||||
std::optional<std::array<uint32_t,121>> pixels_;
|
||||
int scale_ = 1;
|
||||
};
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -108,12 +108,13 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
|
||||
std::optional<TransferActions::MarketDispatch> TransferActions::market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, HumanBuyerMarketEntryPolicy policy,
|
||||
const MarketAccept& acknowledge) {
|
||||
const MarketAccept& acknowledge,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
|
||||
std::optional<MarketDispatch> result;
|
||||
apply(revision, [&] {
|
||||
const auto old_revision = revision;
|
||||
if (policy == HumanBuyerMarketEntryPolicy::normal_interactive) {
|
||||
const auto action = session_.dispatch_transfer_market(request, hooks, revision, error);
|
||||
const auto action = session_.dispatch_transfer_market(request, hooks, revision, error, review);
|
||||
if (!action) return false;
|
||||
result = MarketDispatch{*action, revision != old_revision};
|
||||
} else {
|
||||
@@ -174,7 +175,8 @@ std::string TransferActions::rejection(const ui::TransferMarketRequest& request,
|
||||
return "Dieser Spieler gehört nicht mehr zur gewählten Kaderposition.";
|
||||
} else if (request.kind != ui::TransferMarketRequestKind::open_offer &&
|
||||
request.kind != ui::TransferMarketRequestKind::preview_quote &&
|
||||
request.kind != ui::TransferMarketRequestKind::open_poach)
|
||||
request.kind != ui::TransferMarketRequestKind::open_poach &&
|
||||
request.kind != ui::TransferMarketRequestKind::review_offers)
|
||||
return "Diese Transferaktion ist nicht verfügbar.";
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ public:
|
||||
std::optional<MarketDispatch> market(const ui::TransferMarketRequest&, const HumanBuyerSaleHooks&,
|
||||
uint64_t& revision, std::string& error,
|
||||
HumanBuyerMarketEntryPolicy = HumanBuyerMarketEntryPolicy::normal_interactive,
|
||||
const MarketAccept& = {});
|
||||
const MarketAccept& = {},
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> open_offer(const ui::TransferMarketRequest&,
|
||||
uint64_t& revision, std::string& error, const OfferAccept& = {});
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> preview(const ui::TransferMarketRequest&,
|
||||
|
||||
@@ -160,6 +160,8 @@ void Console::register_transfer_commands() {
|
||||
require_engine(false, "transfer", error);
|
||||
}
|
||||
flush_notices();
|
||||
if (outcome->action.status != TransferActionStatus::accepted)
|
||||
fail("E_RULE", "Der Spieler konnte nicht auf die Transferliste gesetzt werden.");
|
||||
emit('+', utf8(item.name) + (loan
|
||||
? " steht auf der Transferliste; der Entleiher wählt 12 oder 24 Monate im Angebot"
|
||||
: " is on the transfer list"));
|
||||
@@ -175,6 +177,42 @@ void Console::register_transfer_commands() {
|
||||
list_player(v.text("player"), true);
|
||||
});
|
||||
|
||||
add({"Transfer", "ShowOffers", {player}, "incoming offers for an own listed player", false},
|
||||
[this, market_item](const Values& v) {
|
||||
const auto item = market_item(v.text("player"));
|
||||
if (!item.own_listing) fail("E_RULE", "the listing belongs to another club");
|
||||
const auto offers = project_transfer_offer_list(session_->state(), item.list_entry);
|
||||
std::vector<std::vector<std::string>> rows;
|
||||
for (const auto& offer : offers.offers) {
|
||||
if (!offer.present) continue;
|
||||
rows.push_back({std::to_string(offer.bid_index), utf8(session_->state().club_name(offer.buyer)),
|
||||
money(offer.fee), money(offer.monthly_salary), std::to_string(offer.contract_months),
|
||||
offer.loan ? "loan" : "sale",
|
||||
offer.eligible && offer.loan_permitted && offer.transaction_supported ? "yes" : "no"});
|
||||
}
|
||||
emit_table({"Bid", "Club", "Fee", "Monthly salary", "Months", "Type", "Available"}, rows);
|
||||
if (rows.empty()) emit('i', "Noch keine Angebote für diesen Spieler.");
|
||||
});
|
||||
add({"Transfer", "AcceptOffer", {player, integer("bid", 0, 3)}, "accept an existing bid before weekly expiry", true},
|
||||
[this, market, market_item, hooks, flush_notices](const Values& v) {
|
||||
const auto observed = market();
|
||||
const auto item = market_item(v.text("player"));
|
||||
if (!item.own_listing) fail("E_RULE", "the listing belongs to another club");
|
||||
auto request = app::TransferActions::opening(observed, item, false);
|
||||
request.kind = ui::TransferMarketRequestKind::review_offers;
|
||||
request.selected_players.clear();
|
||||
const int bid = int(v.integer("bid"));
|
||||
std::string error;
|
||||
const auto outcome = app::TransferActions(*session_).market(request, hooks(), revision_, error,
|
||||
app::HumanBuyerMarketEntryPolicy::normal_interactive, {},
|
||||
[bid](const GameState&, const TransferOfferListView&) { return bid; });
|
||||
if (!outcome) require_engine(false, "transfer", error);
|
||||
flush_notices();
|
||||
if (outcome->action.status != TransferActionStatus::accepted)
|
||||
fail("E_RULE", "Dieses Angebot kann nicht angenommen werden; die Transferliste bleibt unverändert.");
|
||||
emit('+', "Das Angebot wurde angenommen.");
|
||||
});
|
||||
|
||||
// --- Transfer.Negotiate: the offer editor (06-verein 5.2) -----------------------------
|
||||
auto show_offer = [this] {
|
||||
if (!offer_editor_) fail("E_INTERNAL", "no offer editor");
|
||||
|
||||
@@ -1476,6 +1476,14 @@ inline constexpr auto Pitch_Render_TextPointer2 = 0xae0ec;
|
||||
inline constexpr auto Pitch_Render_TextPointer3 = 0xae0f0;
|
||||
inline constexpr auto Pitch_Render_TextPointer4 = 0xae0f4;
|
||||
inline constexpr auto Pitch_Render_TextPointer5 = 0xae0f8;
|
||||
inline constexpr auto PitchPreferenceDepthBases = 0xa3cc3;
|
||||
inline constexpr auto PitchPreferenceRed = 0xa3cc7;
|
||||
inline constexpr auto PitchPreferenceGreen = 0xa3cd1;
|
||||
inline constexpr auto OriginalPointerPixels = 0xa45b4;
|
||||
inline constexpr auto EnglishPitchPreferenceDepthBases = 0x6e230;
|
||||
inline constexpr auto EnglishPitchPreferenceRed = 0x6e234;
|
||||
inline constexpr auto EnglishPitchPreferenceGreen = 0x6e240;
|
||||
inline constexpr auto EnglishOriginalPointerPixels = 0x70554;
|
||||
inline constexpr auto PitchOrderPositionPointers = 0xa2a37;
|
||||
inline constexpr auto PitchOrderZoneMasks = 0xa2a4b;
|
||||
inline constexpr auto PitchOrderZoneTextPointers = 0xae818;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "formats/fbm.hpp"
|
||||
#include <string_view>
|
||||
|
||||
namespace bmh {
|
||||
// Verified German V2.24 state layout: the supplied Diamond 3.7 changes its
|
||||
// container label, while retaining the same block order and database counts.
|
||||
// Expanded careers have their own layout and must not accept these markers.
|
||||
inline bool supported_native_save_version(std::string_view version, bool expanded = false) {
|
||||
return expanded ? version == "O1.1" : version == "V2.24" || version == "V3.7";
|
||||
}
|
||||
inline void require_native_savegame(const Savegame& save, bool expanded = false) {
|
||||
if (!save.checksum_ok) throw FormatError("savegame: FBM checksum mismatch");
|
||||
if (!supported_native_save_version(save.version, expanded))
|
||||
throw FormatError("savegame: unsupported FBM version " + save.version);
|
||||
// Callers still parse the complete state using the installed edition's
|
||||
// exact DbCounts; a recognized marker never bypasses layout validation.
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,24 @@ Palette load_palette(const std::filesystem::path& path) {
|
||||
return p;
|
||||
}
|
||||
|
||||
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path) {
|
||||
const Bytes bytes = read_file(path);
|
||||
if (bytes.size() < 8) throw FormatError("VGA palette source is truncated");
|
||||
const size_t rle_end = 8 + size_t(le32(bytes, 4));
|
||||
if (rle_end > bytes.size()) throw FormatError("VGA RLE length exceeds palette source");
|
||||
const size_t trailing = bytes.size() - rle_end;
|
||||
if (trailing == 0) return std::nullopt;
|
||||
if (trailing < 768) throw FormatError("truncated embedded VGA palette");
|
||||
Palette palette;
|
||||
for (size_t i = 0; i < palette.argb.size(); ++i) {
|
||||
const auto channel = [&](size_t component) {
|
||||
return uint32_t(vga_dac_rgb8(bytes[rle_end + i * 3 + component]));
|
||||
};
|
||||
palette.argb[i] = 0xff000000u | channel(0) << 16 | channel(1) << 8 | channel(2);
|
||||
}
|
||||
return palette;
|
||||
}
|
||||
|
||||
uint8_t Palette::nearest(uint8_t r, uint8_t g, uint8_t b) const {
|
||||
int best = 0, best_dist = INT32_MAX;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -21,5 +22,7 @@ constexpr uint8_t vga_dac_rgb8(uint8_t channel) {
|
||||
}
|
||||
|
||||
Palette load_palette(const std::filesystem::path& path);
|
||||
// Some full-screen VGA pictures carry their own DAC palette after the RLE data.
|
||||
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path);
|
||||
|
||||
} // namespace bmh
|
||||
@@ -56,19 +56,9 @@ uint32_t facility_level(const GameState& g, int m, int k) {
|
||||
// (balance 1 %, fixed deposit 2 % a year), positive an expense (overdraft 12 %, beyond the
|
||||
// credit line 18 %). The divisor is -36500.
|
||||
int32_t daily_interest_preview(const GameState& g, int m) {
|
||||
constexpr int32_t kAnnual = -0x8e94;
|
||||
const int32_t balance = rec32(g, m, 0x314), deposit = rec32(g, m, 0x318), credit = rec32(g, m, 0x31c);
|
||||
int32_t result = 0;
|
||||
if (balance < 0) {
|
||||
const int32_t with_credit = wrap(int64_t(balance) + credit);
|
||||
if (with_credit < 0) result = wrap(int64_t(with_credit) * 0x12) / kAnnual;
|
||||
int32_t below = wrap(-int64_t(credit));
|
||||
if (below < balance) below = balance;
|
||||
result = wrap(int64_t(result) + wrap(int64_t(below) * 0xc) / kAnnual);
|
||||
} else {
|
||||
result = balance / kAnnual;
|
||||
}
|
||||
return wrap(int64_t(result) + wrap(int64_t(deposit / 10000) * 20000) / kAnnual);
|
||||
const auto interest = daily_interest_amounts(balance, deposit, credit);
|
||||
return interest.borrowing + interest.cash_and_deposit;
|
||||
}
|
||||
|
||||
// SharesAndLoans(manager, flags, months): flags 1 the dividends of the manager's funds and
|
||||
@@ -78,7 +68,7 @@ int32_t shares_and_loans(const GameState& g, int m, int flags, int months) {
|
||||
int32_t sum = 0;
|
||||
if (flags & 1) {
|
||||
for (int k = 0; k < 6; k++) {
|
||||
const uint32_t unit = g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c) * uint32_t(kShareUnits[k]) / 10000;
|
||||
const uint32_t unit = uint32_t((uint64_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c)) * uint32_t(kShareUnits[k])) / 10000);
|
||||
sum = wrap(int64_t(sum) + int64_t(unit * g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c)));
|
||||
}
|
||||
if (flags & 4) sum = wrap(int64_t(sum) * months);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "game/state.hpp"
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
|
||||
namespace bmh {
|
||||
// OpenBMH-owned OBMHEXT1 section BRM1: four little-endian blocked month-start keys.
|
||||
// Unknown histories use UINT32_MAX; original save fields are not repurposed.
|
||||
inline constexpr uint32_t kBankRobberyMonthExtension = 0x314d5242;
|
||||
inline constexpr uint32_t kUnknownBankRobberyMonth = std::numeric_limits<uint32_t>::max();
|
||||
inline constexpr uint32_t kBankRobberyMonthBytes = 16;
|
||||
|
||||
inline std::optional<uint32_t> bank_robbery_guard_month(const GameState& state, int manager) {
|
||||
if (manager < 0 || manager > 3) throw FormatError("bank robbery: invalid manager");
|
||||
if (!state.memory.has(kBankRobberyMonthExtension)) return {};
|
||||
if (!state.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
|
||||
throw FormatError("bank robbery: truncated monthly guard");
|
||||
const auto key = state.memory.u32(kBankRobberyMonthExtension + uint32_t(manager) * 4);
|
||||
return key == kUnknownBankRobberyMonth ? std::nullopt : std::optional<uint32_t>{key};
|
||||
}
|
||||
inline void set_bank_robbery_guard_month(GameState& state, int manager, std::optional<uint32_t> key) {
|
||||
if (manager < 0 || manager > 3) throw FormatError("bank robbery: invalid manager");
|
||||
if (!state.memory.has(kBankRobberyMonthExtension)) {
|
||||
state.memory.add_block(kBankRobberyMonthExtension, kBankRobberyMonthBytes);
|
||||
for (uint32_t slot = 0; slot < 4; ++slot)
|
||||
state.memory.set32(kBankRobberyMonthExtension + slot * 4, kUnknownBankRobberyMonth);
|
||||
}
|
||||
if (!state.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
|
||||
throw FormatError("bank robbery: truncated monthly guard");
|
||||
state.memory.set32(kBankRobberyMonthExtension + uint32_t(manager) * 4, key.value_or(kUnknownBankRobberyMonth));
|
||||
}
|
||||
// The first absolute day of the source calendar month, distinct across years.
|
||||
uint32_t bank_robbery_month_key(uint32_t date);
|
||||
}
|
||||
@@ -10,6 +10,18 @@ CalendarEpoch calendar_epoch_from_executable(const LeImage& exe) {
|
||||
constexpr uint8_t month_and_year_prefix[] = {0xc6,0x44,0x24,0x0c,0x07,0xc7,0x04,0x24};
|
||||
if (!exe.contains(setup) || !exe.contains(setup + 16))
|
||||
throw FormatError("calendar: missing original date setup");
|
||||
constexpr uint8_t english_prefix[] = {0xc6,0x45,0xf6};
|
||||
constexpr uint8_t english_month_and_year[] = {0xc6,0x45,0xf7,0x07,0x66,0xc7,0x45,0xf8};
|
||||
bool english = true;
|
||||
for (uint32_t i=0;i<sizeof english_prefix;++i)
|
||||
english = english && exe.u8(setup+i)==english_prefix[i];
|
||||
for (uint32_t i=0;i<sizeof english_month_and_year;++i)
|
||||
english = english && exe.u8(setup+4+i)==english_month_and_year[i];
|
||||
if (english) {
|
||||
const auto year=exe.u16(setup+12); const int weekday=exe.u8(setup+3);
|
||||
if(year<1600||year>9999||weekday>6)throw FormatError("calendar: invalid original English epoch");
|
||||
return {int(year),weekday};
|
||||
}
|
||||
for (uint32_t i=0;i<sizeof weekday_prefix;++i)
|
||||
if(exe.u8(setup+i)!=weekday_prefix[i])throw FormatError("calendar: unverified weekday setup");
|
||||
for (uint32_t i=0;i<sizeof month_and_year_prefix;++i)
|
||||
|
||||
@@ -171,6 +171,10 @@ GameState startup_state(const LeImage& exe, const Database& db, const Bytes& m3_
|
||||
}
|
||||
const SaveState save(stream, counts);
|
||||
GameState g = GameState::from_save(save, counts);
|
||||
// The original options entry restores ordinary dialogs before any manager
|
||||
// confirmation. The executable's initial value belongs to its boot screens.
|
||||
g.memory.add_block(layout::CompactDialogFrame, 1);
|
||||
g.memory.set8(layout::CompactDialogFrame, 0);
|
||||
competition_pointers(g.memory, exe); // CompetitionPointers
|
||||
return g;
|
||||
}
|
||||
|
||||
+2
-2
@@ -622,7 +622,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
|
||||
g.manager_records.at(at) = uint8_t(n + 1), g.manager_records.at(at + 1) = uint8_t((n + 1) >> 8);
|
||||
}
|
||||
// ListTitleHoldersAf(winner, title): the list of title holders (Titles)
|
||||
mem.set16(::bmh::layout::Titles + uint32_t(title) * 100 + uint32_t(std::min<int>(g.season, 0x31)) * 2, winners[0]);
|
||||
record_title_holder(g, title, winners[0]);
|
||||
}
|
||||
if (type == 0 && !winners.empty()) {
|
||||
// the national cup: winner (Cup_AdvanceCup_RuntimeField5) and the previous holder
|
||||
@@ -654,7 +654,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
|
||||
if (mem.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && winner_display)
|
||||
winner_display(g, {7, winner});
|
||||
if (mem.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && mem.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2)) mem.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2, 0);
|
||||
mem.set16(::bmh::layout::Titles + 7 * 100 + uint32_t(std::min<int>(g.season, 0x31)) * 2, winner);
|
||||
record_title_holder(g, 7, winner);
|
||||
if (mem.has(::bmh::layout::Cup_AdvanceCup_RuntimeField7)) mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField7, winner);
|
||||
const int manager = g.manager_of(winner);
|
||||
if (manager >= 0) {
|
||||
|
||||
@@ -538,6 +538,13 @@ TransferActionResult list_manager_player(GameState& g, int manager, int squad_ro
|
||||
out.status = TransferActionStatus::invalid_player;
|
||||
return out;
|
||||
}
|
||||
bool free_entry = false;
|
||||
for (size_t entry = 0; entry < 40; ++entry) {
|
||||
const int listed = g.squad_slots.at(0xb70 + entry) & 0xfff;
|
||||
if (listed == player) { out.status = TransferActionStatus::pending; out.player = player; out.list_entry = int(entry); return out; }
|
||||
free_entry = free_entry || listed == 0xfff;
|
||||
}
|
||||
if (!free_entry) { out.status = TransferActionStatus::blocked_by_board; return out; }
|
||||
if (!list_transfer_player(g, slot, rand, report)) {
|
||||
out.status = report.unsupported ? TransferActionStatus::invalid_request : TransferActionStatus::blocked_by_board;
|
||||
return out;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "game/transfer_allocator.hpp"
|
||||
// OpenBMH deviates from the original: supports designated set-piece records and the supported transfer-editor rules.
|
||||
// Actions a human manager can take at his desk that change the game state and draw random
|
||||
// numbers (BMH.exe V2.24 + supported rule profile patch). The screens themselves belong to the UI; these
|
||||
@@ -272,6 +273,12 @@ struct TransferOfferEditorSubmitResult {
|
||||
TransferOfferEditorSubmitResult submit_transfer_offer_editor_source(GameState&,
|
||||
const TransferOfferEditorState&,WatcomRandom&,const HumanBuyerSaleHooks&,MinuteReport&);
|
||||
|
||||
// OpenBMH deviates from the original: a seller may accept an existing bid before expiry.
|
||||
// The caller stages state/RNG; cancellation is handled before invoking this action.
|
||||
TransferActionResult accept_manager_transfer_offer(GameState&, int manager, int list_entry,
|
||||
int expected_player, int bid_index, WatcomRandom&, MinuteReport&,
|
||||
TransferAllocatorContext = TransferAllocatorContext::unsupported);
|
||||
|
||||
// Submit a manager bid on an existing list entry. A full-value fee and salary meeting
|
||||
// the demand complete an immediate agreement; lower viable offers persist for weekly review.
|
||||
TransferActionResult submit_transfer_bid(GameState& g, const TransferBidRequest& request, WatcomRandom& rand);
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/long_career.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace bmh {
|
||||
namespace {
|
||||
uint32_t key(int team, int player) {
|
||||
if (team < 0 || team > 0xfff || player < 0 || player >= 0xfff)
|
||||
throw FormatError("long career: invalid player/club identity");
|
||||
return uint32_t(team) << 12 | uint32_t(player);
|
||||
}
|
||||
int manager_team(const GameState& g, int manager) {
|
||||
if (manager >= 0 && size_t(manager) < g.manager_teams.size()) return g.manager_teams[size_t(manager)];
|
||||
const size_t at = size_t(manager) * 0xb0c + 0x290;
|
||||
if (manager < 0 || manager > 4 || at + 1 >= g.manager_records.size())
|
||||
throw FormatError("long career: invalid manager");
|
||||
return int(g.manager_records[at] | uint16_t(g.manager_records[at + 1]) << 8);
|
||||
}
|
||||
PlayerClubStatistics legacy(const std::array<uint8_t, 0x58>& b) {
|
||||
auto word = [&](size_t at) { return uint64_t(b[at] | uint16_t(b[at + 1]) << 8); };
|
||||
return {{b[7], b[8], b[9]}, word(0x48), word(0x4a), word(0x4c)};
|
||||
}
|
||||
void increment(uint64_t& n) {
|
||||
if (n == std::numeric_limits<uint64_t>::max()) throw FormatError("long career: statistics counter exhausted");
|
||||
++n;
|
||||
}
|
||||
void put(Bytes& b, uint64_t n, int width) { for (int i = 0; i < width; ++i) b.push_back(uint8_t(n >> (i * 8))); }
|
||||
struct Reader {
|
||||
const Bytes& bytes; size_t pos = 0;
|
||||
uint64_t get(int width) {
|
||||
if (size_t(width) > bytes.size() - pos) throw FormatError("long career: truncated extension");
|
||||
uint64_t n = 0; for (int i = 0; i < width; ++i) n |= uint64_t(bytes[pos++]) << (i * 8); return n;
|
||||
}
|
||||
std::string string() {
|
||||
const size_t size = size_t(get(2));
|
||||
if (size > bytes.size() - pos) throw FormatError("long career: truncated title name");
|
||||
std::string s(bytes.begin() + pos, bytes.begin() + pos + size); pos += size; return s;
|
||||
}
|
||||
};
|
||||
}
|
||||
PlayerClubStatistics player_club_statistics(const GameState& g, int team, int player,
|
||||
const std::array<uint8_t, 0x58>& board) {
|
||||
const auto found = g.player_statistics.find(key(team, player));
|
||||
return found == g.player_statistics.end() ? legacy(board) : found->second;
|
||||
}
|
||||
void record_player_statistics(GameState& g, int manager, int row, int player, int cls, int kind) {
|
||||
const size_t at = size_t(manager) * 0x840 + size_t(row) * 0x58;
|
||||
if (manager < 0 || row < 0 || row >= 24 || at + 0x58 > g.tactics.size() || cls < 0 || cls > 3 || kind < 0 || kind > 2)
|
||||
throw FormatError("long career: invalid statistics row/event");
|
||||
std::array<uint8_t, 0x58> board; std::copy_n(g.tactics.begin() + at, board.size(), board.begin());
|
||||
const auto identity = key(manager_team(g, manager), player);
|
||||
auto [found, inserted] = g.player_statistics.try_emplace(identity, legacy(board));
|
||||
auto next = found->second;
|
||||
if (kind == 0) { if (cls < 3) increment(next.appearances[size_t(cls)]); increment(next.total); }
|
||||
else if (kind == 1) increment(next.goals);
|
||||
else increment(next.assists);
|
||||
found->second = next;
|
||||
}
|
||||
void reset_player_statistics(GameState& g, int manager, int player) {
|
||||
g.player_statistics.erase(key(manager_team(g, manager), player));
|
||||
}
|
||||
void swap_statistics_clubs(GameState& g, int first, int second) {
|
||||
PlayerStatisticsArchive next;
|
||||
for (const auto& [identity, value] : g.player_statistics) {
|
||||
const int club = int(identity >> 12), player = int(identity & 0xfff);
|
||||
next.emplace(key(club == first ? second : club == second ? first : club, player), value);
|
||||
}
|
||||
g.player_statistics = std::move(next);
|
||||
}
|
||||
TitleHistoryArchive title_history_rows(const GameState& g) {
|
||||
if (g.season < 0) throw FormatError("long career: negative season index");
|
||||
auto rows = g.title_history;
|
||||
if (!g.memory.has(layout::Titles + 899)) return rows;
|
||||
const int first = std::max(0, g.season - 49);
|
||||
for (int slot = 0; slot < 50 && first + slot <= g.season; ++slot) {
|
||||
const auto season = uint32_t(first + slot);
|
||||
if (rows.contains(season)) continue;
|
||||
std::array<std::string, 9> winners;
|
||||
for (size_t category = 0; category < 9; ++category) {
|
||||
const auto team = g.memory.u16(layout::Titles + uint32_t(category) * 100 + uint32_t(slot) * 2);
|
||||
if (team != 0xffff) winners[category] = g.club_name(team);
|
||||
}
|
||||
rows.emplace(season, std::move(winners));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
void capture_title_history(GameState& g) { g.title_history = title_history_rows(g); }
|
||||
void record_title_holder(GameState& g, int category, uint16_t winner) {
|
||||
if (category < 0 || category >= 9 || g.season < 0 || winner >= g.club_ids.size())
|
||||
throw FormatError("long career: invalid title award");
|
||||
capture_title_history(g);
|
||||
const auto name = g.club_name(winner);
|
||||
g.memory.set16(layout::Titles + uint32_t(category) * 100 + uint32_t(std::min(g.season, 49)) * 2, winner);
|
||||
g.title_history[uint32_t(g.season)][size_t(category)] = name;
|
||||
}
|
||||
void shift_legacy_title_history(GameState& g) {
|
||||
if (g.season <= 49) return;
|
||||
for (uint32_t category = 0; category < 9; ++category) {
|
||||
for (uint32_t i = 0; i < 98; ++i)
|
||||
g.memory.set8(layout::Titles + category * 100 + i,
|
||||
g.memory.u8(layout::Season_SeasonEndSteps_RuntimeField + category * 100 + i));
|
||||
g.memory.set16(layout::Season_SeasonEndSteps_RuntimeField2 + category * 100, 0xffff);
|
||||
}
|
||||
}
|
||||
Bytes encode_long_career(const GameState& g) {
|
||||
if (g.player_statistics.empty() && g.title_history.empty()) return {};
|
||||
Bytes b; put(b, 1, 4); put(b, g.player_statistics.size(), 4); put(b, g.title_history.size(), 4);
|
||||
for (const auto& [identity, s] : g.player_statistics) {
|
||||
put(b, identity, 4); for (const auto n : s.appearances) put(b, n, 8);
|
||||
for (const auto n : {s.total, s.goals, s.assists}) put(b, n, 8);
|
||||
}
|
||||
for (const auto& [season, names] : g.title_history) {
|
||||
if (season > 32767) throw FormatError("long career: archived season exceeds native calendar range");
|
||||
put(b, season, 4);
|
||||
for (const auto& name : names) {
|
||||
if (name.size() > UINT16_MAX) throw FormatError("long career: title name too long");
|
||||
put(b, name.size(), 2); b.insert(b.end(), name.begin(), name.end());
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
void decode_long_career(GameState& g, const Bytes& bytes) {
|
||||
Reader r{bytes};
|
||||
if (r.get(4) != 1) throw FormatError("long career: unsupported extension version");
|
||||
const auto players = r.get(4), seasons = r.get(4);
|
||||
if (players > (bytes.size() - r.pos) / 52 || seasons > 32768)
|
||||
throw FormatError("long career: invalid extension counts");
|
||||
PlayerStatisticsArchive stats; TitleHistoryArchive history;
|
||||
for (uint64_t i = 0; i < players; ++i) {
|
||||
const auto identity = uint32_t(r.get(4));
|
||||
if (identity > 0xffffff || (identity & 0xfff) == 0xfff) throw FormatError("long career: invalid archived identity");
|
||||
PlayerClubStatistics s; for (auto& n : s.appearances) n = r.get(8);
|
||||
s.total = r.get(8); s.goals = r.get(8); s.assists = r.get(8);
|
||||
if (!stats.emplace(identity, s).second) throw FormatError("long career: duplicate archived identity");
|
||||
}
|
||||
for (uint64_t i = 0; i < seasons; ++i) {
|
||||
const auto season = uint32_t(r.get(4));
|
||||
if (season > 32767) throw FormatError("long career: invalid archived season");
|
||||
std::array<std::string, 9> names; for (auto& name : names) name = r.string();
|
||||
if (!history.emplace(season, std::move(names)).second) throw FormatError("long career: duplicate archived season");
|
||||
}
|
||||
if (r.pos != bytes.size()) throw FormatError("long career: trailing extension bytes");
|
||||
g.player_statistics = std::move(stats); g.title_history = std::move(history);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "formats/binary.hpp"
|
||||
|
||||
namespace bmh {
|
||||
struct GameState;
|
||||
struct PlayerClubStatistics {
|
||||
std::array<uint64_t, 3> appearances{};
|
||||
uint64_t total = 0, goals = 0, assists = 0;
|
||||
bool operator==(const PlayerClubStatistics&) const = default;
|
||||
};
|
||||
// Optional OBMHEXT1 block, outside the Original guest address space. Payload v1.
|
||||
inline constexpr uint32_t kLongCareerExtension = 0x4f424c43;
|
||||
using PlayerStatisticsArchive = std::map<uint32_t, PlayerClubStatistics>;
|
||||
using TitleHistoryArchive = std::map<uint32_t, std::array<std::string, 9>>;
|
||||
PlayerClubStatistics player_club_statistics(const GameState&, int team, int player,
|
||||
const std::array<uint8_t, 0x58>& board);
|
||||
void record_player_statistics(GameState&, int manager, int row, int player, int competition_class, int kind);
|
||||
void reset_player_statistics(GameState&, int manager, int player);
|
||||
void swap_statistics_clubs(GameState&, int first, int second);
|
||||
TitleHistoryArchive title_history_rows(const GameState&);
|
||||
void capture_title_history(GameState&);
|
||||
void record_title_holder(GameState&, int category, uint16_t winner);
|
||||
void shift_legacy_title_history(GameState&);
|
||||
Bytes encode_long_career(const GameState&);
|
||||
void decode_long_career(GameState&, const Bytes&);
|
||||
}
|
||||
@@ -242,6 +242,7 @@ void player_statistic(GameState& g, int type, int player, int manager, int slot,
|
||||
if (cls == 3 && (g.player_bonus.at(player) & 0x7F) < 0x7F) g.player_bonus.at(player)++;
|
||||
if (manager >= 0) {
|
||||
pay_bonus(g, manager, slot, 2, true);
|
||||
record_player_statistics(g, manager, slot, player, cls, kind);
|
||||
if (cls < 3) g.tactics.at(board + 7 + cls)++;
|
||||
wr16(g.tactics, board + 0x48, uint16_t(rd16(g.tactics, board + 0x48) + 1));
|
||||
}
|
||||
@@ -249,13 +250,17 @@ void player_statistic(GameState& g, int type, int player, int manager, int slot,
|
||||
} else if (kind == 1) { // goal
|
||||
if (manager >= 0) {
|
||||
pay_bonus(g, manager, slot, 0, true);
|
||||
record_player_statistics(g, manager, slot, player, cls, kind);
|
||||
wr16(g.tactics, board + 0x4a, uint16_t(rd16(g.tactics, board + 0x4a) + 1));
|
||||
if (cls == 0) g.manager_records.at(size_t(manager) * kManagerRecord + 0x1ae + std::min(minute, 89) / 5)++;
|
||||
}
|
||||
// league goals in bits 2-7 (a 64th goal carries into bit 8, as in the original)
|
||||
if (cls == 0) p.w364 = (w364 & 0xFFFFFF03u) | ((((w364 >> 2) & 0x3F) << 2) + 4);
|
||||
} else if (kind == 2) { // assist
|
||||
if (manager >= 0) wr16(g.tactics, board + 0x4c, uint16_t(rd16(g.tactics, board + 0x4c) + 1));
|
||||
if (manager >= 0) {
|
||||
record_player_statistics(g, manager, slot, player, cls, kind);
|
||||
wr16(g.tactics, board + 0x4c, uint16_t(rd16(g.tactics, board + 0x4c) + 1));
|
||||
}
|
||||
if (cls == 0) p.w368 = (p.w368 & 0xFF03FFFFu) | ((((p.w368 >> 18) & 0x3F) + 1) << 18);
|
||||
}
|
||||
}
|
||||
@@ -776,7 +781,7 @@ void advance_league_rounds(GameState& g, uint32_t competitions, WatcomRandom& ra
|
||||
if (g.memory.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && winner)
|
||||
winner(g, {0, uint16_t(champion)});
|
||||
if (g.memory.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && g.memory.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2)) g.memory.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2, 0);
|
||||
g.memory.set16(::bmh::layout::Titles + uint32_t(std::min<int>(g.season, 0x31)) * 2, uint16_t(champion));
|
||||
record_title_holder(g, 0, uint16_t(champion));
|
||||
const int manager = g.manager_of(champion);
|
||||
if (manager >= 0) {
|
||||
const size_t at = size_t(manager) * kManagerRecord + 0x8a4;
|
||||
|
||||
+44
-9
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -113,13 +114,8 @@ std::string message_text_following(const GameState& g, uint32_t pointer_variable
|
||||
return text;
|
||||
}
|
||||
|
||||
std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
if (flags & 0x100) {
|
||||
// ConvertCurrency: currency conversion (1/1 unless the savegame says otherwise)
|
||||
const int32_t mul = g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1;
|
||||
const int32_t div = g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1;
|
||||
if (div != 0) value = value * mul / div;
|
||||
}
|
||||
namespace {
|
||||
std::string format_number_digits(const GameState& g, int64_t value, int flags) {
|
||||
// FormatGroupedDigits: digits from the right; with grouping (bit 0x40 clear) a dot before the
|
||||
// 4th, 8th and 12th character; padded to the width (bits 0-5), leading blanks for the
|
||||
// dots a wide field reserves
|
||||
@@ -127,12 +123,12 @@ std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
const int width = flags & 0x3F;
|
||||
int blanks = group && width > 3 ? (width - 4) / 3 + 1 : 0;
|
||||
const bool negative = value < 0;
|
||||
uint32_t v = negative ? uint32_t(-int64_t(value)) : uint32_t(value);
|
||||
uint64_t v = negative ? uint64_t(-(value + 1)) + 1 : uint64_t(value);
|
||||
std::string reversed;
|
||||
int dots = 0;
|
||||
while (v != 0) {
|
||||
const size_t n = reversed.size();
|
||||
if (group && (n == 3 || n == 7 || n == 11)) reversed.push_back('.'), blanks--, dots++;
|
||||
if (group && n % 4 == 3) reversed.push_back('.'), blanks--, dots++;
|
||||
reversed.push_back(char('0' + v % 10));
|
||||
v /= 10;
|
||||
}
|
||||
@@ -149,6 +145,45 @@ std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string format_number(const GameState& g, int32_t value, int flags) {
|
||||
if (flags & 0x100) {
|
||||
// ConvertCurrency: currency conversion (1/1 unless the savegame says otherwise)
|
||||
const int32_t mul = g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1;
|
||||
const int32_t div = g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1;
|
||||
if (div != 0) value = value * mul / div;
|
||||
}
|
||||
return format_number_digits(g, value, flags);
|
||||
}
|
||||
|
||||
std::string format_number_wide(const GameState& g, int64_t value, int flags) {
|
||||
if (flags & 0x100) {
|
||||
const int32_t mul = g.memory.has(layout::CurrencyMultiplier) ? int32_t(g.memory.u32(layout::CurrencyMultiplier)) : 1;
|
||||
const int32_t div = g.memory.has(layout::CurrencyDivisor) ? int32_t(g.memory.u32(layout::CurrencyDivisor)) : 1;
|
||||
if (div != 0) {
|
||||
const bool negative = (value < 0) != ((mul < 0) != (div < 0));
|
||||
const uint64_t magnitude = value < 0 ? uint64_t(-(value + 1)) + 1 : uint64_t(value);
|
||||
const uint64_t multiplier = mul < 0 ? uint64_t(-int64_t(mul)) : uint64_t(mul);
|
||||
const uint64_t divisor = div < 0 ? uint64_t(-int64_t(div)) : uint64_t(div);
|
||||
const uint64_t limit = uint64_t(std::numeric_limits<int64_t>::max()) + uint64_t(negative);
|
||||
// Split before multiplication, keeping exact truncation without
|
||||
// requiring nonportable 128-bit integers for currency conversion.
|
||||
const uint64_t whole = magnitude / divisor;
|
||||
if (multiplier && whole > limit / multiplier)
|
||||
throw FormatError("wide currency amount exceeds display range");
|
||||
const uint64_t base = whole * multiplier;
|
||||
const uint64_t fraction = (magnitude % divisor) * multiplier / divisor;
|
||||
if (fraction > limit - base)
|
||||
throw FormatError("wide currency amount exceeds display range");
|
||||
const uint64_t converted = base + fraction;
|
||||
value = negative ? (converted == uint64_t(std::numeric_limits<int64_t>::max()) + 1
|
||||
? std::numeric_limits<int64_t>::min() : -int64_t(converted)) : int64_t(converted);
|
||||
}
|
||||
}
|
||||
return format_number_digits(g, value, flags);
|
||||
}
|
||||
|
||||
std::string format_amount(const GameState& g, int32_t value) { return format_number(g, value, 0x101); }
|
||||
|
||||
void install_message_texts(const LeImage& exe) {
|
||||
|
||||
@@ -72,5 +72,7 @@ std::string format_amount(const GameState& g, int32_t value);
|
||||
// FormatNumber(buf, value, flags, ""): bits 0-5 the field width, bit 0x40 no dot grouping,
|
||||
// bit 0x100 an amount of money (converted, " EU" appended).
|
||||
std::string format_number(const GameState& g, int32_t value, int flags);
|
||||
// Read-only aggregates can exceed a native save word; preserve currency and padding.
|
||||
std::string format_number_wide(const GameState& g, int64_t value, int flags);
|
||||
|
||||
} // namespace bmh
|
||||
+11
-4
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <optional>
|
||||
@@ -654,7 +655,7 @@ void board_month(GameState& g, int m, WatcomRandom& rand, MinuteReport& report,
|
||||
for (int s = 0; s < 24; s++) g.tactics.at(board(s) + 0xb) &= 0x7F;
|
||||
}
|
||||
|
||||
// MonthChange2: share prices grow by 2.5 %, dividends, loans between the managers.
|
||||
// MonthChange2: share prices grow by 0.25 %, dividends, loans between the managers.
|
||||
void shares_and_loans(GameState& g) {
|
||||
StaticMemory& mem = g.memory;
|
||||
std::vector<uint8_t>& r = g.manager_records;
|
||||
@@ -665,12 +666,16 @@ void shares_and_loans(GameState& g) {
|
||||
uint32_t price = mem.u32(at);
|
||||
price += ((price / 10000) * 0x19 / 10) * 10;
|
||||
mem.set32(at, price);
|
||||
// OpenBMH deviates from the original: keep the price product in 64 bits
|
||||
// until division, retaining per-unit truncation and recipient policy.
|
||||
const uint64_t unit_dividend = (uint64_t(price) * uint32_t(kShareFactor[k])) / 10000;
|
||||
// (a bug of the original: only the last manager's dividend is kept and it is booked
|
||||
// for the manager after the last one)
|
||||
int32_t dividend = 0;
|
||||
for (int m = 0; m < managers; m++)
|
||||
dividend = int32_t(mem.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c) *
|
||||
((price * uint32_t(kShareFactor[k])) / 10000));
|
||||
dividend = std::bit_cast<int32_t>(uint32_t(
|
||||
mem.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + uint32_t(k) * 0x1c) *
|
||||
unit_dividend));
|
||||
book_money(g, managers, -dividend, true);
|
||||
add32(r, size_t(managers) * kRecord + 0x870, dividend);
|
||||
}
|
||||
@@ -694,6 +699,8 @@ void shares_and_loans(GameState& g) {
|
||||
|
||||
} // namespace
|
||||
|
||||
void monthly_shares_and_loans(GameState& g) { shares_and_loans(g); }
|
||||
|
||||
bool list_transfer_player(GameState& g, int slot, WatcomRandom& rand, MinuteReport& report) {
|
||||
return list_player(g, slot, rand, report);
|
||||
}
|
||||
@@ -989,7 +996,7 @@ void month_change(GameState& g, WatcomRandom& rand, MinuteReport& report, GameRa
|
||||
if (report.unsupported) return;
|
||||
// 5. shares and loans
|
||||
turn_step = "month_change: shares";
|
||||
shares_and_loans(g);
|
||||
monthly_shares_and_loans(g);
|
||||
}
|
||||
|
||||
} // namespace bmh
|
||||
@@ -28,6 +28,9 @@ namespace bmh {
|
||||
// `game` is needed when a player leaves at the end of his contract (MonthChange).
|
||||
void month_change(GameState& g, WatcomRandom& rand, MinuteReport& report, GameRandom* game = nullptr);
|
||||
|
||||
// The investment/loan phase, retaining the original dividend recipient policy.
|
||||
void monthly_shares_and_loans(GameState& g);
|
||||
|
||||
// CareerFirstSteps: new players on the transfer list (part of the month change; also at the
|
||||
// start of a season).
|
||||
void new_transfer_list_entries(GameState& g, WatcomRandom& rand, MinuteReport& report);
|
||||
|
||||
@@ -74,6 +74,11 @@ void new_board_entry(GameState& g, int manager, int index, int slot, WatcomRando
|
||||
uint8_t* e = &g.tactics.at(size_t(manager) * kBoard + size_t(index) * kBoardSlot);
|
||||
std::memset(e + 7, 0, 3);
|
||||
std::memset(e + 0x19, 0, 0x24);
|
||||
// OpenBMH deviates from the original: a new arrival must not inherit the
|
||||
// previous occupant's retirement/refusal/month-processing flags.
|
||||
e[0xb] = 0;
|
||||
std::memset(e + 0x48, 0, 6); // Fresh arrivals do not inherit the previous player's totals.
|
||||
reset_player_statistics(g, manager, g.squad_slots.at(size_t(slot)) & 0xfff);
|
||||
e[10] = 2;
|
||||
for (int k = 0; k < 4; k++) e[2 + k] = index < 2 ? 1 : uint8_t(rand.range(2, 0x27));
|
||||
e[0x3f] = 0xff;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/bank_robbery.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
@@ -126,6 +127,16 @@ Bytes save_stream(const GameState& live) {
|
||||
for (uint32_t i = 0; i < size; ++i) bytes[i] = g.memory.u8(at + i);
|
||||
extension.push_back({at, std::move(bytes)});
|
||||
}
|
||||
auto history = encode_long_career(g);
|
||||
if (!history.empty()) extension.push_back({kLongCareerExtension, std::move(history)});
|
||||
if (g.memory.has(kBankRobberyMonthExtension)) {
|
||||
if (!g.memory.has(kBankRobberyMonthExtension + kBankRobberyMonthBytes - 1))
|
||||
throw FormatError("savegame: truncated bank robbery monthly guard");
|
||||
Bytes months(kBankRobberyMonthBytes);
|
||||
for (uint32_t i = 0; i < months.size(); ++i)
|
||||
months[i] = g.memory.u8(kBankRobberyMonthExtension + i);
|
||||
extension.push_back({kBankRobberyMonthExtension, std::move(months)});
|
||||
}
|
||||
append_save_extension(stream, extension);
|
||||
return stream;
|
||||
}
|
||||
|
||||
+3
-4
@@ -787,6 +787,7 @@ void change_places(GameState& g, int a, int b) {
|
||||
mem.set32(::bmh::layout::Career_RemoveJoinLoans_RuntimeField + k * 4, (e & 0xfff) | uint32_t(seller) << 12 | uint32_t(buyer) << 22);
|
||||
}
|
||||
if (!g.club_table.empty() && a < 0xa8 && b < 0xa8) swap_bytes(g.club_table, size_t(a) * 0x4a, size_t(b) * 0x4a, 0x4a);
|
||||
swap_statistics_clubs(g, a, b);
|
||||
std::swap(g.club_ids.at(size_t(a)), g.club_ids.at(size_t(b)));
|
||||
swap_bytes(g.club_heap_bc, size_t(a) * 2, size_t(b) * 2, 2);
|
||||
std::swap(g.team_morale.at(size_t(a)), g.team_morale.at(size_t(b)));
|
||||
@@ -1284,10 +1285,7 @@ SeasonTransitionOutcome season_end_steps(GameState& g, GameRandom& game, WatcomR
|
||||
TransferAllocatorContext allocator) {
|
||||
StaticMemory& mem = g.memory;
|
||||
if (g.season > 0x31) { // SeasonEndSteps
|
||||
for (uint32_t k = 0; k < 9; k++) {
|
||||
for (uint32_t i = 0; i < 0x62; i++) mem.set8(::bmh::layout::Titles + k * 100 + i, mem.u8(::bmh::layout::Season_SeasonEndSteps_RuntimeField + k * 100 + i));
|
||||
mem.set16(::bmh::layout::Season_SeasonEndSteps_RuntimeField2 + k * 100, 0xffff);
|
||||
}
|
||||
shift_legacy_title_history(g);
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++) {
|
||||
for (size_t i = 0; i < 0x93; i++) rec8(g, int(m), 0xda + i) = rec8(g, int(m), 0xdd + i);
|
||||
const size_t at = m * 0xB0C + 0x2aa;
|
||||
@@ -1610,6 +1608,7 @@ SeasonTransitionOutcome season_transition(GameState& g, GameRandom& game, Watcom
|
||||
}
|
||||
g.memory.set8(::bmh::layout::CareerSession_RuntimeError_RuntimeField4, 0);
|
||||
if (g.memory.has(::bmh::layout::Season_SeasonTransition_RuntimeField)) g.memory.set8(::bmh::layout::Season_SeasonTransition_RuntimeField, 0);
|
||||
capture_title_history(g); // Preserve the current window before it advances/shifts.
|
||||
g.season = int16_t(g.season + 1); // SeasonIndex
|
||||
reset_club_moods(g, game, rand);
|
||||
european_setup(g, game, rand, cup_draw);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "game/stadium_blocks.hpp"
|
||||
|
||||
#include "game/matchday.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
@@ -63,6 +64,32 @@ bool valid_resolved_offer(const StandBlockOffer& offer, const StadiumBlockExpans
|
||||
}
|
||||
} // namespace
|
||||
|
||||
StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage& image) {
|
||||
// OpenBMH deviates from the original: allow 144,000 standard places and
|
||||
// size-aware construction times while retaining edition-owned unit prices.
|
||||
static constexpr std::array<uint32_t, 8> minima{
|
||||
14000, 24000, 14000, 20000, 14000, 24000, 14000, 20000};
|
||||
StadiumBlockExpansionConstants out;
|
||||
uint32_t total = 0;
|
||||
for (size_t i = 0; i < minima.size(); ++i) {
|
||||
out.price_per_1000[i] = image.u32(
|
||||
layout::CareerSession_DispatchStadium_RuntimeField + uint32_t((i + 8) * 4));
|
||||
const auto original = uint32_t(image.u8(
|
||||
layout::CareerSession_Invalid_RuntimeField + uint32_t(i))) * 1000;
|
||||
out.max_places[i] = std::max(original, minima[i]);
|
||||
total += out.max_places[i];
|
||||
const auto source_weeks = image.u8(
|
||||
layout::CareerSession_DispatchStadium_RuntimeField2 + uint32_t((i + 22) * 5));
|
||||
const auto weeks = std::max<uint32_t>(source_weeks, 2 * (out.max_places[i] / 1000));
|
||||
if (weeks > 255)
|
||||
throw FormatError("stadium: expanded construction period exceeds saved byte");
|
||||
out.weeks[i] = uint8_t(weeks);
|
||||
}
|
||||
if (total > 255000)
|
||||
throw FormatError("stadium: combined stand limits exceed saved capacity byte");
|
||||
return out;
|
||||
}
|
||||
|
||||
std::optional<StadiumBlockExpansionQuote> quote_stadium_block_expansion(
|
||||
const GameState& g, int manager, StadiumBlockSlot slot, uint32_t total_target_places,
|
||||
uint8_t desired_features, int company_price_percent,
|
||||
|
||||
@@ -20,6 +20,10 @@ struct StadiumBlockExpansionConstants {
|
||||
std::array<uint32_t, 8> max_places{};
|
||||
};
|
||||
|
||||
// OpenBMH1.0.3 expands standard A-H limits to at least144k total. Prices
|
||||
// still come from the edition; larger blocks have at least2weeks per1000places.
|
||||
StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage&);
|
||||
|
||||
// An immutable quote binds the Source owner and every record/table value that
|
||||
// affects the quote. Commit recomputes this value before it touches money.
|
||||
struct StadiumBlockExpansionQuote {
|
||||
|
||||
+13
-1
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "game/bank_robbery.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -99,7 +100,16 @@ GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
|
||||
g.foreign_strength = bytes(::bmh::layout::ForeignClubStrength);
|
||||
g.memory = StaticMemory(save);
|
||||
// memory OpenBMH saves behind the trailer (the English cup blocks, career.hpp)
|
||||
for (const auto& b : save.extension()) {
|
||||
bool long_career_seen=false,robbery_months_seen=false;
|
||||
for(const auto& b:save.extension()){
|
||||
if(b.address==kLongCareerExtension){
|
||||
if(long_career_seen)throw FormatError("long career: duplicate extension block");
|
||||
decode_long_career(g,b.bytes);long_career_seen=true;continue;
|
||||
}
|
||||
if(b.address==kBankRobberyMonthExtension){
|
||||
if(robbery_months_seen||b.bytes.size()!=kBankRobberyMonthBytes)throw FormatError("savegame: invalid or duplicate bank robbery monthly guard");
|
||||
robbery_months_seen=true;
|
||||
}
|
||||
if (!g.memory.has(b.address)) g.memory.add_block(b.address, uint32_t(b.bytes.size()));
|
||||
for (size_t i = 0; i < b.bytes.size(); ++i) g.memory.set8(b.address + uint32_t(i), b.bytes[i]);
|
||||
}
|
||||
@@ -110,6 +120,8 @@ GameState GameState::from_save(const SaveState& save, const DbCounts& c) {
|
||||
g.stadium_names = save.pool(3);
|
||||
g.player_name_offsets = words16(::bmh::layout::PlayerNameOffsets);
|
||||
g.season = int16_t(save.data(::bmh::layout::SeasonIndex)[0] | save.data(::bmh::layout::SeasonIndex)[1] << 8);
|
||||
if (!g.title_history.empty() && (g.season < 0 || g.title_history.rbegin()->first > uint32_t(g.season)))
|
||||
throw FormatError("long career: archived season is beyond the saved calendar");
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "formats/textd.hpp"
|
||||
#include "game/memory.hpp"
|
||||
#include "game/random.hpp"
|
||||
#include "game/long_career.hpp"
|
||||
#include "game/reality_motion.hpp"
|
||||
|
||||
namespace bmh {
|
||||
@@ -36,6 +37,8 @@ constexpr uint16_t kEmptySlot = 0x0FFF;
|
||||
constexpr uint16_t kSlotInLineup = 0x8000;
|
||||
|
||||
struct GameState {
|
||||
PlayerStatisticsArchive player_statistics;
|
||||
TitleHistoryArchive title_history;
|
||||
std::vector<uint16_t> squad_slots; // *SquadSlots, all squads back to back (see squad_range)
|
||||
std::vector<Player> players; // *PlayerConditionTechniqueForm / *PlayerSkillWords / *PlayerIdentityWords, names not filled
|
||||
std::vector<uint8_t> team_morale; // *TeamMorale, per team: bits 0-5 morale / 2, bits 6-7 flags
|
||||
|
||||
+46
-17
@@ -2,12 +2,14 @@
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/week.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
#include "game/bank_robbery.hpp"
|
||||
|
||||
#include "game/matchday.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
@@ -24,6 +26,23 @@ void wr32(std::vector<uint8_t>& v, size_t o, int32_t x) {
|
||||
|
||||
} // namespace
|
||||
|
||||
DailyInterestAmounts daily_interest_amounts(int32_t cash, int32_t deposit, int32_t credit) {
|
||||
// OpenBMH deviates from the original: widen products before annual-rate
|
||||
// division so valid native account amounts do not overflow intermediate sums.
|
||||
// Preserve truncation at each original division, including deposit / 10000.
|
||||
DailyInterestAmounts result;
|
||||
if (cash < 0) {
|
||||
const int64_t with_credit = int64_t(cash) + credit;
|
||||
int64_t borrowing = with_credit < 0 ? with_credit * 18 / -36500 : 0;
|
||||
borrowing += std::max(int64_t(cash), -int64_t(credit)) * 12 / -36500;
|
||||
result.borrowing = int32_t(borrowing);
|
||||
} else {
|
||||
result.cash_and_deposit = cash / -36500;
|
||||
}
|
||||
result.cash_and_deposit += int32_t(int64_t(deposit / 10000) * 20000 / -36500);
|
||||
return result;
|
||||
}
|
||||
|
||||
void daily_interest(GameState& g, WatcomRandom& rand) {
|
||||
// (DailyInterest before the day step: the training camp visits of today are over)
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++) g.manager_records.at(m * kManagerRecord + 0x21f) &= 0x7f;
|
||||
@@ -32,25 +51,29 @@ void daily_interest(GameState& g, WatcomRandom& rand) {
|
||||
const int32_t balance = rd32(g.manager_records, rec + 0x314);
|
||||
const int32_t deposit = rd32(g.manager_records, rec + 0x318);
|
||||
const int32_t credit = rd32(g.manager_records, rec + 0x31c);
|
||||
int32_t amount = 0; // positive = cost
|
||||
const auto interest = daily_interest_amounts(balance, deposit, credit);
|
||||
if (balance < 0) {
|
||||
if (balance + credit < 0) amount = ((balance + credit) * 18) / -36500;
|
||||
int32_t used = -credit < balance ? balance : -credit;
|
||||
amount += (used * 12) / -36500;
|
||||
wr32(g.manager_records, rec + 0x89c, rd32(g.manager_records, rec + 0x89c) + amount);
|
||||
book_money(g, k, amount, true);
|
||||
amount = 0;
|
||||
} else {
|
||||
amount = balance / -36500;
|
||||
const auto statistic = uint32_t(rd32(g.manager_records, rec + 0x89c)) + uint32_t(interest.borrowing);
|
||||
wr32(g.manager_records, rec + 0x89c, std::bit_cast<int32_t>(statistic));
|
||||
book_money(g, k, interest.borrowing, true);
|
||||
}
|
||||
amount += ((deposit / 10000) * 20000) / -36500;
|
||||
wr32(g.manager_records, rec + 0x870, rd32(g.manager_records, rec + 0x870) - amount);
|
||||
book_money(g, k, amount, true);
|
||||
if (rd32(g.manager_records, rec + 0x314) > 100000000) { // read again after the bookings
|
||||
int32_t extra = int32_t(rand.range(10000, 20000)) * 1000;
|
||||
// BookMoney2 with the statistics flag set: counts as an expense (+0x8a0)
|
||||
wr32(g.manager_records, rec + 0x8a0, rd32(g.manager_records, rec + 0x8a0) + extra);
|
||||
book_money(g, k, extra, true);
|
||||
const auto statistic = uint32_t(rd32(g.manager_records, rec + 0x870)) - uint32_t(interest.cash_and_deposit);
|
||||
wr32(g.manager_records, rec + 0x870, std::bit_cast<int32_t>(statistic));
|
||||
book_money(g, k, interest.cash_and_deposit, true);
|
||||
if (rd32(g.manager_records, rec + 0x314) > 100000000) {
|
||||
const auto robbery_month = bank_robbery_month_key(g.date);
|
||||
const auto guard = bank_robbery_guard_month(g, k);
|
||||
// OpenBMH deviates from the original: an unknown history receives
|
||||
// a grace month; later losses occur at most once per source month.
|
||||
if (!guard) {
|
||||
set_bank_robbery_guard_month(g, k, robbery_month);
|
||||
} else if (*guard != robbery_month) {
|
||||
const int32_t extra = int32_t(rand.range(10000, 20000)) * 1000;
|
||||
const auto expense = uint32_t(rd32(g.manager_records, rec + 0x8a0)) + uint32_t(extra);
|
||||
wr32(g.manager_records, rec + 0x8a0, std::bit_cast<int32_t>(expense));
|
||||
book_money(g, k, extra, true);
|
||||
set_bank_robbery_guard_month(g, k, robbery_month);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,6 +391,12 @@ void stock_market(GameState& g, GameRandom& game) {
|
||||
|
||||
namespace bmh {
|
||||
|
||||
uint32_t bank_robbery_month_key(uint32_t date) {
|
||||
const int month = month_code(date);
|
||||
while (date > 0 && month_code(date - 1) == month) --date;
|
||||
return date;
|
||||
}
|
||||
|
||||
int month_code(uint32_t date) {
|
||||
// DeskState_DeskDate_RuntimeField: days per month (index 1-12; February 29 in leap years)
|
||||
uint8_t days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
@@ -28,6 +28,12 @@ namespace bmh {
|
||||
// cleared for every manager.
|
||||
void daily_interest(GameState& g, WatcomRandom& rand);
|
||||
|
||||
struct DailyInterestAmounts {
|
||||
int32_t borrowing = 0;
|
||||
int32_t cash_and_deposit = 0; // Negative amounts are interest income.
|
||||
};
|
||||
DailyInterestAmounts daily_interest_amounts(int32_t cash, int32_t deposit, int32_t credit);
|
||||
|
||||
} // namespace bmh
|
||||
|
||||
namespace bmh {
|
||||
|
||||
+44
-1
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
#include "game/pending_offer.hpp"
|
||||
#include "game/human_buyer_sale.hpp"
|
||||
#include "game/transfer_bid.hpp"
|
||||
@@ -215,7 +216,7 @@ void manager_offers(GameState& g, int manager, WatcomRandom& rand, MinuteReport&
|
||||
if (kind == 14) {
|
||||
for (int k = 0; k < 6; k++) {
|
||||
const uint32_t held = g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(k) * 0x1c);
|
||||
const uint32_t value = uint32_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c) * uint32_t(kShareFactor[k])) / 10000;
|
||||
const uint32_t value = uint32_t((uint64_t(g.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c)) * uint32_t(kShareFactor[k])) / 10000);
|
||||
sum += int(uint32_t(rand.range(10, 20)) * (held * value));
|
||||
}
|
||||
if (sum == 0) continue;
|
||||
@@ -1637,6 +1638,7 @@ static TransferOfferListView project_transfer_offer_list_impl(const GameState& g
|
||||
view.player = player;
|
||||
view.seller = g.memory.u16(list + 8) & 0x7fff;
|
||||
view.seller_manager = g.manager_of(view.seller);
|
||||
offer_bases(g.memory, list, -1, view.asking_fee, view.asking_monthly_salary);
|
||||
for (int bid = 0; bid < 4; ++bid) view.offers[size_t(bid)].bid_index = bid;
|
||||
if (view.seller_manager >= 0 && g.memory.has(::bmh::layout::DeskActions_Unsupported_RuntimeField + uint32_t(view.seller_manager)))
|
||||
view.seller_loan_count = g.memory.u8(::bmh::layout::DeskActions_Unsupported_RuntimeField + uint32_t(view.seller_manager));
|
||||
@@ -2621,6 +2623,47 @@ PendingOfferResult process_national_nomination_pending_after_desk(GameState& g,
|
||||
return process_natural_pending_offers_after_desk(g,request,game,rand,hooks,report);
|
||||
}
|
||||
|
||||
TransferActionResult accept_manager_transfer_offer(GameState& g, int manager, int entry,
|
||||
int expected_player, int bid, WatcomRandom& rand, MinuteReport& report, TransferAllocatorContext allocator) {
|
||||
TransferActionResult result;
|
||||
const auto view = project_transfer_offer_list(g, entry);
|
||||
if (!view.valid || manager < 0 || view.seller_manager != manager ||
|
||||
view.player != expected_player || bid < 0 || bid >= 4) return result;
|
||||
const auto& offer = view.offers[size_t(bid)];
|
||||
if (!offer.present) return result;
|
||||
if (!offer.affordable) { result.status = TransferActionStatus::insufficient_funds; return result; }
|
||||
if (!offer.has_squad_room) { result.status = TransferActionStatus::no_squad_room; return result; }
|
||||
if (!offer.passes_foreign_limit || !offer.loan_permitted) {
|
||||
result.status = TransferActionStatus::blocked_by_board; return result;
|
||||
}
|
||||
if (!offer.transaction_supported) { result.status = TransferActionStatus::unsupported; return result; }
|
||||
const uint32_t list = kTransferList + uint32_t(entry) * kListEntry;
|
||||
auto staged = g;
|
||||
auto staged_rand = rand;
|
||||
const uint32_t salary_at = list + 0x0c + uint32_t(bid) * 4;
|
||||
const auto salary = staged.memory.u32(salary_at);
|
||||
staged.memory.set32(salary_at, (salary * 10u) >> 3);
|
||||
uint32_t fee_pct = 0, salary_pct = 0;
|
||||
const bool rated = evaluate_bid(staged, list, bid, fee_pct, salary_pct, staged_rand, report);
|
||||
staged.memory.set32(salary_at, salary);
|
||||
if (!rated || report.unsupported) { result.status = TransferActionStatus::unsupported; return result; }
|
||||
if (!salary_pct) { result.status = TransferActionStatus::rejected; return result; }
|
||||
if (!accept_transfer_bid_immediately(staged, entry, bid, staged_rand, report,
|
||||
allocator) || report.unsupported) {
|
||||
result.status = TransferActionStatus::unsupported; return result;
|
||||
}
|
||||
const auto buyer_range = squad_range(offer.buyer);
|
||||
const bool moved = std::any_of(staged.squad_slots.begin() + buyer_range.first,
|
||||
staged.squad_slots.begin() + buyer_range.first + buyer_range.count,
|
||||
[&](uint16_t slot) { return (slot & 0xfff) == expected_player; });
|
||||
if (!moved) { result.status = TransferActionStatus::unsupported; return result; }
|
||||
g = std::move(staged); rand = staged_rand;
|
||||
result.status = TransferActionStatus::accepted;
|
||||
result.player = expected_player; result.list_entry = entry;
|
||||
result.fee = int32_t(offer.fee); result.annual_salary = int32_t(offer.monthly_salary);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool accept_transfer_bid_immediately(GameState& g, int entry, int bid, WatcomRandom& rand,
|
||||
MinuteReport& report, TransferAllocatorContext allocator) {
|
||||
if (entry < 0 || entry >= 40 || bid < 0 || bid >= 4) return false;
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace {
|
||||
constexpr uint32_t kEnFileOffset = 0x496d;
|
||||
constexpr uint32_t kEnDataStart = ::bmh::layout::EnDataStart, kEnDataEnd = ::bmh::layout::Career_CompetitionPointersEnglish_RuntimeField;
|
||||
constexpr uint32_t kFltdSize = 507925;
|
||||
constexpr uint32_t kEnglishCalendarDateSetup = 0x684;
|
||||
// The German image the engine expects: LE objects from layout field, data object GermanDataSegmentBegin-layout field.
|
||||
constexpr uint32_t kDeBase = 0x10000, kDeEnd = ::bmh::layout::GermanImageEnd;
|
||||
// A zero byte in the German BSS: the empty string of empty_pointers entries.
|
||||
@@ -118,6 +119,15 @@ LeImage translate_fltd(const fs::path& fltd_exe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Preserve the English date-setup operands in the shared epoch slot. The
|
||||
// English routine uses a different stack layout; the calendar reader
|
||||
// verifies that layout before reading its year and weekday.
|
||||
for (uint32_t i = 0; i < 14; ++i)
|
||||
put(layout::CalendarDateSetup + i, en(kEnglishCalendarDateSetup + i));
|
||||
// The native 11x11 pointer is an edition-owned indexed bitmap.
|
||||
for (uint32_t i = 0; i < 11 * 11; ++i)
|
||||
put(::bmh::layout::OriginalPointerPixels + i,
|
||||
en(::bmh::layout::EnglishOriginalPointerPixels + i));
|
||||
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -225,6 +225,9 @@
|
||||
{::bmh::layout::ClubPlayerDetail_ClubPlayerDetailRedraw_RuntimeField2, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation156, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField7, 10, Kind::copy, ::bmh::layout::EnglishLayoutTranslation157, {}},
|
||||
{::bmh::layout::Pitch_Render_RuntimeField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation163, {}},
|
||||
{::bmh::layout::PitchPreferenceDepthBases, 4, Kind::copy, ::bmh::layout::EnglishPitchPreferenceDepthBases, {}},
|
||||
{::bmh::layout::PitchPreferenceRed, 10, Kind::copy, ::bmh::layout::EnglishPitchPreferenceRed, {}},
|
||||
{::bmh::layout::PitchPreferenceGreen, 10, Kind::copy, ::bmh::layout::EnglishPitchPreferenceGreen, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation176, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation177, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField3, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation178, {}},
|
||||
|
||||
@@ -379,7 +379,7 @@ ResolvedGame resolve_game(const fs::path& input, const fs::path& cache) {
|
||||
const fs::path marker = prepared / ".openbmh-english";
|
||||
// the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built
|
||||
// by another version is built again
|
||||
constexpr const char* kTranslation = "english translation 13"; // 13: setup toggle rows, positive balance colour and desktop bar controls
|
||||
constexpr const char* kTranslation = "english translation 15"; // 15: original pitch affinity tables and pointer bitmap (14: calendar epoch)
|
||||
std::string built;
|
||||
{
|
||||
std::ifstream in(marker);
|
||||
|
||||
@@ -243,3 +243,7 @@ bmh_add_data_test(NAME transfer_history_tests COMMAND transfer_history_tests "${
|
||||
add_executable(sportschau_ui_tests ../../tests/sportschau_ui_tests.cpp)
|
||||
target_link_libraries(sportschau_ui_tests PRIVATE bmhui)
|
||||
bmh_add_data_test(NAME sportschau_ui_tests COMMAND sportschau_ui_tests "${BMH_DATA}")
|
||||
|
||||
add_executable(live_score_reveal_tests live_score_reveal_tests.cpp)
|
||||
target_link_libraries(live_score_reveal_tests PRIVATE bmhui)
|
||||
add_test(NAME live_score_reveal_tests COMMAND live_score_reveal_tests)
|
||||
@@ -88,7 +88,7 @@ int32_t original_share_adjustment(const GameState& game, int manager, bool incom
|
||||
if (income) {
|
||||
for (int k = 0; k < 6; ++k) {
|
||||
const uint32_t shares = game.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c);
|
||||
const uint32_t unit = uint32_t(shares) * uint32_t(kShareUnits[size_t(k)]) / 10000;
|
||||
const uint32_t unit = uint32_t((uint64_t(shares) * uint32_t(kShareUnits[size_t(k)])) / 10000);
|
||||
const uint32_t owned = game.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(k) * 0x1c);
|
||||
amount = wrap_add(amount, signed32(unit * owned));
|
||||
}
|
||||
|
||||
+23
-26
@@ -100,8 +100,8 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
}
|
||||
state.credit_currency = {g.memory.has(::bmh::layout::CurrencyMultiplier) ? int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)) : 1,
|
||||
g.memory.has(::bmh::layout::CurrencyDivisor) ? int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor)) : 1};
|
||||
const auto currency = [&](int32_t amount, int flags) {
|
||||
std::string value = format_number(g, amount, flags);
|
||||
const auto currency = [&](int64_t amount, int flags) {
|
||||
std::string value = format_number_wide(g, amount, flags);
|
||||
// FormatNumber appends currency (CurrencySuffixText) and the caller's Bank_FormatError_ExecutableField suffix.
|
||||
value += exe.cstring(::bmh::layout::Bank_FormatError_ExecutableField);
|
||||
return original_to_utf8(value);
|
||||
@@ -141,8 +141,8 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
fund.owned = g.memory.u16(at + 0x14 + uint32_t(manager) * 2);
|
||||
fund.max_to_buy = fund.price == 0 ? 0 : max_fund_units(g, manager, int(i));
|
||||
fund.name = original_to_utf8(message_text(g, ::bmh::layout::Bank_OriginalToUtf8_TextPointer3 + uint32_t(i) * 4));
|
||||
fund.unit_price_text = currency(wrap_i32(fund.price), 0x108);
|
||||
fund.average_paid_text = currency(fund.owned ? wrap_i32(fund.paid / fund.owned) : 0, 0x108);
|
||||
fund.unit_price_text = currency(fund.price, 0x108);
|
||||
fund.average_paid_text = currency(fund.owned ? fund.paid / fund.owned : 0, 0x108);
|
||||
fund.quantity_text = original_to_utf8(format_number(g, fund.owned, 0x82) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField2));
|
||||
fund.one_quantity_text = original_to_utf8(format_number(g, 1, 0x82) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField2));
|
||||
const uint32_t suffix = exe.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField + uint32_t(i) * 8);
|
||||
@@ -154,49 +154,46 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
// and the separate overdraft limit. All inputs are copied/read-only.
|
||||
state.finance_values[0] = state.balance;
|
||||
state.finance_values[1] = state.deposit;
|
||||
int32_t investment_value = 0, investment_gain = 0;
|
||||
// OpenBMH deviates from the original: read-only totals use wide arithmetic;
|
||||
// individual saved account, price, holding and paid fields are unchanged.
|
||||
int64_t investment_value = 0, investment_gain = 0;
|
||||
for (size_t i = 0; i < state.funds.size(); ++i) {
|
||||
const uint32_t price = g.memory.u32(::bmh::layout::FundBlock + uint32_t(i) * 0x1c);
|
||||
const uint32_t held = g.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(i) * 0x1c);
|
||||
const int32_t value = wrap_i32(price * held);
|
||||
investment_value = wrap_sum(investment_value, value);
|
||||
const int32_t paid = wrap_i32(g.memory.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField5 + uint32_t(i) * 0x1c + uint32_t(manager) * 4));
|
||||
if (held) investment_gain = wrap_sum(investment_gain, wrap_i32(uint32_t(value) - uint32_t(paid)));
|
||||
const int64_t value = int64_t(price) * held;
|
||||
investment_value += value;
|
||||
const int64_t paid = g.memory.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField5 + uint32_t(i) * 0x1c + uint32_t(manager) * 4);
|
||||
if (held) investment_gain += value - paid;
|
||||
}
|
||||
state.finance_values[2] = investment_value;
|
||||
state.finance_gains[0] = investment_gain;
|
||||
int32_t stock_value = 0, stock_gain = 0;
|
||||
int64_t stock_value = 0, stock_gain = 0;
|
||||
for (size_t i = 0; i < state.stocks.size(); ++i) {
|
||||
const int32_t value = wrap_i32(uint32_t(state.stocks[i].price) * state.stocks[i].owned);
|
||||
stock_value = wrap_sum(stock_value, value);
|
||||
if (state.stocks[i].owned) stock_gain = wrap_sum(stock_gain, wrap_i32(uint32_t(value) - uint32_t(state.stocks[i].paid)));
|
||||
const int64_t value = int64_t(state.stocks[i].price) * state.stocks[i].owned;
|
||||
stock_value += value;
|
||||
if (state.stocks[i].owned) stock_gain += value - state.stocks[i].paid;
|
||||
}
|
||||
state.finance_values[3] = stock_value;
|
||||
state.finance_gains[1] = stock_gain;
|
||||
int32_t debts = 0, debt_assets = 0;
|
||||
int64_t debts = 0, debt_assets = 0;
|
||||
for (uint32_t loan = 0; loan < 5; ++loan) {
|
||||
const uint32_t at = ::bmh::layout::Analytics_SourceAssetMaskE_RuntimeField + uint32_t(manager) * 0x78 + loan * 0x18;
|
||||
const uint32_t borrowed = g.memory.u32(at);
|
||||
const uint32_t repaid = g.memory.u32(at + 0x10);
|
||||
debts = wrap_sum(debts, wrap_i32(borrowed - repaid));
|
||||
debt_assets = wrap_sum(debt_assets, wrap_i32(borrowed));
|
||||
debts += int64_t(borrowed) - repaid;
|
||||
debt_assets += borrowed;
|
||||
}
|
||||
state.finance_values[4] = debts;
|
||||
int32_t net = state.balance;
|
||||
net = wrap_sum(net, state.deposit);
|
||||
net = wrap_sum(net, investment_value);
|
||||
net = wrap_sum(net, stock_value);
|
||||
net = wrap_sum(net, wrap_i32(0u - uint32_t(debt_assets)));
|
||||
state.finance_values[5] = net;
|
||||
state.finance_values[5] = int64_t(state.balance) + state.deposit + investment_value + stock_value - debt_assets;
|
||||
state.finance_values[6] = state.credit_line;
|
||||
for (size_t i = 0; i < state.finance_value_text.size(); ++i)
|
||||
state.finance_value_text[i] = currency(state.finance_values[i], 0x188);
|
||||
for (size_t i = 0; i < state.finance_gains.size(); ++i) {
|
||||
const int32_t gain = state.finance_gains[i];
|
||||
const int64_t gain = state.finance_gains[i];
|
||||
const uint32_t sign_address = gain < 0 ? ::bmh::layout::Bank_OriginalToUtf8_ExecutableField5 : gain > 0 ? ::bmh::layout::Bank_OriginalToUtf8_ExecutableField6 : ::bmh::layout::Bank_OriginalToUtf8_ExecutableField7;
|
||||
const int32_t magnitude = gain < 0 ? wrap_i32(0u - uint32_t(gain)) : gain;
|
||||
const int64_t magnitude = gain < 0 ? -gain : gain;
|
||||
state.finance_gain_text[i] = original_to_utf8(exe.cstring(sign_address) +
|
||||
format_number(g, magnitude, 0x101) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
|
||||
format_number_wide(g, magnitude, 0x101) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
|
||||
// 0x101 appends; Source preserves market value and adds signed gain in parentheses.
|
||||
if (state.finance_values[i + 2] != 0)
|
||||
state.finance_value_text[i + 2] += original_to_utf8(exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField4)) + state.finance_gain_text[i];
|
||||
@@ -226,7 +223,7 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
state.finance_fund_labels[i] = original_to_utf8(format_number(g, fund.owned, 0x82) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField2) +
|
||||
message_text(g, ::bmh::layout::Bank_OriginalToUtf8_TextPointer3 + uint32_t(i) * 4) +
|
||||
exe.cstring(exe.u32(::bmh::layout::Bank_OriginalToUtf8_RuntimeField + uint32_t(i) * 8 + (fund.owned > 1 ? 4 : 0))));
|
||||
state.finance_fund_prices[i] = original_to_utf8("(" + format_number(g, wrap_i32(fund.price), 0x108) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
|
||||
state.finance_fund_prices[i] = original_to_utf8("(" + format_number_wide(g, fund.price, 0x108) + exe.cstring(::bmh::layout::Bank_OriginalToUtf8_ExecutableField3));
|
||||
}
|
||||
for (size_t i = 0; i < state.stocks.size(); ++i) {
|
||||
const auto& stock = state.stocks[i];
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@ struct BankState {
|
||||
std::string investment_limit_text;
|
||||
int manager_portrait = 0, badge_sprite = 0;
|
||||
// MaxSharesToBuy case 1: the seven read-only values shown in the finance view.
|
||||
std::array<int32_t, 7> finance_values{};
|
||||
std::array<int32_t, 2> finance_gains{};
|
||||
std::array<int64_t, 7> finance_values{};
|
||||
std::array<int64_t, 2> finance_gains{};
|
||||
std::array<std::string, 7> finance_value_text{};
|
||||
std::array<std::string, 2> finance_gain_text{};
|
||||
// Case 4 (bank credit) readonly values as seen before any local edits.
|
||||
|
||||
@@ -28,7 +28,7 @@ void rect(Image& out, int x, int y, int w, int h, uint8_t color) {
|
||||
for (int yy = std::max(0, y); yy < std::min(out.height, y + h); ++yy)
|
||||
for (int xx = std::max(0, x); xx < std::min(out.width, x + w); ++xx) out.at(xx, yy) = color;
|
||||
}
|
||||
std::string padded(int value, int width = 2) {
|
||||
std::string padded(uint64_t value, int width = 2) {
|
||||
std::string s = std::to_string(value);
|
||||
if (int(s.size()) < width) s.insert(0, size_t(width - int(s.size())), '%');
|
||||
return s;
|
||||
@@ -110,7 +110,10 @@ ClubInfoProjection club_info_from_game(const GameState& g, int team,
|
||||
player.cards = g.player_cards[id];
|
||||
player.bonus = g.player_bonus[id];
|
||||
}
|
||||
if (board) player.manager_board = std::move(board);
|
||||
if (board) {
|
||||
player.manager_board = std::move(board);
|
||||
if (player.player_id >= 0) player.statistics = player_club_statistics(g, team, player.player_id, *player.manager_board);
|
||||
}
|
||||
if (!player.borrowed && player.player_id >= 0) {
|
||||
for (int loan = 0; loan < 200; ++loan) {
|
||||
const uint32_t address = ::bmh::layout::Career_RemoveJoinLoans_RuntimeField + uint32_t(loan) * 4;
|
||||
@@ -296,9 +299,9 @@ Image ClubInfoScreen::render() const {
|
||||
std::string attrs = padded(p.bonus & 127, 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
|
||||
if (p.manager_board) {
|
||||
const auto& b = *p.manager_board;
|
||||
attrs += padded(b[7], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + padded(b[9], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
|
||||
Bytes raw(b.begin(), b.end()); attrs += padded(le16(raw, 0x48), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
|
||||
padded(le16(raw, 0x4a), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + padded(le16(raw, 0x4c), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField);
|
||||
attrs += padded(p.statistics ? p.statistics->appearances[0] : b[7], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + padded(p.statistics ? p.statistics->appearances[2] : b[9], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
|
||||
Bytes raw(b.begin(), b.end()); attrs += padded((p.statistics ? p.statistics->total : le16(raw, 0x48)), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
|
||||
padded((p.statistics ? p.statistics->goals : le16(raw, 0x4a)), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + padded((p.statistics ? p.statistics->assists : le16(raw, 0x4c)), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField);
|
||||
}
|
||||
text(out, 165, baseline, attrs, 0x6c);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ struct ClubInfoPlayer {
|
||||
bool offer_name_color = false;
|
||||
// Present only when this runtime club belongs to a human manager.
|
||||
std::optional<std::array<uint8_t, 0x58>> manager_board;
|
||||
std::optional<PlayerClubStatistics> statistics;
|
||||
};
|
||||
|
||||
// Owned inputs for one render of ClubInfoFromGame / LineupScreen. Build this from the actual
|
||||
|
||||
@@ -148,6 +148,7 @@ ContractsState contracts_from_game(const GameState& game, int manager_slot, uint
|
||||
view.source.name = game.player_name(player); view.source.attributes = source;
|
||||
view.source.cards = game.player_cards.at(size_t(player)); view.source.bonus = game.player_bonus.at(size_t(player));
|
||||
std::copy_n(game.tactics.begin() + std::ptrdiff_t(at), 0x58, view.source.board.begin());
|
||||
view.source.statistics = player_club_statistics(game, team, player, view.source.board);
|
||||
state.players.push_back(std::move(view));
|
||||
}
|
||||
if (!state.players.empty()) {
|
||||
@@ -314,6 +315,7 @@ Image ContractsScreen::render_roster() const {
|
||||
text(out, x, y, original_to_utf8(raw), color, -1);
|
||||
};
|
||||
const auto fixed = [](uint32_t value, int width, bool grouped = false) { return original_number(value, width, grouped); };
|
||||
const auto count = [](uint64_t value) { auto s = std::to_string(value); if(s.size()<3)s.insert(0,3-s.size(),'%'); return s; };
|
||||
const auto title = original_to_utf8(texts_[(::bmh::layout::Contracts_RenderRoster_TextPointer2 - ::bmh::layout::TextPointerTable) / 4]);
|
||||
sprite_font_.draw(out, SpriteFont::centered_title_x(sprite_font_.text_width(title)), 13, title, 5);
|
||||
sprite_font_.draw(out, 5, 235, state_.club_name, 5);
|
||||
@@ -374,9 +376,9 @@ Image ContractsScreen::render_roster() const {
|
||||
original_text(65, baseline, fixed(a.age(), 2) + texts_[(::bmh::layout::ClubInfo_Render_TextPointer5 - ::bmh::layout::TextPointerTable) / 4], 0x6c);
|
||||
for (int skill = 0; skill < 7; ++skill) copy_region(out, atlas_, 256 + a.skill(Player::Skill(skill)) * 16, 32, 87 + skill * 10, baseline - 5, 16, 5, true);
|
||||
auto word = [&](int at) { return uint16_t(s.board[at] | uint16_t(s.board[at + 1]) << 8); };
|
||||
original_text(165, baseline, fixed(s.bonus & 127, 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + fixed(s.board[7], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) +
|
||||
fixed(s.board[9], 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + fixed(word(0x48), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
|
||||
fixed(word(0x4a), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + fixed(word(0x4c), 3) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField), 0x6c);
|
||||
original_text(165, baseline, fixed(s.bonus & 127, 3) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + count(s.statistics ? s.statistics->appearances[0] : s.board[7]) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) +
|
||||
count(s.statistics ? s.statistics->appearances[2] : s.board[9]) + exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5) + count(s.statistics ? s.statistics->total : word(0x48)) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) +
|
||||
count(s.statistics ? s.statistics->goals : word(0x4a)) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2) + count(s.statistics ? s.statistics->assists : word(0x4c)) + exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField), 0x6c);
|
||||
}
|
||||
baseline += 7;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
@@ -690,8 +691,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
|
||||
DeskState load_reference_desk(const std::filesystem::path& path, const LeImage& exe) {
|
||||
auto fbm = load_savegame(path);
|
||||
if (!fbm.checksum_ok) throw FormatError("desk: FBM checksum mismatch");
|
||||
if (fbm.version != "V2.24") throw FormatError("desk: unsupported FBM version");
|
||||
require_native_savegame(fbm);
|
||||
DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
SaveState save(fbm.stream, counts);
|
||||
auto d = desk_from_save(save, exe);
|
||||
|
||||
@@ -103,6 +103,9 @@ public:
|
||||
FlowResult expire_stadium_tip();
|
||||
bool in_stadium() const { return bool(stadium_); }
|
||||
bool in_pitch() const { return bool(pitch_); }
|
||||
std::optional<std::array<uint32_t,121>> pitch_pointer_cursor(const Palette& palette) const {
|
||||
return pitch_ && screen_name() == "pitch" ? pitch_->pointer_cursor(palette) : std::nullopt;
|
||||
}
|
||||
std::optional<Image> pitch_formation_save_feedback(bool restored) const;
|
||||
FlowResult pitch_held_left(int x, int y, uint64_t source_ticks);
|
||||
void consume_orphaned_pitch_release(){pitch_release_barrier_=false;}
|
||||
|
||||
@@ -461,7 +461,10 @@ Image IncomingTransferScreen::render_at_elapsed(uint64_t elapsed_ms) const {
|
||||
std::string(text_at(texts_, ::bmh::layout::IncomingTransfer_RenderAtElapsed_TextPointer14)) + source_number(state_.quoted_years, 1, false) +
|
||||
std::string(text_at(texts_, ::bmh::layout::Contracts_Out_ExecutableField15)) + (state_.quoted_years == 1 ? "" : exe_.cstring(::bmh::layout::Fltd_Layout_TextPointer3)) +
|
||||
exe_.cstring(::bmh::layout::IncomingTransfer_RenderAtElapsed_TextPointer);
|
||||
centered(0, 319, 32, quote, 0x6a);
|
||||
// Early listing review has no newly rolled quote. Explain its input instead
|
||||
// of presenting a fabricated zero-year, zero-price valuation.
|
||||
centered(0, 319, 32, state_.quoted_years ? quote :
|
||||
"Angebot anklicken. Rechtsklick: zurueck.", 0x6a);
|
||||
shadow_text(7, 123, std::string(text_at(texts_, ::bmh::layout::IncomingTransfer_RenderAtElapsed_TextPointer10)) +
|
||||
source_money(state_.asking_fee, 7, state_.currency_numerator, state_.currency_denominator), 0x6a);
|
||||
shadow_text(170, 123, std::string(text_at(texts_, ::bmh::layout::IncomingTransfer_RenderAtElapsed_TextPointer11)) +
|
||||
@@ -527,6 +530,17 @@ bool IncomingTransferScreen::dismiss_notice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void IncomingTransferScreen::pointer_down(bool right) {
|
||||
pointer_buttons_ |= right ? 2 : 1;
|
||||
}
|
||||
|
||||
std::optional<int> IncomingTransferScreen::pointer_up(int x, int y, bool right, uint64_t elapsed_ms) {
|
||||
const uint8_t button = right ? 2 : 1;
|
||||
if (!(pointer_buttons_ & button)) return std::nullopt;
|
||||
pointer_buttons_ &= uint8_t(~button);
|
||||
return click(x, y, right, elapsed_ms);
|
||||
}
|
||||
|
||||
std::optional<int> IncomingTransferScreen::click(int x, int y, bool right, uint64_t elapsed_ms) {
|
||||
if (confirmation_mode_) {
|
||||
if (!right && x >= 95 && x <= 220 && y >= 166 && y <= 176)
|
||||
|
||||
@@ -142,6 +142,10 @@ public:
|
||||
void show_confirmation(uint32_t original_text_address, const Image& backdrop);
|
||||
bool confirmation_dismissed() const { return confirmation_dismissed_; }
|
||||
bool outcome_dismissed() const { return outcome_dismissed_; }
|
||||
// Raw release-driven presenters must own a press in this visible modal.
|
||||
// Semantic Source DOWN actions can continue to use click directly.
|
||||
void pointer_down(bool right = false);
|
||||
std::optional<int> pointer_up(int x, int y, bool right = false, uint64_t elapsed_ms = 0);
|
||||
std::optional<int> click(int x, int y, bool right = false, uint64_t elapsed_ms = 0);
|
||||
std::optional<int> key(std::string_view name);
|
||||
bool dismiss_notice();
|
||||
@@ -159,6 +163,7 @@ private:
|
||||
Image background_, negotiation_;
|
||||
bool gradient_text_ = true;
|
||||
std::optional<int> answer_;
|
||||
uint8_t pointer_buttons_ = 0;
|
||||
bool notice_active_ = false;
|
||||
int outcome_row_count_ = -1;
|
||||
int outcome_accepted_bid_index_ = -1;
|
||||
|
||||
@@ -93,6 +93,24 @@ int main(int argc, char** argv) {
|
||||
"raw Source 0xfff pool seller resolves without indexing a club or national-team token");
|
||||
|
||||
auto state = fixture();
|
||||
IncomingTransferScreen release_owner(argv[1], state);
|
||||
const auto undecided_pixels = release_owner.render().pixels;
|
||||
check(!release_owner.pointer_up(310,230,true) &&
|
||||
!release_owner.pointer_up(309,229,true) && !release_owner.answer() &&
|
||||
release_owner.render().pixels == undecided_pixels,
|
||||
"late/repeated table releases cannot decline the following transfer");
|
||||
release_owner.pointer_down();
|
||||
release_owner.pointer_down(); // Repeated DOWN still owns a single left gesture.
|
||||
check(!release_owner.pointer_up(310,230,true) && !release_owner.answer(),
|
||||
"an orphan right release does not consume an owned left press");
|
||||
check(release_owner.pointer_up(10,150) == 0 &&
|
||||
!release_owner.pointer_up(10,150) && release_owner.answer() == 0,
|
||||
"fresh left gesture selects its raw offer once despite repeated DOWN/UP");
|
||||
IncomingTransferScreen right_owner(argv[1], state);
|
||||
right_owner.pointer_down(true);right_owner.pointer_down(true);
|
||||
check(right_owner.pointer_up(309,229,true) == -1 &&
|
||||
!right_owner.pointer_up(309,229,true) && right_owner.answer() == -1,
|
||||
"fresh moved right gesture still declines exactly once");
|
||||
IncomingTransferScreen screen(argv[1], state);
|
||||
const auto frame = screen.render();
|
||||
check(frame.width == 320 && frame.height == 240 && frame.pixels.size() == 320u * 240u,
|
||||
@@ -247,6 +265,13 @@ int main(int argc, char** argv) {
|
||||
"only a left click inside KLICK can acknowledge the confirmation");
|
||||
check(!confirm.click(95,166) && confirm.confirmation_dismissed() && !confirm.answer(),
|
||||
"KLICK acknowledges without submitting a new transfer decision");
|
||||
IncomingTransferScreen confirmation_owner(argv[1],confirm_state);
|
||||
confirmation_owner.show_confirmation(::bmh::layout::PendingOffer_FormatError_ExecutableField2,settled_image);
|
||||
check(!confirmation_owner.pointer_up(150,170) && !confirmation_owner.confirmation_dismissed(),
|
||||
"an inherited left release cannot acknowledge the next confirmation");
|
||||
confirmation_owner.pointer_down();
|
||||
check(!confirmation_owner.pointer_up(150,170) && confirmation_owner.confirmation_dismissed(),
|
||||
"a fresh complete left gesture acknowledges its owned confirmation");
|
||||
IncomingTransferScreen confirm_edge(argv[1],confirm_state);
|
||||
confirm_edge.show_confirmation(::bmh::layout::PendingOffer_FormatError_ExecutableField2,settled_image);
|
||||
check(!confirm_edge.click(221,176) && !confirm_edge.confirmation_dismissed(),
|
||||
|
||||
+11
-4
@@ -83,7 +83,7 @@ void copy(Image& out, const Image& src, int sx, int sy, int x, int y, int w, int
|
||||
if (c != transparent && x+xx>=0 && x+xx<out.width && y+yy>=0 && y+yy<out.height) out.at(x+xx,y+yy)=c;
|
||||
}
|
||||
}
|
||||
std::string number(int value, int width = 2) {
|
||||
std::string number(uint64_t value, int width = 2) {
|
||||
auto s=std::to_string(value);
|
||||
if (int(s.size())<width) s.insert(0,size_t(width-int(s.size())),'%');
|
||||
return s;
|
||||
@@ -110,11 +110,16 @@ LineupState lineup_from_save(const SaveState& s,const LeImage& exe,uint64_t revi
|
||||
for(size_t at=0;at<w1.size();at+=4) players.push_back({{},le32(w1,at),le32(w2,at),le32(w3,at)});
|
||||
auto out=project(memory,exe,teams,words(block(s,::bmh::layout::SquadSlots)),players,block(s,::bmh::layout::TacticsBoards),block(s,::bmh::layout::ManagerAutomation),
|
||||
words(block(s,::bmh::layout::PlayerCards)),block(s,::bmh::layout::PlayerBonuses),words(block(s,::bmh::layout::PlayerNameOffsets)),s.pool(1),words(block(s,::bmh::layout::ClubIdentities)),s.pool(0),revision);
|
||||
const auto g = GameState::from_save(s);
|
||||
for (auto& p : out.players) if (p.player_id >= 0)
|
||||
p.statistics = player_club_statistics(g, out.runtime_club, p.player_id, p.board);
|
||||
out.source="original_save_read_only"; return out;
|
||||
}
|
||||
LineupState lineup_from_game(const GameState& g,const LeImage& exe,uint64_t revision) {
|
||||
auto out=project(g.memory,exe,g.manager_teams,g.squad_slots,g.players,g.tactics,g.manager_options,
|
||||
g.player_cards,g.player_bonus,g.player_name_offsets,g.player_names,g.club_ids,g.club_names,revision);
|
||||
for (auto& p : out.players) if (p.player_id >= 0)
|
||||
p.statistics = player_club_statistics(g, out.runtime_club, p.player_id, p.board);
|
||||
out.source="engine_projection"; return out;
|
||||
}
|
||||
|
||||
@@ -224,9 +229,9 @@ Image LineupScreen::render() const {
|
||||
} else {
|
||||
text(out,65,baseline,number(a.age())+texts_[(::bmh::layout::ClubInfo_Render_TextPointer5-::bmh::layout::TextPointerTable)/4],0x6c);
|
||||
for(int skill=0;skill<7;++skill)copy(out,atlas_,256+a.skill(Player::Skill(skill))*16,32,87+skill*10,baseline-5,16,5,0);
|
||||
text(out,165,baseline,number(p.bonus&127,3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+number(p.board[7],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+
|
||||
number(p.board[9],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+number(le16(Bytes(p.board.begin(),p.board.end()),0x48),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+
|
||||
number(le16(Bytes(p.board.begin(),p.board.end()),0x4a),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+number(le16(Bytes(p.board.begin(),p.board.end()),0x4c),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField),0x6c);
|
||||
text(out,165,baseline,number(p.bonus&127,3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+number(p.statistics ? p.statistics->appearances[0] : p.board[7],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+
|
||||
number(p.statistics ? p.statistics->appearances[2] : p.board[9],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+number((p.statistics ? p.statistics->total : le16(Bytes(p.board.begin(),p.board.end()),0x48)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+
|
||||
number((p.statistics ? p.statistics->goals : le16(Bytes(p.board.begin(),p.board.end()),0x4a)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+number((p.statistics ? p.statistics->assists : le16(Bytes(p.board.begin(),p.board.end()),0x4c)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField),0x6c);
|
||||
}
|
||||
}
|
||||
button(out,1,215,texts_[(::bmh::layout::Lineup_Render_TextPointer-::bmh::layout::TextPointerTable)/4+(state_.view==LineupView::data_a?1:0)]);
|
||||
@@ -310,6 +315,8 @@ std::string LineupScreen::state_json() const {
|
||||
if(p.player_id>=0)s<<",\"starting\":"<<((p.slot&0x8000)?"true":"false")<<",\"bench\":"<<((p.slot&0x4000)?"true":"false")
|
||||
<<",\"position_type\":"<<p.attributes.position()<<",\"condition\":"<<p.attributes.condition()<<",\"technique\":"<<p.attributes.technique()
|
||||
<<",\"form\":"<<p.attributes.form()<<",\"strength\":"<<p.attributes.strength()<<",\"age\":"<<p.attributes.age()<<",\"exhaustion\":"<<int(p.board[0xf]);
|
||||
if (p.statistics) s << ",\"club_appearances\":[" << p.statistics->appearances[0] << ',' << p.statistics->appearances[1] << ',' << p.statistics->appearances[2]
|
||||
<< "],\"total_appearances\":" << p.statistics->total << ",\"club_goals\":" << p.statistics->goals << ",\"club_assists\":" << p.statistics->assists;
|
||||
s<<'}';}
|
||||
s<<"]}";return s.str();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "formats/font.hpp"
|
||||
#include "game/long_career.hpp"
|
||||
#include "formats/m3d.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
#include "ui/setup.hpp"
|
||||
@@ -22,6 +23,7 @@ struct LineupPlayer {
|
||||
uint16_t cards = 0;
|
||||
uint8_t bonus = 0;
|
||||
std::array<uint8_t, 0x58> board{};
|
||||
std::optional<PlayerClubStatistics> statistics;
|
||||
};
|
||||
struct LineupState {
|
||||
int manager_slot = -1, runtime_club = -1;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -46,6 +47,29 @@ struct LiveMatchdayFrame {
|
||||
LiveMatchdayFrame live_matchday_frame(int minute, const std::vector<MatchGroup>& groups,
|
||||
const GameState& state);
|
||||
|
||||
// The engine commits a chance before its ball/set-piece/shot presentation. Keep
|
||||
// the observed preview scores until the result hook, without delaying simulation.
|
||||
class LiveScoreReveal {
|
||||
public:
|
||||
void observe(LiveChanceStage stage, const LiveMatchdayFrame& frame) {
|
||||
if (stage == LiveChanceStage::preview) preview_ = frame;
|
||||
else preview_.reset();
|
||||
}
|
||||
LiveMatchdayFrame project(LiveMatchdayFrame frame) const {
|
||||
if (!preview_ || preview_->minute != frame.minute) return frame;
|
||||
for (auto& row : frame.matches) for (const auto& before : preview_->matches)
|
||||
if (row.home_team == before.home_team && row.away_team == before.away_team) {
|
||||
row.home_goals = before.home_goals;
|
||||
row.away_goals = before.away_goals;
|
||||
row.score_known = before.score_known;
|
||||
break;
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
private:
|
||||
std::optional<LiveMatchdayFrame> preview_;
|
||||
};
|
||||
|
||||
struct LiveChanceProjection {
|
||||
LiveChanceStage stage = LiveChanceStage::preview;
|
||||
int minute = 0, group = 0, match = 0, side = 0;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/live_matchday.hpp"
|
||||
#include <stdexcept>
|
||||
using namespace bmh::ui;
|
||||
int main() {
|
||||
LiveMatchdayFrame frame;
|
||||
frame.minute=23;
|
||||
LiveMatchRow home;home.home_team=10;home.away_team=11;home.score_known=true;
|
||||
home.home_goals=2;home.away_goals=1;frame.matches.push_back(home);
|
||||
LiveMatchRow other=home;other.home_team=20;other.away_team=21;frame.matches.push_back(other);
|
||||
LiveScoreReveal reveal;
|
||||
if(reveal.project(frame)!=frame)throw std::runtime_error("idle reveal changed scores");
|
||||
for (int side : {0,1}) {
|
||||
reveal.observe(bmh::LiveChanceStage::preview,frame);
|
||||
auto resolved=frame;
|
||||
(side==0?resolved.matches[0].home_goals:resolved.matches[0].away_goals)++;
|
||||
resolved.matches[0].spectators=12500;
|
||||
// Animation frames can be rendered repeatedly without committing scores.
|
||||
for(int animation=0;animation<18;++animation) {
|
||||
const auto shown=reveal.project(resolved);
|
||||
if(shown.matches[0].home_goals!=2 || shown.matches[0].away_goals!=1 ||
|
||||
shown.matches[0].spectators!=12500 || shown.matches[1]!=resolved.matches[1])
|
||||
throw std::runtime_error("animation leaked score or replaced unrelated fields");
|
||||
}
|
||||
reveal.observe(bmh::LiveChanceStage::result,resolved);
|
||||
if(reveal.project(resolved)!=resolved)throw std::runtime_error("result did not reveal goal");
|
||||
}
|
||||
reveal.observe(bmh::LiveChanceStage::preview,frame);
|
||||
if(reveal.project(frame)!=frame)throw std::runtime_error("miss changed score");
|
||||
auto next=frame;next.minute++;
|
||||
if(reveal.project(next)!=next)throw std::runtime_error("old chance held a later minute");
|
||||
// Team identity, rather than row index, survives a reordered board.
|
||||
auto reversed=frame;std::swap(reversed.matches[0],reversed.matches[1]);
|
||||
reversed.matches[1].away_goals++;
|
||||
if(reveal.project(reversed)!=LiveMatchdayFrame{frame.minute,frame.minute_text,frame.gradient_text,
|
||||
{frame.matches[1],frame.matches[0]}})throw std::runtime_error("reordered board used wrong score");
|
||||
}
|
||||
+42
-4
@@ -3,6 +3,7 @@
|
||||
#include "ui/pitch.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
#include "formats/savestate.hpp"
|
||||
@@ -195,7 +196,7 @@ PitchScreen::PitchScreen(const std::filesystem::path& data,LineupState state,Pit
|
||||
PitchScreen::PitchScreen(const PitchScreen& other)
|
||||
:PitchScreen(other.data_,other.state_,other.extras_){
|
||||
pending_=other.pending_;selected_=other.selected_;hovered_=other.hovered_;ghost_=other.ghost_;
|
||||
order_hover_grid_=other.order_hover_grid_;
|
||||
order_hover_grid_=other.order_hover_grid_;pointer_grid_=other.pointer_grid_;
|
||||
scroll_=other.scroll_;close_=other.close_;return_team_=other.return_team_;rejection_=other.rejection_;
|
||||
weights_dirty_=other.weights_dirty_;
|
||||
shooter_editor_open_=other.shooter_editor_open_;shooter_selection_=other.shooter_selection_;
|
||||
@@ -291,6 +292,35 @@ bool PitchScreen::automatic_page()const{
|
||||
// their respective areas even when that bit is retained underneath.
|
||||
return !shooter_editor_open_&&(extras_.native_display_word&0x18)==0x18;
|
||||
}
|
||||
std::optional<std::pair<int,int>> PitchScreen::position_feedback() const {
|
||||
if (!pointer_grid_ || close_ || !(extras_.native_display_word & 8)) return {};
|
||||
const auto row = selected_ ? selected_ : hovered_;
|
||||
if (!row || size_t(*row) >= state_.players.size()) return {};
|
||||
const auto& p = state_.players.at(size_t(*row));
|
||||
if (p.player_id < 0 || !(p.slot & 0xc000) || ((p.attributes.w364 >> 16) & 31)) return {};
|
||||
const int depth = int(exe_.u8(::bmh::layout::PitchPreferenceDepthBases + p.attributes.position())) - 2 +
|
||||
int((p.attributes.w35c >> 21 & 7) >> 1);
|
||||
const int lane = int((p.attributes.w35c >> 24 & 7) * 800 / 7);
|
||||
const auto band = [&](int x, int y) {
|
||||
return std::min(9, (std::abs(depth - x) * 100 + std::abs(lane - y * 100)) / 200);
|
||||
};
|
||||
return std::pair{band(int8_t(p.board[0x41]), int8_t(p.board[0x42])),
|
||||
band(pointer_grid_->first, pointer_grid_->second)};
|
||||
}
|
||||
std::optional<std::array<uint32_t, 121>> PitchScreen::pointer_cursor(const Palette& palette) const {
|
||||
const auto feedback = position_feedback();
|
||||
if (!feedback) return {};
|
||||
const auto band = uint32_t(feedback->second);
|
||||
const uint32_t fill = 0xff000000u |
|
||||
(uint32_t(vga_dac_rgb8(uint8_t(exe_.u8(::bmh::layout::PitchPreferenceRed + band) << 4))) << 16) |
|
||||
(uint32_t(vga_dac_rgb8(uint8_t(exe_.u8(::bmh::layout::PitchPreferenceGreen + band) << 4))) << 8);
|
||||
std::array<uint32_t, 121> pixels{};
|
||||
for (uint32_t i = 0; i < pixels.size(); ++i) {
|
||||
const auto index = exe_.u8(::bmh::layout::OriginalPointerPixels + i);
|
||||
pixels[i] = index == 0 ? 0 : index == 0x11 ? fill : palette.argb[index];
|
||||
}
|
||||
return pixels;
|
||||
}
|
||||
Image PitchScreen::render()const{
|
||||
// PitchScreen's page redraw copies the owned offscreen sheet from y=20: all
|
||||
// 190 rows when source bit 0x08 is clear, only the upper 88 rows when it is
|
||||
@@ -472,6 +502,10 @@ Image PitchScreen::render()const{
|
||||
rect(out,0x105,y+9,value,1,0);rect(out,0x103+value,y+2,1,8,0);}
|
||||
}
|
||||
}
|
||||
// Native lower-right swatches compare the current position with the pointer.
|
||||
const auto feedback = position_feedback();
|
||||
copy(out,atlas_,feedback ? 259 + feedback->first * 5 : 309,68,305,233,5,4,0xc0);
|
||||
copy(out,atlas_,feedback ? 259 + feedback->second * 5 : 309,68,312,230,5,4,0xc0);
|
||||
return out;
|
||||
}
|
||||
std::optional<std::pair<int,int>> PitchScreen::grid(int x,int y){
|
||||
@@ -570,10 +604,12 @@ PitchRequest PitchScreen::order_request(int aspect,int value){
|
||||
}
|
||||
PitchRequest PitchScreen::click(int x,int y,bool right){
|
||||
if(pending_||close_)return {};
|
||||
pointer_grid_=grid(x,y);
|
||||
const uint16_t display_word=shooter_editor_open_
|
||||
? uint16_t(extras_.native_display_word&0xff0f)
|
||||
: extras_.native_display_word;
|
||||
if(right){
|
||||
pointer_grid_.reset();
|
||||
if((display_word&0x08)==0){sheet_->click(x,y,true);close_=sheet_->close_requested();}
|
||||
else if(selected_){selected_.reset();ghost_.reset();}
|
||||
else {close_=true;zone_cover_open_=false;}
|
||||
@@ -740,11 +776,13 @@ PitchRequest PitchScreen::save_formation(int x,int y){
|
||||
pending_=r;return r;
|
||||
}
|
||||
bool PitchScreen::move(int x,int y){if(pending_||close_)return false;
|
||||
const auto old_pointer_grid=pointer_grid_;
|
||||
if((extras_.native_display_word&0x08)==0)return sheet_->move(x,y);
|
||||
pointer_grid_=grid(x,y);
|
||||
const auto old=hovered_;const auto oldghost=ghost_;hovered_=hit_row(x,y);ghost_=selected_?grid(x,y):std::nullopt;
|
||||
const auto old_grid=order_hover_grid_;
|
||||
order_hover_grid_=order_panel_open_?grid(x,y):std::nullopt;
|
||||
return old!=hovered_||oldghost!=ghost_||old_grid!=order_hover_grid_;
|
||||
return old!=hovered_||oldghost!=ghost_||old_grid!=order_hover_grid_||old_pointer_grid!=pointer_grid_;
|
||||
}
|
||||
PitchRequest PitchScreen::key(std::string_view key){
|
||||
// PitchScreen's desktop pages cancel selection/return on mouse event 8.
|
||||
@@ -916,13 +954,13 @@ void PitchScreen::acknowledge(LineupState s,PitchExtras e){
|
||||
}
|
||||
void PitchScreen::reject_action(std::string reason){if(!pending_||reason.empty())throw FormatError("pitch: rejection requires pending action and reason");
|
||||
if(sheet_->pending())sheet_=std::make_unique<LineupScreen>(data_,state_);
|
||||
pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();order_hover_grid_.reset();marking_target_row_.reset();rejection_=std::move(reason);
|
||||
pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();pointer_grid_.reset();order_hover_grid_.reset();marking_target_row_.reset();rejection_=std::move(reason);
|
||||
}
|
||||
void PitchScreen::resolve_local_navigation(){
|
||||
if(!pending_||pending_->kind!=PitchRequestKind::open_player_info)
|
||||
throw FormatError("pitch: only player info can resolve locally");
|
||||
if(sheet_->pending())sheet_->resolve_local_navigation(LineupRequestKind::open_player_info);
|
||||
pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();rejection_.clear();
|
||||
pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();pointer_grid_.reset();rejection_.clear();
|
||||
}
|
||||
std::string PitchScreen::state_json()const{std::ostringstream out;
|
||||
out<<"{\"screen\":\"pitch\",\"manager_slot\":"<<state_.manager_slot<<",\"runtime_club\":"<<state_.runtime_club
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "ui/lineup.hpp"
|
||||
#include "ui/sprite_font.hpp"
|
||||
#include "formats/palette.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace bmh::ui {
|
||||
@@ -81,6 +82,9 @@ public:
|
||||
PitchScreen(PitchScreen&&) noexcept = default;
|
||||
PitchScreen& operator=(PitchScreen&&) noexcept = default;
|
||||
Image render() const;
|
||||
// Current/proposed native distance bands, available only over the pitch.
|
||||
std::optional<std::pair<int,int>> position_feedback() const;
|
||||
std::optional<std::array<uint32_t, 121>> pointer_cursor(const Palette&) const;
|
||||
// PitchScreen: outline only, before the pending save is dispatched/ACKed.
|
||||
static constexpr int formation_save_flash_ms = 5 * 20; // DecodeTaxAnimationScript2(5)
|
||||
std::optional<Image> formation_save_feedback(bool restored) const;
|
||||
@@ -116,6 +120,7 @@ private:
|
||||
std::optional<PitchRequest> pending_;
|
||||
std::optional<int> selected_, hovered_;
|
||||
std::optional<std::pair<int,int>> ghost_;
|
||||
std::optional<std::pair<int,int>> pointer_grid_;
|
||||
std::optional<std::pair<int,int>> order_hover_grid_;
|
||||
int scroll_ = 0;
|
||||
bool close_ = false, return_team_ = false;
|
||||
|
||||
@@ -38,6 +38,35 @@ int main(int argc,char**argv){try{
|
||||
PitchScreen pitch(data,s,e);const auto pixels=pitch.render().pixels;
|
||||
check(pixels.size()==320*240&&pitch.render().pixels==pixels,"pitch render is deterministic");
|
||||
check(pitch.state().players[3].board[0x41]==3&&!pitch.pending(),"render does not mutate authoritative positions");
|
||||
auto affinity_state=s;
|
||||
affinity_state.players[3].attributes.w364=1; // defender
|
||||
affinity_state.players[3].attributes.w35c=(6u<<21)|(4u<<24);
|
||||
PitchScreen affinity(data,affinity_state,e);
|
||||
const auto affinity_initial=affinity.render();
|
||||
const auto colors=load_palette(asset_path(data,"M3PC.COL"));
|
||||
check(!affinity.position_feedback()&&!affinity.pointer_cursor(colors),
|
||||
"idle pitch leaves host cursor and position colors unmodified");
|
||||
affinity.click(30,164);affinity.move(40,164);
|
||||
check(affinity.position_feedback()==std::pair{0,0},
|
||||
"near preferred defender depth/lane uses the best native distance band");
|
||||
const auto near_cursor=affinity.pointer_cursor(colors);
|
||||
const auto near_image=affinity.render();
|
||||
affinity.move(160,208);
|
||||
check(affinity.position_feedback()==std::pair{0,9}&&
|
||||
affinity.pointer_cursor(colors)&&affinity.pointer_cursor(colors)!=near_cursor,
|
||||
"far placement reaches the worst native band and changes cursor fill");
|
||||
const auto far_image=affinity.render();
|
||||
bool swatch_changed=false;
|
||||
for(int y=230;y<234;++y)for(int x=312;x<317;++x)
|
||||
swatch_changed|=near_image.pixels[size_t(y)*320+size_t(x)]!=far_image.pixels[size_t(y)*320+size_t(x)];
|
||||
check(swatch_changed&&affinity.state().players[3].board==s.players[3].board&&!affinity.pending(),
|
||||
"original proposed-position swatch changes without moving a player or dispatching");
|
||||
affinity.move(300,220);
|
||||
check(!affinity.position_feedback()&&!affinity.pointer_cursor(colors),
|
||||
"leaving pitch restores ordinary cursor and clears affinity colors");
|
||||
affinity.click(0,0,true);
|
||||
check(affinity.render().pixels==affinity_initial.pixels&&!affinity.pointer_cursor(colors),
|
||||
"cancelled placement restores original footer and cursor");
|
||||
const auto idle_pitch=pitch.state_json();
|
||||
check(pitch.key("ESC").kind==PitchRequestKind::none&&
|
||||
pitch.key("ESCAPE").kind==PitchRequestKind::none&&
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/preparation.hpp"
|
||||
|
||||
@@ -93,7 +94,7 @@ PreparationState preparation_from_game(const GameState& game, const LeImage& exe
|
||||
|
||||
PreparationState load_preparation_reference(const std::filesystem::path& path, const LeImage& exe) {
|
||||
const auto fbm = load_savegame(path);
|
||||
if (!fbm.checksum_ok || fbm.version != "V2.24") throw FormatError("preparation: unsupported/damaged FBM");
|
||||
require_native_savegame(fbm);
|
||||
const DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
const SaveState save(fbm.stream, counts);
|
||||
PreparationState result;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/save_load.hpp"
|
||||
|
||||
@@ -185,7 +186,8 @@ bool SaveLoadScreen::info_press(int x, int y) {
|
||||
try {
|
||||
const auto saved = load_savegame(entries_.at(size_t(selected_)).path);
|
||||
const auto& h = saved.plain_header;
|
||||
if (!saved.checksum_ok || saved.version != "V2.24" || h.size() < 172 || h[0] < 1 || h[0] > 4)
|
||||
require_native_savegame(saved);
|
||||
if (h.size() < 172 || h[0] < 1 || h[0] > 4)
|
||||
throw FormatError("save/load: invalid native information header");
|
||||
const auto field = [&](size_t at, size_t count) {
|
||||
const auto end = h.begin() + at + count;
|
||||
|
||||
+5
-26
@@ -2,6 +2,7 @@
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/sportschau.hpp"
|
||||
#include "ui/setup.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -89,28 +90,6 @@ Image load_kb(const std::filesystem::path& data_directory, const char* file) {
|
||||
return load_vga(data_directory / "KB" / file);
|
||||
}
|
||||
|
||||
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path) {
|
||||
const Bytes bytes = read_file(path);
|
||||
if (bytes.size() < 8) throw FormatError("sportschau: VGA palette source is truncated");
|
||||
const size_t rle_end = 8 + size_t(le32(bytes, 4));
|
||||
if (rle_end > bytes.size()) throw FormatError("sportschau: VGA RLE length exceeds palette source");
|
||||
const size_t trailing = bytes.size() - rle_end;
|
||||
if (trailing == 0) return std::nullopt;
|
||||
if (trailing < 768) throw FormatError("sportschau: truncated embedded VGA palette");
|
||||
|
||||
// PaletteOverride reads 0x300 bytes after the RLE stream and installs them
|
||||
// through KeepSameSixBitDACExpansion/Size5. Keep the same six-bit DAC expansion
|
||||
// used for M3PC.COL; only the palette source differs for embedded VGA art.
|
||||
Palette palette;
|
||||
for (size_t i = 0; i < palette.argb.size(); ++i) {
|
||||
const auto channel = [&](size_t component) {
|
||||
return uint32_t(vga_dac_rgb8(bytes[rle_end + i * 3 + component]));
|
||||
};
|
||||
palette.argb[i] = 0xff000000u | channel(0) << 16 | channel(1) << 8 | channel(2);
|
||||
}
|
||||
return palette;
|
||||
}
|
||||
|
||||
std::string short_bytes(const std::vector<uint8_t>& bytes) {
|
||||
return std::string(bytes.begin(), bytes.end());
|
||||
}
|
||||
@@ -172,7 +151,7 @@ void restore_source_rect(const Image& source, int source_x, int source_y,
|
||||
} // namespace
|
||||
|
||||
CompetitionWinnerScreen::CompetitionWinnerScreen(const std::filesystem::path& data)
|
||||
: exe_(load_le(data / "BMH.exe")), font_(load_font(data / "F" / "BMH2.FNT")) {
|
||||
: exe_(load_le(asset_path(data, "BMH.exe"))), font_(load_font(data / "F" / "BMH2.FNT")) {
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
const std::string background = i ? "131.VGA" : "128.VGA";
|
||||
backdrop_[i] = load_kb(data, background.c_str());
|
||||
@@ -242,7 +221,7 @@ Image MatchdayIntro::render(const MatchdayIntroView& view) const {
|
||||
}
|
||||
|
||||
SportschauEleven::SportschauEleven(const std::filesystem::path& data_directory)
|
||||
: exe_(load_le(data_directory / "BMH.exe")),
|
||||
: exe_(load_le(asset_path(data_directory, "BMH.exe"))),
|
||||
font_(load_font(data_directory / "F" / "BMH3.FNT")),
|
||||
room_(load_kb(data_directory, "57.VGA")), figures_(load_kb(data_directory, "16.VGA")) {
|
||||
if (room_.width != 320 || room_.height != 240 || figures_.width < 132 || figures_.height < 31)
|
||||
@@ -290,7 +269,7 @@ Image SportschauEleven::render(const SportschauAwardsView& view, bool gradient)
|
||||
}
|
||||
|
||||
SportschauTeamInfo::SportschauTeamInfo(const std::filesystem::path& data_directory)
|
||||
: exe_(load_le(data_directory / "BMH.exe")),
|
||||
: exe_(load_le(asset_path(data_directory, "BMH.exe"))),
|
||||
font_(load_font(data_directory / "F" / "BMH3.FNT")),
|
||||
room_(load_kb(data_directory, "57.VGA")), atlas_(load_kb(data_directory, "59.VGA")) {
|
||||
if (room_.width != 320 || room_.height != 240 || atlas_.width < 152 || atlas_.height < 56)
|
||||
@@ -356,7 +335,7 @@ Image SportschauIntro::render_frame(uint32_t index) const {
|
||||
SportschauMatchReport::SportschauMatchReport(const std::filesystem::path& data_directory,
|
||||
SportschauFixtureView fixture, SportschauReportContext context)
|
||||
: fixture_(std::move(fixture)), context_(std::move(context)),
|
||||
exe_(load_le(data_directory / "BMH.exe")),
|
||||
exe_(load_le(asset_path(data_directory, "BMH.exe"))),
|
||||
small_(load_font(data_directory / "F" / "BMH3.FNT")),
|
||||
heading_(load_font(data_directory / "F" / "BMH2.FNT")),
|
||||
texts_(load_textd(data_directory / "TEXTD.BLK")),
|
||||
|
||||
+11
-15
@@ -181,12 +181,8 @@ bool same_block_quote_owner(const StadiumBlockExpansionQuote& a,
|
||||
a.max_places == b.max_places && a.base_weeks == b.base_weeks;
|
||||
}
|
||||
bool canonical_block_quote(const StadiumBlockExpansionQuote& q, uint32_t total,
|
||||
uint8_t features) {
|
||||
static constexpr std::array<uint32_t, 8> prices{
|
||||
300000, 375000, 300000, 350000, 300000, 375000, 300000, 350000};
|
||||
static constexpr std::array<uint32_t, 8> maxima{
|
||||
8000, 18000, 8000, 14000, 8000, 18000, 8000, 14000};
|
||||
static constexpr std::array<uint8_t, 8> weeks{30, 37, 30, 25, 30, 37, 30, 25};
|
||||
uint8_t features,const StadiumBlockExpansionConstants& constants) {
|
||||
const auto& prices=constants.price_per_1000;const auto& maxima=constants.max_places;const auto& weeks=constants.weeks;
|
||||
const size_t slot = static_cast<uint8_t>(q.slot);
|
||||
if (slot >= prices.size() || q.manager < 0 || q.manager_club < 0 ||
|
||||
q.current_build_weeks != 0 || (q.current_raw_flags & ~uint8_t(3)) != 0 ||
|
||||
@@ -220,11 +216,11 @@ bool canonical_block_quote(const StadiumBlockExpansionQuote& q, uint32_t total,
|
||||
q.undiscounted_cost == sum &&
|
||||
q.base_price == uint32_t(sum * uint32_t(q.company_price_percent) / 100u);
|
||||
}
|
||||
bool valid_editor_projection(const StadiumBlockExpansionEditor& editor) {
|
||||
bool valid_editor_projection(const StadiumBlockExpansionEditor& editor,const StadiumBlockExpansionConstants& constants) {
|
||||
return editor.total_target_places == editor.quote.total_target_places &&
|
||||
editor.desired_features == editor.quote.desired_features &&
|
||||
editor.header_text_variant >= 3 && editor.header_text_variant <= 10 &&
|
||||
canonical_block_quote(editor.quote, editor.total_target_places, editor.desired_features);
|
||||
canonical_block_quote(editor.quote, editor.total_target_places, editor.desired_features,constants);
|
||||
}
|
||||
bool same_block_overviews(const std::array<StadiumBlockOverview, 8>& a,
|
||||
const std::array<StadiumBlockOverview, 8>& b) {
|
||||
@@ -946,7 +942,7 @@ Image StadiumScreen::render_scene() const {
|
||||
const std::string current = format_number(GameState{}, int32_t(available * 1000), 0x85) +
|
||||
texts_[text_id(::bmh::layout::Stadium_FormatError_ExecutableField3)];
|
||||
text_at(out, 221, row_y + 15, current, 0x51);
|
||||
const auto max_places = uint32_t(exe_.u8(::bmh::layout::CareerSession_Invalid_RuntimeField + i)) * 1000;
|
||||
const auto max_places = stadium_block_expansion_constants(exe_).max_places[i];
|
||||
const std::string maximum = texts_[text_id(::bmh::layout::Stadium_Out_TextPointer5)] +
|
||||
format_number(GameState{}, int32_t(max_places), 5) +
|
||||
exe_.cstring(::bmh::layout::Stadium_Out_ExecutableField);
|
||||
@@ -1805,7 +1801,7 @@ void StadiumScreen::acknowledge(StadiumState updated) {
|
||||
if (!old_editor || req.block_slot != int(old_editor->quote.slot) ||
|
||||
old_editor->quote.manager != req.manager_slot || old_editor->quote.manager_club != req.runtime_club ||
|
||||
!req.expected_block_quote ||
|
||||
*req.expected_block_quote != old_editor->quote || !valid_editor_projection(*old_editor) ||
|
||||
*req.expected_block_quote != old_editor->quote || !valid_editor_projection(*old_editor,stadium_block_expansion_constants(exe_)) ||
|
||||
((req.kind != StadiumRequestKind::expansion_set_total &&
|
||||
req.kind != StadiumRequestKind::expansion_toggle_feature) &&
|
||||
(req.block_total_places != old_editor->total_target_places ||
|
||||
@@ -1894,7 +1890,7 @@ void StadiumScreen::acknowledge(StadiumState updated) {
|
||||
quote.new_places == 0 &&
|
||||
editor.total_target_places == quote.total_target_places &&
|
||||
editor.desired_features == quote.desired_features &&
|
||||
valid_editor_projection(editor) &&
|
||||
valid_editor_projection(editor,stadium_block_expansion_constants(exe_)) &&
|
||||
!editor.offer && !updated.construction_tip_dialog &&
|
||||
same_block_overviews(state_.blocks, updated.blocks) && updated.balance == state_.balance &&
|
||||
!updated.selected_investment && !updated.quoted_object;
|
||||
@@ -1908,7 +1904,7 @@ void StadiumScreen::acknowledge(StadiumState updated) {
|
||||
valid = total >= minimum && total <= old_editor->quote.max_places &&
|
||||
req.block_features == old_editor->desired_features &&
|
||||
same_block_quote_owner(old_editor->quote, next.quote) &&
|
||||
canonical_block_quote(next.quote, total, req.block_features) &&
|
||||
canonical_block_quote(next.quote, total, req.block_features,stadium_block_expansion_constants(exe_)) &&
|
||||
next.quote.total_target_places == total && next.quote.desired_features == req.block_features &&
|
||||
next.total_target_places == total && next.desired_features == req.block_features &&
|
||||
!next.offer && !updated.construction_tip_dialog &&
|
||||
@@ -1922,7 +1918,7 @@ void StadiumScreen::acknowledge(StadiumState updated) {
|
||||
valid = (req.block_features & ~uint8_t(3)) == 0 && (changed == 1 || changed == 2) &&
|
||||
!(old_editor->quote.current_raw_flags & changed) &&
|
||||
same_block_quote_owner(old_editor->quote, next.quote) &&
|
||||
canonical_block_quote(next.quote, old_editor->total_target_places, req.block_features) &&
|
||||
canonical_block_quote(next.quote, old_editor->total_target_places, req.block_features,stadium_block_expansion_constants(exe_)) &&
|
||||
next.quote.total_target_places == old_editor->total_target_places &&
|
||||
next.quote.desired_features == req.block_features &&
|
||||
next.total_target_places == old_editor->total_target_places &&
|
||||
@@ -1951,7 +1947,7 @@ void StadiumScreen::acknowledge(StadiumState updated) {
|
||||
req.manager_slot >= 0 && req.manager_slot <= 3 &&
|
||||
updated.construction_tip_dialog->source_flags == 0x204 &&
|
||||
next.offer->decision == StandBlockOfferDecision::Pending &&
|
||||
valid_editor_projection(next) && next.offer->percent >= 6 && next.offer->percent <= 14 &&
|
||||
valid_editor_projection(next,stadium_block_expansion_constants(exe_)) && next.offer->percent >= 6 && next.offer->percent <= 14 &&
|
||||
next.offer->base_price == old_editor->quote.base_price &&
|
||||
next.offer->price == old_editor->quote.base_price &&
|
||||
next.offer->construction_days == old_editor->quote.base_weeks &&
|
||||
@@ -1971,7 +1967,7 @@ void StadiumScreen::acknowledge(StadiumState updated) {
|
||||
state_.construction_tip_dialog->source_manager_flags == req.manager_slot &&
|
||||
req.manager_slot >= 0 && req.manager_slot <= 3 &&
|
||||
state_.construction_tip_dialog->source_flags == 0x204 &&
|
||||
valid_editor_projection(*old_editor) && old_editor->offer->percent >= 6 && old_editor->offer->percent <= 14 &&
|
||||
valid_editor_projection(*old_editor,stadium_block_expansion_constants(exe_)) && old_editor->offer->percent >= 6 && old_editor->offer->percent <= 14 &&
|
||||
old_editor->offer->base_price == old_editor->quote.base_price &&
|
||||
old_editor->offer->price == old_editor->quote.base_price &&
|
||||
old_editor->offer->construction_days == old_editor->quote.base_weeks &&
|
||||
|
||||
@@ -59,7 +59,7 @@ StatisticsRankingState statistics_rankings_from_game(const GameState& game, cons
|
||||
int manager_slot, int category, int first_season,
|
||||
const Image& underlay) {
|
||||
if (category < 0 || category >= int(kTitleCount)) throw FormatError("statistics rankings: category outside 0..8");
|
||||
if (first_season < 0 || first_season >= int(kSeasonCount) || (first_season % 4) != 0)
|
||||
if (first_season < 0 || (first_season % 4) != 0)
|
||||
throw FormatError("statistics rankings: Source page must start at a four-season boundary");
|
||||
if (!game.memory.has(kTitles + kTitleCount * kSeasonCount * 2 - 1))
|
||||
throw FormatError("statistics rankings: save lacks the Original Titles title-holder block");
|
||||
@@ -76,7 +76,14 @@ StatisticsRankingState statistics_rankings_from_game(const GameState& game, cons
|
||||
const uint32_t manager_year_at = uint32_t(manager_slot) * 0xb0c + 0x2aa;
|
||||
out.season_number_base = int(exe.u16(::bmh::layout::Achievements_FormatError_RuntimeField2)) +
|
||||
int(game.manager_records[manager_year_at] | (uint16_t(game.manager_records[manager_year_at + 1]) << 8));
|
||||
out.current_season = std::clamp(game.season, 0, int(kSeasonCount) - 1);
|
||||
const auto history = title_history_rows(game);
|
||||
if (history.empty()) throw FormatError("statistics rankings: missing title history");
|
||||
out.history_first_season = int(history.begin()->first);
|
||||
out.current_season = game.season - out.history_first_season;
|
||||
if (out.current_season < 0 || first_season > out.current_season)
|
||||
throw FormatError("statistics rankings: history page outside known career");
|
||||
out.season_number_base += out.history_first_season - std::max(0, game.season - 49);
|
||||
out.season_known.assign(size_t(out.current_season) + 1, false);
|
||||
out.underlay = underlay;
|
||||
for (uint32_t index = 0; index < kTitleCount; ++index) {
|
||||
const uint8_t title_id = exe.u8(::bmh::layout::StatisticsRankings_FormatError_RuntimeField + index);
|
||||
@@ -84,18 +91,23 @@ StatisticsRankingState statistics_rankings_from_game(const GameState& game, cons
|
||||
if (title_id >= kTitleCount) throw FormatError("statistics rankings: Source title id outside nine stored lists");
|
||||
out.categories[index] = StatisticsRankingCategory{title_id, alternate};
|
||||
}
|
||||
for (uint32_t category_index = 0; category_index < kTitleCount; ++category_index) {
|
||||
for (uint32_t season = 0; season < kSeasonCount; ++season) {
|
||||
// StatisticsRankingsFromGame reads Titles by selected control index (local_14).
|
||||
// title_id only chooses the Original label pointer above.
|
||||
const uint32_t at = kTitles + category_index * 100 + season * 2;
|
||||
out.title_holders[category_index][season] = game.memory.u16(at);
|
||||
const uint16_t team = out.title_holders[category_index][season];
|
||||
if (team != 0xffff) {
|
||||
if (team >= game.club_ids.size())
|
||||
throw FormatError("statistics rankings: Source title holder has no club identity/name");
|
||||
out.club_names[category_index][season] = game.club_name(team);
|
||||
out.club_name_colors[category_index][season] = original_name_color(game, team);
|
||||
for (size_t category = 0; category < 9; ++category) {
|
||||
const auto count = size_t(out.current_season) + 1;
|
||||
out.title_holders[category].assign(count, 0xffff);
|
||||
out.club_names[category].resize(count);
|
||||
out.club_name_colors[category].assign(count, 0x5f);
|
||||
out.title_present[category].assign(count, false);
|
||||
for (const auto& [season, names] : history) {
|
||||
if (int(season) > game.season) throw FormatError("statistics rankings: future archived season");
|
||||
const auto index = size_t(int(season) - out.history_first_season);
|
||||
out.season_known[index] = true;
|
||||
out.club_names[category][index] = names[category];
|
||||
out.title_present[category][index] = !names[category].empty();
|
||||
const int native_index = int(season) - std::max(0, game.season - 49);
|
||||
if (native_index >= 0 && native_index < 50) {
|
||||
const auto team = game.memory.u16(kTitles + uint32_t(category) * 100 + uint32_t(native_index) * 2);
|
||||
out.title_holders[category][index] = team;
|
||||
if (team != 0xffff) out.club_name_colors[category][index] = original_name_color(game, team);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,11 +121,16 @@ StatisticsRankingsScreen::StatisticsRankingsScreen(const std::filesystem::path&
|
||||
button_art_(load_vga(asset_path(data / "KB", "0.VGA"))),
|
||||
texts_(load_textd(asset_path(data, "TEXTD.BLK"))) {
|
||||
if (state_.category < 0 || state_.category >= int(kTitleCount) || state_.current_season < 0 ||
|
||||
state_.current_season >= int(kSeasonCount) || state_.first_season < 0 ||
|
||||
state_.first_season >= int(kSeasonCount) || state_.first_season % 4 != 0 ||
|
||||
state_.first_season < 0 || state_.first_season > state_.current_season || state_.first_season % 4 != 0 ||
|
||||
state_.underlay.width != 320 || state_.underlay.height != 240 ||
|
||||
button_art_.width < 76 || button_art_.height < 84)
|
||||
throw FormatError("statistics rankings: incomplete Source projection");
|
||||
for (size_t i = 0; i < 9; ++i)
|
||||
if (state_.club_names[i].size() != size_t(state_.current_season) + 1 ||
|
||||
state_.club_name_colors[i].size() != state_.club_names[i].size() ||
|
||||
state_.title_present[i].size() != state_.club_names[i].size() ||
|
||||
state_.season_known.size() != state_.club_names[i].size())
|
||||
throw FormatError("statistics rankings: incomplete archived rows");
|
||||
for (size_t i = 0; i < state_.categories.size(); ++i) {
|
||||
const auto& category = state_.categories[i];
|
||||
if (category.title_id >= kTitleCount)
|
||||
@@ -169,21 +186,22 @@ Image StatisticsRankingsScreen::render() const {
|
||||
for (int season = state_.first_season; season <= end; ++season) {
|
||||
const int visible = season - state_.first_season;
|
||||
const int y = 0x31 + visible * 6;
|
||||
const uint16_t team = state_.title_holders[size_t(state_.category)][size_t(season)];
|
||||
if (season < state_.current_season || team != 0xffff) {
|
||||
const bool has_title = state_.title_present[size_t(state_.category)][size_t(season)];
|
||||
if (season < state_.current_season || has_title) {
|
||||
const int source_season_number = state_.season_number_base + season + 1;
|
||||
std::string n = std::to_string(source_season_number);
|
||||
while (n.size() < 4) n.insert(n.begin(), '%');
|
||||
n += "%%"; // FormatNumber(...,0xc4,&StatisticsRankingsRuntimeField): width-four Source number and suffix.
|
||||
const uint8_t year_color = team == 0xffff &&
|
||||
const uint8_t year_color = !has_title &&
|
||||
(state_.category == 5 || state_.category == 6) ? 0x67 : 0x6b;
|
||||
font_.draw(out, 100, y - font_.baseline, n, year_color);
|
||||
if (team != 0xffff) {
|
||||
if (has_title) {
|
||||
font_.draw(out, 130, y - font_.baseline,
|
||||
state_.club_names[size_t(state_.category)][size_t(season)],
|
||||
state_.club_name_colors[size_t(state_.category)][size_t(season)]);
|
||||
} else {
|
||||
font_.draw(out, 130, y - font_.baseline, empty_label_, 0x67);
|
||||
font_.draw(out, 130, y - font_.baseline,
|
||||
state_.season_known[size_t(season)] ? empty_label_ : "Unbekannt", 0x67);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,12 @@ struct StatisticsRankingCategory {
|
||||
|
||||
struct StatisticsRankingState {
|
||||
std::array<StatisticsRankingCategory, 9> categories{};
|
||||
std::array<std::array<uint16_t, 50>, 9> title_holders{};
|
||||
std::array<std::array<std::string, 50>, 9> club_names{};
|
||||
std::array<std::array<uint8_t, 50>, 9> club_name_colors{};
|
||||
std::array<std::vector<uint16_t>, 9> title_holders{};
|
||||
std::array<std::vector<std::string>, 9> club_names{};
|
||||
std::array<std::vector<uint8_t>, 9> club_name_colors{};
|
||||
std::array<std::vector<bool>, 9> title_present{};
|
||||
std::vector<bool> season_known;
|
||||
int history_first_season = 0;
|
||||
int current_season = 0; // SeasonIndex: latest history index; current empty slot is retained.
|
||||
int manager_slot = -1;
|
||||
int season_number_base = 0; // AchievementsRuntimeField[manager] + Achievements_FormatError_RuntimeField2; StatisticsRankingsFromGame adds one.
|
||||
|
||||
@@ -97,6 +97,28 @@ int main(int argc, char** argv) {
|
||||
screen.pending()->kind == StatisticsRankingsRequestKind::close,
|
||||
"right-click is the Source parent-return request");
|
||||
|
||||
auto career = sample(); career.season = 300;
|
||||
career.manager_records[0x2aa] = uint8_t(258); career.manager_records[0x2ab] = uint8_t(258 >> 8);
|
||||
for (uint32_t season = 0; season <= 300; ++season) {
|
||||
std::array<std::string,9> titles; titles[0] = "Bayer"; career.title_history.emplace(season, titles);
|
||||
}
|
||||
auto wide = statistics_rankings_from_game(career, exe, 0, 0, 0, underlay);
|
||||
check(wide.current_season == 300 && wide.history_first_season == 0 && wide.club_names[0].size() == 301 &&
|
||||
wide.club_names[0][0] == "Bayer" && wide.club_names[0][300] == "Bayer",
|
||||
"archived title lists retain all 301 known seasons and original winner snapshots");
|
||||
check(wide.season_number_base == int(exe.u16(::bmh::layout::Achievements_FormatError_RuntimeField2)) + 7,
|
||||
"absolute archive year labels compensate for the native 50-row window shift");
|
||||
StatisticsRankingsScreen long_screen(data, wide);
|
||||
for (int n = 0; n < 100; ++n) long_screen.scroll(1);
|
||||
check(long_screen.state().first_season == 288 && long_screen.render().width == 320,
|
||||
"history paging reaches season 300 instead of stopping at the fiftieth row");
|
||||
for (int n = 0; n < 100; ++n) long_screen.scroll(-1);
|
||||
check(long_screen.state().first_season == 0, "oldest archived title rows remain reachable");
|
||||
auto legacy = sample(); legacy.season = 300;
|
||||
const auto imported = statistics_rankings_from_game(legacy, exe, 0, 0, 0, underlay);
|
||||
check(imported.history_first_season == 251 && imported.current_season == 49,
|
||||
"a legacy late-career save exposes only its surviving 50 seasons, without invented earlier winners");
|
||||
|
||||
GameState missing;
|
||||
bool rejected = false;
|
||||
try { (void)statistics_rankings_from_game(missing, exe, 0, 0, 0, underlay); }
|
||||
|
||||
+45
-14
@@ -32,7 +32,7 @@ void copy(Image& out,const Image& source,int sx,int sy,int x,int y,int w,int h,i
|
||||
if(pixel!=key&&x+xx>=0&&x+xx<out.width&&y+yy>=0&&y+yy<out.height)out.at(x+xx,y+yy)=pixel;
|
||||
}
|
||||
}
|
||||
std::string padded(int n,int width=2) {
|
||||
std::string padded(uint64_t n,int width=2) {
|
||||
auto text=std::to_string(n);if(int(text.size())<width)text.insert(0,size_t(width-int(text.size())),'%');return text;
|
||||
}
|
||||
std::string money(int64_t value) {
|
||||
@@ -191,6 +191,7 @@ TransferMarketState transfer_market_from_game(const GameState& g, uint64_t revis
|
||||
if(int(word&31)==manager&&int(word>>10&0xfff)==id)p.offer_name_color=true;
|
||||
}
|
||||
}
|
||||
if (p.manager_board && p.player_id >= 0) p.statistics = player_club_statistics(g, state.runtime_club, p.player_id, *p.manager_board);
|
||||
state.roster.players.push_back(std::move(p));
|
||||
}
|
||||
for(size_t index=0;index<borrowed.size();++index) {
|
||||
@@ -204,6 +205,7 @@ TransferMarketState transfer_market_from_game(const GameState& g, uint64_t revis
|
||||
const uint32_t board=::bmh::layout::ClubInfo_FormatError_RuntimeField+uint32_t(loan)*0x58;
|
||||
if(!g.memory.has(board+0x57))throw FormatError("transfer market: borrowed board outside Native storage");
|
||||
p.manager_board.emplace();for(uint32_t n=0;n<0x58;++n)(*p.manager_board)[n]=g.memory.u8(board+n);
|
||||
p.statistics = player_club_statistics(g, state.runtime_club, p.player_id, *p.manager_board);
|
||||
state.roster.players.push_back(std::move(p));
|
||||
}
|
||||
for (size_t row = 0; row < ordinary_count; ++row) {
|
||||
@@ -282,7 +284,8 @@ std::string transfer_market_request_json(const TransferMarketRequest& r) {
|
||||
r.kind == TransferMarketRequestKind::list_player ? "list_player" :
|
||||
r.kind == TransferMarketRequestKind::open_offer ? "open_offer" :
|
||||
r.kind == TransferMarketRequestKind::preview_quote ? "preview_quote" :
|
||||
r.kind == TransferMarketRequestKind::open_poach ? "open_poach" : "none";
|
||||
r.kind == TransferMarketRequestKind::open_poach ? "open_poach" :
|
||||
r.kind == TransferMarketRequestKind::review_offers ? "review_offers" : "none";
|
||||
std::ostringstream out;
|
||||
out << "{\"kind\":\"" << kind << "\",\"manager_slot\":" << r.manager_slot
|
||||
<< ",\"runtime_club\":" << r.runtime_club << ",\"revision\":" << r.revision
|
||||
@@ -447,8 +450,8 @@ void TransferMarketScreen::draw_roster(Image& out,bool full) const {
|
||||
for(int skill=0;skill<7;++skill)copy(out,atlas_,256+a.skill(Player::Skill(skill))*16,32,87+skill*10,baseline-5,16,5,0);
|
||||
std::string stats=padded(p.bonus&127,3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
|
||||
if(p.manager_board) {
|
||||
const auto& b=*p.manager_board;stats+=padded(b[7],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+padded(b[9],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
|
||||
if(full){Bytes raw(b.begin(),b.end());stats+=padded(le16(raw,0x48),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+padded(le16(raw,0x4a),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+padded(le16(raw,0x4c),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField);}
|
||||
const auto& b=*p.manager_board;stats+=padded(p.statistics ? p.statistics->appearances[0] : b[7],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5)+padded(p.statistics ? p.statistics->appearances[2] : b[9],3)+exe_.cstring(::bmh::layout::ClubInfo_Render_ExecutableField5);
|
||||
if(full){Bytes raw(b.begin(),b.end());stats+=padded((p.statistics ? p.statistics->total : le16(raw,0x48)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+padded((p.statistics ? p.statistics->goals : le16(raw,0x4a)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+padded((p.statistics ? p.statistics->assists : le16(raw,0x4c)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField);}
|
||||
}
|
||||
original_text(out,165,baseline,stats,0x6c);
|
||||
}
|
||||
@@ -520,6 +523,16 @@ Image TransferMarketScreen::render() const {
|
||||
sprite_font_.draw(out,SpriteFont::centered_title_x(sprite_font_.text_width(title)),13,title);
|
||||
sprite_font_.draw(out,5,235,original_to_utf8(state_.club_name));
|
||||
draw_market_overview(out);
|
||||
if (!feedback_.empty()) {
|
||||
rect(out, 1, 227, 318, 12, 0x39);
|
||||
auto line = feedback_;
|
||||
while (!line.empty() && sprite_font_.text_width(line) > 310) {
|
||||
size_t at = line.size() - 1;
|
||||
while (at > 0 && (uint8_t(line[at]) & 0xc0) == 0x80) --at;
|
||||
line.resize(at);
|
||||
}
|
||||
sprite_font_.draw(out, 5, 235, line);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -553,13 +566,17 @@ TransferMarketRequest TransferMarketScreen::make_bid() {
|
||||
TransferMarketRequest TransferMarketScreen::make_listing(bool loan) {
|
||||
if (pending_ || !selected_squad_) return {};
|
||||
const auto& item = state_.squad.at(size_t(*selected_squad_));
|
||||
if (item.already_listed) { feedback_ = "Spieler steht bereits auf der Liste"; return {}; }
|
||||
if (item.already_listed) {
|
||||
const auto listing = std::find_if(state_.items.begin(), state_.items.end(),
|
||||
[&](const auto& row) { return row.player == item.player && row.own_listing; });
|
||||
if (listing != state_.items.end()) return make_review(*listing);
|
||||
feedback_ = "Spieler steht bereits auf der Liste"; return {};
|
||||
}
|
||||
TransferMarketRequest request;
|
||||
request.kind = TransferMarketRequestKind::list_player;request.offer_is_loan=loan;
|
||||
request.manager_slot = state_.manager_slot; request.runtime_club = state_.runtime_club; request.revision = state_.revision;
|
||||
request.squad_row = item.row; request.expected_player = item.player;
|
||||
for(size_t n=0;n<state_.squad.size();++n) {if(std::find(marked_squad_.begin(),marked_squad_.end(),int(n))==marked_squad_.end())continue;const auto& marked=state_.squad[n];request.selected_players.push_back({-1,state_.roster.squad_start_offset+marked.row,marked.player,state_.runtime_club,marked.row});}
|
||||
if(request.selected_players.empty())request.selected_players.push_back({-1,state_.roster.squad_start_offset+item.row,item.player,state_.runtime_club,item.row});
|
||||
request.selected_players.push_back({-1,state_.roster.squad_start_offset+item.row,item.player,state_.runtime_club,item.row});
|
||||
pending_ = request; feedback_.clear();
|
||||
return request;
|
||||
}
|
||||
@@ -589,18 +606,27 @@ TransferMarketRequest TransferMarketScreen::make_preview(bool purchase) {
|
||||
}
|
||||
pending_=request;preview_.reset();return request;
|
||||
}
|
||||
TransferMarketRequest TransferMarketScreen::make_review(const TransferMarketItem& item) {
|
||||
if (pending_) return {};
|
||||
if (item.offers == 0) { feedback_ = "Noch keine Angebote für diesen Spieler."; return {}; }
|
||||
TransferMarketRequest request;
|
||||
request.kind = TransferMarketRequestKind::review_offers;
|
||||
request.manager_slot = state_.manager_slot; request.runtime_club = state_.runtime_club;
|
||||
request.revision = state_.revision; request.bid.manager = state_.manager_slot;
|
||||
request.bid.list_entry = item.list_entry; request.bid.player = item.player;
|
||||
request.bid.source_slot = item.source_slot;
|
||||
pending_ = request; feedback_.clear(); return request;
|
||||
}
|
||||
TransferMarketRequest TransferMarketScreen::make_open_offer(bool loan) {
|
||||
if(pending_||!selected_item_)return {};
|
||||
const auto& item=state_.items.at(size_t(*selected_item_));
|
||||
if(item.own_listing)return {};
|
||||
if(item.own_listing)return make_review(item);
|
||||
TransferMarketRequest request;request.kind=TransferMarketRequestKind::open_offer;request.offer_is_loan=loan;
|
||||
request.manager_slot=state_.manager_slot;request.runtime_club=state_.runtime_club;request.revision=state_.revision;
|
||||
if(item.own_bid)request.bid=*item.own_bid;
|
||||
request.bid.manager=state_.manager_slot;request.bid.list_entry=item.list_entry;request.bid.player=item.player;
|
||||
request.bid.source_slot=item.source_slot;
|
||||
for(size_t n=0;n<state_.squad.size();++n){if(std::find(marked_squad_.begin(),marked_squad_.end(),int(n))==marked_squad_.end())continue;const auto& marked=state_.squad[n];request.selected_players.push_back({-1,state_.roster.squad_start_offset+marked.row,marked.player,state_.runtime_club,marked.row});}
|
||||
for(int n:market_order()) {if(std::find(marked_items_.begin(),marked_items_.end(),n)==marked_items_.end())continue;const auto& marked=state_.items.at(size_t(n));request.selected_players.push_back({marked.list_entry,marked.source_slot,marked.player,marked.seller,-1});}
|
||||
if(request.selected_players.empty())request.selected_players.push_back({item.list_entry,item.source_slot,item.player,item.seller,-1});
|
||||
request.selected_players.push_back({item.list_entry,item.source_slot,item.player,item.seller,-1});
|
||||
pending_=request;return request;
|
||||
}
|
||||
TransferMarketRequest TransferMarketScreen::move(int x,int y) {
|
||||
@@ -669,14 +695,17 @@ TransferMarketRequest TransferMarketScreen::click(int x,int y,bool right) {
|
||||
if(x>=201&&x<=297&&y>=25&&y<115) {
|
||||
const size_t row=size_t((y-25)/15),index=first+row;
|
||||
if(index<order.size()&&row<6) {
|
||||
const int item=order[index];auto marked=std::find(marked_items_.begin(),marked_items_.end(),item);
|
||||
marked_squad_.clear();
|
||||
const int item=order[index];
|
||||
marked_items_.erase(std::remove_if(marked_items_.begin(),marked_items_.end(),[&](int n){return n!=item;}),marked_items_.end());
|
||||
auto marked=std::find(marked_items_.begin(),marked_items_.end(),item);
|
||||
if(marked==marked_items_.end())marked_items_.push_back(item);else marked_items_.erase(marked);
|
||||
return move(x,y);
|
||||
}
|
||||
}
|
||||
if(y>=202&&y<=212&&x>=185&&x<=318) {
|
||||
if(!marked_items_.empty()){selected_item_=marked_items_.front();selected_squad_.reset();selected_snapshot_.reset();return make_open_offer(x>=254);}
|
||||
if(!marked_squad_.empty()){selected_squad_=marked_squad_.front();selected_item_.reset();return make_listing(x>=254);}
|
||||
if(!marked_items_.empty()){selected_item_=marked_items_.back();selected_squad_.reset();selected_snapshot_.reset();return make_open_offer(x>=254);}
|
||||
if(!marked_squad_.empty()){selected_squad_=marked_squad_.back();selected_item_.reset();return make_listing(x>=254);}
|
||||
view_flags_^=0x1800;preview_.reset();return {};
|
||||
}
|
||||
}
|
||||
@@ -686,6 +715,8 @@ TransferMarketRequest TransferMarketScreen::click(int x,int y,bool right) {
|
||||
const auto found=std::find_if(state_.squad.begin(),state_.squad.end(),[&](const auto& item){return item.row==player.physical_row;});
|
||||
if(found==state_.squad.end())return {};
|
||||
const int index=int(found-state_.squad.begin());
|
||||
marked_items_.clear();
|
||||
marked_squad_.erase(std::remove_if(marked_squad_.begin(),marked_squad_.end(),[&](int n){return n!=index;}),marked_squad_.end());
|
||||
auto marked=std::find(marked_squad_.begin(),marked_squad_.end(),index);
|
||||
if(marked==marked_squad_.end())marked_squad_.push_back(index);else marked_squad_.erase(marked);
|
||||
return move(x,y);
|
||||
|
||||
@@ -65,7 +65,7 @@ TransferMarketState transfer_market_from_game(const GameState&, uint64_t revisio
|
||||
std::string transfer_market_state_json(const TransferMarketState&);
|
||||
TaxDialogProjection poach_notice_from_game(const GameState&,const PoachStart&,std::string original_message);
|
||||
|
||||
enum class TransferMarketRequestKind { none, submit_bid, list_player, open_offer, preview_quote, open_poach };
|
||||
enum class TransferMarketRequestKind { none, submit_bid, list_player, open_offer, preview_quote, open_poach, review_offers };
|
||||
struct TransferMarketSelection {
|
||||
int list_entry=-1,source_slot=-1,player=-1,seller=-1,squad_row=-1;
|
||||
};
|
||||
@@ -147,6 +147,7 @@ private:
|
||||
bool close_requested_ = false;
|
||||
void draw_text(Image&, int x, int y, std::string_view, uint8_t color) const;
|
||||
void commit_numeric_field();
|
||||
TransferMarketRequest make_review(const TransferMarketItem&);
|
||||
TransferMarketRequest make_bid();
|
||||
TransferMarketRequest make_listing(bool loan=false);
|
||||
TransferMarketRequest make_open_offer(bool loan=false);
|
||||
|
||||
@@ -70,6 +70,48 @@ int main(int argc,char** argv){
|
||||
check(request.kind==TransferMarketRequestKind::list_player&&request.squad_row==0&&request.expected_player==0,"existing listing request retains physical row stale-validation boundary");
|
||||
screen.reject_action("Für Müller: Aktion offen");check(screen.state_json().find("Für Müller")!=std::string::npos,"host feedback remains UTF8");
|
||||
|
||||
const auto rejected_frame = screen.render();
|
||||
screen.key("V");
|
||||
screen.reject_action("Anderer sichtbarer Hinweis");
|
||||
check(screen.render().pixels != rejected_frame.pixels, "host rejection is actually rendered in the footer");
|
||||
|
||||
TransferMarketScreen selected(argv[1],s);
|
||||
auto marked_market=selected.click(210,28);selected.acknowledge_preview(s,quote(marked_market));
|
||||
auto marked_squad=selected.click(20,32);selected.acknowledge_preview(s,quote(marked_squad));
|
||||
auto sale=selected.click(200,206);
|
||||
check(sale.kind==TransferMarketRequestKind::list_player&&sale.selected_players.size()==1&&sale.expected_player==0,
|
||||
"latest clicked squad selection replaces an old marked market row");
|
||||
|
||||
auto listed=s;listed.items[0].own_listing=true;listed.items[0].seller=listed.runtime_club;
|
||||
listed.items[0].player=0;listed.squad[0].already_listed=true;listed.items[0].offers=1;
|
||||
TransferMarketScreen review(argv[1],listed);
|
||||
auto hover_listing=review.click(20,32);review.acknowledge_preview(listed,quote(hover_listing));
|
||||
auto inspect=review.click(200,206);
|
||||
check(inspect.kind==TransferMarketRequestKind::review_offers&&inspect.bid.player==0&&inspect.bid.list_entry==4&&
|
||||
transfer_market_request_json(inspect).find("review_offers")!=std::string::npos,
|
||||
"selling an already listed own squad player requests guarded incoming offer review");
|
||||
review.acknowledge_unchanged();
|
||||
listed.items[0].offers=0;TransferMarketScreen waiting(argv[1],listed);
|
||||
auto hover_waiting=waiting.click(20,32);waiting.acknowledge_preview(listed,quote(hover_waiting));
|
||||
check(waiting.key("V").kind==TransferMarketRequestKind::none&&
|
||||
waiting.state_json().find("Noch keine Angebote")!=std::string::npos,
|
||||
"an own listing without incoming offers gives visible feedback");
|
||||
auto expired=fixture();expired.squad_slots[2932]=0x0fff;
|
||||
check(!transfer_market_from_game(expired,5).squad[0].already_listed,
|
||||
"cleared rejected/expired pool entry immediately makes the player listable again");
|
||||
|
||||
auto wide_game=fixture();
|
||||
wide_game.player_statistics.emplace(uint32_t(1)<<12, PlayerClubStatistics{{256,0,256},65536,0,0});
|
||||
const auto wide_state=transfer_market_from_game(wide_game,4);
|
||||
check(wide_state.roster.players[0].statistics&&wide_state.roster.players[0].statistics->appearances[0]==256&&
|
||||
wide_state.roster.players[0].statistics->total==65536,
|
||||
"roster projection owns widened counts instead of showing wrapped Native bytes");
|
||||
TransferMarketScreen wide_screen(argv[1],wide_state),native_screen(argv[1],s);
|
||||
wide_screen.click(65,219);native_screen.click(65,219);
|
||||
wide_screen.click(10,219);native_screen.click(10,219);
|
||||
check(wide_screen.render().pixels!=native_screen.render().pixels,
|
||||
"actual transfer roster renderer visibly retains the 256th appearance");
|
||||
|
||||
auto all=s;all.items.clear();for(int n=0;n<40;++n){auto item=s.items[0];item.list_entry=n;item.source_slot=2928+n;item.player=100+n;item.name="P"+std::to_string(n);item.position=n%4;item.strength=60+n%7;all.items.push_back(item);}
|
||||
TransferMarketScreen pages(argv[1],all);const auto first=visible(pages);std::set<int> reached;
|
||||
for(int page=0;page<7;++page){const auto rows=visible(pages);check(rows.size()==size_t(page==6?4:6),"six original rows per page with final four");reached.insert(rows.begin(),rows.end());pages.click(210,45,true);}
|
||||
|
||||
@@ -4955,6 +4955,7 @@ void check_live_observer_determinism(const std::filesystem::path& data) {
|
||||
int events = 0; bool home_seen = false, away_seen = false;
|
||||
std::optional<LiveChanceEvent> preview;
|
||||
uint8_t preview_score = 0;
|
||||
ui::LiveScoreReveal score_reveal;
|
||||
int previews = 0, outcomes = 0;
|
||||
const auto source_exe = load_le(asset_path(data, "BMH.exe"));
|
||||
int shot_count = 0;
|
||||
@@ -4977,7 +4978,11 @@ void check_live_observer_determinism(const std::filesystem::path& data) {
|
||||
if (step.sprites[i].figure != 24)
|
||||
check(step.sprites[i-1].y <= step.sprites[i].y,"Source figures retain stable depth order");
|
||||
}
|
||||
const auto frame = ui::live_matchday_frame(event.minute,groups,state);
|
||||
const auto frame = score_reveal.project(ui::live_matchday_frame(event.minute,groups,state));
|
||||
if (preview && !frame.matches.empty())
|
||||
check(frame.matches[0].home_goals == (preview_score >> 4) &&
|
||||
frame.matches[0].away_goals == (preview_score & 15),
|
||||
"ball/set-piece/shot scoreboard retains preview until the visible result");
|
||||
const auto images = boundary_screen.render_set_piece(frame,event);
|
||||
check(images.size() == scene.size(),"each Source marker produces exactly one complete displayed frame");
|
||||
const auto backdrop = boundary_screen.render(frame);
|
||||
@@ -5000,7 +5005,11 @@ void check_live_observer_determinism(const std::filesystem::path& data) {
|
||||
const auto before = save_stream(state);
|
||||
const auto g_seed = game.seed(); const auto w_seed = rng.seed();
|
||||
const auto g_calls = game.calls(); const auto w_calls = rng.calls();
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
const auto frame = score_reveal.project(ui::live_matchday_frame(event.minute, groups, state));
|
||||
if (preview && !frame.matches.empty())
|
||||
check(frame.matches[0].home_goals == (preview_score >> 4) &&
|
||||
frame.matches[0].away_goals == (preview_score & 15),
|
||||
"ball/set-piece/shot scoreboard retains preview until the visible result");
|
||||
const auto rendered = boundary_screen.render_shot(frame, event);
|
||||
const auto repeat = boundary_screen.render_shot(frame, event);
|
||||
const auto palette = load_palette(asset_path(data, "M3PC.COL"));
|
||||
@@ -5030,6 +5039,8 @@ void check_live_observer_determinism(const std::filesystem::path& data) {
|
||||
const auto g_calls = game.calls(); const auto w_calls = rng.calls();
|
||||
const auto projection = ui::live_chance_projection(event, groups, state, source_exe);
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
score_reveal.observe(event.stage,frame);
|
||||
check(score_reveal.project(frame)==frame,"preview and visible result publish their own score");
|
||||
(void)boundary_screen.render_chance(frame, projection);
|
||||
(void)boundary_screen.render_chance(frame, projection);
|
||||
check(save_stream(state) == before && game.seed() == g_seed && rng.seed() == w_seed &&
|
||||
@@ -5055,7 +5066,11 @@ void check_live_observer_determinism(const std::filesystem::path& data) {
|
||||
check((distance >= 40 && distance <= 50) || distance == 52,
|
||||
"live ball uses the already drawn Watcom distance or the Source goal endpoint");
|
||||
home_seen |= event.displacement > 0; away_seen |= event.displacement < 0;
|
||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
||||
const auto frame = score_reveal.project(ui::live_matchday_frame(event.minute, groups, state));
|
||||
if (preview && !frame.matches.empty())
|
||||
check(frame.matches[0].home_goals == (preview_score >> 4) &&
|
||||
frame.matches[0].away_goals == (preview_score & 15),
|
||||
"ball/set-piece/shot scoreboard retains preview until the visible result");
|
||||
for (int i = 0; i < ui::LiveMatchdayScreen::ball_frame_count(event.displacement); ++i)
|
||||
(void)boundary_screen.render_ball(frame, event.displacement, i);
|
||||
++events;
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/bank_robbery.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/week.hpp"
|
||||
#include <bit>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh;
|
||||
namespace {
|
||||
void check(bool ok,const char* why){if(!ok)throw std::runtime_error(why);}
|
||||
void cash(GameState& state,int manager,int32_t value) {
|
||||
const size_t at=size_t(manager)*0xb0c+0x314;
|
||||
for(size_t n=0;n<4;++n)state.manager_records.at(at+n)=uint8_t(uint32_t(value)>>(8*n));
|
||||
}
|
||||
uint32_t expense(const GameState& state,int manager) {
|
||||
const size_t at=size_t(manager)*0xb0c+0x8a0;
|
||||
return uint32_t(state.manager_records.at(at))|uint32_t(state.manager_records.at(at+1))<<8|
|
||||
uint32_t(state.manager_records.at(at+2))<<16|uint32_t(state.manager_records.at(at+3))<<24;
|
||||
}
|
||||
GameState fixture() {
|
||||
GameState state;state.level=1;state.manager_records.resize(5*0xb0c);state.manager_teams={0,1};
|
||||
state.memory.add_block(layout::ManagerCount,1);state.memory.set8(layout::ManagerCount,2);
|
||||
state.club_ids={0,0};state.club_names={'C',0};return state;
|
||||
}
|
||||
template<class F>void rejects(F function,const char* why){bool rejected=false;try{function();}catch(const FormatError&){rejected=true;}check(rejected,why);}
|
||||
}
|
||||
int main()try {
|
||||
uint32_t expected_key=0;
|
||||
for(uint32_t day=0;day<1800;++day) {
|
||||
if(day&&month_code(day)!=month_code(day-1))expected_key=day;
|
||||
check(bank_robbery_month_key(day)==expected_key,"monthly key disagrees with the source calendar or collides across years");
|
||||
}
|
||||
auto state=fixture();cash(state,0,90000000);WatcomRandom random(713);
|
||||
const auto initial_calls=random.calls();daily_interest(state,random);
|
||||
check(!bank_robbery_guard_month(state,0)&&random.calls()==initial_calls,
|
||||
"ordinary low cash initializes a guard or consumes randomness");
|
||||
const auto old_native=save_stream(state);
|
||||
check(SaveState(old_native).extension().empty(),"ordinary native saves gain an unnecessary extension");
|
||||
state=GameState::from_save(SaveState(old_native));cash(state,0,250000000);
|
||||
daily_interest(state,random);
|
||||
check(bank_robbery_guard_month(state,0)==0&&expense(state,0)==0&&random.calls()==initial_calls,
|
||||
"an unknown imported history was robbed instead of receiving its grace month");
|
||||
for(int retry=0;retry<5;++retry)daily_interest(state,random);
|
||||
check(expense(state,0)==0&&random.calls()==initial_calls,"grace-month retries charge money or consume random draws");
|
||||
state.date=31;daily_interest(state,random);
|
||||
const auto loss=expense(state,0);
|
||||
check(loss>=10000000&&loss<=20000000&&loss%1000==0&&random.calls()==initial_calls+1&&bank_robbery_guard_month(state,0)==31,
|
||||
"the next month does not preserve the original threshold and loss distribution");
|
||||
for(int retry=0;retry<5;++retry)daily_interest(state,random);
|
||||
check(expense(state,0)==loss&&random.calls()==initial_calls+1,"a monthly repeat charges again or consumes RNG");
|
||||
|
||||
WatcomRandom save_random(25);const auto save=make_savegame(state,save_random);
|
||||
const auto path=std::filesystem::temp_directory_path()/("openbmh-robbery-"+std::to_string(std::chrono::steady_clock::now().time_since_epoch().count())+".FBM");
|
||||
write_savegame(path,save);const auto loaded_file=load_savegame(path);std::filesystem::remove(path);
|
||||
check(loaded_file.checksum_ok,"monthly guard invalidated encrypted save checksum");
|
||||
auto loaded=GameState::from_save(SaveState(loaded_file.stream));
|
||||
WatcomRandom resumed_random(100);daily_interest(loaded,resumed_random);
|
||||
check(bank_robbery_guard_month(loaded,0)==31&&expense(loaded,0)==loss&&resumed_random.calls()==0,
|
||||
"save/load resets the monthly limit or draws a new loss");
|
||||
cash(loaded,1,250000000);daily_interest(loaded,resumed_random);
|
||||
check(bank_robbery_guard_month(loaded,1)==31&&expense(loaded,1)==0&&resumed_random.calls()==0,
|
||||
"one manager's limit is reused by another manager or its grace draws RNG");
|
||||
loaded.date=62;daily_interest(loaded,resumed_random);
|
||||
check(bank_robbery_guard_month(loaded,0)==62&&bank_robbery_guard_month(loaded,1)==62&&resumed_random.calls()==2,
|
||||
"the next calendar month does not permit exactly one independent draw per manager");
|
||||
loaded.date=183;daily_interest(loaded,resumed_random);const auto december_calls=resumed_random.calls();
|
||||
loaded.date=184;daily_interest(loaded,resumed_random);
|
||||
check(resumed_random.calls()==december_calls+2,"December to January does not reset each manager's month");
|
||||
loaded.date=365;daily_interest(loaded,resumed_random);const auto yearly_calls=resumed_random.calls();
|
||||
check(bank_robbery_guard_month(loaded,0)==365,"a later July collides with an earlier year's July");
|
||||
daily_interest(loaded,resumed_random);check(resumed_random.calls()==yearly_calls,"same-month retry after year rollover consumes RNG");
|
||||
auto malformed=old_native;append_save_extension(malformed,{{kBankRobberyMonthExtension,Bytes(15,0)}});
|
||||
rejects([&]{(void)GameState::from_save(SaveState(malformed));},"truncated monthly guard is accepted");
|
||||
malformed=old_native;append_save_extension(malformed,{{kBankRobberyMonthExtension,Bytes(16,0)},{kBankRobberyMonthExtension,Bytes(16,0)}});
|
||||
rejects([&]{(void)GameState::from_save(SaveState(malformed));},"duplicate monthly guards are accepted");
|
||||
std::cout<<"Monthly robbery limit, source month/year boundaries, per-manager grace, no repeat RNG and encrypted save/load passed\n";
|
||||
return 0;
|
||||
}catch(const std::exception& error){std::cerr<<error.what()<<'\n';return 1;}
|
||||
@@ -41,5 +41,14 @@ int main()try {
|
||||
auto different=image(1995,5);const uint8_t unknown=0;different.patch(bmh::layout::CalendarDateSetup,&unknown,1);
|
||||
rejected=false;try{bmh::calendar_epoch_from_executable(different);}catch(const bmh::FormatError&){rejected=true;}
|
||||
check(rejected,"unknown date routine was guessed");
|
||||
auto english=image(1995,5);
|
||||
const uint8_t english_setup[]={0xc6,0x45,0xf6,5,0xc6,0x45,0xf7,7,0x66,0xc7,0x45,0xf8,0xcb,7};
|
||||
english.patch(bmh::layout::CalendarDateSetup,english_setup,sizeof english_setup);
|
||||
const auto english_epoch=bmh::calendar_epoch_from_executable(english);
|
||||
check(english_epoch.year==1995&&english_epoch.weekday==5,"translated English date operands rejected");
|
||||
const uint8_t invalid_weekday=7;
|
||||
english.patch(bmh::layout::CalendarDateSetup+3,&invalid_weekday,1);
|
||||
rejected=false;try{bmh::calendar_epoch_from_executable(english);}catch(const bmh::FormatError&){rejected=true;}
|
||||
check(rejected,"invalid translated English weekday accepted");
|
||||
std::cout<<"Edition calendar epoch, save header and year rollover passed\n";return 0;
|
||||
}catch(const std::exception&e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -15,6 +15,8 @@ int main(int argc,char**argv){try{
|
||||
auto db=load_database(data/"M3D.MAN");auto texts=load_textd(data/"TEXTD.BLK");
|
||||
auto before=startup_state(exe,db,read_file(data/"M3.MEN"),read_file(data/"M3.DAT"));
|
||||
before.texts=&texts;
|
||||
check(before.memory.has(layout::CompactDialogFrame)&&before.memory.u8(layout::CompactDialogFrame)==0,
|
||||
"options entry disables the boot-only black dialog frame");
|
||||
for(unsigned i=0;i<4;++i)check(exe.u32(::bmh::layout::OfferSlots+i*4)==0&&before.memory.u32(::bmh::layout::OfferSlots+i*4)==0,
|
||||
"raw EXE BSS and startup_state carry zero, not empty pending offer sentinel");
|
||||
// Use the existing exact6ba3e split helpers as unchanged baseline, with
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/week.hpp"
|
||||
#include <bit>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh;
|
||||
namespace {
|
||||
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
|
||||
void write(GameState& state,size_t at,int32_t value) {
|
||||
for(int byte=0;byte<4;++byte)state.manager_records.at(at+byte)=uint8_t(uint32_t(value)>>(byte*8));
|
||||
}
|
||||
int32_t read(const GameState& state,size_t at) {
|
||||
uint32_t value=0;
|
||||
for(int byte=0;byte<4;++byte)value|=uint32_t(state.manager_records.at(at+byte))<<(byte*8);
|
||||
return std::bit_cast<int32_t>(value);
|
||||
}
|
||||
}
|
||||
int main()try {
|
||||
check(daily_interest_amounts(0,1500000000,0).cash_and_deposit==-82191,
|
||||
"large deposits reverse interest because of an intermediate product overflow");
|
||||
check(daily_interest_amounts(-2000000000,0,1000000000).borrowing==821917,
|
||||
"large debt loses its annual-rate charges before division");
|
||||
check(daily_interest_amounts(-1800000000,0,1800000000).borrowing==591780,
|
||||
"credit-line interest overflows before division");
|
||||
check(daily_interest_amounts(0,std::numeric_limits<int32_t>::max(),0).cash_and_deposit==-117670,
|
||||
"maximum native deposit interest is not computed with a wide product");
|
||||
check(daily_interest_amounts(std::numeric_limits<int32_t>::min(),0,std::numeric_limits<int32_t>::max()).borrowing==706022,
|
||||
"native debt/credit boundary changed the division order");
|
||||
for(int32_t cash:{-1000000,-1,0,1,1000000})
|
||||
for(int32_t deposit:{0,9999,10000,1000000000})
|
||||
for(int32_t credit:{0,100000,1000000}) {
|
||||
int32_t expected=cash>=0?cash/-36500:0;
|
||||
if(cash<0) {
|
||||
if(cash+credit<0)expected=(cash+credit)*18/-36500;
|
||||
expected+=(cash>-credit?cash:-credit)*12/-36500;
|
||||
}
|
||||
expected+=((deposit/10000)*20000)/-36500;
|
||||
const auto interest=daily_interest_amounts(cash,deposit,credit);
|
||||
check(interest.borrowing+interest.cash_and_deposit==expected,
|
||||
"ordinary balances changed their original truncation or rate split");
|
||||
}
|
||||
GameState state;state.level=1;state.manager_teams={0};state.manager_records.resize(5*0xb0c);
|
||||
write(state,0x318,1500000000);
|
||||
WatcomRandom random(713);const auto seed=random.seed();const auto calls=random.calls();
|
||||
daily_interest(state,random);
|
||||
check(read(state,0x314)==82191&&read(state,0x870)==82191&&read(state,0x318)==1500000000,
|
||||
"daily booking and income statistics disagree with large-deposit interest");
|
||||
check(random.seed()==seed&&random.calls()==calls,"interest arithmetic consumed extra randomness");
|
||||
write(state,0x314,-2000000000);write(state,0x318,0);write(state,0x31c,1000000000);
|
||||
daily_interest(state,random);
|
||||
check(read(state,0x314)==-2000821917&&read(state,0x89c)==821917,
|
||||
"large-debt booking and expense statistics disagree with the wide calculation");
|
||||
std::cout<<"Wide daily interest, native boundary amounts, ordinary-rate parity and actual booking passed\n";
|
||||
return 0;
|
||||
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,90 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "app/controller.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/messages.hpp"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh;
|
||||
using namespace bmh::ui;
|
||||
namespace { void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);} }
|
||||
int main(int argc,char** argv)try {
|
||||
if(argc<2||!*argv[1])return 77;
|
||||
const std::filesystem::path data=argv[1];
|
||||
StartupFlow flow(data);
|
||||
std::unique_ptr<app::CareerSession> session;
|
||||
uint64_t revision=0;
|
||||
openbmh::audio::Playback playback;
|
||||
std::optional<uint64_t> audio;
|
||||
const auto serve=[&](const FlowResult& result) {
|
||||
check(app::serve_flow_request(flow,result,session,data,data,0x12345678,
|
||||
revision,playback,audio,false).empty(),"production startup/navigation failed");
|
||||
};
|
||||
flow.click(150,215);flow.click(5,225,true);flow.click(5,225,true);
|
||||
serve(flow.click(90,169));
|
||||
check(session&&flow.screen_name()=="desktop","edition did not reach an actual career desk");
|
||||
check(session->state().memory.has(layout::CompactDialogFrame)&&
|
||||
session->state().memory.u8(layout::CompactDialogFrame)==0,
|
||||
"setup retained the boot-only black dialog mode");
|
||||
const auto native=save_stream(session->state());
|
||||
const auto game=session->game();const auto random=session->rand();
|
||||
const auto before_revision=revision;
|
||||
for(int kind:{8,7}) {
|
||||
const auto& items=flow.desktop()->state().items;
|
||||
const auto it=std::find_if(items.begin(),items.end(),[&](const auto& item){return item.kind==kind&&!item.disabled;});
|
||||
check(it!=items.end(),"edition lacks the enabled original calendar menu");
|
||||
serve(flow.click(it->x+it->width/2,it->y+it->height/2));
|
||||
check(flow.calendar()&&flow.screen_name()==(kind==8?"calendar":"reschedule_calendar"),
|
||||
"original calendar menu did not open");
|
||||
check(flow.render().pixels.size()==320*240,"calendar did not render a complete original frame");
|
||||
serve(flow.send_key("ESC"));
|
||||
check(flow.screen_name()=="desktop"&&!flow.desktop()->pending(),"calendar did not return its desk owner");
|
||||
}
|
||||
check(save_stream(session->state())==native&&revision==before_revision&&
|
||||
session->game().seed()==game.seed()&&session->game().calls()==game.calls()&&
|
||||
session->rand().seed()==random.seed()&&session->rand().calls()==random.calls(),
|
||||
"opening calendars changed the career or random streams");
|
||||
auto finances=session->state();
|
||||
const int manager=int(finances.memory.u8(layout::ActiveManager));
|
||||
const size_t record=size_t(manager)*0xb0c;
|
||||
const auto record_money=[&](size_t offset,int32_t value) {
|
||||
for(int byte=0;byte<4;++byte)finances.manager_records.at(record+offset+byte)=uint8_t(uint32_t(value)>>(byte*8));
|
||||
};
|
||||
record_money(0x314,1500000000);record_money(0x318,1500000000);
|
||||
for(uint32_t i=0;i<6;++i) {
|
||||
finances.memory.set32(layout::FundBlock+i*0x1c,1000000);
|
||||
finances.memory.set16(layout::Advertising_OriginalShareAdjustment_RuntimeField+uint32_t(manager)*2+i*0x1c,i<2?1500:0);
|
||||
finances.memory.set32(layout::Bank_OriginalToUtf8_RuntimeField5+uint32_t(manager)*4+i*0x1c,0);
|
||||
}
|
||||
for(size_t i=0;i<12;++i) {
|
||||
const size_t at=i*0x5c;
|
||||
const uint16_t price=i==0?60000:1,held=i==0?50000:0;
|
||||
finances.stocks.at(at+0x4e)=uint8_t(price);finances.stocks.at(at+0x4f)=uint8_t(price>>8);
|
||||
finances.stocks.at(at+0x50+size_t(manager)*2)=uint8_t(held);
|
||||
finances.stocks.at(at+0x51+size_t(manager)*2)=uint8_t(held>>8);
|
||||
for(size_t byte=0;byte<4;++byte)finances.stocks.at(at+4+size_t(manager)*4+byte)=0;
|
||||
}
|
||||
for(uint32_t i=0;i<5;++i) {
|
||||
const uint32_t at=layout::Analytics_SourceAssetMaskE_RuntimeField+uint32_t(manager)*0x78+i*0x18;
|
||||
finances.memory.set32(at,i<2?1500000000:0);finances.memory.set32(at+0x10,0);
|
||||
}
|
||||
finances.memory.add_block(layout::CurrencyMultiplier,8);
|
||||
finances.memory.set32(layout::CurrencyMultiplier,1);finances.memory.set32(layout::CurrencyDivisor,1);
|
||||
const auto finance_native=save_stream(finances);
|
||||
const auto exe=load_le(asset_path(data,"BMH.exe"));
|
||||
const auto bank=bank_from_game(finances,exe,revision);
|
||||
check(bank.finance_values[2]==3000000000LL&&bank.finance_values[3]==3000000000LL&&
|
||||
bank.finance_values[4]==3000000000LL&&bank.finance_values[5]==6000000000LL&&
|
||||
bank.finance_gains[0]==3000000000LL&&bank.finance_gains[1]==3000000000LL,
|
||||
"bank display totals wrapped although individual saved amounts fit their native words");
|
||||
check(bank.finance_value_text[5].find("6.000.000.000")!=std::string::npos,
|
||||
"bank net worth text truncated its wide projection");
|
||||
check(save_stream(finances)==finance_native,"read-only bank totals changed the save representation");
|
||||
finances.memory.set32(layout::CurrencyMultiplier,2);finances.memory.set32(layout::CurrencyDivisor,3);
|
||||
check(bank_from_game(finances,exe,revision).finance_value_text[5].find("4.000.000.000")!=std::string::npos,
|
||||
"bank aggregate display uses the wrong native currency units");
|
||||
std::cout<<"Edition career startup, original calendar/rescheduling navigation, dialog mode and wide bank display passed\n";
|
||||
return 0;
|
||||
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,116 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/long_career.hpp"
|
||||
#include "game/matchday.hpp"
|
||||
#include "game/national.hpp"
|
||||
#include "game/save.hpp"
|
||||
using namespace bmh;
|
||||
namespace {
|
||||
void check(bool yes, const char* why) { if (!yes) throw std::runtime_error(why); }
|
||||
GameState fixture() {
|
||||
GameState g; g.season = 0; g.manager_teams = {0};
|
||||
g.manager_records.resize(5 * 0xb0c); g.tactics.resize(5 * 0x840);
|
||||
g.players = {{"Synthetic", 70u << 7 | 70u << 14 | 70u, 0, 6u << 21 | 1u}};
|
||||
g.player_bonus.resize(1); g.squad_slots.resize(3072, 0xfff); g.squad_slots[0] = 0;
|
||||
g.club_ids = {0, 5}; g.club_names = {'C','l','u','b',0,'R','i','v','a','l',0};
|
||||
g.memory.add_block(layout::Titles, 900);
|
||||
for (uint32_t n = 0; n < 900; ++n) g.memory.set8(layout::Titles + n, 0xff);
|
||||
g.memory.add_block(layout::ManagerCount, 1); g.memory.set8(layout::ManagerCount, 1);
|
||||
return g;
|
||||
}
|
||||
std::array<uint8_t, 0x58> board(const GameState& g) {
|
||||
std::array<uint8_t, 0x58> b; std::copy_n(g.tactics.begin(), b.size(), b.begin()); return b;
|
||||
}
|
||||
void counters() {
|
||||
auto g = fixture();
|
||||
g.tactics[7] = g.tactics[8] = g.tactics[9] = 255;
|
||||
for (size_t n = 0x48; n <= 0x4d; ++n) g.tactics[n] = 255;
|
||||
player_statistic(g, 0, 0, 0, 0, 0, 0);
|
||||
player_statistic(g, 1, 0, 0, 0, 0, 0);
|
||||
player_statistic(g, 2, 0, 0, 0, 0, 0);
|
||||
player_statistic(g, 0, 0, 0, 0, 1, 0);
|
||||
player_statistic(g, 0, 0, 0, 0, 2, 0);
|
||||
const auto stats = player_club_statistics(g, 0, 0, board(g));
|
||||
check(stats.appearances == std::array<uint64_t,3>{256,256,256}, "all cumulative byte counters survive 255 -> 256");
|
||||
check(stats.total == 65538 && stats.goals == 65536 && stats.assists == 65536, "word totals survive 65535 -> 65536");
|
||||
check(g.tactics[7] == 0 && g.tactics[8] == 0 && g.tactics[9] == 0 && g.tactics[0x48] == 2,
|
||||
"native byte/word fields retain compatible modulo representation");
|
||||
const auto native = save_stream(g); const SaveState saved(native);
|
||||
auto loaded = GameState::from_save(saved);
|
||||
check(loaded.player_statistics == g.player_statistics && save_stream(loaded) == native,
|
||||
"optional wide counters survive exact native-stream save/load/save roundtrip");
|
||||
const auto payload = encode_long_career(g);
|
||||
auto plain = g; plain.player_statistics.clear();
|
||||
const auto original = save_stream(plain);
|
||||
check(original.size() + payload.size() + 18 == native.size() &&
|
||||
std::equal(original.begin(), original.end(), native.begin()), "extension leaves every Original block and name pool byte unchanged");
|
||||
swap_statistics_clubs(g, 0, 1);
|
||||
check(player_club_statistics(g, 1, 0, board(g)) == stats, "club promotion remapping retains the same player's counts");
|
||||
swap_statistics_clubs(g, 0, 1);
|
||||
WatcomRandom random(713);
|
||||
new_board_entry(g, 0, 0, 0, random);
|
||||
check(g.player_statistics.empty() && player_club_statistics(g, 0, 0, board(g)).total == 0,
|
||||
"replacement player never inherits the previous occupant's wide/native totals");
|
||||
auto exhausted = fixture();
|
||||
exhausted.player_statistics.emplace(0, PlayerClubStatistics{{255,0,0}, UINT64_MAX,0,0});
|
||||
const auto exhausted_before = save_stream(exhausted); bool refused = false;
|
||||
try { player_statistic(exhausted, 0, 0, 0, 0, 0, 0); } catch (const FormatError&) { refused = true; }
|
||||
check(refused && save_stream(exhausted) == exhausted_before, "uint64 exhaustion is explicit and inert, never a silent clamp");
|
||||
auto wrapped = fixture(); // Already lost high bits cannot be reconstructed from a legacy import.
|
||||
player_statistic(wrapped, 0, 0, 0, 0, 0, 0);
|
||||
check(player_club_statistics(wrapped, 0, 0, board(wrapped)).total == 1, "legacy zero is a known lower bound, never fabricated prior appearances");
|
||||
}
|
||||
void history() {
|
||||
auto g = fixture();
|
||||
for (int season = 0; season <= 300; ++season) {
|
||||
if (season) {
|
||||
capture_title_history(g); ++g.season; shift_legacy_title_history(g);
|
||||
}
|
||||
record_title_holder(g, 0, uint16_t(season % 2));
|
||||
record_title_holder(g, 1, uint16_t((season + 1) % 2));
|
||||
}
|
||||
check(g.title_history.size() == 301 && g.title_history.at(0)[0] == "Club" &&
|
||||
g.title_history.at(49)[0] == "Rival" && g.title_history.at(50)[0] == "Club" &&
|
||||
g.title_history.at(300)[1] == "Rival", "title and cup winners remain available across seasons 49/50/300");
|
||||
check(g.memory.u16(layout::Titles) == 1 && g.memory.u16(layout::Titles + 98) == 0,
|
||||
"Original block still contains exactly the latest 50 seasons");
|
||||
const auto bytes = save_stream(g); const SaveState saved(bytes); auto loaded = GameState::from_save(saved);
|
||||
check(loaded.title_history == g.title_history && save_stream(loaded) == bytes, "301 seasons persist in the optional save extension");
|
||||
g.club_names[0] = 'X';
|
||||
check(g.title_history.at(0)[0] == "Club", "winner names are owned snapshots, independent of later renaming/promotion");
|
||||
auto imported = fixture(); imported.season = 300; imported.memory.set16(layout::Titles, 0);
|
||||
capture_title_history(imported);
|
||||
check(imported.title_history.size() == 50 && imported.title_history.begin()->first == 251 &&
|
||||
!imported.title_history.contains(0), "old late-career imports retain only known rows and do not fabricate lost history");
|
||||
}
|
||||
void malformed() {
|
||||
auto g = fixture(); record_title_holder(g, 0, 0); const auto original = encode_long_career(g);
|
||||
for (size_t size = 0; size < original.size(); ++size) {
|
||||
auto old = g; bool refused = false;
|
||||
try { decode_long_career(old, Bytes(original.begin(), original.begin() + size)); }
|
||||
catch (const FormatError&) { refused = true; }
|
||||
check(refused && old.title_history == g.title_history, "truncated archive rejects atomically");
|
||||
}
|
||||
auto version = original; version[0] = 2; bool refused = false;
|
||||
try { decode_long_career(g, version); } catch (const FormatError&) { refused = true; }
|
||||
check(refused, "future archive versions are explicit unsupported outcomes");
|
||||
auto future = g; future.title_history.emplace(1, std::array<std::string,9>{});
|
||||
const auto future_bytes = save_stream(future); refused = false;
|
||||
try { (void)GameState::from_save(SaveState(future_bytes)); } catch (const FormatError&) { refused = true; }
|
||||
check(refused, "future season history cannot silently bind to a different saved calendar");
|
||||
auto base = g; base.title_history.clear(); auto duplicate = save_stream(base);
|
||||
append_save_extension(duplicate, {{kLongCareerExtension,original},{kLongCareerExtension,original}});
|
||||
refused = false;
|
||||
try { (void)GameState::from_save(SaveState(duplicate)); } catch (const FormatError&) { refused = true; }
|
||||
check(refused, "duplicate archive containers reject rather than overwrite history");
|
||||
}
|
||||
}
|
||||
int main() try {
|
||||
counters(); history(); malformed();
|
||||
std::cout << "PASS cumulative 256/65536 counters, 301 title seasons, legacy compatibility and archive roundtrip/validation\n";
|
||||
return 0;
|
||||
} catch (const std::exception& error) { std::cerr << error.what() << '\n'; return 1; }
|
||||
@@ -0,0 +1,61 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/month.hpp"
|
||||
#include "game/balance_plan.hpp"
|
||||
#include "ui/advertising.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh;
|
||||
namespace {
|
||||
uint32_t word(const GameState& g,int manager,size_t offset) {
|
||||
return le32(g.manager_records,size_t(manager)*0xb0c+offset);
|
||||
}
|
||||
GameState fixture(uint32_t price) {
|
||||
GameState g;g.level=1;g.manager_teams={0,1};g.manager_records.resize(5*0xb0c);
|
||||
g.memory.add_block(layout::FundBlock,6*0x1c);
|
||||
g.memory.add_block(layout::Loans,4*0x78);
|
||||
g.memory.add_block(layout::Spending,4*0x24);
|
||||
g.memory.add_block(layout::ManagerCount,1);g.memory.set8(layout::ManagerCount,2);
|
||||
g.memory.add_block(layout::ActiveManager,1);g.memory.set8(layout::ActiveManager,1);
|
||||
g.memory.add_block(layout::GameMode,1);g.memory.set8(layout::GameMode,3);
|
||||
g.memory.add_block(layout::CareerDuration,1);g.memory.set8(layout::CareerDuration,5);
|
||||
g.tactics.resize(4*0x840);g.league_rounds.resize(9);
|
||||
for(size_t m=0;m<4;++m)for(size_t row=0;row<24;++row)g.tactics[m*0x840+row*0x58+0x3d]=0xff;
|
||||
g.memory.set32(layout::FundBlock+5*0x1c,price);
|
||||
g.memory.set16(layout::Advertising_OriginalShareAdjustment_RuntimeField+5*0x1c,3);
|
||||
g.memory.set16(layout::Advertising_OriginalShareAdjustment_RuntimeField+5*0x1c+2,10);
|
||||
return g;
|
||||
}
|
||||
void verify(uint32_t initial,uint32_t grown,uint32_t per_unit) {
|
||||
auto g=fixture(initial);monthly_shares_and_loans(g);
|
||||
if(g.memory.u32(layout::FundBlock+5*0x1c)!=grown)
|
||||
throw std::runtime_error("monthly dividend changed price-growth rounding");
|
||||
// The default legacy policy retains only the last holder and pays record2.
|
||||
if(word(g,0,0x314)!=0||word(g,1,0x314)!=0||
|
||||
word(g,2,0x314)!=10*per_unit||word(g,2,0x870)!=10*per_unit)
|
||||
throw std::runtime_error("representable monthly dividend or legacy recipient is incorrect");
|
||||
const auto settled_records=g.manager_records;
|
||||
const auto preview=bmh::ui::original_finance_preview(g,1);
|
||||
if(preview.income!=int32_t(word(g,2,0x314)))
|
||||
throw std::runtime_error("monthly property preview differs from the real settled dividend");
|
||||
auto forecast=g;forecast.manager_records[0xb0c+0x310]=2; // Twelve-month view.
|
||||
const auto forecast_records=forecast.manager_records;
|
||||
const auto plan=open_balance_plan(forecast,1);
|
||||
if(plan.rows[5]!=int32_t(120*per_unit))
|
||||
throw std::runtime_error("annual property preview differs from settled monthly dividends");
|
||||
if(g.manager_records!=settled_records||forecast.manager_records!=forecast_records)
|
||||
throw std::runtime_error("dividend previews mutated the financial records");
|
||||
#ifdef BMH_TEST_PER_HOLDER_DIVIDENDS
|
||||
auto typed=fixture(initial);monthly_shares_and_loans(typed,true);
|
||||
if(word(typed,0,0x314)!=3*per_unit||word(typed,1,0x314)!=10*per_unit||
|
||||
word(typed,2,0x314)!=0||word(typed,0,0x870)!=3*per_unit||word(typed,1,0x870)!=10*per_unit)
|
||||
throw std::runtime_error("typed policy did not pay the actual holders");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
verify(1'000'000,1'002'500,3'007);
|
||||
verify(999,999,2); // Per-unit truncation must precede multiplying holdings.
|
||||
verify(200'000'000,200'500'000,601'500); // Product exceeds UINT32_MAX, payout fits.
|
||||
verify(2'000'000'000,2'005'000'000,6'015'000);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "app/controller.hpp"
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
using namespace bmh;using namespace bmh::ui;
|
||||
namespace {void check(bool value,const char* why){if(!value)throw std::runtime_error(why);}}
|
||||
int main(int argc,char** argv)try {
|
||||
if(argc<3||!*argv[1]||!*argv[2])return 77;
|
||||
const std::filesystem::path data=argv[1],input=argv[2];const auto unchanged=read_file(input);
|
||||
const auto container=load_savegame(input);require_native_savegame(container);
|
||||
app::CareerSession imported(data,713,input);const auto desk=imported.desktop_projection(1);
|
||||
check(desk.manager_slot>=0&&!desk.manager_name.empty(),"unchanged external save did not produce an actual career desk");
|
||||
const auto exe=load_le(asset_path(data,"BMH.exe"));
|
||||
check(load_reference_desk(input,exe).manager_slot==desk.manager_slot,"read-only desktop importer rejects an accepted version");
|
||||
check(load_preparation_reference(input,exe).desktop.manager_slot==desk.manager_slot,"preparation importer rejects an accepted version");
|
||||
const auto directory=std::filesystem::temp_directory_path()/("openbmh-native-import-"+std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
std::filesystem::create_directories(directory);
|
||||
try {
|
||||
std::filesystem::copy_file(input,directory/"IMPORT.FBM");
|
||||
SaveLoadScreen browser(data,directory,SaveLoadMode::load,desk.manager_slot,1,Image(320,240));
|
||||
check(browser.info_press(80,45)&&browser.info_open(),"load-list information rejects the accepted original save");
|
||||
StartupFlow flow(data,directory);std::unique_ptr<app::CareerSession> session;uint64_t revision=0;
|
||||
openbmh::audio::Playback playback;std::optional<uint64_t> audio;
|
||||
flow.click(214,215);
|
||||
check(flow.screen_name()=="save_load","setup did not open the actual game browser");
|
||||
const auto request=flow.send_key("ENTER");check(request.request==FlowRequest::file_action,"browser did not emit the original save load request");
|
||||
const auto result=app::serve_flow_request(flow,request,session,data,directory,713,revision,playback,audio,false);
|
||||
check(result.empty()&&session&&flow.screen_name()=="desktop","shared production controller rejects the original version");
|
||||
const auto output=directory/"ROUNDTRIP.FBM";std::string error;
|
||||
check(imported.save_game(output,desk.manager_slot,false,error),"regular session save rejected the imported original career");
|
||||
const auto saved=load_savegame(output);require_native_savegame(saved);
|
||||
app::CareerSession reloaded(data,911,output);
|
||||
check(reloaded.desktop_projection(1).manager_slot==desk.manager_slot&&
|
||||
save_stream(reloaded.state())==save_stream(imported.state()),
|
||||
"ordinary save/reload changed the imported career's native state");
|
||||
check(read_file(input)==unchanged,"original input save was changed");
|
||||
std::filesystem::remove_all(directory);
|
||||
}catch(...){std::filesystem::remove_all(directory);throw;}
|
||||
std::cout<<"Unchanged external "<<container.version<<" imported through CareerSession, desktop/preparation and load-list/controller; ordinary session save/reload passed\n";return 0;
|
||||
}catch(const std::exception& error){std::cerr<<error.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,47 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/savestate.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
using namespace bmh;
|
||||
namespace {
|
||||
void check(bool value,const char* why){if(!value)throw std::runtime_error(why);}
|
||||
template<class F>void rejects(F function,const char* message){bool rejected=false;try{function();}catch(const FormatError&){rejected=true;}check(rejected,message);}
|
||||
}
|
||||
int main()try {
|
||||
GameState state;state.manager_records.resize(5*0xb0c);state.manager_teams={0};state.club_ids={0};state.club_names={'Q',0};
|
||||
state.memory.add_block(layout::ManagerCount,1);state.memory.set8(layout::ManagerCount,1);
|
||||
WatcomRandom random(713);const auto original=make_savegame(state,random);
|
||||
for(const char* version:{"V2.24","V3.7"}) {
|
||||
auto saved=original;saved.version=version;require_native_savegame(saved);
|
||||
const SaveState parsed(saved.stream);check(!parsed.blocks().empty(),"recognized synthetic native layout does not parse");
|
||||
auto truncated=saved;truncated.stream.pop_back();
|
||||
rejects([&]{require_native_savegame(truncated);(void)SaveState(truncated.stream);},"recognized version bypassed strict state/trailer validation");
|
||||
auto counts=DbCounts{};++counts.players;
|
||||
rejects([&]{require_native_savegame(saved);(void)SaveState(saved.stream,counts);},"recognized version bypassed installed database dimensions");
|
||||
}
|
||||
for(const char* version:{"V2.20","V3.70","v3.7","V9.99","O1.1","O1.2",""}) {
|
||||
auto saved=original;saved.version=version;
|
||||
rejects([&]{require_native_savegame(saved);},"unknown/different-layout native version was accepted");
|
||||
}
|
||||
check(supported_native_save_version("O1.1",true)&&!supported_native_save_version("V2.24",true)&&
|
||||
!supported_native_save_version("V3.7",true)&&!supported_native_save_version("V2.20",true),
|
||||
"expanded layout accepted a classic/English marker or rejected its own version");
|
||||
auto damaged=original;damaged.checksum_ok=false;
|
||||
try{require_native_savegame(damaged);throw std::runtime_error("checksum failure was accepted");}
|
||||
catch(const FormatError& error){check(std::string(error.what()).find("checksum mismatch")!=std::string::npos,"checksum failure was confused with version support");}
|
||||
auto unsupported=original;unsupported.version="V2.20";
|
||||
try{require_native_savegame(unsupported);throw std::runtime_error("different-layout version was accepted");}
|
||||
catch(const FormatError& error){check(std::string(error.what()).find("unsupported FBM version V2.20")!=std::string::npos,"version rejection lost its actual marker");}
|
||||
const auto path=std::filesystem::temp_directory_path()/("openbmh-version-"+std::to_string(std::chrono::steady_clock::now().time_since_epoch().count())+".FBM");
|
||||
auto version37=original;version37.version="V3.7";write_savegame(path,version37);const auto loaded=load_savegame(path);
|
||||
require_native_savegame(loaded);check(loaded.version=="V3.7"&&loaded.stream==original.stream,"synthetic V3.7 container roundtrip changed its state");
|
||||
auto bytes=read_file(path);bytes.back()^=1;{std::ofstream file(path,std::ios::binary|std::ios::trunc);file.write(reinterpret_cast<const char*>(bytes.data()),std::streamsize(bytes.size()));}
|
||||
const auto corrupt=load_savegame(path);std::filesystem::remove(path);
|
||||
rejects([&]{require_native_savegame(corrupt);},"actual corrupt container checksum was accepted");
|
||||
std::cout<<"Known native save versions, separate expanded layout, strict dimensions/trailers and checksum/version diagnostics passed\n";return 0;
|
||||
}catch(const std::exception& error){std::cerr<<error.what()<<'\n';return 1;}
|
||||
@@ -230,8 +230,8 @@ void test_preview_cancel_zero_and_cross_family(const std::filesystem::path& data
|
||||
page.block_expansion->quote.current_capacity_thousands==10&&
|
||||
page.block_expansion->header_text_variant==expected_header_value,
|
||||
"accepted B editor binds the live capacity and draws its header variant once");
|
||||
check(page.block_expansion->quote.price_per_1000==375000&&page.block_expansion->quote.base_weeks==37,
|
||||
"B uses the literal Source A-H table entries 9 and 23");
|
||||
check(page.block_expansion->quote.price_per_1000==375000&&page.block_expansion->quote.base_weeks==48,
|
||||
"B retains the edition price and uses the expanded24k construction period");
|
||||
const auto& initial_block=*page.block_expansion;
|
||||
const auto amount_text=[&](uint32_t amount) {
|
||||
return format_number(session->state(),int32_t(amount),0x181)+source_exe.cstring(::bmh::layout::CareerSession_FormatNumber_ExecutableField);
|
||||
@@ -385,8 +385,8 @@ void test_literal_eight_block_tables(const std::filesystem::path& data) {
|
||||
page=stadium_state(*session,revision);
|
||||
const auto& quote=page.block_expansion->quote;
|
||||
check(quote.price_per_1000==executable.u32(layout::CareerSession_DispatchStadium_RuntimeField + (size_t(slot)+8)*4)&&
|
||||
quote.base_weeks==executable.u8(layout::CareerSession_DispatchStadium_RuntimeField2 + (size_t(slot)+22)*5),
|
||||
"each A-H slot matches its externally supplied executable table");
|
||||
quote.base_weeks==stadium_block_expansion_constants(executable).weeks[size_t(slot)],
|
||||
"each A-H slot matches edition prices and expanded construction policy");
|
||||
auto cancel=request_from(page,ui::StadiumRequestKind::expansion_cancel,slot,
|
||||
quote.total_target_places,quote.desired_features);
|
||||
check(session->dispatch_stadium(cancel,revision,error)&&error.empty(),"each table quote cancels cleanly");
|
||||
@@ -589,12 +589,7 @@ void test_yes_level_zero_and_funds_refusal(const std::filesystem::path& data) {
|
||||
resolve_stand_block_offer(accepted,true,expected_random);
|
||||
GameState expected=session->state();
|
||||
auto exe=load_le(ui::asset_path(data,"BMH.exe"));
|
||||
StadiumBlockExpansionConstants constants;
|
||||
for(unsigned i=0;i<8;++i) {
|
||||
constants.price_per_1000[i]=exe.u32(::bmh::layout::CareerSession_DispatchStadium_RuntimeField+(i+8)*4);
|
||||
constants.weeks[i]=exe.u8(::bmh::layout::CareerSession_DispatchStadium_RuntimeField2+(i+22)*5);
|
||||
constants.max_places[i]=uint32_t(exe.u8(::bmh::layout::CareerSession_Invalid_RuntimeField+i))*1000;
|
||||
}
|
||||
const auto constants=stadium_block_expansion_constants(exe);
|
||||
check(build_stadium_block_expansion(expected,manager,StadiumBlockSlot::B,constants,
|
||||
quote,accepted,expected_random),"independent Source Engine simulation accepts YES at level 0");
|
||||
const auto game_before=session->game();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/stadium_blocks.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
#include <stdexcept>
|
||||
namespace {
|
||||
void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}
|
||||
}
|
||||
int main()try{
|
||||
using namespace bmh;
|
||||
auto image=LeImage::from_bytes(layout::GermanDataSegmentBegin,Bytes(layout::CareerSession_Invalid_RuntimeField + 8 - layout::GermanDataSegmentBegin));
|
||||
const uint8_t original_max[]={8,18,8,14,8,18,8,14},original_weeks[]={30,37,30,25,30,37,30,25};
|
||||
for(uint32_t i=0;i<8;++i){image.patch(layout::CareerSession_Invalid_RuntimeField+i,original_max+i,1);image.patch(layout::CareerSession_DispatchStadium_RuntimeField2+(i+22)*5,original_weeks+i,1);const uint8_t price[]={0xe0,0x93,0x04,0};image.patch(layout::CareerSession_DispatchStadium_RuntimeField+(i+8)*4,price,4);}
|
||||
const auto constants=stadium_block_expansion_constants(image);
|
||||
check(constants.max_places==std::array<uint32_t,8>{14000,24000,14000,20000,14000,24000,14000,20000},"expanded block limits differ");
|
||||
check(std::accumulate(constants.max_places.begin(),constants.max_places.end(),0u)==144000,"full stadium does not reach144k");
|
||||
check(constants.weeks==std::array<uint8_t,8>{30,48,30,40,30,48,30,40},"larger block duration is not scaled with size");
|
||||
check(constants.price_per_1000[0]==300000&&constants.price_per_1000[7]==300000,"edition unit prices were replaced");
|
||||
const uint8_t custom=20;image.patch(layout::CareerSession_Invalid_RuntimeField,&custom,1);check(stadium_block_expansion_constants(image).max_places[0]==20000,"larger supplied custom stand was reduced");
|
||||
const uint8_t unsupported=255;image.patch(layout::CareerSession_Invalid_RuntimeField,&unsupported,1);bool rejected=false;try{stadium_block_expansion_constants(image);}catch(const FormatError&){rejected=true;}check(rejected,"unrepresentable capacity/duration accepted");
|
||||
std::cout<<"144k stadium policy, edition prices, capacity-based weeks, custom floors and saved byte limits passed\n";
|
||||
}catch(const std::exception& error){std::cerr<<error.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,74 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
#include "game/month.hpp"
|
||||
#include "game/national.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
|
||||
using namespace bmh;
|
||||
namespace {
|
||||
void require(bool value, const char* message) { if (!value) throw std::runtime_error(message); }
|
||||
GameState fixture() {
|
||||
GameState g;
|
||||
g.manager_teams = {0}; g.manager_records.resize(5 * 0xb0c);
|
||||
g.tactics.resize(5 * 0x840); g.squad_slots.resize(3072, 0xfff);
|
||||
g.squad_slots[0] = 0x8000;
|
||||
g.players = {{"Arrival", 70u << 7 | 70u << 14 | 70u, 0, 6u << 21 | 1u}};
|
||||
g.memory.add_block(layout::EditorList, 44 * 0x58);
|
||||
for (uint32_t entry = 0; entry < 44; ++entry)
|
||||
for (uint32_t bid = 0; bid < 4; ++bid)
|
||||
g.memory.set16(layout::EditorList + entry * 0x58 + bid * 2, 0xffff);
|
||||
return g;
|
||||
}
|
||||
void fresh_arrivals() {
|
||||
const auto base = fixture();
|
||||
for (uint8_t inherited : {0x00, 0x20, 0x40, 0x60, 0x80, 0xff}) {
|
||||
for (uint8_t tenure : {0, 127, 255}) {
|
||||
auto g = base;
|
||||
g.tactics[0xb] = inherited; g.tactics[0x11] = tenure;
|
||||
WatcomRandom actual(713), reference(713);
|
||||
auto clean = base;
|
||||
new_board_entry(clean, 0, 0, 0, reference);
|
||||
new_board_entry(g, 0, 0, 0, actual);
|
||||
require(g.tactics == clean.tactics, "new arrival inherits no previous contract flags or tenure");
|
||||
require(actual.calls() == reference.calls() && actual.seed() == reference.seed(), "flag fix consumes no extra RNG");
|
||||
require(g.tactics[0xc] == 24 && g.tactics[0xb] == 0, "arrival gets ordinary two-year initial term and clean negotiation flags");
|
||||
g.tactics[0xd] = 105;
|
||||
const auto demands = contract_demands(g, 0, 0, true, actual);
|
||||
for (const auto amount : demands)
|
||||
require(amount != UINT32_MAX && amount > 0, "young arrival can negotiate every supported term immediately");
|
||||
}
|
||||
}
|
||||
auto retired = base;
|
||||
retired.tactics[0xb] = 0x20; retired.tactics[0xc] = 24; retired.tactics[0xd] = 100;
|
||||
WatcomRandom rand(713);
|
||||
for (const auto demand : contract_demands(retired, 0, 0, true, rand))
|
||||
require(demand == UINT32_MAX, "existing player's genuine retirement decision remains effective");
|
||||
}
|
||||
void ordinary_list_guards() {
|
||||
auto g = fixture();
|
||||
for (size_t n = 0; n < 40; ++n) g.squad_slots[0xb70 + n] = 1;
|
||||
WatcomRandom rand(713); MinuteReport report;
|
||||
const auto full = list_manager_player(g, 0, 0, rand, report);
|
||||
require(full.status == TransferActionStatus::blocked_by_board && !report.unsupported && rand.calls() == 0,
|
||||
"full ordinary market refuses without taking reserved entries or RNG");
|
||||
require(g.squad_slots[0xb70 + 40] == 0xfff, "special offer rows are preserved");
|
||||
g.squad_slots[0xb70] = 0;
|
||||
const auto listed = list_manager_player(g, 0, 0, rand, report);
|
||||
require(listed.status == TransferActionStatus::pending && !report.unsupported && rand.calls() == 0,
|
||||
"already listed is an explicit inert outcome");
|
||||
const auto native = g.squad_slots;
|
||||
const auto rejected = accept_manager_transfer_offer(g, 1, 0, 0, 0, rand, report);
|
||||
require(rejected.status == TransferActionStatus::invalid_request && g.squad_slots == native && rand.calls() == 0,
|
||||
"unowned listing cannot be settled through seller action");
|
||||
}
|
||||
}
|
||||
int main() try {
|
||||
fresh_arrivals(); ordinary_list_guards();
|
||||
std::cout << "PASS fresh-arrival contract flags, tenure boundaries and ordinary listing guards\n";
|
||||
return 0;
|
||||
} catch (const std::exception& error) { std::cerr << error.what() << '\n'; return 1; }
|
||||
@@ -0,0 +1,123 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <stdexcept>
|
||||
#include "app/career_session.hpp"
|
||||
#include "app/window_actions.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "ui/incoming_transfer.hpp"
|
||||
|
||||
using namespace bmh;
|
||||
namespace {
|
||||
void require(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
|
||||
struct Snapshot {
|
||||
Bytes native; GameRandom game; WatcomRandom rand; uint64_t revision;
|
||||
Snapshot(app::CareerSession& s, uint64_t r) : native(save_stream(s.state())), game(s.game()), rand(s.rand()), revision(r) {}
|
||||
bool same(app::CareerSession& s, uint64_t r) const {
|
||||
return native == save_stream(s.state()) && revision == r && game.seed() == s.game().seed() &&
|
||||
game.calls() == s.game().calls() && rand.seed() == s.rand().seed() && rand.calls() == s.rand().calls();
|
||||
}
|
||||
};
|
||||
ui::IncomingTransferDecisionState panel(const GameState& state, const TransferOfferListView& offers) {
|
||||
ui::IncomingTransferDecisionView view;
|
||||
view.valid = offers.valid; view.list_entry = offers.list_entry; view.player = offers.player;
|
||||
view.seller = offers.seller; view.seller_manager = offers.seller_manager; view.viewer_manager = offers.seller_manager;
|
||||
view.asking_fee = offers.asking_fee; view.asking_monthly_salary = offers.asking_monthly_salary;
|
||||
for (size_t n = 0; n < 4; ++n) {
|
||||
const auto& source = offers.offers[n]; auto& row = view.offers[n];
|
||||
row.bid_index = source.bid_index; row.buyer = source.buyer; row.buyer_manager = source.buyer_manager;
|
||||
row.present = source.present; row.eligible = source.eligible; row.transaction_supported = source.transaction_supported;
|
||||
row.fee = source.fee; row.monthly_salary = source.monthly_salary; row.contract_months = source.contract_months;
|
||||
row.fee_reference = source.fee_reference; row.salary_reference = source.salary_reference;
|
||||
row.loan = source.loan; row.bonuses = source.bonuses;
|
||||
}
|
||||
return ui::incoming_transfer_decision_from_game(state, view);
|
||||
}
|
||||
}
|
||||
int main(int argc, char** argv) try {
|
||||
if (argc != 3 && argc != 4) return 2;
|
||||
const std::filesystem::path data = argv[1];
|
||||
app::CareerSession session(data, 37, argv[2]); uint64_t revision = 1;
|
||||
const auto base = session.state(); const auto manager = base.memory.u8(layout::ActiveManager);
|
||||
const auto range = squad_range(base.manager_teams.at(manager));
|
||||
int entry = -1, player = -1, chosen = -1;
|
||||
// Produce offers through real listing/bid routines on the supplied career.
|
||||
// No bidder/amount/term/table bytes are fabricated for this integration test.
|
||||
for (size_t row = 0; row < range.count && chosen < 0; ++row) {
|
||||
if ((base.squad_slots[range.first + row] & 0xfff) == 0xfff) continue;
|
||||
auto listed = base; auto w = session.rand(); auto game = session.game(); MinuteReport listing_report;
|
||||
const auto listing = list_manager_player(listed, manager, int(row), w, listing_report);
|
||||
if (listing.status != TransferActionStatus::accepted || listing_report.unsupported) continue;
|
||||
for (int attempt = 0; attempt < 4 && chosen < 0; ++attempt) {
|
||||
MinuteReport report;
|
||||
transfer_bid(listed, 0xb70 + listing.list_entry,
|
||||
layout::EditorList + uint32_t(listing.list_entry) * 0x58, false, -1, game, w, report);
|
||||
if (report.unsupported) break;
|
||||
const auto offers = project_transfer_offer_list(listed, listing.list_entry);
|
||||
for (const auto& offer : offers.offers) {
|
||||
if (!offer.present || offer.loan || !offer.eligible) continue;
|
||||
auto expected = listed; auto expected_rand = w; MinuteReport expected_report;
|
||||
const auto result = accept_manager_transfer_offer(expected, manager, listing.list_entry,
|
||||
listing.player, offer.bid_index, expected_rand, expected_report);
|
||||
if (result.status != TransferActionStatus::accepted || expected_report.unsupported) continue;
|
||||
session.state() = listed; session.game() = game; session.rand() = w;
|
||||
chosen = offer.bid_index; entry = listing.list_entry; player = listing.player; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
require(chosen >= 0, "supplied career produces a natural eligible seller offer");
|
||||
if (argc == 4) {
|
||||
std::string save_error;
|
||||
require(session.save_game(argv[3], 0, false, save_error), "natural offer evidence saves through the session writer");
|
||||
}
|
||||
const auto before = Snapshot(session, revision);
|
||||
ui::TransferMarketRequest request;
|
||||
request.kind = ui::TransferMarketRequestKind::review_offers;
|
||||
request.manager_slot = manager; request.runtime_club = session.state().manager_teams[manager];
|
||||
request.revision = revision; request.bid.manager = manager; request.bid.list_entry = entry;
|
||||
request.bid.source_slot = 0xb70 + entry; request.bid.player = player;
|
||||
std::string error; int presentations = 0;
|
||||
auto choose = [&](const GameState& state, const TransferOfferListView& offers) {
|
||||
++presentations; ui::IncomingTransferScreen screen(data, panel(state, offers));
|
||||
require(screen.render().width == 320, "actual incoming modal renders natural offer rows");
|
||||
const auto selected = screen.click(10, 150 + chosen * 17);
|
||||
require(selected && *selected == chosen, "actual incoming row input returns its raw bidder identity");
|
||||
return *selected;
|
||||
};
|
||||
auto cancel = [&](const GameState& state, const TransferOfferListView& offers) {
|
||||
ui::IncomingTransferScreen screen(data, panel(state, offers));
|
||||
const auto answer = screen.click(200, 100, true);
|
||||
require(answer && *answer == -1, "actual incoming modal right click cancels early review"); return *answer;
|
||||
};
|
||||
const auto canceled = app::TransferActions(session).market(request, {}, revision, error,
|
||||
app::HumanBuyerMarketEntryPolicy::normal_interactive, {}, cancel);
|
||||
if (!canceled) std::fprintf(stderr, "early cancel rejected: %s\n", error.c_str());
|
||||
require(canceled && !canceled->changed && before.same(session, revision), "early cancel preserves complete state and both RNGs");
|
||||
for (int malformed = 0; malformed < 3; ++malformed) {
|
||||
auto stale = request;
|
||||
if (malformed == 0) ++stale.bid.player;
|
||||
if (malformed == 1) --stale.revision;
|
||||
if (malformed == 2) ++stale.bid.source_slot;
|
||||
require(!app::TransferActions(session).market(stale, {}, revision, error,
|
||||
app::HumanBuyerMarketEntryPolicy::normal_interactive, {}, choose) &&
|
||||
before.same(session, revision) && presentations == 0, "stale review rejects before presenter and mutation");
|
||||
}
|
||||
bool rolled_back = false;
|
||||
try {
|
||||
(void)app::TransferActions(session).market(request, {}, revision, error,
|
||||
app::HumanBuyerMarketEntryPolicy::normal_interactive,
|
||||
[](const app::TransferActions::MarketDispatch&) { throw std::runtime_error("interrupted acknowledgement"); }, choose);
|
||||
} catch (const std::runtime_error&) { rolled_back = true; }
|
||||
require(rolled_back && before.same(session, revision), "interrupted acknowledgement rolls back seller transfer and RNG");
|
||||
const auto accepted = app::TransferActions(session).market(request, {}, revision, error,
|
||||
app::HumanBuyerMarketEntryPolicy::normal_interactive, {}, choose);
|
||||
require(accepted && accepted->changed && accepted->action.status == TransferActionStatus::accepted &&
|
||||
revision == before.revision + 1 && (session.state().squad_slots.at(size_t(0xb70 + entry)) & 0xfff) == 0xfff,
|
||||
"qualified natural offer settles exactly once through shared session transaction");
|
||||
const Snapshot settled(session, revision);
|
||||
require(!app::TransferActions(session).market(request, {}, revision, error,
|
||||
app::HumanBuyerMarketEntryPolicy::normal_interactive, {}, choose) && settled.same(session, revision),
|
||||
"replaying accepted seller request is inert");
|
||||
std::printf("PASS natural seller offer: player=%d entry=%d raw_bid=%d; real modal cancel/accept, stale guards, acknowledgement rollback\n", player, entry, chosen);
|
||||
return 0;
|
||||
} catch (const std::exception& error) { std::fprintf(stderr, "%s\n", error.what()); return 1; }
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/messages.hpp"
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh;
|
||||
namespace { void check(bool ok,const char* why){if(!ok)throw std::runtime_error(why);} }
|
||||
int main()try {
|
||||
GameState state;state.currency_suffix=" EU";
|
||||
state.memory.add_block(layout::CurrencyMultiplier,8);
|
||||
state.memory.set32(layout::CurrencyMultiplier,1);state.memory.set32(layout::CurrencyDivisor,1);
|
||||
for(int32_t amount:{-1000000,-1,0,1,1234567})
|
||||
for(int flags:{0,1,8,0x44,0x82,0x101,0x108,0x188})
|
||||
check(format_number_wide(state,amount,flags)==format_number(state,amount,flags),
|
||||
"wide display changed ordinary grouping, padding or currency");
|
||||
check(format_number_wide(state,6300000000LL,0x101)=="6.300.000.000 EU","large positive aggregate wrapped");
|
||||
check(format_number_wide(state,-6300000000LL,0x101)=="-6.300.000.000 EU","large negative aggregate lost its sign");
|
||||
state.memory.set32(layout::CurrencyMultiplier,2);state.memory.set32(layout::CurrencyDivisor,3);
|
||||
check(format_number_wide(state,6300000000LL,0x101)=="4.200.000.000 EU","wide totals changed currency units");
|
||||
check(format_number_wide(state,-5,0x101)=="-3 EU","currency division stopped truncating toward zero");
|
||||
state.memory.set32(layout::CurrencyMultiplier,2);state.memory.set32(layout::CurrencyDivisor,2);
|
||||
check(format_number_wide(state,std::numeric_limits<int64_t>::max(),0x101)=="9.223.372.036.854.775.807 EU",
|
||||
"representable currency conversion overflowed its intermediate product");
|
||||
check(format_number_wide(state,std::numeric_limits<int64_t>::min(),0x101)=="-9.223.372.036.854.775.808 EU",
|
||||
"minimum signed display amount overflowed while taking its magnitude");
|
||||
state.currency_suffix=" &";
|
||||
check(format_number_wide(state,3000000000LL,0x101)=="& 3.000.000.000","English currency prefix changed");
|
||||
state.memory.set32(layout::CurrencyDivisor,1);
|
||||
bool rejected=false;
|
||||
try{(void)format_number_wide(state,std::numeric_limits<int64_t>::max(),0x101);}catch(const FormatError&){rejected=true;}
|
||||
check(rejected,"unrepresentable currency output was silently clamped or wrapped");
|
||||
std::cout<<"Wide aggregate formatting, native parity, currency scaling and signed boundaries passed\n";
|
||||
return 0;
|
||||
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
Reference in new issue
Block a user