Compare commits
132
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7031f4ff02 | ||
|
|
9daf649563 | ||
|
|
9870d90d65 | ||
|
|
205a543b40 | ||
|
|
33566566ac | ||
|
|
81046f89f2 | ||
|
|
31ff36fb09 | ||
|
|
d552c59a77 | ||
|
|
cb6d3b6035 | ||
|
|
74d6cde914 | ||
|
|
0bcb0d2507 | ||
|
|
8a37be898a | ||
|
|
c8dee2c377 | ||
|
|
99200f1dc8 | ||
|
|
71aeb7cc61 | ||
|
|
2173915d20 | ||
|
|
ff32ef1dbc | ||
|
|
b7f748688c | ||
|
|
16b9b24c84 | ||
|
|
e174f99594 | ||
|
|
3ceb431aa4 | ||
|
|
a503fff55f | ||
|
|
fb3c2fe757 | ||
|
|
901f3dec1c | ||
|
|
d9d408069e | ||
|
|
1ddce1dcc8 | ||
|
|
748eb4df01 | ||
|
|
4c099a93b3 | ||
|
|
a426b209bf | ||
|
|
bd3f11216a | ||
|
|
6e4c6f17c8 | ||
|
|
68f56f3d51 | ||
|
|
e65bd27375 | ||
|
|
09fcd8383f | ||
|
|
cafd6c1573 | ||
|
|
5b845fbab3 | ||
|
|
23201fa637 | ||
|
|
551d564efb | ||
|
|
b6bc17a381 | ||
|
|
fb72de3895 | ||
|
|
f1f5fa523c | ||
|
|
32b08e3799 | ||
|
|
20f5e4eb28 | ||
|
|
9e593f921f | ||
|
|
524b9e4158 | ||
|
|
6aa7c4f4a2 | ||
|
|
adcaa9b569 | ||
|
|
000ee20238 | ||
|
|
d2c5fade43 | ||
|
|
e01ac929ac | ||
|
|
9286428a5a | ||
|
|
fbb2ab66b0 | ||
|
|
65df52ae2c | ||
|
|
0a95dbcba6 | ||
|
|
933567232e | ||
|
|
b2484350d9 | ||
|
|
ff4ad035a7 | ||
|
|
e9ba514a65 | ||
|
|
93ca832c71 | ||
|
|
09b92c9b2a | ||
|
|
78118a6333 | ||
|
|
73ffd23dcb | ||
|
|
96d52202fc | ||
|
|
f63c0217ef | ||
|
|
73af2a657d | ||
|
|
e088704dff | ||
|
|
287b5a9251 | ||
|
|
aa6ec96305 | ||
|
|
e337c3c6b2 | ||
|
|
6cccbb01d3 | ||
|
|
8780d7b5a5 | ||
|
|
a279bfb6df | ||
|
|
0535764834 | ||
|
|
2f5303d9bd | ||
|
|
7cc7c3a7ea | ||
|
|
f33b381f18 | ||
|
|
39de3dc9d4 | ||
|
|
fcd6eb9204 | ||
|
|
16ae7df7f8 | ||
|
|
b8a37353cc | ||
|
|
7cfc8267b6 | ||
|
|
f12857414e | ||
|
|
81ae6ad236 | ||
|
|
38f69fa37b | ||
|
|
1e7df751a0 | ||
|
|
af634ae8ff | ||
|
|
04ff3b7656 | ||
|
|
f7d20dad9e | ||
|
|
d661ec5eb0 | ||
|
|
048f617395 | ||
|
|
249bdca1a8 | ||
|
|
b8904db92d | ||
|
|
9ec136a09f | ||
|
|
a275ffa1a9 | ||
|
|
fcb6ac14bb | ||
|
|
acdc7d5c14 | ||
|
|
0faad16148 | ||
|
|
f44de65e22 | ||
|
|
bea5478433 | ||
|
|
2d744e380c | ||
|
|
9140fb4b03 | ||
|
|
02f47f7972 | ||
|
|
564af00d8d | ||
|
|
e8ba78e135 | ||
|
|
fcbe1ebc13 | ||
|
|
8b1dc16233 | ||
|
|
9c10a2bfeb | ||
|
|
6f33f9c155 | ||
|
|
9c82cb16b5 | ||
|
|
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
@@ -1,2 +1,3 @@
|
||||
* text=auto eol=lf
|
||||
*.bat text eol=crlf
|
||||
third_party/** -text
|
||||
@@ -3,7 +3,7 @@ name: Build without game data
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, release/1.0, poc/1.1-international]
|
||||
branches: [main, release/1.0]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
@@ -43,7 +43,6 @@ jobs:
|
||||
python3 tools/public_release/check_public_tree.py --root .
|
||||
python3 tools/ci/test_build_runnable_tests.py
|
||||
python3 tools/package/test_verify_ci_release.py
|
||||
python3 -m unittest discover -s tools/poc -p "test_*.py"
|
||||
- name: Set up MSVC x64
|
||||
if: runner.os == 'Windows'
|
||||
uses: ilammy/msvc-dev-cmd@a102174a2b586eec2ea151a69e6fd14404a8ce7c # v1.13.0
|
||||
|
||||
@@ -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.13/RELEASE_NOTES.md
|
||||
+152
-34
@@ -1,11 +1,11 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 1.1.0 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 1.0.13 LANGUAGES CXX C)
|
||||
if(APPLE)
|
||||
# Enable native languages before dependencies/subdirectories inherit rules.
|
||||
enable_language(OBJC OBJCXX)
|
||||
endif()
|
||||
set(OPENBMH_PRERELEASE "poc.1" CACHE STRING "Prerelease identifier; empty for final release")
|
||||
set(OPENBMH_PRERELEASE "" CACHE STRING "Prerelease identifier; empty for final release")
|
||||
set(OPENBMH_PRODUCT_VERSION "${PROJECT_VERSION}")
|
||||
if(OPENBMH_PRERELEASE)
|
||||
string(APPEND OPENBMH_PRODUCT_VERSION "-${OPENBMH_PRERELEASE}")
|
||||
@@ -126,24 +126,38 @@ if(TARGET SDL2::SDL2main)
|
||||
list(PREPEND BMH_SDL_TARGET SDL2::SDL2main)
|
||||
endif()
|
||||
|
||||
# App sources share objects only within identical compile environments.
|
||||
# MSVC consumers currently differ in target/source /utf-8 flags; keep that path.
|
||||
set(BMH_APP_SESSION_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src/app/career_session.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/app/window_actions.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/app/desktop_actions.cpp")
|
||||
set(BMH_APP_SESSION_SDL_SOURCE "${BMH_APP_SESSION_SOURCE}")
|
||||
set(BMH_APP_CONTROLLER_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src/app/controller.cpp")
|
||||
if(NOT MSVC)
|
||||
add_library(bmh_app_session OBJECT src/app/career_session.cpp src/app/window_actions.cpp src/app/desktop_actions.cpp)
|
||||
target_link_libraries(bmh_app_session PRIVATE bmhui)
|
||||
add_library(bmh_app_session_sdl OBJECT src/app/career_session.cpp src/app/window_actions.cpp src/app/desktop_actions.cpp)
|
||||
target_link_libraries(bmh_app_session_sdl PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
add_library(bmh_app_controller_sdl OBJECT src/app/controller.cpp)
|
||||
target_link_libraries(bmh_app_controller_sdl PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
set(BMH_APP_SESSION_SOURCE "$<TARGET_OBJECTS:bmh_app_session>")
|
||||
set(BMH_APP_SESSION_SDL_SOURCE "$<TARGET_OBJECTS:bmh_app_session_sdl>")
|
||||
set(BMH_APP_CONTROLLER_SOURCE "$<TARGET_OBJECTS:bmh_app_controller_sdl>")
|
||||
# The app sources (career session, window/desktop actions, controller) are compiled once per
|
||||
# compile environment and shared as objects by the game and by about forty tests and tools.
|
||||
# On MSVC they are compiled with /utf-8 like the game itself: their German messages are UTF-8
|
||||
# string literals. (Until 1.0.12 the MSVC build compiled these sources again for every
|
||||
# consumer, which cost most of the build time; controller.cpp then got /utf-8 only from
|
||||
# targets that set it.)
|
||||
# The career session is defined by topic in career_session*.cpp (the class: src/app/career_session.hpp).
|
||||
set(BMH_APP_SESSION_SOURCES
|
||||
src/app/career_session.cpp
|
||||
src/app/career_session_club.cpp
|
||||
src/app/career_session_league.cpp
|
||||
src/app/career_session_statistics.cpp
|
||||
src/app/career_session_transfer.cpp
|
||||
src/app/career_session_desk.cpp
|
||||
src/app/career_session_match.cpp
|
||||
src/app/career_session_management.cpp
|
||||
src/app/window_actions.cpp
|
||||
src/app/desktop_actions.cpp)
|
||||
add_library(bmh_app_session OBJECT ${BMH_APP_SESSION_SOURCES})
|
||||
target_link_libraries(bmh_app_session PRIVATE bmhui)
|
||||
add_library(bmh_app_session_sdl OBJECT ${BMH_APP_SESSION_SOURCES})
|
||||
target_link_libraries(bmh_app_session_sdl PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
add_library(bmh_app_controller_sdl OBJECT src/app/controller.cpp)
|
||||
target_link_libraries(bmh_app_controller_sdl PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
if(MSVC)
|
||||
target_compile_options(bmh_app_session PRIVATE /utf-8)
|
||||
target_compile_options(bmh_app_session_sdl PRIVATE /utf-8)
|
||||
target_compile_options(bmh_app_controller_sdl PRIVATE /utf-8)
|
||||
endif()
|
||||
set(BMH_APP_SESSION_SOURCE "$<TARGET_OBJECTS:bmh_app_session>")
|
||||
set(BMH_APP_SESSION_SDL_SOURCE "$<TARGET_OBJECTS:bmh_app_session_sdl>")
|
||||
set(BMH_APP_CONTROLLER_SOURCE "$<TARGET_OBJECTS:bmh_app_controller_sdl>")
|
||||
|
||||
# (before the first subdirectory: tests added there are only registered once testing is on)
|
||||
enable_testing()
|
||||
@@ -211,16 +225,16 @@ add_library(bmhcore STATIC
|
||||
src/formats/vga.cpp
|
||||
src/formats/font.cpp
|
||||
src/formats/textd.cpp
|
||||
src/formats/text_encoding.cpp
|
||||
src/formats/fbm.cpp
|
||||
src/formats/le.cpp
|
||||
src/formats/data_profile.cpp
|
||||
src/formats/diamond_image.cpp
|
||||
src/formats/m3d.cpp
|
||||
src/formats/savestate.cpp
|
||||
src/game/schedule.cpp
|
||||
src/game/league_pairings.cpp
|
||||
src/game/source_tip.cpp
|
||||
src/game/table_forecast.cpp
|
||||
src/game/profile_runtime.cpp
|
||||
src/game/state.cpp
|
||||
src/game/rating.cpp
|
||||
src/game/match.cpp
|
||||
@@ -234,6 +248,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
|
||||
@@ -241,6 +256,7 @@ add_library(bmhcore STATIC
|
||||
src/game/matchday_setup.cpp
|
||||
src/game/prediction.cpp
|
||||
src/game/month.cpp
|
||||
src/game/search_profile.cpp
|
||||
src/game/desk.cpp
|
||||
src/game/cup.cpp
|
||||
src/game/club_info.cpp
|
||||
@@ -266,6 +282,8 @@ add_library(bmhcore STATIC
|
||||
src/game/bank_credit.cpp
|
||||
src/game/career.cpp
|
||||
src/game/save.cpp
|
||||
src/game/digest.cpp
|
||||
src/game/world_layout.cpp
|
||||
src/game/turn.cpp
|
||||
src/game/turn_driver.cpp
|
||||
)
|
||||
@@ -277,19 +295,20 @@ else()
|
||||
target_compile_options(bmhcore PRIVATE -Wall -Wextra)
|
||||
endif()
|
||||
|
||||
# The asset viewer of the first milestone (not the game). Its file is named openbmh_viewer: as
|
||||
# "openbmh" it would be the same file as the game (OpenBMH, target openbmh_play below) on a file
|
||||
# system that ignores case, and whichever of the two was linked last would win.
|
||||
add_executable(openbmh src/main.cpp)
|
||||
set_target_properties(openbmh PROPERTIES OUTPUT_NAME openbmh_viewer)
|
||||
target_link_libraries(openbmh PRIVATE bmhcore ${BMH_SDL_TARGET})
|
||||
if(MSVC)
|
||||
target_compile_options(openbmh PRIVATE /utf-8)
|
||||
endif()
|
||||
|
||||
# --- Game data launcher (src/launch): find, unpack and check the original game data ---------
|
||||
# ZIP: miniz (MIT), 7z: the C decoder of the LZMA SDK (public domain), file dialog:
|
||||
# ZIP: miniz 3.0.2 (MIT, vendored in third_party/miniz), 7z: the C decoder of the LZMA SDK (public domain), file dialog:
|
||||
# nativefiledialog-extended (zlib). All pinned; fetched like SDL2.
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(miniz
|
||||
URL https://github.com/richgel999/miniz/releases/download/3.0.2/miniz-3.0.2.zip
|
||||
URL_HASH SHA256=ada38db0b703a56d3dd6d57bf84a9c5d664921d870d8fea4db153979fb5332c5)
|
||||
FetchContent_Declare(lzma_sdk
|
||||
GIT_REPOSITORY https://github.com/ip7z/7zip.git
|
||||
GIT_TAG 24.09
|
||||
@@ -301,8 +320,9 @@ FetchContent_Declare(nfd
|
||||
GIT_REPOSITORY https://github.com/btzy/nativefiledialog-extended.git
|
||||
GIT_TAG v1.2.1
|
||||
GIT_SHALLOW TRUE)
|
||||
FetchContent_MakeAvailable(miniz lzma_sdk nfd)
|
||||
FetchContent_MakeAvailable(lzma_sdk nfd)
|
||||
|
||||
set(miniz_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/miniz") # vendored: no download that can fail
|
||||
add_library(bmh_miniz STATIC ${miniz_SOURCE_DIR}/miniz.c)
|
||||
target_include_directories(bmh_miniz PUBLIC ${miniz_SOURCE_DIR})
|
||||
set(BMH_LZMA_C ${lzma_sdk_SOURCE_DIR}/C)
|
||||
@@ -342,6 +362,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)
|
||||
@@ -446,21 +470,45 @@ target_link_libraries(desk_check PRIVATE bmhcore)
|
||||
add_executable(init_check tests/init_check.cpp)
|
||||
target_link_libraries(init_check PRIVATE bmhcore)
|
||||
|
||||
# The approved compressed title is embedded: no install-time sidecar dependency.
|
||||
set(BMH_START_SCREEN_DATA "${CMAKE_BINARY_DIR}/generated/start_screen_data.cpp")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/generated")
|
||||
add_custom_command(OUTPUT "${BMH_START_SCREEN_DATA}"
|
||||
COMMAND "${CMAKE_COMMAND}" "-DINPUT=${CMAKE_SOURCE_DIR}/assets/start-screen.jpg"
|
||||
"-DOUTPUT=${BMH_START_SCREEN_DATA}" -P "${CMAKE_SOURCE_DIR}/cmake/EmbedStartScreen.cmake"
|
||||
DEPENDS assets/start-screen.jpg cmake/EmbedStartScreen.cmake
|
||||
VERBATIM)
|
||||
add_library(openbmh_start_screen STATIC src/app/start_screen.cpp "${BMH_START_SCREEN_DATA}")
|
||||
target_include_directories(openbmh_start_screen PRIVATE "${CMAKE_SOURCE_DIR}/src")
|
||||
target_link_libraries(openbmh_start_screen PUBLIC ${BMH_SDL_TARGET})
|
||||
add_executable(start_screen_tests tests/start_screen_tests.cpp)
|
||||
target_include_directories(start_screen_tests PRIVATE "${CMAKE_SOURCE_DIR}/src")
|
||||
target_link_libraries(start_screen_tests PRIVATE openbmh_start_screen)
|
||||
add_test(NAME start_screen_tests COMMAND start_screen_tests)
|
||||
|
||||
# The playable program: the shared UI library connected to the engine by src/app.
|
||||
# The game program: main() sets up data, window and sound; struct App (src/app/app.hpp) is the running
|
||||
# program, its member functions are defined by topic in the app_*.cpp files.
|
||||
add_executable(openbmh_play
|
||||
src/app/main.cpp
|
||||
src/app/app_run.cpp
|
||||
src/app/app_services.cpp
|
||||
src/app/app_season.cpp
|
||||
src/app/app_sportschau.cpp
|
||||
src/app/app_transfer.cpp
|
||||
src/app/app_club.cpp
|
||||
src/app/app_notices.cpp
|
||||
src/app/app_live.cpp
|
||||
${BMH_APP_CONTROLLER_SOURCE}
|
||||
${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(openbmh_play PRIVATE bmhui bmhlaunch_dialog openbmh_audio ${BMH_SDL_TARGET})
|
||||
target_link_libraries(openbmh_play PRIVATE openbmh_start_screen)
|
||||
# a game without a console window on double-click (SDL2main provides WinMain); started from a
|
||||
# console it attaches to that one for --version, --help and start errors (src/app/main.cpp)
|
||||
set_target_properties(openbmh_play PROPERTIES WIN32_EXECUTABLE TRUE OUTPUT_NAME OpenBMH)
|
||||
target_include_directories(openbmh_play PRIVATE "${CMAKE_BINARY_DIR}/generated")
|
||||
if(MSVC)
|
||||
target_compile_options(openbmh_play PRIVATE /utf-8)
|
||||
# App sources also compile in headless tests/helpers without target /utf-8.
|
||||
set_source_files_properties(src/app/career_session.cpp src/app/window_actions.cpp
|
||||
src/app/desktop_actions.cpp PROPERTIES COMPILE_OPTIONS /utf-8)
|
||||
endif()
|
||||
|
||||
# Development helper: drives the career session like the UI, without a window
|
||||
@@ -493,7 +541,17 @@ if(MSVC)
|
||||
target_compile_options(app_controller_tests PRIVATE /utf-8)
|
||||
endif()
|
||||
bmh_add_data_test(NAME app_controller_tests COMMAND app_controller_tests "${BMH_DATA}")
|
||||
|
||||
# Regression tool (not a test): replays an input script against the UI flow and the controller without a
|
||||
# window and writes picture/state fingerprints per step (see tests/ui_walk.cpp).
|
||||
add_executable(ui_walk tests/ui_walk.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(ui_walk PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
if(MSVC)
|
||||
target_compile_options(ui_walk PRIVATE /utf-8)
|
||||
endif()
|
||||
set(BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 "" CACHE PATH "External input 1 for app_delay_settings_tests; not distributed")
|
||||
bmh_add_data_test(NAME app_desktop_input_tests COMMAND app_controller_tests "${BMH_DATA}" --desktop-input-only)
|
||||
bmh_add_data_test(NAME app_advertising_input_tests COMMAND app_controller_tests "${BMH_DATA}" --advertising-input-only)
|
||||
bmh_add_data_test(NAME app_environment_tests COMMAND app_controller_tests "${BMH_DATA}" --environment-only)
|
||||
bmh_add_data_test(NAME app_delay_settings_tests REQUIRED_OPTIONS BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 COMMAND app_controller_tests "${BMH_DATA}"
|
||||
--delay-settings-only "${BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1}")
|
||||
@@ -514,6 +572,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)
|
||||
@@ -938,6 +1000,8 @@ bmh_add_data_test(NAME league_views_data_tests COMMAND league_views_data_tests "
|
||||
# FLTD is translated by launch_check/the launcher first. Do not point these
|
||||
# tests at the raw DOS directory: the shared UI consumes the prepared image.
|
||||
set(BMH_ENGLISH_DATA "" CACHE PATH "Prepared Football Limited game-data directory")
|
||||
bmh_add_data_test(NAME english_environment_controller_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND app_controller_tests "${BMH_ENGLISH_DATA}" --environment-only)
|
||||
bmh_add_data_test(NAME english_edition_startup_app_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND edition_startup_app_tests "${BMH_ENGLISH_DATA}")
|
||||
bmh_add_data_test(NAME english_pairings_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_pairings_data_tests "${BMH_ENGLISH_DATA}")
|
||||
bmh_add_data_test(NAME english_desktop_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND desktop_data_tests "${BMH_ENGLISH_DATA}" --english)
|
||||
bmh_add_data_test(NAME english_league_views_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_views_data_tests "${BMH_ENGLISH_DATA}")
|
||||
@@ -1059,9 +1123,16 @@ set(BMH_TEST_SPORTSCHAU_APP_TESTS_INPUT_1 "" CACHE PATH "External input 1 for sp
|
||||
bmh_add_data_test(NAME sportschau_app_tests REQUIRED_OPTIONS BMH_TEST_SPORTSCHAU_APP_TESTS_INPUT_1 COMMAND sportschau_app_tests "${BMH_DATA}"
|
||||
"${BMH_TEST_SPORTSCHAU_APP_TESTS_INPUT_1}")
|
||||
|
||||
# The runtime component deliberately contains only the two products and notices.
|
||||
# openbmh.dat (the game texts of the original executables, tools/diamond_constants) ships next to the programs and is copied
|
||||
# next to the built programs as well, where the game looks for it.
|
||||
foreach(product IN ITEMS openbmh_play openbmh_cli)
|
||||
add_custom_command(TARGET ${product} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/data/openbmh.dat" "$<TARGET_FILE_DIR:${product}>")
|
||||
endforeach()
|
||||
|
||||
# The runtime component deliberately contains only the two products, openbmh.dat and notices.
|
||||
install(TARGETS openbmh_play openbmh_cli RUNTIME DESTINATION . COMPONENT Runtime)
|
||||
install(FILES README.md LICENSE THIRD_PARTY_NOTICES.md ACKNOWLEDGEMENTS.md CONTRIBUTING.md
|
||||
install(FILES README.md LICENSE THIRD_PARTY_NOTICES.md ACKNOWLEDGEMENTS.md CONTRIBUTING.md data/openbmh.dat
|
||||
DESTINATION . COMPONENT Runtime)
|
||||
install(DIRECTORY docs/ DESTINATION docs COMPONENT Runtime)
|
||||
if(MSVC)
|
||||
@@ -1122,10 +1193,18 @@ foreach(dependency IN ITEMS SDL2 miniz lzma_sdk nfd)
|
||||
endforeach()
|
||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/package-dependencies.json" CONTENT "${package_dependencies}\n")
|
||||
|
||||
add_executable(environment_profile_tests tests/environment_profile_tests.cpp)
|
||||
target_link_libraries(environment_profile_tests PRIVATE bmhcore)
|
||||
add_test(NAME environment_profile_tests COMMAND environment_profile_tests)
|
||||
add_executable(classic_rules_unit_tests tests/classic_rules_unit_tests.cpp)
|
||||
target_link_libraries(classic_rules_unit_tests PRIVATE bmhcore)
|
||||
add_test(NAME classic_rules_unit_tests COMMAND classic_rules_unit_tests)
|
||||
|
||||
# The Classic world layout equals the numbers the engine used as literals (no game data needed).
|
||||
add_executable(world_layout_tests tests/world_layout_tests.cpp)
|
||||
target_link_libraries(world_layout_tests PRIVATE bmhcore)
|
||||
add_test(NAME world_layout_tests COMMAND world_layout_tests)
|
||||
|
||||
add_executable(season_player_reset_tests tests/season_player_reset_tests.cpp)
|
||||
target_link_libraries(season_player_reset_tests PRIVATE bmhcore)
|
||||
add_test(NAME season_player_reset_tests COMMAND season_player_reset_tests)
|
||||
@@ -1155,6 +1234,45 @@ 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(data_profile_tests tests/data_profile_tests.cpp)
|
||||
target_link_libraries(data_profile_tests PRIVATE bmhcore)
|
||||
add_test(NAME data_profile_tests COMMAND data_profile_tests)
|
||||
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(diamond_image_tests tests/diamond_image_tests.cpp)
|
||||
target_link_libraries(diamond_image_tests PRIVATE bmhcore)
|
||||
add_test(NAME diamond_image_tests COMMAND diamond_image_tests - "${CMAKE_CURRENT_SOURCE_DIR}/data/openbmh.dat")
|
||||
bmh_add_data_test(NAME diamond_image_data_tests COMMAND diamond_image_tests "${BMH_DATA}" "${CMAKE_CURRENT_SOURCE_DIR}/data/openbmh.dat")
|
||||
add_executable(search_profile_tests tests/search_profile_tests.cpp)
|
||||
target_link_libraries(search_profile_tests PRIVATE bmhcore)
|
||||
add_test(NAME search_profile_tests COMMAND search_profile_tests)
|
||||
|
||||
add_executable(transfer_seller_app_tests tests/transfer_seller_app_tests.cpp ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(transfer_seller_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
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,8 +1,13 @@
|
||||
# OpenBMH
|
||||
|
||||
**Classic-Version: 1.0.13.** Die originalgetreue Linie bleibt in diesem Repository.
|
||||
Erweiterte Ligen, die gemeinsame deutsche/englische Karriere und der Dateneditor
|
||||
werden separat als **[OpenBMH-Extended 1.0 Beta](https://github.com/Weyoune/OpenBMH-extended)** entwickelt.
|
||||
|
||||
|
||||
A faithful, standalone community reconstruction of *Bundesliga Manager Hattrick*, using the player's original installation and SDL2 interface.
|
||||
|
||||
OpenBMH 1.0 builds on v0.1.2 with reviewed bug fixes and starts directly with the original game data. Original game files, graphics, audio and manuals are not distributed. German CD-compatible BMH and verified Diamond editions are the primary release targets. Football Limited remains experimental; the older floppy executable is not supported.
|
||||
OpenBMH 1.0 builds on v0.1.2 with reviewed bug fixes and starts directly with the original game data. Original game files, graphics, audio, texts and manuals are not distributed. German CD-compatible BMH and verified Diamond editions are the primary release targets. Football Limited remains experimental; the older floppy executable is not supported.
|
||||
|
||||
This is an independent community project, with no affiliation with or endorsement by the original rights holders, the DFL or the Bundesliga. It is an engine implementation, not an official source release or a remaster.
|
||||
|
||||
@@ -10,9 +15,9 @@ This is an independent community project, with no affiliation with or endorsemen
|
||||
|
||||
Check the [releases page](https://github.com/Weyoune/openbmh/releases) for available packages and their platform notes. A Windows package uses the name `OpenBMH-<version>-windows-x64.zip`. Availability and native validation are stated for each release; source build instructions do not establish platform support on their own.
|
||||
|
||||
1. Have your own supported game installation available.
|
||||
1. Have your own supported game installation available. OpenBMH needs its asset files (texts, master database, pictures, fonts, sounds) and **either** `BMH.EXE` (`FLTD.EXE` for the English game) **or** `openbmh.dat`, which ships next to the programs in the release package and holds the game texts of the original executables; the numbers of those executables are built into OpenBMH. If both are there, the executable is used. If neither is there, OpenBMH asks for the game directory or for `BMH.EXE`.
|
||||
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
|
||||
3. Start `OpenBMH` (`OpenBMH.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
3. Start `OpenBMH` (`OpenBMH.exe` on Windows). Select the game directory (or `BMH.EXE`) when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
|
||||
From a terminal in the extracted package on Linux or macOS:
|
||||
|
||||
@@ -23,7 +28,9 @@ From a terminal in the extracted package on Linux or macOS:
|
||||
|
||||
In Windows PowerShell, use `.\OpenBMH.exe` and `.\openbmh_cli.exe` instead.
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0/RELEASE_NOTES.md).
|
||||
To report a problem, start the game with `-debug`. It then writes `openbmh-debug.log` (timestamped events, errors and refused actions) and `openbmh-stderr.log` into the `debug` sub folder of the save directory, and saves the game there after every match day (`DBG00001.FBM`, `DBG00002.FBM`, ...). Attach the log and the last save to the report.
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0.13/RELEASE_NOTES.md).
|
||||
|
||||
## Features and direction
|
||||
|
||||
@@ -97,7 +104,7 @@ Reports with reproducible steps, documentation corrections and focused patches a
|
||||
|
||||
## How the project was developed
|
||||
|
||||
The implementation grew from study of file formats and behaviour of a legally obtained game installation. The public repository contains independently written implementation and format documentation. It does not contain the proprietary implementation or its extracted resources.
|
||||
The implementation grew from study of file formats and behaviour of a legally obtained game installation. The public repository contains independently written implementation and format documentation. It also contains the numeric tables and constants of the Diamond edition 3.7 executable (rates, positions, prices; `src/formats/diamond_constants.inc`, generated by `tools/diamond_constants`) so that the game runs from its asset files alone. It does not contain the executable's program code or any original game text, graphics, audio or master data.
|
||||
|
||||
## License and thanks
|
||||
|
||||
@@ -106,3 +113,5 @@ OpenBMH's own code and documentation are licensed under **GNU GPL version 3 only
|
||||
Every published binary release identifies its matching source tag and provides a corresponding source archive. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
|
||||
|
||||
Bundled components retain their own licenses, including Nuked OPL3 under LGPL-2.1-or-later. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and [ACKNOWLEDGEMENTS.md](ACKNOWLEDGEMENTS.md).
|
||||
|
||||
The supplied project start artwork is embedded at native resolution; see [start-screen artwork](docs/START_SCREEN.md). It replaces the original title image while the game continues to use your own original data and assets.
|
||||
@@ -4,6 +4,7 @@ OpenBMH's own code and documentation use GPL-3.0-only. This does not replace the
|
||||
|
||||
| Component | Version used by the build | License | Included notice |
|
||||
|---|---|---|---|
|
||||
| [stb_image](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h) | 2.30, vendored header; JPEG decoder only | MIT or public-domain alternative | [stb_image.txt](docs/licenses/stb_image.txt) |
|
||||
| [SDL2](https://github.com/libsdl-org/SDL/tree/release-2.32.10) | 2.32.10, or an explicitly selected system SDL2 | zlib license | [SDL2.txt](docs/licenses/SDL2.txt) |
|
||||
| SDL2 HIDAPI code | Included with SDL2 | BSD-3-Clause option; upstream also offers GPL-3.0 and its original license | [license options](docs/licenses/SDL2-HIDAPI-options.txt), [BSD text](docs/licenses/SDL2-HIDAPI-BSD.txt), [original text](docs/licenses/SDL2-HIDAPI-original.txt) |
|
||||
| SDL2 yuv2rgb code | Included with SDL2 | BSD-3-Clause | [SDL2-yuv2rgb.txt](docs/licenses/SDL2-yuv2rgb.txt) |
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# OpenBMH Classic start artwork
|
||||
|
||||
The project maintainer supplied this new start-screen artwork for use and
|
||||
repository distribution with this application. It is not extracted game content.
|
||||
The repository license applies to project artwork; original game assets remain
|
||||
external. The unmodified upstream decoder has its separate documented license.
|
||||
|
||||
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
|
||||
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
|
||||
without EXIF or other input metadata. It occupies 587,410 bytes.
|
||||
The application embeds it at build time and decodes it once at startup, so
|
||||
installed applications need no image sidecar or original title-screen VGA.
|
||||
|
||||
The SDL renderer uses the actual image dimensions while showing the title,
|
||||
including high-DPI output and aspect-preserving side bars, then restores the
|
||||
320 × 240 game/input canvas. A complete left or right mouse click continues;
|
||||
there is no loading-ball animation. Changing the artwork also requires an
|
||||
explicit review/update of its SHA256 in the public-source guard.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 574 KiB |
@@ -0,0 +1,4 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
file(READ "${INPUT}" artwork HEX)
|
||||
string(REGEX REPLACE "(..)" "0x\\1," artwork "${artwork}")
|
||||
file(WRITE "${OUTPUT}" "// Generated from the repository-owned compressed start screen.\n#include \"app/start_screen_data.hpp\"\nnamespace bmh::app {\nconst unsigned char start_screen_jpeg[] = {${artwork}};\nconst std::size_t start_screen_jpeg_size=sizeof(start_screen_jpeg);\n}\n")
|
||||
Binary file not shown.
@@ -139,12 +139,16 @@ 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 |
|
||||
| `HirePlayer` | player:Player, months:int(12\|24) | VER-LEIHEN on a market player: the loan offer |
|
||||
| `OpenOffers` | player:Player | Open Offers. See current Help for behaviour and bounds. |
|
||||
| `OpenSearch` | – | Open Search. See current Help for behaviour and bounds. |
|
||||
| `ShowSearchProfile` | – | SUCHEN: your search profile as 18 values (positions, age, strength, attributes, sides, price classes) |
|
||||
| `SuggestSearchProfile` | [whole:bool], [apply:bool] | VORSCHLAG: the profile your squad asks for; `apply` stores it and lists the matching players |
|
||||
| `SetSearchProfile` | values:[18 numbers], [apply:bool] | SUCHEN: store the profile; all values 0 or all 1 count as no search; `apply` lists the players on the transfer list that fit (the original's "Spieler ... ist interessant!" boxes) |
|
||||
| `OpenPoach` | – | ABWERBEN: pick a player of another club (Transfer.Poach) |
|
||||
| `ShowTransferNews` | [count:int] | Show Transfer News. See current Help for behaviour and bounds. |
|
||||
| `ShowTeamInfo` | – | Show Team Info. See current Help for behaviour and bounds. |
|
||||
|
||||
@@ -209,7 +209,9 @@
|
||||
"Transfer";"BuyPlayer";"player:Player";"VER-KAUFEN on a market player: the offer editor";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"HirePlayer";"player:Player, months:int(12|24)";"VER-LEIHEN on a market player: the loan offer";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Transfer";"OpenOffers";"player:Player";"Open Offers. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"OpenSearch";"–";"Open Search. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"ShowSearchProfile";"–";"SUCHEN: your search profile as 18 values";"";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"SuggestSearchProfile";"[whole:bool], [apply:bool]";"VORSCHLAG: the profile your squad asks for; apply stores it and lists the matches";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"SetSearchProfile";"values:[18 numbers], [apply:bool]";"SUCHEN: store the search profile; apply lists the matching players";"E_BAD_ARGUMENT";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"OpenPoach";"–";"ABWERBEN: pick a player of another club (Transfer.Poach)";"—";"";"";"ready";"06-verein.md"
|
||||
"Transfer";"ShowTransferNews";"[count:int]";"Show Transfer News. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"ShowTeamInfo";"–";"Show Team Info. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
|
||||
|
+136
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
OpenBMH aims to preserve the familiar game while handling malformed input and unsafe edge cases explicitly. A reconstruction can remain faithful without reproducing a crash or pretending to implement an unknown path.
|
||||
|
||||
- Content such as names, text, graphics and edition-specific tables is loaded from the user's installation. The loaded program retains its own rule-table values; loading no longer applies the former shared replacement profile.
|
||||
- Names, text, graphics and compatible data tables come from the user's installation. The common gameplay implementation follows the documented Diamond 3.7 engine policy; original programme instructions are not executed or selected as separate engines.
|
||||
- Safety checks reject transactions that would exhaust required return capacity, use stale identities or lose a valid state. Unsupported operations report their limitation rather than inventing an outcome.
|
||||
- Calendar progression handles boundary days and seasonal transitions without relying on unsafe fixed-day assumptions.
|
||||
- Saves are written from the committed session state. Saving does not deliberately replay unrelated game actions.
|
||||
@@ -23,14 +23,33 @@ An unavailable native message box also cancels the request. This applies to
|
||||
voluntary application exits, including quit events received during animations;
|
||||
normal completed-career handling remains separate.
|
||||
|
||||
## Original edition rules in 1.0
|
||||
## Common engine and source data
|
||||
|
||||
Loaded executable images retain their own rule tables. Career strength ranges are read from all nine pairs of the supplied original table.
|
||||
|
||||
The six-budget monthly environment implementation has been checked against the provided CD and Diamond 3.6/3.7 program code. Its budget increments are read from that program's own table. Capability recognition uses verified code fingerprints, never directory names. Unrecognized environment implementations cannot be edited or simulated through a guessed model; they require separate compatibility verification. Older Diamond academy patches are not silently treated as the monthly model. The old floppy executable remains unsupported, and Football Limited remains experimental.
|
||||
The common engine uses the Diamond 3.7 six-budget monthly environment model for every supported source-data edition, including Diamond 3.6 and Football Limited. Original programme instruction fingerprints do not select another engine or block compatible data. The six numeric budget increments are read from the supplied table and installed together only when all are present and nonzero; malformed layouts remain rejected. Existing saved lump-sum academy contracts retain their established accounting until edited. English translation supplies the actual English geometry, steps and suffixes for this common model. The old floppy executable remains unsupported, and Football Limited remains experimental.
|
||||
|
||||
Football Limited's data distinguishes five internal domestic slots from four
|
||||
player-visible levels. Fresh manager selection cycles those four levels and
|
||||
hides the internal fifth picker group; confirmation rejects hidden targets and
|
||||
clubs before changing options or consuming RNG. Additional club pages remain
|
||||
separate. Internal sizes, squads, rankings and fixtures are retained, and saved
|
||||
internal league values do not cause a general load rejection.
|
||||
|
||||
Release acceptance of individual editions is recorded separately from their recognition. Source compatibility and automated tests do not establish full original-game or platform validation.
|
||||
|
||||
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 +60,117 @@ 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 size: the edition's limits (extension of 1.0.3 withdrawn)
|
||||
|
||||
The stadium blocks A–H use the limits, unit prices and construction periods of
|
||||
the supplied edition unchanged. Diamond 3.6/3.7 allows 8/18/8/14 thousand places
|
||||
per block, twice, so 96,000 places in total; its 14k stands take 25 weeks, the 8k
|
||||
stands 30 and the 18k stands 37 (original data, not a mistaken timer). Contractor
|
||||
shortening remains unchanged. The UI validates quotes against the actual edition.
|
||||
|
||||
Versions 1.0.3 to 1.0.12 raised the standard maxima to 14/24/14/20 thousand
|
||||
(144,000 in total) with longer construction periods. That extension is withdrawn:
|
||||
the match broadcast of the original has no room for attendances of 100,000 and
|
||||
more and showed them wrongly. A savegame whose stadium is already larger than the
|
||||
edition's limit keeps its places (the capacity bytes are unchanged), but such a
|
||||
block cannot be extended any further.
|
||||
## 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.
|
||||
|
||||
## Host file overwrite confirmation
|
||||
|
||||
The file picker reuses the Original overwrite question and Ja/Nein button
|
||||
layout. A separate Yes click or Enter confirms; repeated double-clicks do not.
|
||||
OpenBMH deviates from the original: host file operations use the shared dialog's
|
||||
system identity because the picker does not own a live manager portrait projection.
|
||||
+13
-4
@@ -5,28 +5,37 @@ Generated from source comment markers by `tools/public_release/collect_differenc
|
||||
See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These entries
|
||||
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/app_run.cpp](../src/app/app_run.cpp): display the repository-owned title at its native resolution until a complete left/right click, without loading balls.
|
||||
- [src/app/career_session_match.cpp](../src/app/career_session_match.cpp): supports designated set-piece record initialization and validation.
|
||||
- [src/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
|
||||
- [src/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
||||
- [src/game/career.hpp](../src/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
- [src/game/desk_actions.cpp](../src/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): supports designated set-piece records and the supported transfer-editor rules.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): a seller may accept an existing bid before expiry.
|
||||
- [src/game/environment.cpp](../src/game/environment.cpp): the common Diamond 3.7 monthly environment model applies to every supported source-data edition.
|
||||
- [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image.
|
||||
- [src/game/lineup.hpp](../src/game/lineup.hpp): supports owner-bound designated set-piece selection.
|
||||
- [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules.
|
||||
- [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/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [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): 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/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/desk_state.cpp](../src/ui/desk_state.cpp): the desk shows the opponent's badge whenever the data has one.
|
||||
- [src/ui/league_pairings.cpp](../src/ui/league_pairings.cpp): the computer tip is ignored silently once a visible result is known, instead of raising an engine error.
|
||||
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
|
||||
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): omits DOS drive and delete buttons in the directory-confined save/load view.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): the host file picker uses the shared dialog's system identity without a live manager portrait projection.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): permits cancelling host file dialogs with the right mouse button.
|
||||
- [src/ui/settings.cpp](../src/ui/settings.cpp): the settings page names the product and its build version instead of the original's version text.
|
||||
@@ -0,0 +1,81 @@
|
||||
# Measurement against Diamond 3.7: matchdays, weekly processing, month change, season end
|
||||
|
||||
OpenBMH Classic follows the game and match engine of BMH 2026-27 DIAMOND Edition 3.7. Besides the routine-by-routine
|
||||
comparisons (see the 1.0.9 release notes) the engine is checked against **recordings of the real 3.7** running in an
|
||||
emulator (DOSBox-X). A recorder reads the emulator's memory without touching the game: at every match minute, at every
|
||||
change of the calendar day and at every pause it stores the random number states (game and C library generator) and all
|
||||
tables the engine reads (squads, player words, team flags, cards, managers, stock market, transfer list, mailbox, ...).
|
||||
The port replays the same turn from the save game that precedes it and is compared at every one of these checkpoints.
|
||||
|
||||
The recorder and the automation that operates the original are not part of this repository (they need the original
|
||||
program); the checker is `tests/week_check.cpp`.
|
||||
|
||||
## Scope of the November 2026 series
|
||||
|
||||
- 73 recorded "Weiter" turns of one career, from the first Saturday in August 2026 (game day 38) through the whole
|
||||
first season, the season end on 1 July 2027 (day 365) and most of the second season up to April 2028 (day 645).
|
||||
The human manager's club played every matchday (league, cup and the indoor tournament). Incoming transfer offers
|
||||
were declined.
|
||||
- **Match phase:** 7,642 recorded match minutes, every one inside the interval of random draws that the port passes
|
||||
through, none outside. Final whistle, stoppage time and the first extra-time pass match in every turn, in the second
|
||||
season as well.
|
||||
- **Weekly processing:** 70 runs of the routine ported from the original (days 43 to 645). At the desk after each turn
|
||||
the random states and **all tables are identical** to the recording.
|
||||
- **Month change:** 17 runs (1 September 2026 to 1 April 2028, among them the change of the year and the summer break).
|
||||
Identical at the desk afterwards.
|
||||
- **Season end:** one run (day 365 with the last weekly processing and the month change, from the last matchday of the
|
||||
season on 8 May 2027 to the desk of 1 July 2027). Identical, all tables.
|
||||
- **Indoor tournament:** eleven rounds (see below).
|
||||
- Training, the stock market, the matchday preparation and the kick-off of the next matchday are part of the same turns
|
||||
and match as well (the match groups built by the port equal the first minute snapshot of the next matchday).
|
||||
|
||||
Of the 73 evaluated turns 71 are identical at the desk (random states and all tables; the transfer list is shown
|
||||
separately, see below). The other two are explained:
|
||||
|
||||
- One differs in a single lineup flag of one player slot that the original clears when the manager's lineup page is
|
||||
shown (a routine of the user interface, not of the engine); the recording passed through that page.
|
||||
- The last round of the indoor tournament ends with the tournament processing of the original (prizes, next
|
||||
fixtures); the checker replays only the playing part of an indoor round, so that part is not compared.
|
||||
|
||||
## Indoor tournament
|
||||
|
||||
All eleven recorded rounds play their 40 minutes with the same random draws as the original. The six strength values
|
||||
of the side records at the kick-off first differed by 1 to 4 points in about half of the rounds (the port mostly
|
||||
higher). Cause (issue 82, resolved): the strengths depend on the **chance weather**, a runtime value that the
|
||||
original keeps from the last chance of the round before (rain above 2 or a temperature below 0 lowers players
|
||||
whose condition is below their technique). A savegame does not hold it, and the checker starts every turn from a
|
||||
savegame, so it had rain 0 / temperature 0. With the weather of the previous turn's last chance
|
||||
(`WEEK_PREV_WEATHER=rain,temperature`, taken from the "last chance weather" line of the previous check) the kick-off
|
||||
of **all eleven rounds is identical**, bytes 0 to 5 of every side. A running game keeps the weather in memory
|
||||
like the original, so this was a gap of the check and not of the engine. The desk after the round is identical in
|
||||
ten of eleven rounds (the eleventh is the tournament end above).
|
||||
|
||||
## How to read the "DIFF" lines of the checker
|
||||
|
||||
The recorder takes a day snapshot when the date changes, i.e. **inside** the original's processing of that day; the
|
||||
port's state belongs to the end of the processing. The checker therefore prints such checkpoints as "late snapshot ...
|
||||
draws ahead of the port's state, not counted". They are not differences of the engine: the checkpoint after them (and the
|
||||
desk at the end of the turn) is identical in every counted turn. The transfer list is compared but not counted (the
|
||||
amounts of new bids depend on stale data in the original, documented in the source); a few desks show a handful of
|
||||
bytes there and the line says so.
|
||||
|
||||
## Recordings that were not used
|
||||
|
||||
Four turns of the series were dropped, none because of a difference of the engine: two were disturbed by the operation
|
||||
of the original (a mouse click that listed two players for transfer; a turn that clicked through several matchdays
|
||||
and did not keep the recorder running), two belong to the start of the second season before the first matchday
|
||||
(the season start screens with the Super Cup; no minutes were recorded). A first recording of the season end failed
|
||||
because the recorder gave up after 60 s of the long end-of-season processing; recorded again with a longer wait it
|
||||
matches.
|
||||
|
||||
## Not covered
|
||||
|
||||
- Only one career and one human manager. Contract expiry on 1 July and the other manager decisions at the season end
|
||||
were not driven by a human in this series.
|
||||
- The start of the second season between the desk of 1 July and the first matchday (Super Cup, season start screens)
|
||||
was played without recording.
|
||||
- Offers made by the weekly processing to the human manager (new transfer bids): the amounts depend on a stale stack
|
||||
value in the original and are not reproduced (documented in the source).
|
||||
- Foul and card chances are derived from the constants of the 3.7 code and show no difference in the recorded
|
||||
minutes, but a deliberate comparison of the single routine was not made.
|
||||
- A second season end and later seasons; the end of the indoor tournament.
|
||||
@@ -0,0 +1,18 @@
|
||||
# OpenBMH Classic start artwork
|
||||
|
||||
The project maintainer supplied this new start-screen artwork for use and
|
||||
repository distribution with this application. It is not extracted game content.
|
||||
The repository license applies to project artwork; original game assets remain
|
||||
external. The unmodified upstream decoder has its separate documented license.
|
||||
|
||||
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
|
||||
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
|
||||
without EXIF or other input metadata. It occupies 587,410 bytes.
|
||||
The application embeds it at build time and decodes it once at startup, so
|
||||
installed applications need no image sidecar or original title-screen VGA.
|
||||
|
||||
The SDL renderer uses the actual image dimensions while showing the title,
|
||||
including high-DPI output and aspect-preserving side bars, then restores the
|
||||
320 × 240 game/input canvas. A complete left or right mouse click continues;
|
||||
there is no loading-ball animation. Changing the artwork also requires an
|
||||
explicit review/update of its SHA256 in the public-source guard.
|
||||
@@ -0,0 +1,51 @@
|
||||
# Desktop and advertising mouse input fixes
|
||||
|
||||
The optional desktop frame bit controls decoration, not whether the visible
|
||||
widget contents accept input. The corrections reuse the Original renderer,
|
||||
coordinates, layout records and action dispatchers.
|
||||
|
||||
- The date widget activates the same owned advance action as Anstoß, with or
|
||||
without a frame. In a multiplayer turn this first hands control to the next
|
||||
manager. The separate calendar/rescheduling menu keeps its own behavior.
|
||||
- Stored icons remain clickable and draggable from unframed folders. Extraction
|
||||
restores the actual icon record to the visible chain; the folder stays put.
|
||||
Hidden or unlinked owners remain invalid. Removal corners keep their separate
|
||||
transaction and mouse-release barrier. The same frame-origin correction also
|
||||
covers the existing admission scale and five automation controls.
|
||||
- A true double-click on an existing save opens the shared Original-style
|
||||
overwrite question. A separate single click on Ja confirms, Nein returns to
|
||||
the picker, and repeated double-click releases cannot write. Enter and cancel
|
||||
paths remain. FBM, EIN and MEN use the same confirmation boundary.
|
||||
- Advertising follows all nineteen original hit rectangles with palette0x27
|
||||
outlines and the installed edition's detail/help text. Motion alone does not
|
||||
change the career, revision or either random stream. Offers/calculators retain
|
||||
their input owner; returning from them reevaluates the actual pointer, avoiding
|
||||
a stale highlight without requiring another mouse movement.
|
||||
|
||||
## Validation
|
||||
|
||||
The focused configured-data tests are `app_desktop_input_tests`,
|
||||
`app_advertising_input_tests`, `ui_desktop_input_tests`, `ui_save_load_tests` and
|
||||
`ui_advertising_tests`. They cover frame variants, exact field boundaries,
|
||||
canonical actions, stale/hidden-owner refusal, cancellation, input release,
|
||||
overwrite confirmation and unchanged game/random state for presentation-only
|
||||
input. The desktop input test isolates these checks from unrelated private
|
||||
text/badge inventories; the existing full test retains its additional checks.
|
||||
|
||||
Private Linux SDL before/after captures and actual saved games are maintained in
|
||||
`bmh_4k_ui/docs/qa/classic-extended-ui-input`. The fixtures use actual club/player
|
||||
data with a controlled desktop layout. No results are fabricated. A successful
|
||||
compile or CI run alone is not native Windows/macOS UI verification.
|
||||
|
||||
Tracked reports: [#51](https://github.com/Weyoune/openbmh/issues/51), [#52](https://github.com/Weyoune/openbmh/issues/52), [#53](https://github.com/Weyoune/openbmh/issues/53), [#54](https://github.com/Weyoune/openbmh/issues/54).
|
||||
|
||||
The primary regression run uses the supplied Diamond 3.7 installation. Unrelated
|
||||
historical rendering fixtures retain their declared reference requirements.
|
||||
Two existing Classic test fixtures were aligned with the already implemented
|
||||
stadium-capacity policy and verified edition-specific crest gate; product
|
||||
validation was not relaxed to satisfy those tests.
|
||||
|
||||
The overwrite prompt also maps the actual Football Limited English pointer.
|
||||
The translation copies exactly that four-byte pointer and preserves adjacent
|
||||
empty slots. The launcher translation-cache revision is advanced, so an existing
|
||||
cached English installation receives the newly supported prompt as well.
|
||||
@@ -32,6 +32,23 @@ The current game model combines interpreted vectors with fixed-layout compatibil
|
||||
|
||||
Legacy saves serialize blocks in a fixed order and store name pools separately. Runtime UI owners, pending input and frontend capabilities are not additional save fields. See [FBM](formats/FBM.md), [state records](formats/STATE.md) and [RNG](RNG.md).
|
||||
|
||||
## World layout
|
||||
|
||||
The dimensions of the game world are described in one place, `src/game/world_layout.hpp`, instead of as numbers spread over the engine:
|
||||
|
||||
- `WorldLayout` holds the team id ranges (league clubs, amateur clubs, foreign cup clubs without squads, the pseudo team "no club", national teams) and the squad slot table with the player pools behind it.
|
||||
- `LeagueSystem` holds the league structure of the loaded game: league sizes, calendar groups, promotion ladder, European places and the cup structure. The session installs it from the tables of the game version, so the same engine runs the German and the English data.
|
||||
- `src/game/records.hpp` names the sizes of the fixed records (manager record, tactics board, club record).
|
||||
|
||||
OpenBMH Classic only ever uses `classic_world_layout()`, which returns the numbers of the original; a test compares them and the squad table with the former literals. Code asks `world_layout()` and `league_system()` rather than writing 138 or 168.
|
||||
|
||||
This is a parameterisation, not yet a larger world. Still fixed, and to be lifted for an edition with more leagues:
|
||||
|
||||
- the number of leagues (`kLeagueCount`) and of calendar groups (eight competition bits),
|
||||
- the results block (one fixed stride per league, `kLeagueResultsStride`) and the other save blocks sized for the Classic world; the save format is unchanged and a larger world needs a format of its own,
|
||||
- the id of "no club" as a compile-time constant (`kNoTeam`), five manager records, and some stack tables sized for the Classic club count,
|
||||
- the per-club tables of the loaded state, whose sizes are checked against the Classic numbers.
|
||||
|
||||
## Public interfaces and validation
|
||||
|
||||
The [console reference](CLI_CONCEPT/README.md) documents window commands. [protocol.md](protocol.md) describes structured requests, and [CONSOLE_CLIENTS.md](CONSOLE_CLIENTS.md) explains safe client ownership and batching. Prefer shared projections/actions when adding another frontend.
|
||||
|
||||
@@ -250,7 +250,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `CareerSession_DispatchDesktopLayout_RuntimeField2` | `0xa2517` | German-compatible image / runtime field |
|
||||
| `CareerSession_DispatchLeagueTableControl_RuntimeField` | `0xa454d` | German-compatible image / runtime field |
|
||||
| `CareerSession_DispatchLeagueTableControl_RuntimeField2` | `0xbb834` | German-compatible image / runtime field |
|
||||
| `CareerSession_DispatchLineup_RuntimeField` | `0xa2c30` | German-compatible image / runtime field |
|
||||
| `LeagueClubCount` | `0xa2c30` | German-compatible image / runtime field |
|
||||
| `CareerSession_DispatchLiveSubstitution_ExecutableField` | `0xa366c` | German-compatible image / runtime field |
|
||||
| `CareerSession_DispatchLiveTactic_RuntimeField` | `0xa20eb` | German-compatible image / runtime field |
|
||||
| `CareerSession_DispatchLiveTactic_RuntimeField2` | `0xa20f3` | German-compatible image / runtime field |
|
||||
@@ -307,12 +307,12 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `CareerSession_FormatNumber_TextPointer` | `0xa137e` | German-compatible image / runtime field |
|
||||
| `CareerSession_InitializeClubModalRuntime_ExecutableField` | `0xa25c0` | German-compatible image / runtime field |
|
||||
| `CareerSession_InitializeClubModalRuntime_ExecutableFieldUnsigned` | `0xa25c0u` | German-compatible image / runtime field |
|
||||
| `CareerSession_InstallLeagueSizes_RuntimeField` | `0xa2be9` | German-compatible image / runtime field |
|
||||
| `CareerSession_InstallLeagueSizes_RuntimeField2` | `0xa2bf2` | German-compatible image / runtime field |
|
||||
| `CareerSession_InstallLeagueSizes_RuntimeField3` | `0xa2c00` | German-compatible image / runtime field |
|
||||
| `CareerSession_InstallLeagueSizes_RuntimeField4` | `0xa2c0b` | German-compatible image / runtime field |
|
||||
| `CareerSession_InstallLeagueSizes_RuntimeField5` | `0xa2c13` | German-compatible image / runtime field |
|
||||
| `CareerSession_InstallLeagueSizes_RuntimeField6` | `0xa2c34` | German-compatible image / runtime field |
|
||||
| `LeagueEuropeanPlaces` | `0xa2be9` | German-compatible image / runtime field |
|
||||
| `LeagueRelegationPlaces` | `0xa2bf2` | German-compatible image / runtime field |
|
||||
| `LeagueNameSuffixes` | `0xa2c00` | German-compatible image / runtime field |
|
||||
| `PromotionGroupBelowCounts` | `0xa2c0b` | German-compatible image / runtime field |
|
||||
| `PromotionGroupBelowLeagues` | `0xa2c13` | German-compatible image / runtime field |
|
||||
| `NewcomerClubCount` | `0xa2c34` | German-compatible image / runtime field |
|
||||
| `CareerSession_Int32T_TextPointer` | `0xaeffc` | German-compatible image / runtime field |
|
||||
| `CareerSession_Int32T_TextPointer2` | `0xaf21c` | German-compatible image / runtime field |
|
||||
| `CareerSession_Int32T_TextPointer3` | `0xaf228` | German-compatible image / runtime field |
|
||||
@@ -462,7 +462,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `ClubKitSelectorsUnsigned` | `0xbb68bu` | German-compatible image / runtime field |
|
||||
| `ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField` | `0xa25bb` | German-compatible image / runtime field |
|
||||
| `ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField2` | `0xa25bf` | German-compatible image / runtime field |
|
||||
| `ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField3` | `0xa2c36` | German-compatible image / runtime field |
|
||||
| `ForeignCupClubCount` | `0xa2c36` | German-compatible image / runtime field |
|
||||
| `ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField4` | `0xa364a` | German-compatible image / runtime field |
|
||||
| `ClubPlayerDetail_ClubPlayerDetailRedraw_RuntimeField` | `0xa2c4e` | German-compatible image / runtime field |
|
||||
| `ClubPlayerDetail_ClubPlayerDetailRedraw_RuntimeField2` | `0xa3c9b` | German-compatible image / runtime field |
|
||||
@@ -591,8 +591,8 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `CupDraw_FormatError_ExecutableField5` | `0xae704` | German-compatible image / runtime field |
|
||||
| `CupDraw_FormatError_ExecutableField6` | `0xae70c` | German-compatible image / runtime field |
|
||||
| `CupDraw_FormatError_RuntimeField` | `0xa2547` | German-compatible image / runtime field |
|
||||
| `CupDraw_FormatError_RuntimeField2` | `0xb6ea8` | German-compatible image / runtime field |
|
||||
| `CupDraw_FormatError_RuntimeField3` | `0xb9ad8` | German-compatible image / runtime field |
|
||||
| `ManagerRecord0Club` | `0xb6ea8` | German-compatible image / runtime field |
|
||||
| `ManagerRecord4Club` | `0xb9ad8` | German-compatible image / runtime field |
|
||||
| `CupDraw_FormatError_TextPointer` | `0xa1612` | German-compatible image / runtime field |
|
||||
| `CupDraw_FormatError_TextPointer2` | `0xa1619` | German-compatible image / runtime field |
|
||||
| `CupDraw_FormatError_TextPointer3` | `0xa161e` | German-compatible image / runtime field |
|
||||
@@ -783,7 +783,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishLayoutTranslation157` | `0x6e094` | English image adapter |
|
||||
| `EnglishLayoutTranslation158` | `0x6e0b8` | English image adapter |
|
||||
| `EnglishLayoutTranslation159` | `0x6e0bb` | English image adapter |
|
||||
| `EnglishLayoutTranslation16` | `0x6be4f` | English image adapter |
|
||||
| `EnglishLayoutTranslation16` | `0x6be50` | English image adapter |
|
||||
| `EnglishLayoutTranslation160` | `0x6e0d8` | English image adapter |
|
||||
| `EnglishLayoutTranslation161` | `0x6e110` | English image adapter |
|
||||
| `EnglishLayoutTranslation162` | `0x6e11c` | English image adapter |
|
||||
@@ -893,6 +893,12 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishLayoutTranslation256` | `0x6f2ae` | English image adapter |
|
||||
| `EnglishLayoutTranslation257` | `0x6f2d4` | English image adapter |
|
||||
| `EnglishLayoutTranslation258` | `0x6f2e0` | English image adapter |
|
||||
| `EnglishEnvironmentTileX` | `0x6d230` | English image adapter |
|
||||
| `EnglishEnvironmentTileY` | `0x6d238` | English image adapter |
|
||||
| `EnglishEnvironmentYouthColors` | `0x6d240` | English image adapter |
|
||||
| `EnglishEnvironmentBudgetSteps` | `0x6d244` | English image adapter |
|
||||
| `EnglishEnvironmentYouthPositionSuffix` | `0x6d24a` | English image adapter |
|
||||
| `EnglishEnvironmentCostSuffix` | `0x6d24f` | English image adapter |
|
||||
| `EnglishLayoutTranslation259` | `0x6f2fc` | English image adapter |
|
||||
| `EnglishLayoutTranslation26` | `0x6bf2c` | English image adapter |
|
||||
| `EnglishLayoutTranslation260` | `0x6f300` | English image adapter |
|
||||
@@ -1005,7 +1011,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishLayoutTranslation70` | `0x6d270` | English image adapter |
|
||||
| `EnglishLayoutTranslation71` | `0x6d272` | English image adapter |
|
||||
| `EnglishLayoutTranslation72` | `0x6d274` | English image adapter |
|
||||
| `EnglishLayoutTranslation73` | `0x6d29c` | English image adapter |
|
||||
| `EnglishLayoutTranslation73` | `0x6d29d` | English image adapter |
|
||||
| `EnglishLayoutTranslation74` | `0x6d3b4` | English image adapter |
|
||||
| `EnglishLayoutTranslation75` | `0x6d404` | English image adapter |
|
||||
| `EnglishLayoutTranslation76` | `0x6d408` | English image adapter |
|
||||
@@ -1495,6 +1501,14 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `Pitch_Render_TextPointer3` | `0xae0f0` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer4` | `0xae0f4` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer5` | `0xae0f8` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceDepthBases` | `0xa3cc3` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceRed` | `0xa3cc7` | German-compatible image / runtime field |
|
||||
| `PitchPreferenceGreen` | `0xa3cd1` | German-compatible image / runtime field |
|
||||
| `OriginalPointerPixels` | `0xa45b4` | German-compatible image / runtime field |
|
||||
| `EnglishPitchPreferenceDepthBases` | `0x6e230` | English image adapter |
|
||||
| `EnglishPitchPreferenceRed` | `0x6e234` | English image adapter |
|
||||
| `EnglishPitchPreferenceGreen` | `0x6e240` | English image adapter |
|
||||
| `EnglishOriginalPointerPixels` | `0x70554` | English image adapter |
|
||||
| `PitchOrderPositionPointers` | `0xa2a37` | German-compatible image / runtime field |
|
||||
| `PitchOrderZoneMasks` | `0xa2a4b` | German-compatible image / runtime field |
|
||||
| `PitchOrderZoneTextPointers` | `0xae818` | German-compatible image / runtime field |
|
||||
@@ -1570,6 +1584,7 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `SaveLoad_Render_RuntimeField` | `0xa2334` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_RuntimeField2` | `0xa233f` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_RuntimeField3` | `0xa234a` | German-compatible image / runtime field |
|
||||
| `SaveLoad_OverwriteQuestionPointer` | `0xa21c4` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_TextPointer` | `0xa1512` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_TextPointer2` | `0xae5f0` | German-compatible image / runtime field |
|
||||
| `SaveLoad_Render_TextPointer3` | `0xae620` | German-compatible image / runtime field |
|
||||
@@ -1918,6 +1933,8 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `TransferMarket_Rect_TextPointer3` | `0xae148` | German-compatible image / runtime field |
|
||||
| `TransferMarket_Rect_TextPointer4` | `0xae14c` | German-compatible image / runtime field |
|
||||
| `TransferMarket_Rect_TextPointer5` | `0xae150` | German-compatible image / runtime field |
|
||||
| `TransferMarket_SearchRows_RuntimeField` | `0xa20fb` | German-compatible image / runtime field |
|
||||
| `TransferMarket_SearchButton_TextPointer` | `0xae144` | German-compatible image / runtime field |
|
||||
| `TransferMarket_Rect_TextPointer6` | `0xaecac` | German-compatible image / runtime field |
|
||||
| `TransferMarket_Rect_TextPointer7` | `0xaf250` | German-compatible image / runtime field |
|
||||
| `TransferMarket_Render_TextPointer` | `0xaf264` | German-compatible image / runtime field |
|
||||
@@ -1991,13 +2008,11 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `EnglishSixTeamFixtureTable` | `0x6eed4` | English image adapter |
|
||||
| `EnglishTwelveTeamFixtureTable` | `0x6f0bc` | English image adapter |
|
||||
| `EnglishTwentyTeamFixtureTable` | `0x6ee40` | English image adapter |
|
||||
|
||||
## Verified edition-dependent parameters
|
||||
|
||||
| Field | Address | Use |
|
||||
|---|---|---|
|
||||
| `CalendarDateSetup` | `0x21270` | Verified date setup: weekday byte at +4, initial year dword at +13. Original CD uses 1995/Saturday; checked Diamond editions use 2026/Wednesday. |
|
||||
| `ForeignBadgeGateInstruction` | `0x10070` | Verified original drawing gate; operand at +3 selects neutral foreign crests or individual W-sheet selectors. |
|
||||
| `EnvironmentBudgetSteps` | `0xa50ff` | Six budget increments in the verified monthly environment implementation. |
|
||||
|
||||
Calendar presentation, engine weekday processing and save-list headers share the supplied installation's epoch. The original four-year date arithmetic is preserved; this reader does not substitute a different calendar system or rewrite the installation. Unknown date setup instructions and invalid values are rejected.
|
||||
| `EnglishDesktopBinSourceX` | `0x6e180` | English image adapter |
|
||||
| `EnglishDesktopBinSourceY` | `0x6e182` | English image adapter |
|
||||
| `EnglishDesktopSocketSourceX` | `0x6e184` | English image adapter |
|
||||
| `EnvironmentBudgetSteps` | `0xa50ff` | German-compatible image / runtime field |
|
||||
| `EnvironmentVerifiedCodeBegin` | `0x6c000` | English image adapter |
|
||||
| `EnvironmentVerifiedCodeEnd` | `0x6cb40` | English image adapter |
|
||||
| `EnvironmentVerifiedHookBegin` | `0x7af65` | English image adapter |
|
||||
| `EnvironmentVerifiedHookEnd` | `0x7b020` | English image adapter |
|
||||
+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.
|
||||
@@ -12,3 +12,5 @@ These files preserve upstream license and attribution wording. They are not a gr
|
||||
- [LGPL version 2.1](LGPL-2.1.txt): full license supplied with Nuked OPL3. Its source notices permit version 2.1 or any later version.
|
||||
|
||||
[THIRD_PARTY_NOTICES.md](../../THIRD_PARTY_NOTICES.md) identifies the upstream versions and distribution requirements. Include this directory, that notice file and the root LICENSE with release packages. Preserve upstream attribution within these verbatim texts.
|
||||
|
||||
- [stb_image](stb_image.txt): complete upstream dual-license text from the vendored 2.30 header. JPEG-only decoding is used for the supplied project start screen.
|
||||
@@ -0,0 +1,38 @@
|
||||
This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
@@ -1,64 +0,0 @@
|
||||
# Classic-plus-1 profile
|
||||
|
||||
This opt-in experimental profile keeps the Classic competition types and indexed artwork formats. It is not a DOS patch. The original executable is read only; verified dimension data and the expanded calendar are prepared in memory. Unmarked installations retain Classic dimensions and save identity.
|
||||
|
||||
## Discovery and dimensions
|
||||
|
||||
`OBMHPROF.INI` contains exactly:
|
||||
|
||||
```ini
|
||||
[OpenBMH]
|
||||
profile=classic-plus-1
|
||||
```
|
||||
|
||||
Unknown keys/profiles are rejected. The German executable and calendar are required.
|
||||
|
||||
| Table | Classic | Classic-plus-1 |
|
||||
| --- | ---: | ---: |
|
||||
| League sizes, German divisions | 18/18/18/18/18 | 18/18/18/18/18 |
|
||||
| Spain/England/France/Italy | 12/12/12/12 | 18/20/18/18 |
|
||||
| League clubs | 138 | 164 |
|
||||
| Cup-only clubs | 30 | 30 |
|
||||
| League and cup records | 168 | 194 |
|
||||
| Other foreign clubs | 189 | 189 |
|
||||
| National teams | 62 | 62 |
|
||||
| All club/country entries | 419 | 445 |
|
||||
| Players | 2,574 | 3,334 |
|
||||
| Clubs with 24 roster slots | 90 | 164 |
|
||||
| First market slot | 2,928 | 3,936 |
|
||||
| First national roster slot | 3,072 | 4,080 |
|
||||
| First extra-player slot | 3,096 | 4,104 |
|
||||
| Total runtime slots | 3,150 | 4,158 |
|
||||
|
||||
Player identifiers still use twelve bits, with 4,095 reserved for empty. **An absolute roster slot is not a player identifier**: extended auxiliary slots exceed 4,095 and must not be masked. Club identifiers fit existing packed club fields and crest selectors fit nine bits.
|
||||
|
||||
## Master database and artwork
|
||||
|
||||
The M3D table order and encoding remain unchanged. Kit selectors scale with all club/country entries; short-name offsets and auxiliary words scale with league-plus-cup entries. The squad master has four fewer rows than runtime, because temporary transfer rows are inserted during career initialization. String pools retain unsigned 16-bit offsets. Imported names use ISO 646-DE, with explicit transliteration of unsupported letters.
|
||||
|
||||
The preparation script keeps original player words and original IDs, appends supplemental players and records the source-to-runtime club mapping. Existing twelve-club foreign cores are retained; additional clubs are ranked by donor mean player strength. Missing-person data are not silently fetched or invented. Every supplied provenance/fictional-field note is retained in the private import report.
|
||||
|
||||
Crests are fitted into 38-by-38 cells of 304-by-38 VGA sheets, using the supplied VGA palette. No PNG/SVG decoder is needed at runtime. Transparency is index zero for these generated crest cells. Existing protected crest cells remain intact. Repeated Original placeholder images are rejected rather than counted as real club crests. Missing crests use explicitly fictional vector monograms, and dark monochrome logos can use a light contrast variant; both are recorded per club. Asset source and rights notes remain separate from the application's GPL license.
|
||||
|
||||
The offline preparation utility accepts local paths:
|
||||
|
||||
```sh
|
||||
python3 -m venv asset-tools
|
||||
asset-tools/bin/pip install Pillow CairoSVG
|
||||
asset-tools/bin/python tools/poc/prepare_international.py \
|
||||
--source /path/to/supplied/german-game \
|
||||
--supplement /path/to/supplied/season.obw \
|
||||
--output /path/to/new/private-data
|
||||
```
|
||||
|
||||
The destination must not exist. Inputs are never overwritten. Original content and private import reports must stay outside public source trees, issues and CI artifacts.
|
||||
|
||||
## Save and memory boundaries
|
||||
|
||||
Classic containers retain `V2.24`. Extended containers use `O1.1`, checked against the selected installation before state decoding. The table sequence remains familiar, with count-derived sizes for club records, manager/opponent histories, crests, kits and short-name offsets. Extended typed tables must not grow into adjacent globals in the guest-memory compatibility representation.
|
||||
|
||||
The result store already reserves nine leagues with 38 rounds and ten matches per round. Expanded scheduling uses each league's own fixture size. The shared foreign calendar supplies 38 dates; each league stops at its own 34 or 38 rounds. Domestic/cup/national flags are preserved. Dates are an experimental calendar policy, not a claim about real-world fixtures.
|
||||
|
||||
## Distribution
|
||||
|
||||
Public artifacts contain the implementation, build information and corresponding sources. The community data ZIP is prepared privately and separately; existing content provenance and rights are unchanged. The stable 1.0 release line is not replaced by this POC.
|
||||
@@ -1,20 +0,0 @@
|
||||
# International-league POC
|
||||
|
||||
Working branch: `poc/1.1-international`, based on `v1.0.2`. Stable main remains separate.
|
||||
|
||||
Implemented:
|
||||
|
||||
- Explicit `OBMHPROF.INI` metadata; unmarked installations retain Classic dimensions.
|
||||
- Five German divisions unchanged; international sizes 18/20/18/18, 164 league clubs.
|
||||
- Twenty starting players and 24 slots per league club; 4,158 runtime roster/auxiliary slots.
|
||||
- Profile-aware master-database and executable-data views, preserving executable bytes on disk.
|
||||
- Count-derived club records, opponent histories, kit/short-name and fair-play tables.
|
||||
- Per-league fixtures and 38 foreign calendar dates, with smaller leagues stopping at 34 rounds.
|
||||
- Extended save identity `O1.1`; Classic retains `V2.24` and its existing dimensions.
|
||||
- Offline private data preparation, provenance, crest fitting and Original-format VGA output.
|
||||
|
||||
Local integration evidence so far: the expanded career completed 180 turns with seed 1 (three season ends), and another 180 with seed 11 (two season ends). No simulator invariant violations or contract-policy errors were reported. These are automated manager-policy runs, not claims of complete human gameplay QA or validation of all editions/platforms.
|
||||
|
||||
The prepared private dataset has 445 club/country entries, 3,334 players and 263 individual foreign club crests. Original German rosters and all 2,574 Original player word records are preserved by assertions during preparation. The visual review identified 175 usable supplied foreign crests and 88 missing/shared Original placeholders. Those 88 now have explicit fictional club-specific monograms instead of the computer symbol; very dark monochrome crests receive a documented contrast variant. Donor fields retain their real/fictional provenance. No original game content is committed here.
|
||||
|
||||
Validation: 37 configured synthetic tests executed successfully, with 158 external-input tests explicitly skipped; four offline preparation tests passed. Extended save/reload and both cross-profile rejection paths passed. Two separate season-end snapshots each contain every fixture in all nine leagues. A Classic 80-turn run produces a byte-identical save to stable 1.0.2. Screenshots and saves are archived privately. Native platform CI also builds and tests Windows x64, macOS ARM64 and Linux x64; release QA receipts identify the exact successful revision. See [FORMAT.md](FORMAT.md) for dimensions, preparation and distribution boundaries. A development commit is not a completed release claim.
|
||||
@@ -0,0 +1,61 @@
|
||||
# OpenBMH Classic 1.0.10
|
||||
|
||||
This release adds the transfer market search dialog, fixes the "Angebot" button
|
||||
of the poaching dialog and corrects the asking price shown in the market. It
|
||||
requires the player's own game installation. Extended development remains
|
||||
separate in [OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.9
|
||||
|
||||
- **Suchen and Vorschlag in the transfer market.** Both buttons did nothing.
|
||||
They now open the search profile dialog of the original (positions, age,
|
||||
strength, attributes, sides, price classes). "Suchen" opens the stored
|
||||
profile, "Vorschlag" the profile your squad asks for. Closing with the
|
||||
confirm button stores the profile and announces the listed players that
|
||||
fit, one message box each; the right mouse button or Esc closes it and
|
||||
switches the search off. The rules (closing rule, matching, suggestion) were
|
||||
compared with the Diamond 3.7 routines on ten savegames without a
|
||||
difference. The console has the same steps: `ShowSearchProfile`,
|
||||
`SuggestSearchProfile`, `SetSearchProfile`.
|
||||
- **Abwerben: "Angebot" button.** Two causes. The engine asks the selling
|
||||
manager and the buyer a yes/no question when a poaching offer is decided;
|
||||
the graphical client did not provide the question dialog. And the agreement
|
||||
of the poached player ("Ihr erstes Angebot wird angenommen!") had no message
|
||||
dialog, which refused the whole offer. Both exist now. A refused offer or
|
||||
transfer action also shows its reason (and writes it to the debug log)
|
||||
instead of a dead button.
|
||||
- **Verkaufen on a listed player.** Clicking a player who is already on the transfer
|
||||
list and then VERKAUFEN did nothing when no offer had arrived yet. It now asks
|
||||
the question of the original, "Wollen Sie ... vom Transfermarkt holen?": yes takes
|
||||
the player off the list (he stays in the squad), no leads on to the offers.
|
||||
- **Pressed buttons.** Suchen, Vorschlag, Abwerben and the other buttons of
|
||||
the market are drawn pressed while the mouse button is held.
|
||||
- **Scouting message.** Confirming the search dialog first shows the message
|
||||
of the scouting department, then one box per fitting listing.
|
||||
- **Asking price in the market list.** The list showed the asking fee scaled
|
||||
by 1.25, the factor of an older Diamond build. Diamond 3.7 rounds to whole
|
||||
10,000 (the offer editor and the weekly processing already did).
|
||||
- **Tests.** The controller tests now drive the whole route of reviewing and
|
||||
accepting offers on an own listing, of relisting a player after a declined
|
||||
listing and of the search dialog.
|
||||
|
||||
## Open points
|
||||
|
||||
- **"Angebote prüfen" / listing again after a declined offer.** Reported by the
|
||||
Diamond author. The console and the controller tests show the expected
|
||||
behaviour (offers can be reviewed and accepted before expiry; a player who
|
||||
left the list after a decline can be listed again). It could not be
|
||||
reproduced, so a debug log (`-debug`) or exact steps are still needed.
|
||||
- **Measurement against Diamond 3.7.** The match engine (minute, duels, shots)
|
||||
and the whole weekly processing with the bid amounts are not yet compared
|
||||
with the real 3.7. The bid amounts of new offers depend on stale data in the
|
||||
original and cannot be reproduced exactly (documented in the source).
|
||||
- Earlier open points remain: "player card: original atlas bounds" (#77), sporadic
|
||||
double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,87 @@
|
||||
# OpenBMH Classic 1.0.11
|
||||
|
||||
This release lets the game run from the asset files alone, adds the transfer
|
||||
market search dialog, fixes the "Angebot" button of the poaching dialog and the
|
||||
selling of a listed player, and corrects the asking price shown in the market.
|
||||
Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## BMH.EXE or openbmh.dat
|
||||
|
||||
- A game needs its asset files and **either** the executable (`BMH.EXE`, or
|
||||
`FLTD.EXE` for the English game) **or** the file **openbmh.dat**. If both are
|
||||
there, the executable is used as before. If neither is there, OpenBMH asks for
|
||||
a game directory or for `BMH.EXE`.
|
||||
- The numbers of the Diamond 3.7 executable (tables, rates, positions, prices) and
|
||||
of the English Football Limited are built into the program. `openbmh.dat` holds
|
||||
the game texts of those executables (live commentary, messages). It ships next
|
||||
to `OpenBMH` and `openbmh_cli` in the release package and is found in the
|
||||
game folder, in the program folder and in the current folder (or where
|
||||
`OPENBMH_DAT` points to). A folder, ZIP or 7z with only the asset files
|
||||
(`TEXTD.BLK` and `M3D.MAN`, or `TEXTE.BLK` and `M3E.MAN`, plus the
|
||||
picture, font and sound folders) is a complete game when `openbmh.dat` is
|
||||
found.
|
||||
- The default manager name is "OpenBMH" instead of "Nobody".
|
||||
- A recorded session gives the same output as with the real `BMH.EXE`.
|
||||
## Changes since 1.0.9 (1.0.10 was never published; its changes are part of this release)
|
||||
|
||||
- **Suchen and Vorschlag in the transfer market.** Both buttons did nothing.
|
||||
They now open the search profile dialog of the original (positions, age,
|
||||
strength, attributes, sides, price classes). "Suchen" opens the stored
|
||||
profile, "Vorschlag" the profile your squad asks for. Closing with the
|
||||
confirm button stores the profile and announces the listed players that
|
||||
fit, one message box each; the right mouse button or Esc closes it and
|
||||
switches the search off. The rules (closing rule, matching, suggestion) were
|
||||
compared with the Diamond 3.7 routines on ten savegames without a
|
||||
difference. The console has the same steps: `ShowSearchProfile`,
|
||||
`SuggestSearchProfile`, `SetSearchProfile`.
|
||||
- **Abwerben: "Angebot" button.** Two causes. The engine asks the selling
|
||||
manager and the buyer a yes/no question when a poaching offer is decided;
|
||||
the graphical client did not provide the question dialog. And the agreement
|
||||
of the poached player ("Ihr erstes Angebot wird angenommen!") had no message
|
||||
dialog, which refused the whole offer. Both exist now. A refused offer or
|
||||
transfer action also shows its reason (and writes it to the debug log)
|
||||
instead of a dead button.
|
||||
- **Verkaufen on a listed player.** Clicking a player who is already on the transfer
|
||||
list and then VERKAUFEN did nothing when no offer had arrived yet. It now asks
|
||||
the question of the original, "Wollen Sie ... vom Transfermarkt holen?": yes takes
|
||||
the player off the list (he stays in the squad), no leads on to the offers.
|
||||
- **Pressed buttons.** Suchen, Vorschlag, Abwerben and the other buttons of
|
||||
the market are drawn pressed while the mouse button is held.
|
||||
- **Scouting message.** Confirming the search dialog first shows the message
|
||||
of the scouting department, then one box per fitting listing.
|
||||
- **Asking price in the market list.** The list showed the asking fee scaled
|
||||
by 1.25, the factor of an older Diamond build. Diamond 3.7 rounds to whole
|
||||
10,000 (the offer editor and the weekly processing already did).
|
||||
- **Tests.** The controller tests now drive the whole route of reviewing and
|
||||
accepting offers on an own listing, of relisting a player after a declined
|
||||
listing and of the search dialog.
|
||||
|
||||
## Measurement against Diamond 3.7
|
||||
|
||||
- The match engine of a recorded matchday in the real 3.7 (DOSBox-X) matches the
|
||||
port in all 94 minutes, with the random number state at kick-off, in every
|
||||
minute, at the final whistle and at the next desk.
|
||||
- Two apparent deviations (from minute 10, and on the days after the match) were
|
||||
errors of the comparison tool, not of the engine, and are fixed or explained there.
|
||||
|
||||
## Open points
|
||||
|
||||
- **"Angebote prüfen" / listing again after a declined offer.** Reported by the
|
||||
Diamond author. The console and the controller tests show the expected
|
||||
behaviour. It could not be reproduced, so a debug log (`-debug`) or exact
|
||||
steps are still needed.
|
||||
- The bid amounts of new offers in the weekly processing depend on stale data in
|
||||
the original and cannot be reproduced exactly (documented in the source).
|
||||
- Only one matchday and the days after it were recorded from the real 3.7; the
|
||||
weekly processing, month changes and transfers are not yet compared.
|
||||
- The graphical client has not yet been tried with `openbmh.dat` and asset files only.
|
||||
- Earlier open points remain: "player card: original atlas bounds" (#77), sporadic
|
||||
double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,83 @@
|
||||
# OpenBMH Classic 1.0.12
|
||||
|
||||
This release makes the buttons of the dialogs behave like the original: a button
|
||||
without a lasting state is drawn pressed while the mouse button is held. It also
|
||||
carries everything of [1.0.11](../1.0.11/RELEASE_NOTES.md) (the game from asset
|
||||
files plus `openbmh.dat`, the transfer market search, the poaching and selling
|
||||
fixes). Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Pressed buttons
|
||||
|
||||
Many dialogs drew their buttons raised at all times, the original shows them
|
||||
pressed for as long as the mouse button is down (the friendly match question
|
||||
already did). Now pressed while held:
|
||||
|
||||
- **Bank:** the two buttons of stocks, property, savings and credit, the OK of
|
||||
its notices, Ja/Nein of the credit fee question and the keys of its calculator.
|
||||
- **Spieler kaufen (offer editor):** Team-Info, Spieler-Info, Angebot, Abbruch and
|
||||
the calculator keys.
|
||||
- **Aufstellung:** Daten A/B and Spielfeld; **Spielfeld page:** Daten and Kurz
|
||||
(the action starts after a short moment, as the pressed look has to be seen).
|
||||
- **Contracts:** the buttons under the offer and the team premium panels
|
||||
(Team-Prämien), OK of the answer and the calculator keys.
|
||||
- **Advertising:** Abbrechen/Annehmen of an offer, OK of its notices and the keys of
|
||||
its calculator.
|
||||
- **Player card:** Schließen, Statistik and Zurück; **training camp:** the booking
|
||||
button and OK; **file dialog:** Ja/Nein of the overwrite question and the page
|
||||
button of a long list; **manager confirmation:** JA and NEIN; **transfer
|
||||
decision:** OK of the confirmation.
|
||||
- **Start menu (game setup):** the minus and plus buttons show the original's
|
||||
darker pressed picture while the mouse button is held (also in the joining
|
||||
manager's setup). It is a different picture (36x36 pixels, drawn two pixels right
|
||||
and down of the raised button on the plain background), not a shifted copy of the
|
||||
button, and was compared pixel for pixel with a recording of the real game.
|
||||
- The notices that wait for any click (Sportschau, cup draw, game end screens) have
|
||||
no button and are unchanged. Toggles that stay on (training, filters) keep their
|
||||
lasting state.
|
||||
|
||||
## Transfer market
|
||||
|
||||
- **Verkaufen on a listed player chosen in the market list.** Choosing an own listed
|
||||
player in the right-hand list and pressing VERKAUFEN gave "Noch keine Angebote"
|
||||
(or went straight to the offers) instead of the question of the original,
|
||||
"Wollen Sie ... vom Transfermarkt holen?". It now asks first, as it already did for
|
||||
a player chosen in the squad list: yes takes him off the list, no leads on to the
|
||||
offers.
|
||||
|
||||
- **No status text in the footer.** The transfer market replaced the club name in the
|
||||
bottom row with status texts (rejections, hints). The original has no such line; the
|
||||
club name now always stays there.
|
||||
|
||||
- **League table: club names in full.** Names were cut after about 17 characters
|
||||
("EINTRACHT FRANKFU"); the original shows them completely ("EINTRACHT FRANKFURT",
|
||||
"TSG 1899 HOFFENHEIM") and lets the games column cover what reaches into it.
|
||||
|
||||
## Internal
|
||||
|
||||
- The drawing of the wide push button, of the calculator window (panel and keys) and
|
||||
of the dialog frame is now shared (`ui/button_frame.hpp`,
|
||||
`ui/calculator_widgets.hpp`, `ui/dialog_frame.hpp`) instead of being copied in
|
||||
about twenty dialogs. A test compares the shared drawing pixel for pixel with the
|
||||
former one. A few buttons whose former drawing differs by one pixel (statistics
|
||||
rankings, team statistics, opportunities, analytics) were left as they are.
|
||||
|
||||
## Open points
|
||||
|
||||
- The pressed look was checked by tests and by reading the drawing code, not yet
|
||||
against a recording of the real Diamond 3.7; the exact timing of the short press on
|
||||
the Spielfeld page is an estimate.
|
||||
- **"Angebote prüfen" / listing again after a declined offer.** Could not be
|
||||
reproduced; a debug log (`-debug`) or exact steps are still needed.
|
||||
- The graphical client has not yet been tried with `openbmh.dat` and asset files only.
|
||||
- The weekly processing, month changes and transfers are not yet compared with the
|
||||
real 3.7 (only one matchday and the days after it were).
|
||||
- Earlier open points remain: "player card: original atlas bounds" (#77), sporadic
|
||||
double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,51 @@
|
||||
# OpenBMH Classic 1.0.13
|
||||
|
||||
This release returns the stadium to the size of the original and carries a large
|
||||
internal clean-up. Apart from the stadium the game plays exactly as
|
||||
[1.0.12](../1.0.12/RELEASE_NOTES.md): the same careers, turn by turn, and the same
|
||||
pictures. Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Stadium: 96,000 places as in the original
|
||||
|
||||
- **The block limits are those of the game edition again.** Versions 1.0.3 to 1.0.12
|
||||
allowed 14/24/14/20 thousand places per block, 144,000 in total. From 100,000
|
||||
spectators on the live match could not show the attendance correctly: the original
|
||||
display has room for five digits. The limits are now taken from the game data as
|
||||
supplied: Diamond 3.7 gives 8/18/8/14 thousand per block, twice, which is 96,000
|
||||
places. Building times follow the edition as well (30/37/30/25 weeks for a block
|
||||
built in one go).
|
||||
- The documented deviation "larger stadium" is gone from
|
||||
[DIFFERENCES](../../DIFFERENCES.md); [COMPATIBILITY](../../COMPATIBILITY.md)
|
||||
describes the rule.
|
||||
|
||||
## Engine checks against the original
|
||||
|
||||
- **Indoor tournament strengths explained.** The team strengths at the kick-off of an
|
||||
indoor match differed from a recording of the real 3.7 in some turns. The cause is
|
||||
the weather the original keeps from the last chance of the previous match (rain or
|
||||
frost lowers players whose condition is below their technique), not the engine. The
|
||||
comparison tool now carries that weather over, and the turns agree.
|
||||
|
||||
## Internal
|
||||
|
||||
Nothing in this section changes the game. Every step was compared with the state
|
||||
before it: nine careers of 110 turns each (state checksum per turn, German and
|
||||
English data), 86 recorded turns of the real 3.7, a walk through the screens with a
|
||||
checksum per picture, and the window program played by a script.
|
||||
|
||||
- **Smaller files with named functions.** The window program (`main.cpp`, 4,500
|
||||
lines), the controller's request function (2,000 lines) and the career session
|
||||
(9,000 lines) are split into files by topic with one named function per presenter
|
||||
or request.
|
||||
- **Shared helpers.** The pixel loops of about forty screens (`ui/draw.hpp`), the
|
||||
text encoding (`formats/text_encoding.hpp`) and the check helper of the tests
|
||||
exist once instead of as copies.
|
||||
- **World layout.** The dimensions of the game world (team id ranges, squad slots,
|
||||
league sizes, promotion ladder, record sizes) are described in one place
|
||||
(`game/world_layout.hpp`, `game/records.hpp`) instead of as numbers spread over
|
||||
the engine. Classic uses the numbers of the original; see "World layout" in
|
||||
[architecture](../../architecture.md).
|
||||
- **Build.** On Windows the asset viewer no longer overwrites the game in the build
|
||||
directory (both were `openbmh.exe` to a file system that ignores case), and the
|
||||
app sources are compiled once instead of once per test.
|
||||
@@ -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.
|
||||
@@ -0,0 +1,57 @@
|
||||
# OpenBMH Classic 1.0.4
|
||||
|
||||
This Classic patch release includes the desktop, save and advertising fixes
|
||||
added after 1.0.3. It requires the player's own supported game installation.
|
||||
Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.3
|
||||
|
||||
- The supplied Classic start artwork is embedded at its native resolution and
|
||||
displayed with correct proportions, including high-DPI output. A complete
|
||||
left or right mouse click continues into the game.
|
||||
- An unframed desktop calendar/date control now starts the next turn correctly.
|
||||
Unframed admission-price and automation controls use their correct origins;
|
||||
hidden controls and national-team restrictions remain enforced.
|
||||
- Dragging an icon out of a stored desktop folder moves the selected icon while
|
||||
keeping the folder in place. Folder-corner removal uses the original input
|
||||
geometry.
|
||||
- Double-clicking an occupied save slot opens the original overwrite question.
|
||||
Its Yes/No buttons work entirely with the mouse. No preserves the existing
|
||||
file; Yes writes the selected slot.
|
||||
- Advertising choices use the original hover outlines and help areas. Returning
|
||||
from a dialog refreshes the pointer state and removes stale highlighting.
|
||||
- Malformed saved formation automation is rejected before desktop projection,
|
||||
without changing the career state or random streams.
|
||||
- Football Limited retains its original overwrite question during English-data
|
||||
translation. The launcher rebuilds older translated caches automatically.
|
||||
|
||||
## Validation
|
||||
|
||||
The release workflow requires successful builds, configured tests, version and
|
||||
package checks for Windows x64, macOS ARM64 and Linux x64 at the exact tagged
|
||||
revision. Downloads include checksums, a platform test report and corresponding
|
||||
source with pinned open-source dependencies.
|
||||
|
||||
Additional private Linux validation of the fixes used Diamond 3.7 data and real
|
||||
mouse input. The 211-test configured suite executed 116 passing tests, skipped
|
||||
95 checks needing other private fixtures, and reported no failures. Focused
|
||||
save, desktop and advertising input checks executed. Native before/after checks
|
||||
verified mouse-only overwrite refusal/acceptance, folder extraction and a real
|
||||
two-manager calendar handoff, with saved-state verification. An original
|
||||
Football Limited data probe verified the translated overwrite question.
|
||||
|
||||
These checks do not establish manual gameplay acceptance on Windows or macOS.
|
||||
Issues [#51](https://github.com/Weyoune/openbmh/issues/51),
|
||||
[#52](https://github.com/Weyoune/openbmh/issues/52),
|
||||
[#53](https://github.com/Weyoune/openbmh/issues/53) and
|
||||
[#54](https://github.com/Weyoune/openbmh/issues/54) remain open for human QA.
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
|
||||
No original executables, databases, saves, graphics or audio are included.
|
||||
@@ -0,0 +1,52 @@
|
||||
# OpenBMH Classic 1.0.5
|
||||
|
||||
This patch fixes environment access with compatible older DIAMOND data and
|
||||
English contract labels. It requires the player's own game installation.
|
||||
Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.4
|
||||
|
||||
- Environment management uses the common Diamond 3.7 monthly model for supported
|
||||
source-data editions. Different original programme instructions no longer
|
||||
block compatible numeric data. Six budget steps are validated and installed
|
||||
together; malformed layouts and artwork bounds remain guarded. Existing
|
||||
saved lump-sum academy budgets retain their accounting until edited.
|
||||
- Football Limited translation supplies its actual environment geometry,
|
||||
numeric steps and suffixes. Selecting the original English installation
|
||||
rebuilds older translated caches automatically.
|
||||
- Contract tabs use the installation's original text and font path, including
|
||||
English data, salary and team-bonus captions.
|
||||
- English manager selection exposes the Original four starting levels. The
|
||||
fifth internal data league remains in the model, squads, rankings and fixture
|
||||
data. Hidden targets/clubs are rejected before fresh-manager mutation or RNG;
|
||||
existing saved league values are not generally rejected.
|
||||
|
||||
## Validation and human QA
|
||||
|
||||
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
|
||||
builds, configured tests, product-version checks and package/source verification
|
||||
for the exact tagged revision. Downloads include checksums, a platform test
|
||||
report and corresponding source with pinned open-source dependencies.
|
||||
|
||||
Local checks use an older primary DIAMOND installation, separately identified
|
||||
Diamond 3.6 and 3.7 data, German CD data and translated Football Limited data.
|
||||
They cover all six environment controls, transaction ownership and unchanged RNG,
|
||||
source-language contract glyphs, valid manager selection and hidden-level refusal.
|
||||
Native Linux before/after checks reproduce the older DIAMOND menu block and
|
||||
verify the corrected environment screen and English contract captions. The older
|
||||
package's precise edition name remains unconfirmed; the separately supplied
|
||||
3.6 installation also passed the original controller check.
|
||||
|
||||
Issues [#55](https://github.com/Weyoune/openbmh/issues/55) and
|
||||
[#56](https://github.com/Weyoune/openbmh/issues/56) remain open for human QA.
|
||||
Native Windows/macOS gameplay acceptance is not established by CI builds.
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
|
||||
No original executables, databases, saves, graphics or audio are included.
|
||||
@@ -0,0 +1,54 @@
|
||||
# OpenBMH Classic 1.0.6
|
||||
|
||||
This patch fixes bugs reported by Windows and macOS testers and adds a `-debug`
|
||||
mode. It requires the player's own game installation. Extended development
|
||||
remains separate in [OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.5
|
||||
|
||||
- **Debug mode.** `-debug` writes a log and the redirected error output to a
|
||||
`debug` folder inside the save directory and stores a savegame after every
|
||||
kick-off, so a failing session can be reproduced from the files.
|
||||
- **Settings.** Every unlocked switch of the settings screen is stored; only
|
||||
locked rows stay fixed.
|
||||
- **Training.** The skill bars per player and the hovered row are drawn.
|
||||
- **Line-up.** Set-piece takers can be picked and players placed in the shooter
|
||||
editor. The live line-up now also opens at the national-team desk.
|
||||
- **Mouse pointer.** The original game pointer is used, at the correct size on
|
||||
high-DPI displays (macOS).
|
||||
- **Calendar.** The calendar works after a kick-off and at the end of the
|
||||
season, shows the original colour gradient and uses the live season values.
|
||||
- **Running matchday.** Table, Strengths and the results page no longer hang or
|
||||
reject clicks while a matchday is running.
|
||||
- **National-team desk.** Save loading, Table, Strengths, Other Games, Top
|
||||
Scorers and the live line-up work for the national coach; the club badges on
|
||||
the desk follow the opponent of the day.
|
||||
- **Joined managers.** A manager who joins a running career sees his next
|
||||
opponent instead of "no match".
|
||||
- **Club information.** The Radio/Video setting of the club information screen
|
||||
persists, so an AI match set to Video appears live.
|
||||
- **Stadium.** The yellow hover frame appears over seat blocks, investments and
|
||||
buildings; the panorama view is not framed.
|
||||
- **Advertising.** ANNEHMEN is hidden when the offer cannot be accepted, as in
|
||||
the original. Settings screen shows the product name and version.
|
||||
- **Table calculator.** The right mouse button closes the From/To calculator.
|
||||
|
||||
## Validation and human QA
|
||||
|
||||
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
|
||||
builds, configured tests, product-version checks and package/source verification
|
||||
for the exact tagged revision. Downloads include checksums, a platform test
|
||||
report and corresponding source with pinned open-source dependencies.
|
||||
|
||||
Several fixes were reproduced on testers' savegames and checked with test
|
||||
programmes; native Windows/macOS gameplay acceptance is not established by CI
|
||||
builds. Open points: the "player card: original atlas bounds" error (#77),
|
||||
KI-Tipp after a match (#69), sporadic double clicks (#58) and the macOS match
|
||||
scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,35 @@
|
||||
# OpenBMH Classic 1.0.7
|
||||
|
||||
This patch fixes national-team desk screens and two small interface details
|
||||
reported by testers. It requires the player's own game installation. Extended
|
||||
development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.6
|
||||
|
||||
- **National-team desk.** Other Games and Top Scorers open again; both screens
|
||||
are identified by the home club, so the desk is no longer rejected as stale
|
||||
or as a mismatched acknowledgement.
|
||||
- **Computer tip.** After the results of a round are known the button is only
|
||||
pressed and released, as in the original, instead of raising an engine error.
|
||||
- **Manager selection.** JA of the confirmation question is shown pushed in
|
||||
briefly after it is clicked.
|
||||
|
||||
## Validation and human QA
|
||||
|
||||
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
|
||||
builds, configured tests, product-version checks and package/source verification
|
||||
for the exact tagged revision. Downloads include checksums, a platform test
|
||||
report and corresponding source with pinned open-source dependencies.
|
||||
|
||||
The fixes were checked with the desktop, controller and manager tests; native
|
||||
Windows/macOS gameplay acceptance is not established by CI builds. Open points
|
||||
from 1.0.6 remain: the "player card: original atlas bounds" error (#77),
|
||||
sporadic double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,43 @@
|
||||
# OpenBMH Classic 1.0.8
|
||||
|
||||
This patch makes the bank credit annuity identical on every platform. It
|
||||
requires the player's own game installation. Extended development remains
|
||||
separate in [OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Changes since 1.0.7
|
||||
|
||||
- **Bank credit annuity.** The original computes the monthly payment with
|
||||
x87 floating point (64-bit mantissa at every step, one final store to a
|
||||
double). The host `long double` is only 64 bits wide on Windows (MSVC) and
|
||||
on Apple silicon, so the payment differed by 1 for roughly 0.2 % of loans of
|
||||
one to sixty million. The chain is now evaluated with integer arithmetic and
|
||||
gives the original's result on every platform.
|
||||
|
||||
## Validation and human QA
|
||||
|
||||
Release publication requires successful Windows x64, macOS ARM64 and Linux x64
|
||||
builds, configured tests, product-version checks and package/source verification
|
||||
for the exact tagged revision. Downloads include checksums, a platform test
|
||||
report and corresponding source with pinned open-source dependencies.
|
||||
|
||||
This release follows a quality pass that ran single routines of the original
|
||||
programme in an emulator and compared them with the engine on whole savegames,
|
||||
with boundary values and a deliberately wrong result per rule that must fail.
|
||||
Compared without a difference: the random generator, market value and salary,
|
||||
the willingness of clubs to sell, the rating of transfer bids, club mood and
|
||||
flags at the end of a season, the order of national cup ties, weekly advertising
|
||||
offers, facility ageing and damage, offers to managers, weekly statistics,
|
||||
familiarity decay, squad training and daily interest. The one difference found
|
||||
is the annuity fixed above. Rules that depend on screens, dialogs or the master
|
||||
database were not part of this pass.
|
||||
|
||||
Native Windows/macOS gameplay acceptance is not established by CI builds. Open
|
||||
points from earlier releases remain: the "player card: original atlas bounds"
|
||||
error (#77), sporadic double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -0,0 +1,65 @@
|
||||
# OpenBMH Classic 1.0.9
|
||||
|
||||
This release aligns the engine's hard-coded rules with BMH 2026-27 DIAMOND
|
||||
Edition 3.7. It requires the player's own game installation. Extended
|
||||
development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## Why
|
||||
|
||||
The engine had been checked against an older Diamond build whose executable
|
||||
differs from 3.7 in about 2,700 bytes (50 code ranges, the Diamond patch area
|
||||
and 64 data bytes). Rules from v2.24, an older Diamond and 3.7 were therefore
|
||||
mixed. The routines of the real 3.7 executable were run in an emulator and
|
||||
compared with the engine; every difference found was ported and documented.
|
||||
|
||||
## Changes since 1.0.8
|
||||
|
||||
- **Injuries and cards.** New injury tables (thresholds and durations), the
|
||||
injury history factor 1.25, doctor and insurance caps, and the foul, booking
|
||||
and red-card chances of 3.7.
|
||||
- **Economy.** Credit limit 8,000,000, transfer fee base, DFB fee, advertising
|
||||
base, start capital, bankruptcy limit, championship and cup premiums,
|
||||
periphery prices, contract talk limit and training injury range.
|
||||
- **Weekly processing.** Retirement chance, side rating rhythm for human and
|
||||
computer managers, facility values, per-visitor income and the season
|
||||
ticket price.
|
||||
- **Youth academy.** 3.7 generation with its monthly budget gate. An age check
|
||||
was inverted in the port (older players were recycled the wrong way round);
|
||||
this is fixed.
|
||||
- **Season end.** Retirement and leave rules for the player slots.
|
||||
- **Live match statistics.** The chance counters at the bottom of the live
|
||||
matchday screen counted a chance as soon as the engine logged it, before the
|
||||
presentation started. They are now held back like the score and appear with
|
||||
the result of the chance.
|
||||
|
||||
## What was measured, what was derived
|
||||
|
||||
Compared with the 3.7 executable without any difference (boundary values and a
|
||||
deliberately wrong result per rule that must fail): random generator, market
|
||||
value, bank annuity, club mood and flags, cup tie order, advertising offers,
|
||||
bid rating, poaching, facility ageing and damage, manager offers, weekly
|
||||
statistics, familiarity decay, squad training, daily interest, youth academy,
|
||||
month change, new transfer list entries, and injuries including doctor and
|
||||
insurance (932 runs).
|
||||
|
||||
Derived from the constants of the 3.7 code but **not** measured in the
|
||||
emulator: foul and card chances in a match, and several economy numbers.
|
||||
Not covered: the complete weekly processing routine, and the amounts of newly
|
||||
created transfer bids (the original reads a stale stack value there; documented
|
||||
in the source as a known gap).
|
||||
|
||||
## Open points
|
||||
|
||||
Reported by the Diamond author and not changed here: the bug in "fetch player
|
||||
from transfer market / check offers" (exact steps still to be reproduced).
|
||||
Earlier open points remain: the
|
||||
"player card: original atlas bounds" error (#77), sporadic double clicks (#58)
|
||||
and the macOS match scene speed (#70).
|
||||
|
||||
## Known limits
|
||||
|
||||
The compatibility and long-career limits documented for
|
||||
[1.0.3](../1.0.3/RELEASE_NOTES.md) remain. Football Limited is experimental;
|
||||
its original V2.20 save layout remains unsupported. Keep backups of saves.
|
||||
macOS packages are unsigned terminal executables, not notarised app bundles.
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// All-or-nothing wrapper for one UI window action on a CareerSession (used by
|
||||
// desktop_actions.cpp and window_actions.cpp). It snapshots the game state, the RNG and the
|
||||
// revision counter, runs the action and, if the action returns false or throws, restores
|
||||
// all three, so a rejected action leaves no half-applied change behind.
|
||||
// apply_native() is the variant for owners that keep their state in CareerSession::state().
|
||||
// Header-only; owns no state of its own.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
+369
@@ -0,0 +1,369 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// struct App: the running window program (see the comment on the class). Internal header of the game
|
||||
// program: included by src/app/main.cpp and the app_*.cpp files that define the member functions.
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/start_screen.hpp"
|
||||
#include "ui/live_timing.hpp"
|
||||
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
|
||||
// career initialised by the engine (app/career_session.hpp) and its desk.
|
||||
//
|
||||
// Usage: openbmh_play [<game>] [--seed <Watcom seed>] [--save-directory <directory>] [--mute] [--volume <0..1>] [--music] [--live-frame-ms <0..1000>]
|
||||
// <game> (also as --data <game>): the game directory, its BMH.EXE, or a ZIP/7z archive with
|
||||
// exactly one game (src/launch). Without a game the system's file dialog asks for one.
|
||||
#include <SDL.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <deque>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "app/canvas.hpp"
|
||||
#include "app/controller.hpp"
|
||||
#include "app/quit_confirmation.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include "launch/file_dialog.hpp"
|
||||
#include "launch/game_data.hpp"
|
||||
#include "version.hpp"
|
||||
#include "app/video_session.hpp"
|
||||
#include "app/live_matchday_events.hpp"
|
||||
#include "app/debug_log.hpp"
|
||||
#include "app/pitch_pointer.hpp"
|
||||
#include "audio/playback.hpp"
|
||||
#include "app/audio.hpp"
|
||||
#include "formats/palette.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
#include "ui/flow.hpp"
|
||||
#include "ui/source_hold.hpp"
|
||||
#include "ui/live_matchday.hpp"
|
||||
#include "ui/live_reality.hpp"
|
||||
#include "ui/reality_reporter.hpp"
|
||||
#include "ui/league_table.hpp"
|
||||
#include "ui/league_pairings.hpp"
|
||||
#include "ui/other_games.hpp"
|
||||
#include "ui/process_timer.hpp"
|
||||
#include "ui/strengths.hpp"
|
||||
#include "ui/league_table_range_dialog.hpp"
|
||||
#include "ui/settings.hpp"
|
||||
#include "ui/lineup.hpp"
|
||||
#include "ui/tactics.hpp"
|
||||
#include "ui/sportschau.hpp"
|
||||
#include "ui/incoming_transfer.hpp"
|
||||
#include "ui/outgoing_transfer.hpp"
|
||||
#include "ui/pending_offer.hpp"
|
||||
#include "ui/season_entrants.hpp"
|
||||
#include "ui/season_promotion.hpp"
|
||||
#include "ui/cup_draw.hpp"
|
||||
#include "ui/club_info.hpp"
|
||||
#include "ui/team_statistics.hpp"
|
||||
#include "ui/club_player_detail.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
#include "ui/game_end_alternate.hpp"
|
||||
#include "ui/game_end_tax_animation.hpp"
|
||||
#include "ui/contracts.hpp"
|
||||
#include "game/month.hpp"
|
||||
#include "game/driver.hpp"
|
||||
#include "game/messages.hpp"
|
||||
|
||||
// (this internal header is only included by the files of the game program; they share these two)
|
||||
namespace fs = std::filesystem;
|
||||
using namespace bmh;
|
||||
|
||||
// Reattach the native editor when an in-game filename field takes focus. Cocoa
|
||||
// owns a field-editor responder in addition to SDL's TEXTINPUT enable flag.
|
||||
// Moves the platform text-input rectangle over the save-file name field (logical canvas
|
||||
// coordinates 106,209 to 262,219 converted to window pixels) and restarts text input.
|
||||
// Called when an in-game filename field gains focus.
|
||||
inline void focus_filename_input(SDL_Renderer* renderer) {
|
||||
int left, top, right, bottom;
|
||||
SDL_RenderLogicalToWindow(renderer, 106, 209, &left, &top);
|
||||
SDL_RenderLogicalToWindow(renderer, 262, 219, &right, &bottom);
|
||||
const SDL_Rect field{left, top, std::max(1, right - left), std::max(1, bottom - top)};
|
||||
SDL_StopTextInput();
|
||||
SDL_SetTextInputRect(&field);
|
||||
SDL_StartTextInput();
|
||||
}
|
||||
|
||||
// The running game program: everything main() does after the window is set up.
|
||||
//
|
||||
// main() used to hold all of this in one function of about 4,300 lines: the state of the window
|
||||
// program as locals and every presenter (season end, Sportschau, tax, promotion, cup draw, club
|
||||
// dialogs, live match, ...) as a lambda capturing them. App holds the same things as members: the
|
||||
// objects main() created (as references under their old names), the state, one member function per
|
||||
// former lambda in the original order, and run() with the statements that stood between them (the
|
||||
// wiring of the hooks, the title screen, the event loop, the tear-down). The code inside moved
|
||||
// unchanged.
|
||||
//
|
||||
// The member functions are defined by topic:
|
||||
// app_services.cpp the timers and deadlines the event loop serves between inputs (process timer, table, balance, pairings, stadium, friendly match pickers)
|
||||
// app_season.cpp season end and season start (season pictures, contract expiry, tax, promotion, highscore, entrants, cup draw)
|
||||
// app_sportschau.cpp the Sportschau (intro, replay scenes, fixtures, winner, awards, team info) and its waits
|
||||
// app_transfer.cpp transfers (incoming offers, decisions, pending offers, market sales, loan returns, poaching)
|
||||
// app_club.cpp the club dialogs (club information, player list, player detail, statistics)
|
||||
// app_notices.cpp notices and questions over a screen (construction, season tickets, advertising renewal, national friendly, environment)
|
||||
// app_live.cpp the live match (minute display, the observer with its interventions, the event animations, reality mode, phase results)
|
||||
// app_run.cpp handle() - one request through the controller - and run() - wiring, title screen, event loop, tear-down
|
||||
struct App { fs::path& data;
|
||||
fs::path& save_directory;
|
||||
uint32_t& seed;
|
||||
bool& music_enabled;
|
||||
int& live_frame_ms;
|
||||
bool& live_frame_ms_explicit;
|
||||
bool& english_game;
|
||||
const Palette& palette;
|
||||
ui::StartupFlow& flow;
|
||||
std::unique_ptr<app::CareerSession>& session;
|
||||
uint64_t& revision;
|
||||
openbmh::audio::Playback& playback;
|
||||
std::string& audio_error;
|
||||
std::optional<uint64_t>& audio_session;
|
||||
SDL_Window*& window;
|
||||
SDL_Renderer*& renderer;
|
||||
SDL_Texture*& texture;
|
||||
app::PitchPointer& pitch_pointer;
|
||||
std::vector<uint32_t>& pixels;
|
||||
app::Canvas& canvas;
|
||||
ui::LiveMatchdayScreen& live_screen;
|
||||
ui::RealityReporterPanel& reality_reporter;
|
||||
ui::SportschauIntro& sportschau_intro;
|
||||
ui::MatchdayIntro& matchday_intro;
|
||||
ui::SportschauEleven& sportschau_eleven;
|
||||
ui::SportschauTeamInfo& sportschau_team_info;
|
||||
ui::CompetitionWinnerScreen& competition_winner;
|
||||
const LeImage& season_exe;
|
||||
app::QuitConfirmation& quit_confirmation;
|
||||
app::OriginalMouseSound& mouse_sound;
|
||||
const TextDb& season_texts;
|
||||
const std::chrono::steady_clock::time_point& process_clock_origin;
|
||||
auto process_source_seconds() -> uint64_t;
|
||||
ui::ProcessTimer process_timer;
|
||||
// Identifies which session/manager/day a process timer belongs to.
|
||||
struct ProcessTimerOwner {
|
||||
uint64_t session;
|
||||
int manager;
|
||||
uint32_t day;
|
||||
bool operator==(const ProcessTimerOwner&) const = default;
|
||||
};
|
||||
std::optional<ProcessTimerOwner> process_timer_owner;
|
||||
std::optional<ui::ProcessTimer::Sample> process_timer_frame;
|
||||
auto process_timer_image(Image image) -> bmh::Image;
|
||||
auto poll_process_timer(bool update_texture, bool present) -> bool;
|
||||
// `running` ends every loop below; `dirty` requests a redraw of the flow screen.
|
||||
bool running = true, dirty = true;
|
||||
// Remembers the current left mouse press (position, time, screen, source tick, revision)
|
||||
// so the matching release can be judged against it later.
|
||||
struct Press {
|
||||
int x, y;
|
||||
uint32_t time;
|
||||
std::string screen;
|
||||
uint64_t source_tick, revision;
|
||||
bool pitch_hold_attempted = false;
|
||||
};
|
||||
std::optional<Press> press;
|
||||
std::optional<std::string> right_press_screen;
|
||||
auto transfer_view(const GameState& state, const TransferOfferListView& offers, int viewer_manager) -> bmh::ui::IncomingTransferDecisionView;
|
||||
std::optional<Image> season_backdrop;
|
||||
auto present_season(const Image& image, const char* title, const Palette* palette_override = nullptr) -> void;
|
||||
auto present_desk_record_points() -> void;
|
||||
auto contract_expiry_presenter(GameState& staged, WatcomRandom& random, int manager, int expired_row) -> int;
|
||||
auto game_end_options(const GameState& state) -> bmh::ui::GameEndRenderOptions;
|
||||
auto wait_season_ack() -> void;
|
||||
auto wait_sportschau_ack() -> void;
|
||||
auto source_tick_wait(unsigned ticks) -> void;
|
||||
auto wait_source_retraces(unsigned count) -> void;
|
||||
// --- Sportschau (results show) presenters: the engine calls these hooks synchronously. ---
|
||||
SportschauPresentationHooks sportschau_presenter;
|
||||
auto sportschau_context(const GameState& state) -> bmh::ui::SportschauReportContext;
|
||||
std::optional<ui::SportschauMatchReport> sportschau_replay_screen;
|
||||
size_t sportschau_step_index = 0;
|
||||
auto show_tax(const GameState& state, const SeasonTaxEvent& event) -> bool;
|
||||
// Hooks for the season tax events: question via show_tax, notices and the animation below.
|
||||
SeasonTaxHooks tax_presenter;
|
||||
auto wait_promotion_time(Uint32 milliseconds) -> void;
|
||||
// Presents the promotion/relegation table animation (39 steps) unless the manager's
|
||||
// animation-skip flag is set.
|
||||
SeasonPromotionHook promotion_presenter;
|
||||
auto present_pending_dialog(const GameState& state, ui::TaxDialogProjection view, const Image& backdrop, const char* title, std::optional<ui::GameEndRenderOptions> effective_options = {}) -> PendingOfferAnswer;
|
||||
auto loan_return_presenter(GameState& state, WatcomRandom&, int manager, const std::string& question) -> int;
|
||||
auto make_pending_offer_hooks(Image backdrop) -> bmh::PendingOfferHooks;
|
||||
auto make_market_sale_hooks(Image backdrop) -> bmh::HumanBuyerSaleHooks;
|
||||
// Forward declarations: the club, player and statistics presenters call each other, so
|
||||
// they are assigned further below.
|
||||
std::function<bool(app::ClubModalServices&, int)> present_club_information;
|
||||
std::function<std::optional<bool>(app::ClubModalServices&,const ClubPlayerDetailSelection&,const Image&)> present_player_detail;
|
||||
auto loan_return_offer_presenter(GameState& staged, GameRandom& game_random, WatcomRandom& watcom_random, app::ClubModalServices& services, int manager, int source_slot, int list_entry, const HumanBuyerSaleHooks& sale_hooks) -> int;
|
||||
// Assigned to the genuine Source submodal presenters below before the
|
||||
// controller advances a new career or annual transition.
|
||||
std::function<bool(app::ClubModalServices&, const ui::ClubInfoRequest&, const Image&)> present_club_player;
|
||||
std::function<void(app::ClubModalServices&, int, const Image&)> present_club_statistics;
|
||||
bool poach_selection_active=false;
|
||||
std::optional<ClubPlayerDetailSelection> poach_card_selection;
|
||||
// Selector the engine calls while the player chooses a player to poach: shows league table
|
||||
// pages, the range dialog, club info and player cards in nested modal loops. Returns the
|
||||
// chosen player, or std::nullopt when closed or the process timer expired.
|
||||
app::CareerSession::PoachPlayerSelector poach_player_selector;
|
||||
// CupDrawFromGame local_14 belongs to the whole linked-record traversal. A
|
||||
// skipped reveal still presents every overview; a normal reveal ACK or
|
||||
// the right press leaving an overview does not skip subsequent groups.
|
||||
bool group_reveal_skipped = false;
|
||||
// Presents a cup draw: the reveal animation (draw phase) or the overview of a round.
|
||||
// In the overview a left click on a club opens its club info, a right click leaves.
|
||||
SeasonCupDrawHook cup_draw_presenter;
|
||||
auto show_highscore(const GameState& state, bool display) -> void;
|
||||
std::optional<Uint64> timed_notice_presented_at;
|
||||
std::optional<Uint8> timed_notice_release;
|
||||
// --- the request in service (state of App::handle and of the presenters it passes on) ---
|
||||
// handle() is never re-entered: every presenter below runs inside one handle() call.
|
||||
|
||||
bool live_skipped;
|
||||
uint64_t live_overview_sequence;
|
||||
std::optional<Image> outcome_backdrop;
|
||||
auto present_live_lineup(int minute, MatchEngine& engine, std::vector<MatchGroup>& groups, GameState& state, uint64_t& live_revision, int selected_team, int selected_opponent, const app::LiveLineupDispatcher& dispatch, const app::LiveTacticsDispatcher& dispatch_tactic, const app::LivePitchDispatcher& dispatch_pitch, const app::LiveInterventionScopeDispatcher& dispatch_scope, bool live_skipped, bool event_origin) -> bool;
|
||||
// Callback type through which the overview screen asks the engine for its actions.
|
||||
using RunningOverviewDispatcher = std::function<std::optional<app::CareerSession::LiveOverviewDispatch>(
|
||||
const app::CareerSession::LiveOverviewAction&, std::string&,
|
||||
const app::TransferOfferTeamInfoPresenter&)>;
|
||||
auto present_running_overview(std::optional<app::CareerSession::LiveOverviewProjection> projection, const GameState& state, uint64_t& live_revision, const RunningOverviewDispatcher& dispatch_overview, const PhaseResultRequest* phase_result) -> bool;
|
||||
// State used by the live-match presenters below.
|
||||
ui::LiveScoreReveal live_score_reveal;
|
||||
std::optional<ui::LiveChanceProjection> live_chance_context;
|
||||
std::unique_ptr<ui::RealityFieldScreen> reality_field;
|
||||
ui::RealityReporterLayoutState reality_layout;
|
||||
Image reality_pristine, reality_surface;
|
||||
Palette reality_colors;
|
||||
auto present_live_minute(int minute, const std::vector<MatchGroup>& groups, const GameState& state) -> void;
|
||||
auto choose_transfer_offer(const GameState& state, const TransferOfferListView& offers) -> int;
|
||||
auto present_transfer_decision(const GameState& state, const TransferDecisionEvent& decision) -> void;
|
||||
auto present_season_checkpoint(const char* checkpoint, const GameState& state) -> void;
|
||||
auto show_club_information(app::ClubModalServices& services,int team,const Image&) -> bool;
|
||||
auto show_player_detail(app::ClubModalServices& services,const ClubPlayerDetailSelection& selection,const Image& parent) -> bool;
|
||||
auto present_construction_notice(const GameState& staged, const ConstructionNotice& notice) -> void;
|
||||
auto present_ticket_compensation_notice(const GameState& staged, const SeasonTicketCompensationNotice& notice) -> void;
|
||||
auto ask_advertising_renewal(const GameState& staged, const AdvertisingRenewal& renewal, const Image& backdrop) -> app::CareerSession::AdvertisingRenewalPresentation;
|
||||
auto present_poach_notices(const GameState& staged,const PoachStart& attempt,const Image& backdrop) -> void;
|
||||
auto ask_national_friendly(const GameState& staged,ui::TaxDialogProjection view,const Image& backdrop) -> std::optional<bool>;
|
||||
auto observe_live_minute(int minute, MatchEngine& engine, std::vector<MatchGroup>& groups, GameState& state, uint64_t& live_revision, const app::LiveLineupDispatcher& dispatch, const app::LiveTacticsDispatcher& dispatch_tactic, const app::LivePitchDispatcher& dispatch_pitch, const app::LiveInterventionScopeDispatcher& dispatch_scope) -> void;
|
||||
auto present_environment_notice(const GameState& staged, ui::TaxDialogProjection view, const Image& backdrop) -> bool;
|
||||
auto present_live_event_lineup(const LiveMatchEvent& event, MatchEngine& engine, std::vector<MatchGroup>& groups, GameState& state, uint64_t& live_revision, const app::LiveLineupDispatcher& dispatch, const app::LiveTacticsDispatcher& dispatch_tactic, const app::LivePitchDispatcher& dispatch_pitch, const app::LiveInterventionScopeDispatcher& dispatch_scope) -> void;
|
||||
auto animate_ball(const LiveBallEvent& event, const std::vector<MatchGroup>& groups, const GameState& state) -> void;
|
||||
auto animate_chance(const LiveChanceEvent& event, const std::vector<MatchGroup>& groups, const GameState& state) -> void;
|
||||
auto animate_shot(const LiveShotEvent& event, const std::vector<MatchGroup>& groups, const GameState& state) -> void;
|
||||
auto animate_set_piece(const LiveSetPieceEvent& event, const std::vector<MatchGroup>& groups, const GameState& state) -> void;
|
||||
auto animate_booking(const LiveBookingEvent& event, const std::vector<MatchGroup>& groups, const GameState& state) -> void;
|
||||
auto animate_shootout(const LiveShootoutEvent& event, const std::vector<MatchGroup>& groups, const GameState& state) -> void;
|
||||
auto present_reality(const LiveRealityEvent& event, const std::vector<MatchGroup>& groups, const GameState& state) -> bool;
|
||||
auto present_phase_result(const PhaseResultRequest& request, const std::vector<MatchGroup>& groups, const GameState& state) -> void;
|
||||
auto handle(const ui::FlowResult& r) -> void;
|
||||
auto present_formation_save_feedback() -> void;
|
||||
auto service_pitch_hold() -> void;
|
||||
const std::chrono::steady_clock::time_point pairings_clock_start = std::chrono::steady_clock::now();
|
||||
auto pairings_source_seconds() -> uint64_t;
|
||||
auto balance_source_milliseconds() -> uint64_t;
|
||||
auto family_table_source_units() -> uint64_t;
|
||||
auto mark_family_table_presented() -> void;
|
||||
auto present_family_table_redraw() -> void;
|
||||
// A key typed for the table range dialog or toto calculator, tagged with its owner so
|
||||
// that keys for a screen that has since changed are dropped.
|
||||
struct TableRangeKey {
|
||||
std::string key;
|
||||
ui::StrengthsIdentity identity;
|
||||
int toto_manager = -1;
|
||||
uint64_t toto_revision = 0;
|
||||
};
|
||||
std::deque<TableRangeKey> table_range_keys;
|
||||
auto queue_table_range_event(const SDL_Event& event) -> bool;
|
||||
auto service_family_table() -> void;
|
||||
// Which balance screen state was last presented (to avoid redrawing identical frames).
|
||||
std::optional<ui::BalanceIdentity> presented_balance;
|
||||
bool presented_balance_notice=false;
|
||||
auto present_balance_redraw() -> void;
|
||||
auto service_balance_timer() -> void;
|
||||
// KB6 waits start after the pressed/final calculator image reaches SDL.
|
||||
// Keep a matching physical UP until the four-tick press is over; N's
|
||||
// last calculator frame stays visible through its fifty-tick wait.
|
||||
// Pending release of a button pressed on the stadium calculator.
|
||||
struct CalculatorRelease {
|
||||
SDL_MouseButtonEvent button;
|
||||
uint64_t scope = 0, sequence = 0;
|
||||
};
|
||||
std::optional<CalculatorRelease> calculator_release;
|
||||
std::optional<uint64_t> calculator_tick_anchor;
|
||||
// A calculator key tagged with the owner state it was typed for.
|
||||
struct CalculatorKey {
|
||||
std::string key;
|
||||
uint64_t revision = 0, scope = 0, sequence = 0;
|
||||
};
|
||||
std::deque<CalculatorKey> calculator_keys;
|
||||
auto queue_calculator_key(std::string key) -> void;
|
||||
auto queue_calculator_event(const SDL_Event& event) -> bool;
|
||||
auto mark_stadium_calculator_presented() -> void;
|
||||
auto service_stadium_calculator() -> void;
|
||||
// Which pairings page was last presented (to avoid redrawing identical frames).
|
||||
std::optional<ui::LeaguePairingsIdentity> presented_pairings;
|
||||
auto present_pairings_redraw() -> void;
|
||||
auto service_pairings_timer() -> void;
|
||||
//PresentManagerDialog presents its question before polling2de66. Bind the actual
|
||||
//freshly drawn frame, never an old texture or a preceding modal ACK.
|
||||
// Frame identities: each tuple names the owner state (session, manager, scope, sequence,
|
||||
// revision, ...) of a modal question that was actually drawn. A process-timer deadline
|
||||
// is applied only to a frame that has been presented, never to a stale one.
|
||||
using StadiumQuestionFrame = std::array<uint64_t,5>;
|
||||
std::optional<StadiumQuestionFrame> presented_stadium_question;
|
||||
auto stadium_question_frame() -> std::optional<StadiumQuestionFrame>;
|
||||
auto mark_stadium_question_presented() -> void;
|
||||
auto service_stadium_deadline() -> bool;
|
||||
auto service_idle_stadium_deadline() -> void;
|
||||
// Same idea for the national friendly picker.
|
||||
using NationalPickerFrame = std::pair<uint64_t,ui::NationalFriendlyUiOwner>;
|
||||
std::optional<NationalPickerFrame> presented_national_picker;
|
||||
auto national_picker_frame() -> std::optional<NationalPickerFrame>;
|
||||
auto mark_national_picker_presented() -> void;
|
||||
using FriendlyPickerFrame = std::array<uint64_t,5>;
|
||||
std::optional<FriendlyPickerFrame> presented_friendly_picker;
|
||||
auto friendly_picker_frame() -> std::optional<FriendlyPickerFrame>;
|
||||
auto mark_friendly_picker_presented() -> void;
|
||||
// Same idea for the friendly match calendar.
|
||||
using FriendlyCalendarFrame = std::array<uint64_t,5>;
|
||||
std::optional<FriendlyCalendarFrame> presented_friendly_calendar;
|
||||
auto friendly_calendar_frame() -> std::optional<FriendlyCalendarFrame>;
|
||||
auto mark_friendly_calendar_presented() -> void;
|
||||
// Same idea for the friendly match question.
|
||||
using FriendlyQuestionFrame = std::array<uint64_t,8>;
|
||||
std::optional<FriendlyQuestionFrame> presented_friendly_question;
|
||||
auto friendly_question_frame() -> std::optional<FriendlyQuestionFrame>;
|
||||
auto mark_friendly_question_presented() -> void;
|
||||
auto service_friendly_question_deadline() -> bool;
|
||||
auto service_process_timer() -> void;
|
||||
// filename_input_active: the save/load filename field already has focus.
|
||||
// setup_button_down: [0] left, [1] right button pressed while on the setup screen.
|
||||
bool filename_input_active = false;
|
||||
std::array<bool, 2> setup_button_down{};
|
||||
auto present_sportschau_intro(const GameState&, const SportschauIntroView&) -> void;
|
||||
auto present_matchday_intro(const GameState&, const MatchdayIntroView& view) -> void;
|
||||
auto present_sportschau_replay_step(const GameState& state, const SportschauFixtureView& fixture, const SportschauReportStep& step) -> bool;
|
||||
auto present_sportschau_scene(const GameState& state, const SportschauFixtureView& fixture, const SportschauSceneView& scene) -> void;
|
||||
auto present_sportschau_fixture(const GameState& state, const SportschauFixtureView& fixture) -> void;
|
||||
auto present_competition_winner(const GameState& state, const CompetitionWinnerView& view) -> void;
|
||||
auto present_sportschau_awards(const GameState& state, const SportschauAwardsView& view) -> void;
|
||||
auto present_sportschau_team_info(const GameState& state, const SportschauTeamInfoView& view) -> void;
|
||||
auto present_tax_event(const GameState& state, const SeasonTaxEvent& event) -> void;
|
||||
auto present_promotion(const GameState& state, const SeasonPromotionEvent& event) -> void;
|
||||
auto club_information_dialog(app::ClubModalServices& services, int team) -> bool;
|
||||
auto club_player_dialog(app::ClubModalServices& services, const ui::ClubInfoRequest& selected, const Image& parent_image) -> bool;
|
||||
auto player_detail_dialog(app::ClubModalServices& services,const ClubPlayerDetailSelection& selection,const Image& parent_image) -> std::optional<bool>;
|
||||
auto club_statistics_dialog(app::ClubModalServices& services, int team, const Image& parent_frame) -> void;
|
||||
auto select_poach_player(app::CareerSession& staged,app::ClubModalServices&,int manager, uint64_t& selection_revision,const Image& transfer_backdrop) -> std::optional<ClubPlayerDetailSelection>;
|
||||
auto present_cup_draw(const GameState& state, const SeasonCupDrawEvent& event) -> void;
|
||||
auto run() -> int;
|
||||
};
|
||||
@@ -0,0 +1,339 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// App: the club dialogs (club information, player list, player detail, statistics).
|
||||
// (moved out of main.cpp unchanged; the class is declared in app/app.hpp)
|
||||
#include "app/app.hpp"
|
||||
|
||||
// Callback: club information screen (true if the program is still running).
|
||||
auto App::show_club_information(app::ClubModalServices& services,int team,const Image&) -> bool {
|
||||
return present_club_information(services,team) && running;
|
||||
}
|
||||
|
||||
// Next callback: player detail card.
|
||||
auto App::show_player_detail(app::ClubModalServices& services,const ClubPlayerDetailSelection& selection,const Image& parent) -> bool {
|
||||
// Direct1b556 already owns persistent bbcde=1. The shared
|
||||
//ClubPlayerDetailFromGame presenter never restores a temporary club mode here.
|
||||
return present_player_detail(services,selection,parent).has_value() && running;
|
||||
}
|
||||
|
||||
// Modal club information screen for `team`. Returns true when it was left normally (or
|
||||
// the process timer expired), false when the program is quitting.
|
||||
auto App::club_information_dialog(app::ClubModalServices& services, int team) -> bool {
|
||||
if (!running) return false;
|
||||
//ClubInfoFromGame owns the opening DOWN and consumes its paired UP inside
|
||||
// this synchronous loop. The parent must not retain a held press
|
||||
// after that UP has already been consumed by the child.
|
||||
// The child loop consumes the matching release itself.
|
||||
press.reset();
|
||||
ui::ClubInfoView selected_view = ui::ClubInfoView::data_a;
|
||||
std::unique_ptr<ui::ClubInfoScreen> club_screen;
|
||||
// Rebuilds the club screen from the current game state.
|
||||
const auto redraw = [&] {
|
||||
std::string error;
|
||||
ClubInfoEntry snapshot;
|
||||
if (team == kNoTeam || team < season_exe.u16(::bmh::layout::LeagueClubCount)) {
|
||||
snapshot = services.enter_club(team);
|
||||
}
|
||||
auto projection = ui::club_info_from_game(services.state(), team, snapshot,
|
||||
season_exe, season_texts);
|
||||
projection.view = selected_view;
|
||||
club_screen = std::make_unique<ui::ClubInfoScreen>(data, std::move(projection));
|
||||
};
|
||||
// Presents the club screen; the window title encodes the view state.
|
||||
const auto show = [&] {
|
||||
auto title = "OpenBMH - cup_club_info_" + std::to_string(team) + "_" +
|
||||
std::to_string(int(selected_view)) + "_category_" +
|
||||
std::to_string(club_screen->projection().category);
|
||||
if (club_screen->pressed_button())
|
||||
title += "_pressed_" + std::to_string(int(*club_screen->pressed_button()));
|
||||
else if (club_screen->hovered_row())
|
||||
title += "_hover_" + std::to_string(*club_screen->hovered_row());
|
||||
present_season(club_screen->render(), title.c_str());
|
||||
};
|
||||
redraw(); show();
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
// True when the process timer ran out and no button is currently held down.
|
||||
const auto deadline_expired = [&] {
|
||||
return !club_screen->pressed_button() && poll_process_timer(true, true);
|
||||
};
|
||||
while (running) {
|
||||
if (deadline_expired()) return true; //ClubInfoFromGame event8 returns to its owning caller.
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return false; }
|
||||
if (deadline_expired()) return true;
|
||||
ui::ClubInfoRequest request;
|
||||
if (input.type == SDL_MOUSEMOTION) {
|
||||
if (club_screen->move(input.motion.x, input.motion.y)) show();
|
||||
} else if (input.type == SDL_MOUSEBUTTONDOWN) {
|
||||
if (input.button.button == SDL_BUTTON_RIGHT) return true;
|
||||
if (input.button.button != SDL_BUTTON_LEFT) continue;
|
||||
(void)club_screen->move(input.button.x, input.button.y);
|
||||
request = club_screen->pointer_down(input.button.x, input.button.y);
|
||||
if (request.kind == ui::ClubInfoRequestKind::none) {
|
||||
club_screen->press(input.button.x, input.button.y);
|
||||
show();
|
||||
}
|
||||
} else if (input.type == SDL_MOUSEBUTTONUP && input.button.button == SDL_BUTTON_LEFT) {
|
||||
request = club_screen->release(input.button.x, input.button.y);
|
||||
show();
|
||||
}
|
||||
switch (request.kind) {
|
||||
case ui::ClubInfoRequestKind::none: break;
|
||||
case ui::ClubInfoRequestKind::close: return true;
|
||||
case ui::ClubInfoRequestKind::toggle_view:
|
||||
selected_view = selected_view == ui::ClubInfoView::data_a
|
||||
? ui::ClubInfoView::data_b : ui::ClubInfoView::data_a;
|
||||
redraw(); show();
|
||||
break;
|
||||
case ui::ClubInfoRequestKind::change_category: {
|
||||
std::string error;
|
||||
const auto applied = services.change_category(team, request.requested_category);
|
||||
// Source changes the icon without re-entering2af41 or
|
||||
// altering the list's owned pre-cleanup drawing flags.
|
||||
auto projection = club_screen->projection();
|
||||
projection.category = applied;
|
||||
club_screen = std::make_unique<ui::ClubInfoScreen>(data, std::move(projection));
|
||||
show();
|
||||
break;
|
||||
}
|
||||
case ui::ClubInfoRequestKind::open_statistics:
|
||||
if (!present_club_statistics) throw FormatError("club statistics presenter is unavailable");
|
||||
present_club_statistics(services, team, club_screen->render());
|
||||
if (!running) return false;
|
||||
redraw(); show();
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
break;
|
||||
case ui::ClubInfoRequestKind::open_player_detail:
|
||||
if (!present_club_player) throw FormatError("club player presenter is unavailable");
|
||||
if (present_club_player(services, request, club_screen->render())) return true;
|
||||
if (!running) return false;
|
||||
redraw(); show();
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Opens the player detail card for a row chosen in the club list. The runtime input mode
|
||||
// byte is switched for the card and restored afterwards (RAII helper below).
|
||||
auto App::club_player_dialog(app::ClubModalServices& services, const ui::ClubInfoRequest& selected, const Image& parent_image) -> bool {
|
||||
if (!running) return false;
|
||||
const ClubPlayerDetailSelection selection{selected.runtime_team, selected.player_id,
|
||||
selected.rendered_row, selected.physical_row, selected.human_loan_index};
|
||||
const uint8_t prior_mode = services.runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField);
|
||||
const uint8_t input_mode = club_player_detail_input_mode(prior_mode);
|
||||
// Restores the saved runtime byte when the card is left, including by exception.
|
||||
struct PlayerInputModeRestore {
|
||||
app::ClubModalServices& services;
|
||||
uint8_t prior;
|
||||
~PlayerInputModeRestore() { services.set_runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField, prior); }
|
||||
} mode_restore{services, prior_mode};
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField, input_mode);
|
||||
if(!present_player_detail)throw FormatError("generic player presenter unavailable");
|
||||
return present_player_detail(services,selection,parent_image).value_or(false);
|
||||
}
|
||||
|
||||
// Modal player detail card. Returns the card's close-parent flag, or std::nullopt when
|
||||
// the program is quitting.
|
||||
auto App::player_detail_dialog(app::ClubModalServices& services,const ClubPlayerDetailSelection& selection,const Image& parent_image) -> std::optional<bool> {
|
||||
if(!running)return std::nullopt;
|
||||
press.reset(); //ClubPlayerDetailFromGame now owns physical hold/release through its own Source wait.
|
||||
const uint8_t input_mode=services.runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField);
|
||||
size_t rebuild_count = 0;
|
||||
// Asks the engine to redraw the player's data and projects it for the card.
|
||||
const auto rebuild = [&] {
|
||||
std::string error;
|
||||
auto redraw = services.redraw_player(selection);
|
||||
++rebuild_count;
|
||||
return ui::club_player_detail_from_game(services.state(), std::move(redraw), season_exe);
|
||||
};
|
||||
ui::ClubPlayerDetailScreen card(data, rebuild(), parent_image);
|
||||
// Presents the card; the window title encodes selection and statistics state.
|
||||
const auto show = [&] {
|
||||
const auto title = "OpenBMH - cup_player_detail_" + std::to_string(selection.runtime_team) +
|
||||
"_" + std::to_string(selection.player_id) + (card.in_statistics() ? "_player_statistics_" : "_card_") +
|
||||
"_statistics_flags_" + std::to_string(card.projection().statistics_flags) +
|
||||
"_rebuild_" + std::to_string(rebuild_count);
|
||||
present_season(card.render(), title.c_str());
|
||||
};
|
||||
// Waits until the left button is up, but only if the engine recorded a long hold before
|
||||
// the card opened.
|
||||
const auto wait_prior_left_release = [&] {
|
||||
if (input_mode == 0) return;
|
||||
// Source waits only for an already set CareerSession_InitializeClubModalRuntime_ExecutableField (>25 held ticks),
|
||||
// then clears it. A fresh list DOWN is not an already held flag.
|
||||
const bool prior_long_hold = services.runtime_byte(::bmh::layout::CareerSession_InitializeClubModalRuntime_ExecutableField) != 0;
|
||||
if (!prior_long_hold) return;
|
||||
SDL_PumpEvents();
|
||||
while (running && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON_LMASK)) {
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input))
|
||||
if (input.type == SDL_QUIT) { running = false; return; }
|
||||
SDL_PumpEvents();
|
||||
if (running) SDL_Delay(10);
|
||||
}
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_InitializeClubModalRuntime_ExecutableField, 0); // Source consumes the owned hold flag.
|
||||
};
|
||||
show(); wait_prior_left_release();
|
||||
// Source tick at which a left button hold began (for the card's hold shortcut).
|
||||
std::optional<uint64_t> held_left_since;
|
||||
SDL_PumpEvents();
|
||||
// ClubPlayerDetailFromGame consumes the opening DOWN when bbcde!=0. Only its
|
||||
// selection mode retains that inherited DOWN as a hold candidate.
|
||||
if (input_mode == 0 && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON_LMASK))
|
||||
held_left_since = ui::pointer_hold_source_ticks(SDL_GetTicks64());
|
||||
// Executes a request coming from the card. A returned value means the card is left
|
||||
// (true/false = close the parent screens too).
|
||||
const auto apply_request = [&](ui::ClubPlayerDetailRequest request) -> std::optional<bool> {
|
||||
switch (request.kind) {
|
||||
case ui::ClubPlayerDetailRequestKind::none: return std::nullopt;
|
||||
case ui::ClubPlayerDetailRequestKind::close:
|
||||
if(poach_selection_active && input_mode==0 && request.source_return>0)
|
||||
poach_card_selection=request.selection;
|
||||
present_season(parent_image, "OpenBMH - cup_club_player_restored");
|
||||
return request.close_parent();
|
||||
case ui::ClubPlayerDetailRequestKind::redraw_card: {
|
||||
// CopyOpaqueSlice saves active-manager preferences only on exit.
|
||||
const int manager = card.projection().redraw.context.active_manager;
|
||||
const uint32_t flags = ::bmh::layout::Flags + uint32_t(manager) * 3 + 2;
|
||||
if (!services.state().memory.has(flags))
|
||||
throw FormatError("club player statistics: active preference block missing");
|
||||
services.state().memory.set8(flags, request.statistics_flags);
|
||||
card.replace_redraw(rebuild()); // One actual42dbd rebuild, never per presentation.
|
||||
held_left_since.reset();
|
||||
show(); wait_prior_left_release();
|
||||
return std::nullopt;
|
||||
}
|
||||
case ui::ClubPlayerDetailRequestKind::national_action: {
|
||||
present_season(parent_image, "OpenBMH - cup_club_player_restored");
|
||||
std::string error;
|
||||
(void)services.national_action(request.selection);
|
||||
// Source returnsff even when a full national squad prevents an add.
|
||||
return request.close_parent();
|
||||
}
|
||||
case ui::ClubPlayerDetailRequestKind::offer_action: {
|
||||
// ClubPlayerDetailFromGame restores its saved parent before3140f; the
|
||||
// question overlays the club list, not the departed card.
|
||||
present_season(parent_image, "OpenBMH - pending_offer_parent_restored");
|
||||
const auto hooks = make_pending_offer_hooks(parent_image);
|
||||
std::string error;
|
||||
try { (void)services.pending_offers(request.selection, hooks); }
|
||||
catch(const std::exception& e) {
|
||||
if(services.transactional)throw;
|
||||
if(running) {std::fprintf(stderr,"pending offer: %s\n",e.what());show();}
|
||||
return std::nullopt;
|
||||
}
|
||||
present_season(parent_image, "OpenBMH - cup_club_player_restored");
|
||||
return request.close_parent();
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
};
|
||||
// Applies the process-timer deadline to the card unless a mouse release is still awaited.
|
||||
const auto expire_card = [&]() -> std::optional<bool> {
|
||||
if (card.source_mouse_wait_release_pending()) return std::nullopt;
|
||||
if (poll_process_timer(true, true) && card.process_timer_expired())
|
||||
return apply_request(card.take_request());
|
||||
return std::nullopt;
|
||||
};
|
||||
while (running) {
|
||||
if (const auto complete = expire_card()) return *complete;
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return std::nullopt; }
|
||||
if (const auto complete = expire_card()) return *complete;
|
||||
bool changed = false;
|
||||
if (input.type == SDL_MOUSEMOTION) {
|
||||
changed = card.move(input.motion.x, input.motion.y);
|
||||
if (changed) held_left_since.reset(); // ExpireQuestion move-out cancels its held press.
|
||||
} else if (input.type == SDL_MOUSEBUTTONDOWN) {
|
||||
if (input.button.button == SDL_BUTTON_RIGHT) {
|
||||
held_left_since.reset();
|
||||
changed = card.press(input.button.x, input.button.y, true);
|
||||
} else if (input.button.button == SDL_BUTTON_LEFT) {
|
||||
// ExpireQuestion waits for the paired release itself;
|
||||
// its button hold does not run42dbd's hold shortcut.
|
||||
held_left_since.reset();
|
||||
changed = card.press(input.button.x, input.button.y);
|
||||
}
|
||||
} else if (input.type == SDL_MOUSEBUTTONUP && input.button.button == SDL_BUTTON_LEFT) {
|
||||
held_left_since.reset();
|
||||
changed = card.release(input.button.x, input.button.y);
|
||||
}
|
||||
const auto request = card.take_request();
|
||||
if (const auto complete = apply_request(request)) return *complete;
|
||||
if (!running) return std::nullopt;
|
||||
if (changed && request.kind == ui::ClubPlayerDetailRequestKind::none) show();
|
||||
}
|
||||
// While the button is held, report the elapsed source ticks to the card; forget the hold
|
||||
// when the physical button is up.
|
||||
if (held_left_since) {
|
||||
SDL_PumpEvents();
|
||||
if (!(SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON_LMASK)) held_left_since.reset();
|
||||
else if (card.held_left_ticks(uint32_t(ui::pointer_hold_source_ticks(SDL_GetTicks64()) - *held_left_since))) {
|
||||
if (const auto complete = apply_request(card.take_request())) return *complete;
|
||||
}
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Modal team statistics screen with a mode toggle; leaves on close, right press or timer.
|
||||
auto App::club_statistics_dialog(app::ClubModalServices& services, int team, const Image& parent_frame) -> void {
|
||||
if (!running) return;
|
||||
auto mode = ui::TeamStatisticsMode::combined;
|
||||
std::unique_ptr<ui::TeamStatisticsScreen> statistics;
|
||||
// Rebuilds the statistics screen for the current mode.
|
||||
const auto rebuild = [&] {
|
||||
auto projection = ui::team_statistics_from_game(services.state(), team, mode,
|
||||
season_exe, season_texts);
|
||||
statistics = std::make_unique<ui::TeamStatisticsScreen>(data,
|
||||
std::move(projection), parent_frame);
|
||||
};
|
||||
// Presents the statistics screen; the window title encodes team, mode and pressed button.
|
||||
const auto show = [&] {
|
||||
auto title = "OpenBMH - cup_team_statistics_" + std::to_string(team) +
|
||||
"_mode_" + std::to_string(int(mode));
|
||||
if (statistics->pressed_button())
|
||||
title += "_pressed_" + std::to_string(int(*statistics->pressed_button()));
|
||||
present_season(statistics->render(), title.c_str());
|
||||
};
|
||||
rebuild(); show();
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
// True when the process timer ran out and no button is currently held down.
|
||||
const auto deadline_expired = [&] {
|
||||
return !statistics->pressed_button() && poll_process_timer(true, true);
|
||||
};
|
||||
while (running) {
|
||||
if (deadline_expired()) return; //LeagueCalculations frees its child before4f548 polls again.
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return; }
|
||||
if (deadline_expired()) return;
|
||||
// A right press leaves at once without waiting for its release.
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_RIGHT)
|
||||
return; // ExpireQuestion right DOWN: do not wait for release.
|
||||
if (input.type == SDL_MOUSEMOTION) {
|
||||
if (statistics->move(input.motion.x, input.motion.y)) show();
|
||||
} else if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_LEFT) {
|
||||
statistics->press(input.button.x, input.button.y);
|
||||
show();
|
||||
} else if (input.type == SDL_MOUSEBUTTONUP && input.button.button == SDL_BUTTON_LEFT) {
|
||||
const auto request = statistics->release(input.button.x, input.button.y);
|
||||
if (request.kind == ui::TeamStatisticsRequestKind::close) return;
|
||||
if (request.kind == ui::TeamStatisticsRequestKind::change_mode) {
|
||||
mode = request.mode;
|
||||
rebuild(); // Pure Source table projection; neither RNG advances.
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
}
|
||||
show();
|
||||
}
|
||||
// OriginalMouseSound keys, including ESC, do not select a button.
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,88 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// App: notices and questions over a screen (construction, season tickets, advertising renewal, national friendly, environment).
|
||||
// (moved out of main.cpp unchanged; the class is declared in app/app.hpp)
|
||||
#include "app/app.hpp"
|
||||
|
||||
// Next callback: stadium construction payment notice, shown over the investment detail.
|
||||
auto App::present_construction_notice(const GameState& staged, const ConstructionNotice& notice) -> void {
|
||||
if (!flow.stadium()) throw std::runtime_error("construction notice has no stadium owner");
|
||||
// The Original payment notices restore the investment detail,
|
||||
// after the tip question has returned, before the outer ACK.
|
||||
const Image backdrop = flow.stadium()->construction_notice_backdrop();
|
||||
auto view = ui::construction_notice_dialog(staged, season_exe, notice);
|
||||
std::optional<ui::GameEndRenderOptions> effective_options;
|
||||
if (flow.stadium()->state().block_expansion || flow.stadium()->state().quoted_object) {
|
||||
const auto& owner = flow.stadium()->state();
|
||||
view.compact_dialog_frame = owner.compact_dialog_frame;
|
||||
effective_options = ui::GameEndRenderOptions{owner.plain_background, owner.gradient_text};
|
||||
}
|
||||
const char* title = notice.kind == ConstructionNoticeKind::InsufficientFunds
|
||||
? "OpenBMH - stadium_funds_notice" : "OpenBMH - stadium_sponsor_notice";
|
||||
if (present_pending_dialog(staged, view, backdrop, title, effective_options) == PendingOfferAnswer::unsupported)
|
||||
throw std::runtime_error("construction notice presenter stopped");
|
||||
}
|
||||
|
||||
// Next callback: season ticket compensation notice.
|
||||
auto App::present_ticket_compensation_notice(const GameState& staged, const SeasonTicketCompensationNotice& notice) -> void {
|
||||
if (!flow.stadium()) throw std::runtime_error("compensation notice has no stadium owner");
|
||||
const Image backdrop = flow.stadium()->construction_notice_backdrop();
|
||||
auto view = ui::season_ticket_compensation_notice_dialog(staged, season_exe, notice);
|
||||
const auto& owner = flow.stadium()->state();
|
||||
view.compact_dialog_frame = owner.compact_dialog_frame;
|
||||
if (present_pending_dialog(staged, view, backdrop,
|
||||
"OpenBMH - stadium_ticket_compensation_notice",
|
||||
ui::GameEndRenderOptions{owner.plain_background, owner.gradient_text}) == PendingOfferAnswer::unsupported)
|
||||
throw std::runtime_error("compensation notice presenter stopped");
|
||||
}
|
||||
|
||||
// Callback: advertising contract renewal. A question gives renew/decline; a sponsor's
|
||||
// refusal is a notice that gives acknowledged; anything else aborts.
|
||||
auto App::ask_advertising_renewal(const GameState& staged, const AdvertisingRenewal& renewal, const Image& backdrop) -> app::CareerSession::AdvertisingRenewalPresentation {
|
||||
if (!running) return app::CareerSession::AdvertisingRenewalPresentation::abort;
|
||||
const int manager = int(staged.memory.u8(::bmh::layout::ActiveManager));
|
||||
if (renewal.status == AdvertisingRenewal::Status::offered) {
|
||||
const auto view = ui::advertising_renewal_question_dialog(staged, manager, renewal);
|
||||
const auto answer = present_pending_dialog(staged, view, backdrop,
|
||||
"OpenBMH - advertising_renewal_question");
|
||||
if (answer == PendingOfferAnswer::yes) return app::CareerSession::AdvertisingRenewalPresentation::renew;
|
||||
if (answer == PendingOfferAnswer::no) return app::CareerSession::AdvertisingRenewalPresentation::decline;
|
||||
return app::CareerSession::AdvertisingRenewalPresentation::abort;
|
||||
}
|
||||
if (renewal.status == AdvertisingRenewal::Status::declined_by_sponsor) {
|
||||
const auto view = ui::advertising_renewal_notice_dialog(staged, manager, renewal);
|
||||
if (present_pending_dialog(staged, view, backdrop,
|
||||
"OpenBMH - advertising_renewal_notice") == PendingOfferAnswer::yes)
|
||||
return app::CareerSession::AdvertisingRenewalPresentation::acknowledged;
|
||||
}
|
||||
return app::CareerSession::AdvertisingRenewalPresentation::abort;
|
||||
}
|
||||
|
||||
// Callback: national friendly question. Returns yes/no, or std::nullopt when unsupported
|
||||
// or the program is quitting.
|
||||
auto App::ask_national_friendly(const GameState& staged,ui::TaxDialogProjection view,const Image& backdrop) -> std::optional<bool> {
|
||||
if(!running)return {};
|
||||
const auto answer=present_pending_dialog(staged,std::move(view),backdrop,
|
||||
"OpenBMH - national_friendly_question");
|
||||
flow.acknowledge_national_friendly_modal_release();
|
||||
// The synchronous questions already consumed their UP;
|
||||
// do not retain the picker DOWN as a held parent press.
|
||||
press.reset();
|
||||
if(answer==PendingOfferAnswer::unsupported)return {};
|
||||
return answer==PendingOfferAnswer::yes;
|
||||
}
|
||||
|
||||
// Next callback: environment/settings notice dialog. Returns false when the program is
|
||||
// quitting or the dialog could not be shown.
|
||||
auto App::present_environment_notice(const GameState& staged, ui::TaxDialogProjection view, const Image& backdrop) -> bool {
|
||||
if (!running) return false;
|
||||
const bool settings_notice = flow.in_settings() && flow.pending_settings();
|
||||
const bool shown = present_pending_dialog(staged, std::move(view), backdrop,
|
||||
settings_notice ? "OpenBMH - settings_notice" : "OpenBMH - environment_notice")
|
||||
!= PendingOfferAnswer::unsupported;
|
||||
if (settings_notice) {
|
||||
flow.acknowledge_settings_notice_release();
|
||||
press.reset();
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
}
|
||||
return shown;
|
||||
}
|
||||
@@ -0,0 +1,565 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// App: handle() - one request through the controller - and run() - wiring, title screen, event loop, tear-down.
|
||||
// (moved out of main.cpp unchanged; the class is declared in app/app.hpp)
|
||||
#include "app/app.hpp"
|
||||
|
||||
// =====================================================================================
|
||||
// Handling FlowResults (requests from the UI flow)
|
||||
// =====================================================================================
|
||||
// Called by the main loop for every ui::FlowResult. It handles quitting and the process
|
||||
// timer, then passes the request to app::serve_flow_request() together with the
|
||||
// presenter lambdas defined inside, which the engine may call back synchronously.
|
||||
auto App::handle(const ui::FlowResult& r) -> void {
|
||||
pitch_pointer.show({}, renderer);
|
||||
// A quit request must be confirmed by the player; otherwise the desk reports it as cancelled.
|
||||
if (r.request == ui::FlowRequest::end_session && !quit_confirmation.confirm()) {
|
||||
flow.reject_desk_action(english_game ? "Quit cancelled." : "Beenden abgebrochen.");
|
||||
dirty = true;
|
||||
return;
|
||||
}
|
||||
// Play the sounds the desk queued during this action.
|
||||
if (const auto* desk = flow.desktop())
|
||||
for (const auto id : desk->take_sound_ids()) app::original_audio_command(playback, id);
|
||||
// Process timer: kickoff and quitting stop it; opening the menus 10, 11, 19 and 29
|
||||
// (save/load, settings, new manager) pauses it.
|
||||
if (r.request == ui::FlowRequest::kickoff || r.request == ui::FlowRequest::end_session) {
|
||||
// DeskDate clears CareerSession_DispatchStrengths_ExecutableField2 before returning to the match caller.
|
||||
process_timer.stop(); process_timer_owner.reset(); process_timer_frame.reset();
|
||||
} else if (r.desk_action.kind == ui::DeskRequestKind::open_menu &&
|
||||
(r.desk_action.menu_kind == 10 || r.desk_action.menu_kind == 11 ||
|
||||
r.desk_action.menu_kind == 19 || r.desk_action.menu_kind == 29)) {
|
||||
// ApplySettingsFile suspends save/load, settings and new-manager waits.
|
||||
process_timer.pause(process_source_seconds()); process_timer_frame.reset();
|
||||
}
|
||||
// Confirmed quit: end the program at once, without advancing the calendar or saving.
|
||||
if (r.request == ui::FlowRequest::end_session) {
|
||||
// DeskDate's confirmed socket exit tears down the running
|
||||
// session without a calendar turn, RNG draw, or implicit save.
|
||||
running = false;
|
||||
dirty = false;
|
||||
return;
|
||||
}
|
||||
dirty |= r.changed;
|
||||
live_skipped = false; // (a member now; fresh for every request like the former local)
|
||||
live_overview_sequence = 0; // (a member now; fresh for every request like the former local)
|
||||
outcome_backdrop = std::optional<Image>{}; // (a member now; fresh for every request like the former local)
|
||||
// State used by the live-match presenters below.
|
||||
live_score_reveal = ui::LiveScoreReveal{}; // (a member now; fresh for every request like the former local)
|
||||
live_chance_context = std::optional<ui::LiveChanceProjection>{}; // (a member now; fresh for every request like the former local)
|
||||
reality_field.reset(); // (a member now; fresh for every request like the former local)
|
||||
reality_layout = ui::RealityReporterLayoutState{}; // (a member now; fresh for every request like the former local)
|
||||
reality_pristine = Image{}; reality_surface = Image{}; // (a member now; fresh for every request like the former local)
|
||||
reality_colors = Palette{}; // (a member now; fresh for every request like the former local)
|
||||
// Hand the flow result to the controller. The arguments after the audio ones are the
|
||||
// presenter callbacks the engine may call synchronously (live frame, incoming transfers,
|
||||
// transfer decisions, season checkpoints, tax, highscore, promotion, cup draw, offers,
|
||||
// club/player screens, notices, poaching, contracts, ...). The returned message is
|
||||
// printed to stderr by the caller; "career_complete" ends the program.
|
||||
const std::string message = app::serve_flow_request(flow, r, session, data, save_directory, seed, revision,
|
||||
playback, audio_session, music_enabled,
|
||||
[this](auto&&... a) -> decltype(auto) { return present_live_minute(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return choose_transfer_offer(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return present_transfer_decision(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return present_season_checkpoint(std::forward<decltype(a)>(a)...); },
|
||||
// Further callbacks: tax, highscore, promotion and cup draw presenters (defined above).
|
||||
tax_presenter, [this](auto&&... a) -> decltype(auto) { return show_highscore(std::forward<decltype(a)>(a)...); }, promotion_presenter, cup_draw_presenter,
|
||||
// Pending-offer hooks exist only for kickoff; market sale hooks for kickoff and for
|
||||
// transfer market / outgoing transfer submenu actions.
|
||||
r.request == ui::FlowRequest::kickoff
|
||||
? make_pending_offer_hooks(flow.render()) : PendingOfferHooks{},
|
||||
app::PendingOfferEntryPolicy::normal_interactive,
|
||||
(r.request == ui::FlowRequest::kickoff || (r.request == ui::FlowRequest::submenu_action &&
|
||||
(std::holds_alternative<ui::TransferMarketRequest>(r.submenu_action) ||
|
||||
std::holds_alternative<ui::OutgoingTransferRequest>(r.submenu_action))
|
||||
)) ? make_market_sale_hooks(flow.render()) : HumanBuyerSaleHooks{},
|
||||
app::HumanBuyerMarketEntryPolicy::normal_interactive,
|
||||
[this](auto&&... a) -> decltype(auto) { return show_club_information(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return show_player_detail(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return present_construction_notice(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return present_ticket_compensation_notice(std::forward<decltype(a)>(a)...); }, sportschau_presenter,
|
||||
[this](auto&&... a) -> decltype(auto) { return ask_advertising_renewal(std::forward<decltype(a)>(a)...); }, poach_player_selector,
|
||||
[this](auto&&... a) -> decltype(auto) { return present_poach_notices(std::forward<decltype(a)>(a)...); }, [this](auto&&... a) -> decltype(auto) { return contract_expiry_presenter(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return ask_national_friendly(std::forward<decltype(a)>(a)...); },
|
||||
// The loan-return presenters (defined above), then the live match observer.
|
||||
[this](auto&&... a) -> decltype(auto) { return loan_return_presenter(std::forward<decltype(a)>(a)...); }, [this](auto&&... a) -> decltype(auto) { return loan_return_offer_presenter(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return observe_live_minute(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return present_environment_notice(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return present_live_event_lineup(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return animate_ball(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return animate_chance(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return animate_shot(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return animate_set_piece(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return animate_booking(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return animate_shootout(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return present_reality(std::forward<decltype(a)>(a)...); },
|
||||
[this](auto&&... a) -> decltype(auto) { return present_phase_result(std::forward<decltype(a)>(a)...); }, true);
|
||||
// In -debug mode every request and its outcome is logged.
|
||||
if (app::debug::enabled()) app::debug::log("request " + std::to_string(int(r.request)) + (message.empty() ? std::string(" ok") : " -> " + message));
|
||||
// The controller reports the end of the career by this message: leave the main loop.
|
||||
if (message == "career_complete") { running = false; return; }
|
||||
if (!message.empty()) std::fprintf(stderr, "engine: %s\n", message.c_str());
|
||||
// Autosave problems are reported but do not stop the game.
|
||||
if (session) {
|
||||
const auto autosave_error = session->take_autosave_error();
|
||||
if (!autosave_error.empty()) std::fprintf(stderr, "autosave: %s\n", autosave_error.c_str());
|
||||
}
|
||||
// Table requests own their redraw boundary. In particular a
|
||||
// same-league map ACK and a forecast Present ACK retain the frame.
|
||||
if (!flow.in_family_table() || !message.empty()) dirty = true;
|
||||
// DeskDate checks the pending mailbox latch after the normal desk
|
||||
// request has completed. Poll only on the returned, idle desk so
|
||||
// load/weekly/close acknowledgements can open the Source notice
|
||||
// immediately without interrupting another modal or read-only view.
|
||||
if (running && session && flow.desktop() && !flow.desktop()->pending() &&
|
||||
!flow.in_preparation_menu() && !flow.in_results_view() &&
|
||||
!flow.in_readonly_view() && !flow.in_mailbox() && flow.screen_name() == "desktop") {
|
||||
if (auto mailbox = session->pending_mailbox_notification(revision)) {
|
||||
flow.show_notified_mailbox(std::move(*mailbox));
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
// Forget the presentation time once no timed notice is open.
|
||||
if(!flow.timed_notice_open())timed_notice_presented_at.reset();
|
||||
SDL_SetWindowTitle(window, ("OpenBMH - " + flow.screen_name()).c_str());
|
||||
}
|
||||
|
||||
// The statements of the former main(): hook wiring, title screen, event loop and tear-down.
|
||||
auto App::run() -> int {
|
||||
sportschau_presenter.intro = [this](auto&&... a) -> decltype(auto) { return present_sportschau_intro(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.kickoff = [this](auto&&... a) -> decltype(auto) { return present_matchday_intro(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.replay.step = [this](auto&&... a) -> decltype(auto) { return present_sportschau_replay_step(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.replay.scene = [this](auto&&... a) -> decltype(auto) { return present_sportschau_scene(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.fixture = [this](auto&&... a) -> decltype(auto) { return present_sportschau_fixture(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.winner = [this](auto&&... a) -> decltype(auto) { return present_competition_winner(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.awards = [this](auto&&... a) -> decltype(auto) { return present_sportschau_awards(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.team_info = [this](auto&&... a) -> decltype(auto) { return present_sportschau_team_info(std::forward<decltype(a)>(a)...); };
|
||||
|
||||
tax_presenter.choose = [this](auto&&... a) -> decltype(auto) { return show_tax(std::forward<decltype(a)>(a)...); };
|
||||
tax_presenter.observe = [this](auto&&... a) -> decltype(auto) { return present_tax_event(std::forward<decltype(a)>(a)...); };
|
||||
promotion_presenter = [this](auto&&... a) -> decltype(auto) { return present_promotion(std::forward<decltype(a)>(a)...); };
|
||||
present_club_information = [this](auto&&... a) -> decltype(auto) { return club_information_dialog(std::forward<decltype(a)>(a)...); };
|
||||
present_club_player = [this](auto&&... a) -> decltype(auto) { return club_player_dialog(std::forward<decltype(a)>(a)...); };
|
||||
present_player_detail = [this](auto&&... a) -> decltype(auto) { return player_detail_dialog(std::forward<decltype(a)>(a)...); };
|
||||
present_club_statistics = [this](auto&&... a) -> decltype(auto) { return club_statistics_dialog(std::forward<decltype(a)>(a)...); };
|
||||
poach_player_selector = [this](auto&&... a) -> decltype(auto) { return select_poach_player(std::forward<decltype(a)>(a)...); };
|
||||
cup_draw_presenter = [this](auto&&... a) -> decltype(auto) { return present_cup_draw(std::forward<decltype(a)>(a)...); };
|
||||
|
||||
// =====================================================================================
|
||||
// Opening screen
|
||||
// =====================================================================================
|
||||
// OpenBMH deviates from the original: display the repository-owned title
|
||||
// at its native resolution until a complete left/right click, without loading balls.
|
||||
{
|
||||
app::StartScreen title_screen(renderer);
|
||||
title_screen.present();
|
||||
bool opening_confirmed = false;
|
||||
std::optional<Uint8> opening_press;
|
||||
// Only a complete click confirms: press and release of the same button. Losing focus
|
||||
// forgets the press; expose and resize events redraw the title picture.
|
||||
while (running && !opening_confirmed) {
|
||||
SDL_Event opening_event;
|
||||
while (quit_confirmation.poll(&opening_event)) {
|
||||
if (opening_event.type == SDL_QUIT) running = false;
|
||||
if (opening_event.type == SDL_KEYDOWN && opening_event.key.keysym.sym == SDLK_ESCAPE &&
|
||||
quit_confirmation.confirm()) running = false;
|
||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||
(opening_event.window.event == SDL_WINDOWEVENT_EXPOSED ||
|
||||
opening_event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED))
|
||||
title_screen.present();
|
||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||
opening_event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
opening_press.reset();
|
||||
if (opening_event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(opening_event.button.button == SDL_BUTTON_LEFT ||
|
||||
opening_event.button.button == SDL_BUTTON_RIGHT))
|
||||
opening_press = opening_event.button.button;
|
||||
if (opening_event.type == SDL_MOUSEBUTTONUP && opening_press &&
|
||||
opening_event.button.button == *opening_press)
|
||||
opening_confirmed = true;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
// Restore the indexed game canvas and its logical input mapping.
|
||||
// Opening input must not also change an option on the first setup frame.
|
||||
SDL_FlushEvents(SDL_KEYDOWN, SDL_KEYUP);
|
||||
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
|
||||
season_backdrop.reset();
|
||||
|
||||
dirty = true;
|
||||
|
||||
// Text input stays on for the whole session so SDL_TEXTINPUT events arrive.
|
||||
SDL_StartTextInput();
|
||||
|
||||
// =====================================================================================
|
||||
// Main event loop
|
||||
// =====================================================================================
|
||||
// Each pass: keep the filename field focused on the save/load screen, expire timed
|
||||
// notices, service the timers, then drain the SDL event queue through
|
||||
// quit_confirmation.poll(). SDL_QUIT ends the loop. Mouse down, up and motion, text and
|
||||
// key events are translated into StartupFlow calls (pointer_down, click or hold,
|
||||
// move_action, text, send_key); every FlowResult is passed to handle(), which serves
|
||||
// the request. After the queue is empty the loop services holds and timers again, plays
|
||||
// queued sounds, pumps audio, redraws the 320x240 canvas if dirty, presents it and
|
||||
// sleeps 10 ms.
|
||||
while (running) {
|
||||
const bool filename_open = flow.screen_name() == "save_load";
|
||||
if (filename_open && !filename_input_active) focus_filename_input(renderer);
|
||||
filename_input_active = filename_open;
|
||||
// A timed notice closes by itself after 70*3*20 ms.
|
||||
if(timed_notice_presented_at && flow.timed_notice_open() &&
|
||||
SDL_GetTicks64()-*timed_notice_presented_at>=70*3*20)
|
||||
handle(flow.expire_timed_notice());
|
||||
service_process_timer();
|
||||
if (!running) break;
|
||||
SDL_Event e;
|
||||
while (quit_confirmation.poll(&e)) {
|
||||
if (e.type == SDL_QUIT) {
|
||||
running = false;
|
||||
break;
|
||||
}
|
||||
// Losing focus forgets the pressed setup buttons; regaining it restores text input.
|
||||
if (e.type == SDL_WINDOWEVENT) {
|
||||
if (e.window.event == SDL_WINDOWEVENT_FOCUS_LOST) setup_button_down.fill(false);
|
||||
if (e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
|
||||
if (flow.screen_name() == "save_load") focus_filename_input(renderer);
|
||||
else SDL_StartTextInput();
|
||||
}
|
||||
}
|
||||
// A native picker/window activation can leave an unmatched UP.
|
||||
// Only a press which began on setup may toggle its options.
|
||||
if ((e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) &&
|
||||
(e.button.button == SDL_BUTTON_LEFT || e.button.button == SDL_BUTTON_RIGHT)) {
|
||||
const size_t button = e.button.button == SDL_BUTTON_LEFT ? 0 : 1;
|
||||
if (e.type == SDL_MOUSEBUTTONDOWN) setup_button_down[button] = flow.screen_name() == "setup";
|
||||
else {
|
||||
const bool owned = setup_button_down[button];
|
||||
setup_button_down[button] = false;
|
||||
if (flow.screen_name() == "setup" && !owned) continue;
|
||||
}
|
||||
}
|
||||
// Swallow the release of the press that dismissed a timed notice.
|
||||
if(e.type==SDL_MOUSEBUTTONUP&&timed_notice_release&&e.button.button==*timed_notice_release) {
|
||||
timed_notice_release.reset();continue;
|
||||
}
|
||||
if(flow.timed_notice_open()&&e.type==SDL_MOUSEBUTTONDOWN&&
|
||||
(e.button.button==SDL_BUTTON_LEFT||e.button.button==SDL_BUTTON_RIGHT)) {
|
||||
// PresentManagerDialog consumes DOWN. Do not deliver its release to
|
||||
// the restored caller as a second booking/purchase.
|
||||
timed_notice_release=e.button.button;press.reset();
|
||||
handle(flow.expire_timed_notice());continue;
|
||||
}
|
||||
// Keyboard input is ignored while a timed notice is open.
|
||||
if(flow.timed_notice_open()&&(e.type==SDL_KEYDOWN||e.type==SDL_TEXTINPUT))continue;
|
||||
// InLeaguePairings handles a changed league selector before5147b's
|
||||
// timer. Preserve that precedence without moving other inputs.
|
||||
bool selector_consumed = false;
|
||||
if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_LEFT &&
|
||||
flow.in_league_pairings()) {
|
||||
const auto selection = flow.league_pairings()->selector_event(e.button.x,e.button.y);
|
||||
if (selection && (selection->kind == LeaguePairingsAction::toggle_group ||
|
||||
selection->value != flow.league_pairings()->state().source.owner.league)) {
|
||||
handle(flow.pointer_down(e.button.x,e.button.y));
|
||||
present_pairings_redraw();
|
||||
selector_consumed = true;
|
||||
}
|
||||
}
|
||||
// Other polled input keeps the Original timer precedence;
|
||||
// held controls remain blocked by release ownership.
|
||||
service_process_timer();
|
||||
service_pairings_timer();
|
||||
service_balance_timer();
|
||||
service_family_table();
|
||||
service_stadium_calculator();
|
||||
service_idle_stadium_deadline();
|
||||
// Keys for the table range dialog or toto calculator are queued, not dispatched at once.
|
||||
if (queue_table_range_event(e)) {
|
||||
service_family_table();
|
||||
continue;
|
||||
}
|
||||
// While the stadium calculator is in a timed wait, its keys are queued and its release
|
||||
// is remembered; no other input is processed (release barrier).
|
||||
if (flow.in_stadium() && flow.stadium()->calculator_source_waiting()) {
|
||||
// DecodeTaxAnimationScript2 delays without consuming keyboard input. Retain
|
||||
// FIFO keys for this accepted calculator owner, including
|
||||
// every digit of one SDL text-input packet.
|
||||
queue_calculator_event(e);
|
||||
if (e.type == SDL_MOUSEBUTTONUP && e.button.button == SDL_BUTTON_LEFT &&
|
||||
flow.stadium()->calculator_waiting_for_key_release() && !calculator_release) {
|
||||
const auto& owner = flow.stadium()->state();
|
||||
calculator_release = CalculatorRelease{e.button, owner.scope, owner.sequence};
|
||||
}
|
||||
// The Source calculator helper owns input until its wait
|
||||
// completes. SDL_QUIT was serviced above this barrier.
|
||||
continue;
|
||||
}
|
||||
// The open calculator owns all keyboard input.
|
||||
if (flow.in_stadium() && flow.stadium()->calculator_open() && queue_calculator_event(e)) {
|
||||
service_stadium_calculator();
|
||||
continue;
|
||||
}
|
||||
// ESC asks to quit (after confirmation) unless it is a close key in a menu or view.
|
||||
if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE &&
|
||||
!flow.in_preparation_menu() && !flow.in_results_view() && !flow.in_readonly_view() &&
|
||||
quit_confirmation.confirm())
|
||||
running = false;
|
||||
// Remember the left press so its release can be judged as a click or a 2 second hold.
|
||||
if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_LEFT)
|
||||
press = Press{e.button.x, e.button.y, SDL_GetTicks(), flow.screen_name(),
|
||||
ui::pointer_hold_source_ticks(SDL_GetTicks64()), revision};
|
||||
// Remember where the right press began, to detect releases without a matching press.
|
||||
if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_RIGHT)
|
||||
right_press_screen = flow.screen_name();
|
||||
// Buttons without a lasting state look pressed while the mouse button is held (bank, offer editor,
|
||||
// lineup, pitch). The pitch runs its action at the press itself, so the pressed look is held briefly.
|
||||
if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_LEFT &&
|
||||
flow.press_hold(e.button.x, e.button.y)) {
|
||||
const auto image = process_timer_image(flow.render());
|
||||
canvas.show(image, palette);
|
||||
dirty = false;
|
||||
if (flow.in_pitch()) SDL_Delay(90);
|
||||
}
|
||||
// Screens that react to the press itself get pointer_down() now.
|
||||
if(!selector_consumed&&e.type==SDL_MOUSEBUTTONDOWN&&(flow.desktop()||flow.in_balance()||flow.in_desk_records()||flow.in_achievements()||flow.in_indoor_standings()||flow.in_reschedule_calendar()||flow.in_league_pairings()||flow.in_family_table()||flow.in_toto_calculator()||flow.in_stadium()||flow.in_environment()||flow.in_strengths()||flow.in_top_scorers()||flow.in_opportunities()||flow.in_statistics_menu()||flow.in_statistics_page()||flow.in_analytics()||flow.in_other_games()||flow.in_pitch()||flow.in_settings())&&
|
||||
(e.button.button==SDL_BUTTON_LEFT||e.button.button==SDL_BUTTON_RIGHT)) {
|
||||
handle(flow.pointer_down(e.button.x,e.button.y,e.button.button==SDL_BUTTON_RIGHT));
|
||||
if (!running) break;
|
||||
if(flow.in_family_table()) {
|
||||
// This path also owns pressed KB6 frames. Upload and
|
||||
// copy must succeed before their Present starts a wait
|
||||
// or commits a staged forecast random stream.
|
||||
present_family_table_redraw();
|
||||
// Screens with held controls are redrawn at once, so the pressed state is visible before
|
||||
// the release arrives.
|
||||
} else if(flow.in_balance()||flow.in_desk_records()||flow.in_achievements()||flow.in_indoor_standings()||flow.in_reschedule_calendar()||flow.in_league_pairings()||flow.in_stadium()||flow.in_environment()||flow.in_strengths()||flow.in_top_scorers()||flow.in_opportunities()||flow.in_statistics_menu()||flow.in_statistics_page()||flow.in_analytics()||flow.in_other_games()||flow.in_pitch()||flow.in_settings()||flow.friendly_question_screen()) {
|
||||
//48529/ExpireQuestion/67e80 present the held control before waiting
|
||||
//for its release. The existing UP ownership remains intact.
|
||||
const auto image=process_timer_image(flow.render());
|
||||
for(size_t i=0;i<pixels.size();++i)pixels[i]=palette.argb[image.pixels[i]];
|
||||
if (SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4)!=0 ||
|
||||
SDL_RenderClear(renderer)!=0 || SDL_RenderCopy(renderer,texture,nullptr,nullptr)!=0)
|
||||
throw std::runtime_error(std::string("Held controls renderer: ")+SDL_GetError());
|
||||
app::present(renderer);
|
||||
mark_stadium_question_presented();
|
||||
mark_national_picker_presented();
|
||||
mark_friendly_picker_presented();
|
||||
mark_friendly_calendar_presented();
|
||||
mark_friendly_question_presented();
|
||||
if(flow.in_balance())flow.mark_balance_presented_source_milliseconds(balance_source_milliseconds());
|
||||
mark_stadium_calculator_presented();
|
||||
dirty=false;
|
||||
} else if (flow.desktop() && flow.desktop()->socket_confirmation_armed()) {
|
||||
// SDLSetWindowTitle paints its pressed socket sprite before
|
||||
// DeskDate waits for the physical release.
|
||||
SDL_SetWindowTitle(window, "OpenBMH - desktop");
|
||||
const auto image=process_timer_image(flow.render());
|
||||
canvas.show(image, palette);
|
||||
dirty=false;
|
||||
}
|
||||
}
|
||||
if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_RIGHT &&
|
||||
flow.file_info_press(e.button.x, e.button.y)) {
|
||||
// InfoPress→Centered paints immediately and waits for mouse UP.
|
||||
// Present before polling a queued release, which restores the list.
|
||||
const auto image = process_timer_image(flow.render());
|
||||
canvas.show(image, palette);
|
||||
dirty = false;
|
||||
}
|
||||
// Mouse release. Order: an expired question that owns this release, then right-button
|
||||
// releases whose press was consumed elsewhere (orphaned releases), then click or hold.
|
||||
if (e.type == SDL_MOUSEBUTTONUP && (e.button.button == SDL_BUTTON_LEFT || e.button.button == SDL_BUTTON_RIGHT)) {
|
||||
if(e.button.button==SDL_BUTTON_LEFT&&service_friendly_question_deadline()) {
|
||||
press.reset();continue; // The expired question owns this UP, not its returned calendar/desk.
|
||||
}
|
||||
if (e.button.button == SDL_BUTTON_LEFT && service_stadium_deadline()) {
|
||||
// The release belongs to the expired question, never
|
||||
// to the newly accepted stadium scene underneath it.
|
||||
press.reset();
|
||||
continue;
|
||||
}
|
||||
if (e.button.button == SDL_BUTTON_RIGHT) {
|
||||
// ClubInfoFromGame consumes the right press and clears CareerSession_BeginFriendlyOpponentTable_ExecutableField2
|
||||
// before returning. Its release is not another Source8
|
||||
// cancel event in the parent OpenTransferEditor input loop.
|
||||
// owned: the right press began on this same screen.
|
||||
const bool owned = right_press_screen && *right_press_screen == flow.screen_name();
|
||||
const bool source_wait_release = flow.source_mouse_wait_release_pending();
|
||||
// Menu6's right DOWN closes1e06b immediately. Its real
|
||||
// UP must still consume the existing national barrier.
|
||||
const bool national_picker_release = right_press_screen &&
|
||||
*right_press_screen == "national_friendly_picker";
|
||||
right_press_screen.reset();
|
||||
if (!owned && flow.settings_readme_release_pending()) {
|
||||
handle(flow.click(e.button.x, e.button.y, true));
|
||||
press.reset();
|
||||
continue;
|
||||
}
|
||||
if (!owned && (source_wait_release || national_picker_release)) {
|
||||
handle(flow.click(e.button.x, e.button.y, true));
|
||||
press.reset();
|
||||
continue;
|
||||
}
|
||||
if (!owned) { flow.consume_orphaned_pitch_release(); continue; }
|
||||
}
|
||||
// A left release is a hold (2000 ms or more, same position, same screen) only on screens
|
||||
// that support it; everywhere else it is a click.
|
||||
const bool held = e.button.button == SDL_BUTTON_LEFT && !flow.in_pitch() && !flow.friendly_question_screen() && !flow.friendly_question_release_pending() && !flow.in_family_table() && !flow.in_balance() && !flow.in_desk_records() && !flow.in_achievements() && !flow.in_indoor_standings() && !flow.in_reschedule_calendar() && !flow.in_top_scorers() && !flow.in_opportunities() && !flow.in_statistics_menu() && !flow.in_statistics_page() && !flow.in_analytics() && !flow.in_other_games() && press && e.button.x == press->x && e.button.y == press->y &&
|
||||
press->screen == flow.screen_name() && SDL_GetTicks() - press->time >= 2000;
|
||||
const auto released = held ? flow.hold(e.button.x, e.button.y, 2000)
|
||||
// clicks >= 2 reports a double click.
|
||||
: flow.click(e.button.x, e.button.y, e.button.button == SDL_BUTTON_RIGHT, e.button.clicks >= 2);
|
||||
present_formation_save_feedback();
|
||||
// JA of the manager confirmation is shown pushed in briefly before the
|
||||
// (possibly slow) next step starts, as in the original.
|
||||
if (flow.screen_name() == "manager_accepted") {
|
||||
present_season(flow.render(), "OpenBMH - manager_accepted");
|
||||
SDL_Delay(150);
|
||||
}
|
||||
handle(released);
|
||||
present_desk_record_points();
|
||||
press.reset();
|
||||
}
|
||||
// Moving away from the pressed position cancels the hold candidate.
|
||||
if (e.type == SDL_MOUSEMOTION) {
|
||||
if (press && (e.motion.x != press->x || e.motion.y != press->y)) press.reset();
|
||||
const auto moved = flow.move_action(e.motion.x, e.motion.y);
|
||||
if (moved.request != ui::FlowRequest::none) handle(moved);
|
||||
else dirty |= moved.changed;
|
||||
// BalanceFromGame presents a drag move before sampling the next
|
||||
// keyboard/mouse event, even when both are already queued.
|
||||
present_family_table_redraw();
|
||||
}
|
||||
// Typed characters go to the flow; a FormatError only produces a message.
|
||||
if (e.type == SDL_TEXTINPUT) {
|
||||
try {
|
||||
dirty |= flow.text(e.text.text);
|
||||
present_desk_record_points();
|
||||
} catch (const FormatError& err) {
|
||||
std::fprintf(stderr, "input: %s\n", err.what());
|
||||
}
|
||||
}
|
||||
// Ctrl/Cmd+A selects all in the filename field.
|
||||
if (e.type == SDL_KEYDOWN && flow.screen_name() == "save_load" &&
|
||||
e.key.keysym.sym == SDLK_a && (e.key.keysym.mod & (KMOD_CTRL | KMOD_GUI))) {
|
||||
handle(flow.send_key("SELECT_ALL"));
|
||||
continue;
|
||||
}
|
||||
// Only keys the current screen type uses are forwarded to the flow (by name); on the
|
||||
// desktop the letters A-Z are shortcuts.
|
||||
if (e.type == SDL_KEYDOWN && (e.key.keysym.sym == SDLK_RETURN || e.key.keysym.sym == SDLK_BACKSPACE ||
|
||||
(flow.screen_name() == "save_load" && (e.key.keysym.sym == SDLK_UP ||
|
||||
e.key.keysym.sym == SDLK_DOWN || e.key.keysym.sym == SDLK_PAGEUP || e.key.keysym.sym == SDLK_PAGEDOWN)) ||
|
||||
((flow.in_preparation_menu() || flow.in_results_view() || flow.in_readonly_view()) && e.key.keysym.sym == SDLK_ESCAPE) ||
|
||||
((flow.in_results_view() || flow.in_readonly_view() || flow.screen_name() == "friendly_match") && (e.key.keysym.sym == SDLK_LEFT ||
|
||||
e.key.keysym.sym == SDLK_RIGHT || e.key.keysym.sym == SDLK_SPACE)) ||
|
||||
((flow.in_balance() || flow.in_stadium()) && e.key.keysym.sym == SDLK_SPACE) ||
|
||||
(flow.desktop() && !flow.in_balance() && e.key.keysym.sym >= SDLK_a && e.key.keysym.sym <= SDLK_z))) {
|
||||
const std::string key = e.key.keysym.sym == SDLK_RETURN ? "ENTER"
|
||||
: e.key.keysym.sym == SDLK_BACKSPACE ? "BACKSPACE"
|
||||
: e.key.keysym.sym == SDLK_ESCAPE ? "ESC"
|
||||
: e.key.keysym.sym == SDLK_LEFT ? "LEFT"
|
||||
: e.key.keysym.sym == SDLK_RIGHT ? "RIGHT"
|
||||
: e.key.keysym.sym == SDLK_SPACE ? "SPACE"
|
||||
: e.key.keysym.sym == SDLK_UP ? "UP"
|
||||
: e.key.keysym.sym == SDLK_DOWN ? "DOWN"
|
||||
: e.key.keysym.sym == SDLK_PAGEUP ? "PAGEUP"
|
||||
: e.key.keysym.sym == SDLK_PAGEDOWN ? "PAGEDOWN"
|
||||
: std::string(1, char('A' + e.key.keysym.sym - SDLK_a));
|
||||
handle(flow.send_key(key));
|
||||
present_desk_record_points();
|
||||
}
|
||||
if (!running) break;
|
||||
}
|
||||
// Queue drained: service holds, timers and sounds, then draw.
|
||||
if (!running) break;
|
||||
service_pitch_hold();
|
||||
if (!running) break;
|
||||
service_process_timer();
|
||||
service_pairings_timer();
|
||||
service_balance_timer();
|
||||
service_family_table();
|
||||
service_stadium_calculator();
|
||||
service_idle_stadium_deadline();
|
||||
if (const auto* desk = flow.desktop())
|
||||
for (const auto id : desk->take_sound_ids()) app::original_audio_command(playback, id);
|
||||
// Keep the audio options in step with the game's settings.
|
||||
if (session) playback.set_original_options(app::original_audio_options(session->state(), music_enabled));
|
||||
if (playback.needs_pump()) {
|
||||
playback.pump(audio_error);
|
||||
if (!audio_error.empty()) std::fprintf(stderr, "audio: %s\n", audio_error.c_str());
|
||||
}
|
||||
// Present the frame. Tables redraw through their own path so that their acknowledgement
|
||||
// is tied to a freshly drawn frame.
|
||||
if (flow.in_family_table()) {
|
||||
// Family ACKs belong to a freshly rendered, successfully
|
||||
// copied image. Do not ACK an old texture at the routine
|
||||
// end-of-loop Present after an earlier ACK changed the Flow.
|
||||
present_family_table_redraw();
|
||||
} else {
|
||||
// A preceding service Present can request the calculator's
|
||||
// restored-underlay frame. This fresh end-of-loop frame owns
|
||||
// its own ACK; an unchanged texture never advances the modal.
|
||||
const bool toto_calculator_redraw = dirty && flow.in_toto_calculator();
|
||||
const bool stadium_redraw = dirty && flow.in_stadium();
|
||||
const bool national_picker_redraw = dirty && national_picker_frame().has_value();
|
||||
const bool friendly_picker_redraw = dirty && friendly_picker_frame().has_value();
|
||||
const bool friendly_calendar_redraw = dirty && friendly_calendar_frame().has_value();
|
||||
const bool friendly_question_redraw = dirty && friendly_question_frame().has_value();
|
||||
const bool source_modal_redraw = toto_calculator_redraw || stadium_redraw ||
|
||||
national_picker_redraw || friendly_picker_redraw || friendly_calendar_redraw || friendly_question_redraw;
|
||||
if (dirty) {
|
||||
const auto image = process_timer_image(flow.render());
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]];
|
||||
if (SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4) != 0 && source_modal_redraw)
|
||||
throw std::runtime_error(std::string("Source modal texture: ") + SDL_GetError());
|
||||
dirty = false;
|
||||
}
|
||||
// Update the custom pitch cursor, then present the canvas texture.
|
||||
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))
|
||||
throw std::runtime_error(std::string("Source modal renderer: ") + SDL_GetError());
|
||||
app::present(renderer);
|
||||
if(flow.timed_notice_open()&&!timed_notice_presented_at)
|
||||
timed_notice_presented_at=SDL_GetTicks64();
|
||||
if (stadium_redraw) mark_stadium_question_presented();
|
||||
if (national_picker_redraw) mark_national_picker_presented();
|
||||
if (friendly_picker_redraw) mark_friendly_picker_presented();
|
||||
if (friendly_calendar_redraw) mark_friendly_calendar_presented();
|
||||
if (friendly_question_redraw) mark_friendly_question_presented();
|
||||
if (toto_calculator_redraw) mark_family_table_presented();
|
||||
mark_stadium_calculator_presented();
|
||||
if(flow.in_balance()) {
|
||||
const auto identity=flow.balance()->state().identity;
|
||||
const bool notice=flow.balance()->notice_open();
|
||||
flow.mark_balance_presented_source_milliseconds(balance_source_milliseconds());
|
||||
presented_balance=identity;presented_balance_notice=notice;
|
||||
}
|
||||
}
|
||||
// Limit the loop to roughly 100 passes per second.
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
// =====================================================================================
|
||||
// Shutdown
|
||||
// =====================================================================================
|
||||
// Stop text input, release the SDL objects, detach the mouse sound and close audio.
|
||||
SDL_StopTextInput();
|
||||
|
||||
pitch_pointer.clear();
|
||||
|
||||
SDL_DestroyTexture(texture);
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
mouse_sound.detach();
|
||||
// Remove event producers before closing the audio device.
|
||||
playback.shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,491 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// App: season end and season start (season pictures, contract expiry, tax, promotion, highscore, entrants, cup draw).
|
||||
// (moved out of main.cpp unchanged; the class is declared in app/app.hpp)
|
||||
#include "app/app.hpp"
|
||||
|
||||
// Paints a 320x240 indexed image through the palette into the texture and presents it.
|
||||
// Also sets the window title and remembers the image as the backdrop for later dialogs.
|
||||
auto App::present_season(const Image& image, const char* title,
|
||||
const Palette* palette_override) -> void {
|
||||
SDL_SetWindowTitle(window, title);
|
||||
season_backdrop = image;
|
||||
const Palette& frame_palette = palette_override ? *palette_override : palette;
|
||||
const Image painted = process_timer_image(image);
|
||||
canvas.show(painted, frame_palette);
|
||||
}
|
||||
|
||||
// Plays the highscore point animation of the desk, one rendered frame per step, if active.
|
||||
auto App::present_desk_record_points() -> void {
|
||||
if(!flow.desk_records_points_active())return;
|
||||
while(flow.advance_desk_records_point())
|
||||
present_season(flow.render(),"OpenBMH - highscore");
|
||||
if(flow.finish_desk_records_points())
|
||||
present_season(flow.render(),"OpenBMH - highscore");
|
||||
dirty=false;
|
||||
}
|
||||
|
||||
// Modal contracts screen shown when a player's contract expires. Runs its own event loop
|
||||
// and applies the player's contract actions to a staged copy of the game state.
|
||||
// Returns 1 if the expired player was renewed, 0 if not, -2 on quit or error (the staged
|
||||
// state and random generator are then restored).
|
||||
auto App::contract_expiry_presenter(GameState& staged, WatcomRandom& random,
|
||||
int manager, int expired_row) -> int {
|
||||
const GameState before = staged;
|
||||
const WatcomRandom random_before = random;
|
||||
try {
|
||||
uint64_t local_revision = revision;
|
||||
uint64_t next_quote_id = 1;
|
||||
auto initial = ui::contracts_from_game(staged, manager, local_revision);
|
||||
ui::ContractsScreen screen(data, std::move(initial));
|
||||
bool renewed_expired_player = false;
|
||||
bool dirty_contracts = true;
|
||||
// Modal sub-loop: polls events itself instead of returning to the main loop.
|
||||
while (running) {
|
||||
if (dirty_contracts) {
|
||||
present_season(screen.render(), "OpenBMH - contracts");
|
||||
dirty_contracts = false;
|
||||
}
|
||||
if (screen.close_requested()) return renewed_expired_player ? 1 : 0;
|
||||
SDL_Event event;
|
||||
bool changed = false;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) {
|
||||
running = false;
|
||||
staged = before;
|
||||
random = random_before;
|
||||
return -2;
|
||||
}
|
||||
// Clicks act on button release; a button held down is drawn pressed meanwhile.
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) {
|
||||
if (screen.press(event.button.x, event.button.y)) {
|
||||
present_season(screen.render(), "OpenBMH - contracts");
|
||||
}
|
||||
} else if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
changed |= screen.click(event.button.x, event.button.y,
|
||||
event.button.button == SDL_BUTTON_RIGHT);
|
||||
changed = true; // also ends a pressed look that did not lead to a change
|
||||
} else if (event.type == SDL_MOUSEMOTION) {
|
||||
changed |= screen.move(event.motion.x, event.motion.y);
|
||||
} else if (event.type == SDL_TEXTINPUT) {
|
||||
changed |= screen.text(event.text.text);
|
||||
} else if (event.type == SDL_KEYDOWN) {
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE) changed |= screen.key("ESC");
|
||||
else if (event.key.keysym.sym == SDLK_BACKSPACE) changed |= screen.key("BACKSPACE");
|
||||
}
|
||||
// The screen asks for an engine action (quote, offer, bonuses, insurance); it is validated
|
||||
// and executed on the staged state, then acknowledged to the screen. Any exception rolls
|
||||
// the staged state back.
|
||||
if (const ui::ContractRequest* pending = screen.pending()) {
|
||||
const ui::ContractRequest request = *pending;
|
||||
const auto old_game = staged;
|
||||
const auto old_random = random;
|
||||
try {
|
||||
// Reject requests that do not belong to the current club or row range.
|
||||
if (request.manager_slot != manager || request.runtime_club != staged.manager_teams.at(size_t(manager)) ||
|
||||
request.row < 0 || request.row >= 24)
|
||||
throw FormatError("Vertragsaktion gehört nicht zum aktuellen Verein");
|
||||
if (request.kind == ui::ContractActionKind::request_demands) {
|
||||
auto demands = contract_demands(staged, manager, request.row, false, random);
|
||||
auto next = ui::contracts_from_game(staged, manager, ++local_revision);
|
||||
next.demands = demands;
|
||||
next.quote_id = next_quote_id++;
|
||||
next.quote_row = request.row;
|
||||
screen.acknowledge_quote(next);
|
||||
} else if (request.kind == ui::ContractActionKind::submit_offer) {
|
||||
if (request.term_column >= 4 || request.quote_id != screen.state().quote_id ||
|
||||
request.row != screen.state().quote_row || !screen.state().demands ||
|
||||
request.demand != (*screen.state().demands)[request.term_column] ||
|
||||
// Stale quote, wrong row or implausibly high salary: refuse.
|
||||
request.monthly_salary > 200000)
|
||||
throw FormatError("Vertragsangebot ist nicht mehr aktuell");
|
||||
const bool accepted = contract_offer(staged, manager, request.row,
|
||||
request.term_column, request.monthly_salary, request.demand,
|
||||
false, request.row == expired_row, random, &request.proposed_bonuses);
|
||||
auto next = ui::contracts_from_game(staged, manager, ++local_revision);
|
||||
next.feedback = accepted ? "Der Vertrag wurde verlängert." : "Das Angebot wurde abgelehnt.";
|
||||
screen.acknowledge_offer(next);
|
||||
if (accepted && request.row == expired_row) renewed_expired_player = true;
|
||||
} else if (request.kind == ui::ContractActionKind::submit_bonuses) {
|
||||
const bool accepted = contract_bonuses(staged, manager, request.row,
|
||||
request.proposed_bonuses);
|
||||
auto next = ui::contracts_from_game(staged, manager, ++local_revision);
|
||||
next.feedback = accepted ? "Die Prämien wurden übernommen." : "Die Prämien wurden nicht geändert.";
|
||||
screen.acknowledge_bonus_offer(next);
|
||||
} else if (request.kind == ui::ContractActionKind::insure_player) {
|
||||
const auto insured = contract_insurance(staged, manager, request.row,
|
||||
request.term_column, request.insurance_months);
|
||||
if (!insured.accepted) {
|
||||
screen.reject("Die Versicherung konnte nicht übernommen werden.");
|
||||
} else {
|
||||
auto next = ui::contracts_from_game(staged, manager, ++local_revision);
|
||||
next.demands = screen.state().demands;
|
||||
next.quote_id = screen.state().quote_id;
|
||||
next.quote_row = screen.state().quote_row;
|
||||
screen.acknowledge_insurance(next);
|
||||
}
|
||||
} else {
|
||||
throw FormatError("Unbekannte Vertragsaktion");
|
||||
}
|
||||
changed = true;
|
||||
} catch (...) {
|
||||
staged = old_game;
|
||||
random = old_random;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
if (screen.close_requested()) return renewed_expired_player ? 1 : 0;
|
||||
if (renewed_expired_player && !screen.result_page_open()) return 1;
|
||||
dirty_contracts |= changed;
|
||||
}
|
||||
// Keep audio streaming while idle, then yield the CPU briefly.
|
||||
if (playback.needs_pump()) playback.pump(audio_error);
|
||||
SDL_Delay(10);
|
||||
}
|
||||
staged = before;
|
||||
random = random_before;
|
||||
return -2;
|
||||
} catch (const std::exception&) {
|
||||
staged = before;
|
||||
random = random_before;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
// Reads the plain-background and text-gradient switches for the end-of-season dialogs.
|
||||
auto App::game_end_options(const GameState& state) -> bmh::ui::GameEndRenderOptions {
|
||||
return ui::GameEndRenderOptions{
|
||||
state.memory.has(::bmh::layout::PlainBackground) && state.memory.u8(::bmh::layout::PlainBackground) != 0,
|
||||
(!state.memory.has(::bmh::layout::TextGradientDisabled) || state.memory.u8(::bmh::layout::TextGradientDisabled) == 0) && season_exe.u8(::bmh::layout::TextGradientMode) == 2};
|
||||
}
|
||||
|
||||
// Blocks until a fresh left or right mouse press (pending mouse events are flushed first)
|
||||
// or quit.
|
||||
auto App::wait_season_ack() -> void {
|
||||
// Source SDLFlushEvents2/SDLFlushEvents flush pending mouse events, then wait for
|
||||
// a new left/right press. Physical keyboard ESC is not event8.
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
while (running) {
|
||||
SDL_Event event;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) return;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
// Modal dialog for the season tax event (question, notice or outcome). Returns true if the
|
||||
// player answered Yes. A button counts only when pressed and released on the same button.
|
||||
auto App::show_tax(const GameState& state, const SeasonTaxEvent& event) -> bool {
|
||||
if (!running) return false;
|
||||
const size_t base = size_t(event.manager_slot) * kManagerRecordSize;
|
||||
ui::TaxDialogProjection view;
|
||||
view.kind = event.kind == SeasonTaxEventKind::question
|
||||
? ui::TaxDialogKind::question : ui::TaxDialogKind::acknowledgement;
|
||||
view.compact_dialog_frame = state.memory.has(::bmh::layout::CompactDialogFrame) && state.memory.u8(::bmh::layout::CompactDialogFrame) != 0;
|
||||
for (size_t i = 0; i < 30 && state.manager_records[base + 0xa8 + i]; ++i)
|
||||
view.manager_name += char(state.manager_records[base + 0xa8 + i]);
|
||||
view.body = event.text;
|
||||
view.portrait = state.manager_records[base + 0x221];
|
||||
view.badge_fallback = original_badge_fallback(event.team);
|
||||
view.badge_sprite = view.badge_fallback ? 0 : le16(state.club_heap_78, size_t(event.team) * 2) & 0x1ff;
|
||||
ui::GameEndTaxDialog screen(data, std::move(view), game_end_options(state),
|
||||
event.kind == SeasonTaxEventKind::outcome ? season_backdrop : std::optional<Image>{});
|
||||
auto complete = [&](bool answer) {
|
||||
present_season(screen.backdrop(), "OpenBMH - season_tax_restored");
|
||||
return answer;
|
||||
};
|
||||
present_season(screen.render(), event.kind == SeasonTaxEventKind::question
|
||||
? "OpenBMH - season_tax_question" : event.kind == SeasonTaxEventKind::notice
|
||||
? "OpenBMH - season_tax_notice" : "OpenBMH - season_tax_outcome");
|
||||
auto pressed = ui::GameEndTaxDialog::Button::none;
|
||||
// Modal sub-loop (own event polling).
|
||||
while (running) {
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return false; }
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN) {
|
||||
if (event.kind != SeasonTaxEventKind::question &&
|
||||
input.button.button == SDL_BUTTON_RIGHT) return complete(false);
|
||||
if (input.button.button != SDL_BUTTON_LEFT) continue;
|
||||
pressed = screen.hit_test(input.button.x, input.button.y);
|
||||
if (event.kind != SeasonTaxEventKind::question &&
|
||||
pressed == ui::GameEndTaxDialog::Button::none) return complete(false);
|
||||
} else if (input.type == SDL_MOUSEMOTION &&
|
||||
screen.hit_test(input.motion.x, input.motion.y) != pressed) {
|
||||
pressed = ui::GameEndTaxDialog::Button::none;
|
||||
} else if (input.type == SDL_MOUSEBUTTONUP && input.button.button == SDL_BUTTON_LEFT) {
|
||||
const auto button = screen.hit_test(input.button.x, input.button.y);
|
||||
if (pressed != ui::GameEndTaxDialog::Button::none && button == pressed) {
|
||||
if (button == ui::GameEndTaxDialog::Button::yes) return complete(true);
|
||||
return complete(false);
|
||||
}
|
||||
pressed = ui::GameEndTaxDialog::Button::none;
|
||||
}
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Waits without consuming gameplay input; only a quit request is handled.
|
||||
auto App::wait_promotion_time(Uint32 milliseconds) -> void {
|
||||
const auto start = SDL_GetTicks();
|
||||
while (running && Uint32(SDL_GetTicks() - start) < milliseconds) {
|
||||
// SeasonPromotionScreen does not read gameplay input. Keep queued mouse/keyboard
|
||||
// events for the next Original input boundary; only handle SDL exit.
|
||||
SDL_PumpEvents();
|
||||
SDL_Event quit;
|
||||
if (quit_confirmation.peep(&quit, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) running = false;
|
||||
if (running) SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
// End-of-game highscore presentation: an interactive calculator when the signature is 0,
|
||||
// otherwise the table is updated on disk and shown when `display` is set; ends with the
|
||||
// final screen.
|
||||
auto App::show_highscore(const GameState& state, bool display) -> void {
|
||||
if (!running) return;
|
||||
const auto options = game_end_options(state);
|
||||
const uint16_t signature = state.memory.u16(::bmh::layout::CareerSession_FormatError_RuntimeField7);
|
||||
if (signature == 0) {
|
||||
// Source GameEndAlternateScoreScreen's alternate branch ignores display: both calls
|
||||
// open the calculator, followed by one presentation for each point.
|
||||
ui::GameEndAlternateScoreScreen screen(ui::load_game_end_alternate_score_assets(data),
|
||||
season_backdrop ? *season_backdrop : flow.render(), options.gradient_text);
|
||||
present_season(screen.render(), "OpenBMH - game_end_calculator");
|
||||
bool right_cancel = false;
|
||||
while (running && screen.phase() == ui::AlternateScorePhase::Calculator) {
|
||||
SDL_Event event;
|
||||
bool changed = false;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT) {
|
||||
right_cancel = true;
|
||||
changed |= screen.cancel(); // Source mouse cancellation event8
|
||||
} else if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) {
|
||||
const auto button = screen.button_at(event.button.x, event.button.y);
|
||||
if (button && *button < 15) {
|
||||
present_season(screen.render(button), "OpenBMH - game_end_calculator");
|
||||
SDL_Delay(4 * 20); // Source DecodeTaxAnimationScript2(4), 50-Hz ticks
|
||||
}
|
||||
changed |= screen.mouse_down(event.button.x, event.button.y);
|
||||
} else if (event.type == SDL_MOUSEMOTION) {
|
||||
changed |= screen.mouse_move(event.motion.x, event.motion.y);
|
||||
} else if (event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_LEFT) {
|
||||
changed |= screen.mouse_up();
|
||||
} else if (event.type == SDL_TEXTINPUT) {
|
||||
changed |= screen.text(event.text.text);
|
||||
} else if (event.type == SDL_KEYDOWN) {
|
||||
const auto key = event.key.keysym.sym;
|
||||
if (key == SDLK_RETURN) changed |= screen.key("ENTER");
|
||||
else if (key == SDLK_BACKSPACE) changed |= screen.key("BACKSPACE");
|
||||
else if (key == SDLK_SPACE) changed |= screen.key("SPACE");
|
||||
}
|
||||
if (screen.phase() != ui::AlternateScorePhase::Calculator) break;
|
||||
}
|
||||
if (changed && screen.phase() == ui::AlternateScorePhase::Calculator)
|
||||
present_season(screen.render(), "OpenBMH - game_end_calculator");
|
||||
SDL_Delay(10);
|
||||
}
|
||||
if (!running) return;
|
||||
if (!screen.accepted_value()) {
|
||||
if (!right_cancel) SDL_Delay(50 * 20); // Source N-key wait; mouse cancel skips it
|
||||
present_season(screen.render(), "OpenBMH - game_end_calculator_cancelled");
|
||||
} else {
|
||||
while (running && screen.advance_point())
|
||||
present_season(screen.render(), "OpenBMH - game_end_points");
|
||||
screen.finish_points();
|
||||
present_season(screen.render(), "OpenBMH - game_end_points_ack");
|
||||
wait_season_ack();
|
||||
}
|
||||
} else {
|
||||
const auto file = highscore_file(save_directory, signature, season_texts[889]);
|
||||
auto scores = make_highscore_projection(state, load_highscore_table(file), HighscoreContext::SeasonBoundary);
|
||||
// The Original stores this table outside the native FBM. Use the
|
||||
// configured writable save base rather than a working-directory path.
|
||||
std::error_code directory_error;
|
||||
fs::create_directories(file.parent_path(), directory_error);
|
||||
if (directory_error || !save_highscore_table(file, scores.rows))
|
||||
std::fprintf(stderr, "highscore: cannot write %s\n", file.string().c_str());
|
||||
if (display) {
|
||||
ui::GameEndHighscoreScreen screen(data, std::move(scores), options);
|
||||
present_season(screen.render(), "OpenBMH - game_end_highscore");
|
||||
wait_season_ack();
|
||||
}
|
||||
}
|
||||
if (display && running) {
|
||||
ui::GameEndFinalScreen screen(data, options);
|
||||
present_season(screen.render(), "OpenBMH - game_end_final");
|
||||
wait_season_ack();
|
||||
}
|
||||
}
|
||||
|
||||
// Callback at season-transition checkpoints; only the one for the German entrants does
|
||||
// anything: it shows the entrant screens, each closed by a mouse release.
|
||||
auto App::present_season_checkpoint(const char* checkpoint, const GameState& state) -> void {
|
||||
if (!running || std::strcmp(checkpoint, "the German entrants (CompetitionWinnerScreen)") != 0) return;
|
||||
// SeasonEntrantsFromGame / CompetitionWinnerScreen: show the three owned Original
|
||||
// projections while the transition is suspended at its checkpoint.
|
||||
// Other season animations remain separate implementation work.
|
||||
for (auto view : ui::season_entrants_from_game(state, season_exe, season_texts)) {
|
||||
ui::SeasonEntrantsScreen entrants_screen(data, std::move(view));
|
||||
SDL_SetWindowTitle(window, "OpenBMH - season_entrants");
|
||||
const Image image = entrants_screen.render();
|
||||
canvas.show(image, palette);
|
||||
bool dismissed = false;
|
||||
while (running && !dismissed) {
|
||||
SDL_Event event;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONUP &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
dismissed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!dismissed) SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto App::present_tax_event(const GameState& state, const SeasonTaxEvent& event) -> void {
|
||||
if (event.kind == SeasonTaxEventKind::notice || event.kind == SeasonTaxEventKind::outcome)
|
||||
(void)show_tax(state, event);
|
||||
if (running && event.kind == SeasonTaxEventKind::animation) {
|
||||
ui::GameEndTaxAnimationScreen animation(ui::load_game_end_tax_animation_assets(data),
|
||||
unsigned(event.animation_variant), season_backdrop ? *season_backdrop : flow.render(),
|
||||
state.memory.has(::bmh::layout::SolidPanelBackground) && state.memory.u8(::bmh::layout::SolidPanelBackground) != 0);
|
||||
while (running && animation.advance_step()) {
|
||||
present_season(animation.render(), "OpenBMH - season_tax_animation");
|
||||
const auto started = SDL_GetTicks();
|
||||
while (running && Uint32(SDL_GetTicks() - started) < animation.wait_milliseconds()) {
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) if (input.type == SDL_QUIT) running = false;
|
||||
// Source param4=0: clicks/keys cannot change this script or RNG.
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
// Source marker150 flips buffers without copying the visible frame.
|
||||
// Outcome ACK must start on the older drawing frame in this case.
|
||||
season_backdrop = animation.drawing_frame();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto App::present_promotion(const GameState& state, const SeasonPromotionEvent& event) -> void {
|
||||
if (!running) return;
|
||||
auto view = ui::season_promotion_from_game(state, event, season_exe, season_texts);
|
||||
ui::SeasonPromotionScreen screen(data, std::move(view));
|
||||
const auto show_step = [&](int step) {
|
||||
const auto title = "OpenBMH - season_promotion_" + std::to_string(event.group) + "_" + std::to_string(step);
|
||||
present_season(screen.render(step), title.c_str());
|
||||
};
|
||||
show_step(0);
|
||||
// Original checks the manager's stored animation-skip flag once,
|
||||
// after presenting the starting table, before both 50-tick waits.
|
||||
if (state.memory.has(::bmh::layout::BalancePlan_BalanceFromGame_RuntimeField) && state.memory.u8(::bmh::layout::BalancePlan_BalanceFromGame_RuntimeField) != 0) return;
|
||||
wait_promotion_time(50 * 20);
|
||||
for (int step = 1; running && step <= 38; ++step) show_step(step);
|
||||
if (running) wait_promotion_time(50 * 20);
|
||||
}
|
||||
|
||||
|
||||
auto App::present_cup_draw(const GameState& state, const SeasonCupDrawEvent& event) -> void {
|
||||
if (!running) return;
|
||||
if (event.phase == SeasonCupDrawPhase::draw) {
|
||||
if (!event.group_stage || event.group_index == 0)
|
||||
group_reveal_skipped = false;
|
||||
if (event.group_stage && group_reveal_skipped) {
|
||||
// SDLFlushEvents still runs before the native overview.
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto view = ui::cup_draw_from_game(state, event, season_exe, season_texts);
|
||||
if (!view.source_eligible) return;
|
||||
ui::CupDrawScreen screen(data, std::move(view));
|
||||
bool first_draw_frame = true;
|
||||
// Presents the current draw frame; the first frame or flagged steps flush queued mouse events.
|
||||
const auto show_draw = [&] {
|
||||
const auto title = "OpenBMH - cup_draw_" + std::to_string(screen.revealed_count());
|
||||
present_season(screen.render(), title.c_str());
|
||||
// DecodeTaxAnimationScript(1) flushes outside script execution (Main_Screen_RuntimeField2=0).
|
||||
// Script 0/1 presentations retain queued input (Main_Screen_RuntimeField2=1).
|
||||
if (first_draw_frame || screen.queue_flush_needed())
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
first_draw_frame = false;
|
||||
};
|
||||
if (event.phase == SeasonCupDrawPhase::draw) {
|
||||
// Source ignores the first OriginalMouseSound poll's gameplay result, then
|
||||
// presents the starting scene before its ten option-delay polls.
|
||||
SDL_Event initial;
|
||||
if (quit_confirmation.poll(&initial) && initial.type == SDL_QUIT) { running = false; return; }
|
||||
show_draw();
|
||||
while (running && screen.advance_step()) {
|
||||
if (screen.present_needed()) show_draw();
|
||||
wait_promotion_time(Uint32(screen.option_delay_milliseconds()));
|
||||
if (!running) return;
|
||||
if (screen.input_poll_needed()) {
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return; }
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(input.button.button == SDL_BUTTON_LEFT || input.button.button == SDL_BUTTON_RIGHT)) {
|
||||
screen.source_input(input.button.button == SDL_BUTTON_LEFT ? 2 : 8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// OriginalMouseSound synthetic left press at its normal poll
|
||||
// boundary; missing transient blocks are not zero values.
|
||||
if ((state.memory.has(::bmh::layout::BalancePlan_BalanceFromGame_RuntimeField) && state.memory.u8(::bmh::layout::BalancePlan_BalanceFromGame_RuntimeField) != 0) ||
|
||||
(state.memory.has(::bmh::layout::CareerSession_SportschauSourceOptions_ExecutableField) && state.memory.u8(::bmh::layout::CareerSession_SportschauSourceOptions_ExecutableField) == 0))
|
||||
screen.source_input(2);
|
||||
}
|
||||
if (screen.held_mouse_check_needed()) {
|
||||
SDL_PumpEvents();
|
||||
const auto held = SDL_GetMouseState(nullptr, nullptr);
|
||||
screen.source_held_mouse(uint8_t((held & SDL_BUTTON_LMASK ? 1 : 0) |
|
||||
(held & SDL_BUTTON_RMASK ? 2 : 0)));
|
||||
}
|
||||
if (!screen.reveal_aborted()) wait_promotion_time(Uint32(screen.wait_milliseconds()));
|
||||
}
|
||||
if (running && screen.reveal_complete() && !screen.reveal_aborted()) {
|
||||
present_season(screen.render(), "OpenBMH - cup_draw_ack");
|
||||
wait_season_ack();
|
||||
}
|
||||
if (event.group_stage && screen.reveal_aborted())
|
||||
group_reveal_skipped = true;
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP); // SDLFlushEvents before native sort
|
||||
return;
|
||||
}
|
||||
present_season(screen.render(), "OpenBMH - cup_overview");
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
while (running) {
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return; }
|
||||
if (input.type != SDL_MOUSEBUTTONDOWN) continue;
|
||||
if (input.button.button == SDL_BUTTON_RIGHT) return;
|
||||
if (input.button.button == SDL_BUTTON_LEFT) {
|
||||
const auto club = screen.hit_test_team(input.button.x, input.button.y);
|
||||
if (club) {
|
||||
auto services=session->live_club_modal_services(revision);
|
||||
(void)present_club_information(services,*club);
|
||||
if (!running) return;
|
||||
// Native category/squad edits belong to the clicked
|
||||
// Source modal. Rebuild the overview from the current
|
||||
// state while retaining its owned sorted round field.
|
||||
auto current = ui::cup_draw_from_game(session->state(), event, season_exe, season_texts);
|
||||
screen = ui::CupDrawScreen(data, std::move(current));
|
||||
present_season(screen.render(), "OpenBMH - cup_overview");
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,446 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// App: the timers and deadlines the event loop serves between inputs (process timer, table, balance, pairings, stadium, friendly match pickers).
|
||||
// (moved out of main.cpp unchanged; the class is declared in app/app.hpp)
|
||||
#include "app/app.hpp"
|
||||
|
||||
// Seconds since this process started; the time source for the process timer.
|
||||
auto App::process_source_seconds() -> uint64_t {
|
||||
return uint64_t(std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::steady_clock::now()-process_clock_origin).count());
|
||||
}
|
||||
|
||||
// Returns the image with the process timer bar painted on it while the timer runs.
|
||||
auto App::process_timer_image(Image image) -> bmh::Image {
|
||||
if (!process_timer.paused() && process_timer_frame)
|
||||
ui::ProcessTimer::paint(image, *process_timer_frame, season_exe);
|
||||
return image;
|
||||
}
|
||||
|
||||
// Sample writes only y0. Nested synchronous presenters poll the
|
||||
// same Desk-owned clock without re-entering Session/Flow dispatch.
|
||||
// Samples the process timer. When the bar changed and update_texture is set, only the
|
||||
// top pixel row of the texture is refreshed (and presented if `present`). Returns true
|
||||
// once the timer has expired.
|
||||
auto App::poll_process_timer(bool update_texture, bool present) -> bool {
|
||||
const auto sample = process_timer.sample(process_source_seconds());
|
||||
const bool changed_bar = sample && !sample->expired &&
|
||||
(!process_timer_frame || sample->percent != process_timer_frame->percent);
|
||||
process_timer_frame = sample;
|
||||
if (changed_bar && update_texture) {
|
||||
Image bar(320,240);
|
||||
ui::ProcessTimer::paint(bar,*sample,season_exe);
|
||||
for (size_t x=0;x<320;++x) pixels[x]=palette.argb[bar.pixels[x]];
|
||||
const SDL_Rect top{0,0,320,1};
|
||||
if (SDL_UpdateTexture(texture,&top,pixels.data(),320*4)!=0)
|
||||
throw std::runtime_error(std::string("Process timer texture: ")+SDL_GetError());
|
||||
if (present) {
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer,texture,nullptr,nullptr);
|
||||
app::present(renderer);
|
||||
}
|
||||
}
|
||||
return sample && sample->expired;
|
||||
}
|
||||
|
||||
// Flashes the formation-saved feedback image, then shows the restored screen.
|
||||
auto App::present_formation_save_feedback() -> void {
|
||||
for (bool restored : {false, true}) {
|
||||
const auto feedback = flow.pitch_formation_save_feedback(restored);
|
||||
if (!feedback) break;
|
||||
const auto image = process_timer_image(*feedback);
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]];
|
||||
if (SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4) != 0 ||
|
||||
SDL_RenderClear(renderer) != 0 || SDL_RenderCopy(renderer, texture, nullptr, nullptr) != 0)
|
||||
throw std::runtime_error(std::string("Formation save renderer: ") + SDL_GetError());
|
||||
app::present(renderer);
|
||||
if (!restored) SDL_Delay(ui::PitchScreen::formation_save_flash_ms);
|
||||
}
|
||||
}
|
||||
|
||||
// Called every loop pass. If the left button has been held long enough on the pitch
|
||||
// screen at the position where it was pressed, triggers the hold action once.
|
||||
auto App::service_pitch_hold() -> void {
|
||||
if (!press || press->pitch_hold_attempted || !flow.in_pitch() ||
|
||||
press->screen != flow.screen_name() || press->revision != revision) return;
|
||||
const auto ticks = ui::pointer_hold_source_ticks(SDL_GetTicks64()) - press->source_tick;
|
||||
if (!ui::pointer_source_hold_ready(ticks)) return;
|
||||
int window_x=0,window_y=0;
|
||||
if (!(SDL_GetMouseState(&window_x,&window_y) & SDL_BUTTON_LMASK)) return;
|
||||
float x=0,y=0;
|
||||
SDL_RenderWindowToLogical(renderer,window_x,window_y,&x,&y);
|
||||
if (int(x)!=press->x || int(y)!=press->y) { press.reset(); return; }
|
||||
press->pitch_hold_attempted = true;
|
||||
const auto held = flow.pitch_held_left(press->x,press->y,ticks);
|
||||
present_formation_save_feedback();
|
||||
handle(held);
|
||||
}
|
||||
|
||||
// Seconds since the loop started in the pairings screen's source units.
|
||||
auto App::pairings_source_seconds() -> uint64_t {
|
||||
const auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - pairings_clock_start).count();
|
||||
return ui::league_pairings_source_seconds(uint64_t(milliseconds));
|
||||
}
|
||||
|
||||
// Milliseconds since the same clock started; the base for the table, balance and
|
||||
// calculator timers below.
|
||||
auto App::balance_source_milliseconds() -> uint64_t {
|
||||
return uint64_t(std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now()-pairings_clock_start).count());
|
||||
}
|
||||
|
||||
// DecodeTaxAnimationScript2 multiplies its argument by 20 before host timer's
|
||||
// millisecond conversion. This is the host unit scale, not a claim
|
||||
// of parity with the Original DOS clock's quantization.
|
||||
// Elapsed time in 20 ms source units.
|
||||
auto App::family_table_source_units() -> uint64_t {
|
||||
return balance_source_milliseconds() / 20;
|
||||
}
|
||||
|
||||
// Tells the flow the table frame has reached the screen; it may answer with a request.
|
||||
auto App::mark_family_table_presented() -> void {
|
||||
const auto acknowledged = flow.in_toto_calculator()
|
||||
? flow.after_toto_present(family_table_source_units())
|
||||
: flow.after_family_table_present(family_table_source_units());
|
||||
if (acknowledged.request != ui::FlowRequest::none) handle(acknowledged);
|
||||
else dirty |= acknowledged.changed;
|
||||
}
|
||||
|
||||
// Redraws the league table or toto screen when dirty, then marks it as presented.
|
||||
auto App::present_family_table_redraw() -> void {
|
||||
if ((!flow.in_family_table() && flow.screen_name() != "toto") || !dirty) return;
|
||||
const auto image = process_timer_image(flow.render());
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]];
|
||||
if (SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4) != 0 ||
|
||||
SDL_RenderClear(renderer) != 0 || SDL_RenderCopy(renderer, texture, nullptr, nullptr) != 0)
|
||||
throw std::runtime_error(std::string("Table renderer: ") + SDL_GetError());
|
||||
app::present(renderer);
|
||||
dirty = false;
|
||||
mark_family_table_presented();
|
||||
}
|
||||
|
||||
// Collects typed digits, ENTER, BACKSPACE and SPACE for those screens. Returns true when
|
||||
// the event belongs to them (unsupported keys are swallowed too).
|
||||
auto App::queue_table_range_event(const SDL_Event& event) -> bool {
|
||||
if (!flow.in_toto_calculator() &&
|
||||
(!flow.in_family_table_range_dialog() || !flow.league_family_identity())) return false;
|
||||
const auto queue = [&](std::string key) {
|
||||
if (flow.in_toto_calculator())
|
||||
table_range_keys.push_back({std::move(key), {}, flow.toto()->state().manager_slot,
|
||||
flow.toto()->state().revision});
|
||||
else table_range_keys.push_back({std::move(key), *flow.league_family_identity()});
|
||||
};
|
||||
if (event.type == SDL_TEXTINPUT) {
|
||||
const std::string_view text(event.text.text);
|
||||
if (std::all_of(text.begin(), text.end(), [](char c) { return c >= '0' && c <= '9'; }))
|
||||
for (char c : text) queue(std::string(1, c));
|
||||
return true;
|
||||
}
|
||||
if (event.type != SDL_KEYDOWN) return false;
|
||||
if (event.key.keysym.sym == SDLK_RETURN) queue("ENTER");
|
||||
else if (event.key.keysym.sym == SDLK_BACKSPACE) queue("BACKSPACE");
|
||||
else if (event.key.keysym.sym == SDLK_SPACE) queue("SPACE");
|
||||
// No SDL Escape/right-button origin for Source raw event 8 has
|
||||
// been established for this modal. Unsupported keys stay owned.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Called every loop pass while a table or toto screen is open: advances its timers,
|
||||
// redraws, and feeds queued keys whenever the screen is ready for input.
|
||||
auto App::service_family_table() -> void {
|
||||
if (!flow.in_family_table() && flow.screen_name() != "toto") { table_range_keys.clear(); return; }
|
||||
const auto tick = flow.in_toto_calculator()
|
||||
? flow.tick_toto_source_units(family_table_source_units())
|
||||
: flow.tick_family_table_source_units(family_table_source_units());
|
||||
if (tick.request != ui::FlowRequest::none) handle(tick);
|
||||
else dirty |= tick.changed;
|
||||
present_family_table_redraw();
|
||||
if (!flow.in_family_table_range_dialog() && !flow.in_toto_calculator()) table_range_keys.clear();
|
||||
while (!table_range_keys.empty() &&
|
||||
(flow.family_table_range_input_ready() || flow.toto_calculator_input_ready())) {
|
||||
auto input = std::move(table_range_keys.front());
|
||||
table_range_keys.pop_front();
|
||||
if ((input.toto_manager >= 0 && flow.in_toto_calculator() &&
|
||||
input.toto_manager == flow.toto()->state().manager_slot &&
|
||||
input.toto_revision == flow.toto()->state().revision) ||
|
||||
(input.toto_manager < 0 && flow.league_family_identity() && input.identity == *flow.league_family_identity())) {
|
||||
handle(flow.send_key(input.key));
|
||||
present_family_table_redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Presents the balance screen only when its identity or notice state changed.
|
||||
auto App::present_balance_redraw() -> void {
|
||||
if (!flow.in_balance()) { presented_balance.reset();presented_balance_notice=false; return; }
|
||||
const auto identity=flow.balance()->state().identity;
|
||||
const bool notice=flow.balance()->notice_open();
|
||||
if(presented_balance&&*presented_balance==identity&¬ice==presented_balance_notice)return;
|
||||
const auto image=process_timer_image(flow.render());
|
||||
canvas.show(image, palette);
|
||||
flow.mark_balance_presented_source_milliseconds(balance_source_milliseconds());
|
||||
presented_balance=identity;presented_balance_notice=notice;dirty=false;
|
||||
}
|
||||
|
||||
// Called every loop pass: advances the balance screen's millisecond timer.
|
||||
auto App::service_balance_timer() -> void {
|
||||
present_balance_redraw();
|
||||
const auto tick=flow.tick_balance_source_milliseconds(balance_source_milliseconds());
|
||||
if(tick.request!=ui::FlowRequest::none){handle(tick);present_balance_redraw();}
|
||||
else if(tick.changed){dirty=true;presented_balance.reset();}
|
||||
}
|
||||
|
||||
// Queues a key for the current stadium calculator owner.
|
||||
auto App::queue_calculator_key(std::string key) -> void {
|
||||
const auto& owner = flow.stadium()->state();
|
||||
calculator_keys.push_back({std::move(key), owner.revision, owner.scope, owner.sequence});
|
||||
}
|
||||
|
||||
// Collects typed digits, ENTER, BACKSPACE and SPACE for the stadium calculator; returns
|
||||
// true when the event is consumed.
|
||||
auto App::queue_calculator_event(const SDL_Event& event) -> bool {
|
||||
if (event.type == SDL_TEXTINPUT) {
|
||||
const std::string_view text(event.text.text);
|
||||
if (!std::all_of(text.begin(), text.end(), [](char c) { return c >= '0' && c <= '9'; }))
|
||||
return true;
|
||||
for (const char c : text) queue_calculator_key(std::string(1, c));
|
||||
return true;
|
||||
}
|
||||
if (event.type != SDL_KEYDOWN) return false;
|
||||
if (event.key.keysym.sym == SDLK_RETURN) queue_calculator_key("ENTER");
|
||||
else if (event.key.keysym.sym == SDLK_BACKSPACE) queue_calculator_key("BACKSPACE");
|
||||
else if (event.key.keysym.sym == SDLK_SPACE) queue_calculator_key("SPACE");
|
||||
// The calculator owns every keyboard event. Unsupported keys,
|
||||
// including Escape, must not reach the outer application shortcut.
|
||||
// Digits arrive separately through SDL_TEXTINPUT.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Starts the calculator's wait clock once its frame has reached the screen.
|
||||
auto App::mark_stadium_calculator_presented() -> void {
|
||||
if (!flow.in_stadium() || !flow.stadium()->calculator_source_waiting()) {
|
||||
calculator_tick_anchor.reset();
|
||||
return;
|
||||
}
|
||||
flow.mark_stadium_calculator_presented();
|
||||
if (!calculator_tick_anchor) calculator_tick_anchor = balance_source_milliseconds();
|
||||
}
|
||||
|
||||
// Called every loop pass while the stadium screen is open: converts elapsed time into
|
||||
// source ticks for the calculator's waits and feeds queued keys.
|
||||
auto App::service_stadium_calculator() -> void {
|
||||
if (!flow.in_stadium()) {
|
||||
calculator_release.reset(); calculator_tick_anchor.reset();
|
||||
calculator_keys.clear();
|
||||
return;
|
||||
}
|
||||
if (flow.stadium()->calculator_source_waiting() && calculator_tick_anchor) {
|
||||
const uint64_t now = balance_source_milliseconds();
|
||||
const uint64_t ticks = (now - *calculator_tick_anchor) / 20;
|
||||
if (ticks != 0) {
|
||||
// No wait exceeds fifty ticks, so bound narrowing and keep
|
||||
// the unused remainder for the next physical-clock sample.
|
||||
const unsigned step = unsigned(std::min<uint64_t>(ticks, 50));
|
||||
*calculator_tick_anchor += uint64_t(step) * 20;
|
||||
const auto tick = flow.tick_stadium_calculator_source_ticks(step);
|
||||
if (tick.request != ui::FlowRequest::none) handle(tick);
|
||||
else dirty |= tick.changed;
|
||||
}
|
||||
}
|
||||
if (!flow.in_stadium()) {
|
||||
calculator_release.reset(); calculator_tick_anchor.reset();
|
||||
calculator_keys.clear();
|
||||
return;
|
||||
}
|
||||
if (!flow.stadium()->calculator_source_waiting()) {
|
||||
calculator_tick_anchor.reset();
|
||||
// The remembered release is delivered only if the calculator owner is unchanged and still
|
||||
// waits for the key release.
|
||||
if (calculator_release) {
|
||||
const auto release = *calculator_release;
|
||||
calculator_release.reset();
|
||||
const auto& owner = flow.stadium()->state();
|
||||
if (owner.scope == release.scope && owner.sequence == release.sequence &&
|
||||
flow.stadium()->calculator_waiting_for_key_release())
|
||||
handle(flow.click(release.button.x, release.button.y));
|
||||
press.reset();
|
||||
}
|
||||
}
|
||||
if (!flow.stadium()->calculator_open()) calculator_keys.clear();
|
||||
while (!calculator_keys.empty() && !flow.stadium()->calculator_source_waiting() &&
|
||||
!flow.stadium()->calculator_waiting_for_key_release() && !flow.stadium()->pending()) {
|
||||
auto input = std::move(calculator_keys.front());
|
||||
calculator_keys.pop_front();
|
||||
const auto& owner = flow.stadium()->state();
|
||||
if (owner.revision == input.revision && owner.scope == input.scope &&
|
||||
owner.sequence == input.sequence)
|
||||
handle(flow.send_key(input.key));
|
||||
}
|
||||
}
|
||||
|
||||
// Presents the league pairings screen when its page identity changed.
|
||||
auto App::present_pairings_redraw() -> void {
|
||||
if (!flow.in_league_pairings()) { presented_pairings.reset(); return; }
|
||||
const auto identity = flow.league_pairings()->state().identity;
|
||||
if (presented_pairings && *presented_pairings == identity) return;
|
||||
const auto image = process_timer_image(flow.render());
|
||||
canvas.show(image, palette);
|
||||
flow.mark_league_pairings_presented_source_seconds(pairings_source_seconds());
|
||||
presented_pairings = identity;
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
// Called every loop pass: advances the pairings screen's second timer.
|
||||
auto App::service_pairings_timer() -> void {
|
||||
present_pairings_redraw();
|
||||
const auto tick = flow.tick_league_pairings_source_seconds(pairings_source_seconds());
|
||||
if (tick.request != ui::FlowRequest::none) {
|
||||
handle(tick);
|
||||
// Move anchors its clock after each accepted full redraw.
|
||||
present_pairings_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
// Identity of the stadium tip/quote question currently open, if any.
|
||||
auto App::stadium_question_frame() -> std::optional<StadiumQuestionFrame> {
|
||||
if (!session || !flow.in_stadium()) return {};
|
||||
const auto& question=flow.stadium()->state();
|
||||
if (!question.construction_tip_dialog && !question.periphery_quote_dialog) return {};
|
||||
const auto& state=flow.stadium()->state();
|
||||
return StadiumQuestionFrame{session->session_id(),uint64_t(state.manager_slot),state.scope,state.sequence,state.revision};
|
||||
}
|
||||
|
||||
// Records the current stadium question frame as presented.
|
||||
auto App::mark_stadium_question_presented() -> void { presented_stadium_question=stadium_question_frame(); }
|
||||
|
||||
// If the presented stadium question has expired, hands the expiry to the flow. Returns
|
||||
// true when it did.
|
||||
auto App::service_stadium_deadline() -> bool {
|
||||
const auto owner=stadium_question_frame();
|
||||
if (!owner || owner!=presented_stadium_question) return false;
|
||||
if (!session->stadium_tip_deadline_expired() && !poll_process_timer(false,false)) return false;
|
||||
const auto expired = flow.expire_stadium_tip();
|
||||
if (expired.request == ui::FlowRequest::none) return false;
|
||||
handle(expired);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Same check from the idle path, but not while the question's button is being held.
|
||||
auto App::service_idle_stadium_deadline() -> void {
|
||||
// OriginalMouseSound/Sample can synthesize event8 on expiry, including idle.
|
||||
// ExpireQuestion's held-button helper must return before57ef7 answers.
|
||||
if (flow.in_stadium() && !flow.stadium()->construction_tip_held())
|
||||
service_stadium_deadline();
|
||||
}
|
||||
|
||||
|
||||
auto App::national_picker_frame() -> std::optional<NationalPickerFrame> {
|
||||
if (!session || flow.screen_name() != "national_friendly_picker" || !flow.national_friendly_owner()) return {};
|
||||
return NationalPickerFrame{session->session_id(),*flow.national_friendly_owner()};
|
||||
}
|
||||
|
||||
|
||||
auto App::mark_national_picker_presented() -> void { presented_national_picker=national_picker_frame(); }
|
||||
|
||||
// Identity of the friendly opponent picker currently open, if any.
|
||||
auto App::friendly_picker_frame() -> std::optional<FriendlyPickerFrame> {
|
||||
const auto* picker=flow.friendly_opponent_picker();
|
||||
if (!session || !picker || !flow.desktop()) return {};
|
||||
const auto& desk=flow.desktop()->state();
|
||||
return FriendlyPickerFrame{session->session_id(),uint64_t(desk.manager_slot),
|
||||
uint64_t(desk.runtime_club),desk.revision,uint64_t(picker->selected_league())};
|
||||
}
|
||||
|
||||
|
||||
auto App::mark_friendly_picker_presented() -> void { presented_friendly_picker=friendly_picker_frame(); }
|
||||
|
||||
|
||||
auto App::friendly_calendar_frame() -> std::optional<FriendlyCalendarFrame> {
|
||||
if (!session || !flow.friendly_calendar_quote()) return {};
|
||||
const auto& quote=*flow.friendly_calendar_quote();
|
||||
return FriendlyCalendarFrame{session->session_id(),uint64_t(quote.manager_slot),
|
||||
uint64_t(quote.runtime_team),quote.revision,quote.request_id};
|
||||
}
|
||||
|
||||
|
||||
auto App::mark_friendly_calendar_presented() -> void { presented_friendly_calendar=friendly_calendar_frame(); }
|
||||
|
||||
|
||||
auto App::friendly_question_frame() -> std::optional<FriendlyQuestionFrame> {
|
||||
const auto* question=flow.friendly_question_screen();
|
||||
if(!session||!question||!flow.desktop())return {};
|
||||
const auto& desk=flow.desktop()->state();
|
||||
return FriendlyQuestionFrame{session->session_id(),uint64_t(desk.manager_slot),
|
||||
uint64_t(desk.runtime_club),desk.revision,uint64_t(question->stage()),
|
||||
uint64_t(question->selected_opponent()),question->quote()?question->quote()->request_id:0,
|
||||
uint64_t(question->active_question()->source_manager_flags)};
|
||||
}
|
||||
|
||||
|
||||
auto App::mark_friendly_question_presented() -> void { presented_friendly_question=friendly_question_frame(); }
|
||||
|
||||
// If the presented friendly question has expired, hands the expiry to the flow. Returns
|
||||
// true when it did.
|
||||
auto App::service_friendly_question_deadline() -> bool {
|
||||
const auto owner=friendly_question_frame();
|
||||
if(!owner||owner!=presented_friendly_question||!poll_process_timer(false,false))return false;
|
||||
const auto expired=flow.expire_friendly_question(true);
|
||||
if(expired.request==ui::FlowRequest::none&&!expired.changed)return false;
|
||||
handle(expired);return true;
|
||||
}
|
||||
|
||||
// Called every loop pass and before each event. On the desktop it starts or resumes the
|
||||
// process timer for the current session/manager/day and polls it. It does nothing until
|
||||
// the modal frames above have been presented and while a button is held. On expiry the
|
||||
// flow is told with the current logical mouse position.
|
||||
auto App::service_process_timer() -> void {
|
||||
// SDLFlushEvents3's notice owns its wait. Keep the desk clock polling,
|
||||
// but hand its outer expiry back only after this notice restores.
|
||||
if(flow.timed_notice_open()) { poll_process_timer(!dirty,false); return; }
|
||||
if (!session || !flow.desktop()) {
|
||||
process_timer.stop(); process_timer_owner.reset(); process_timer_frame.reset();
|
||||
return;
|
||||
}
|
||||
if (flow.screen_name() == "desktop") {
|
||||
const auto& desk = flow.desktop()->state();
|
||||
const ProcessTimerOwner owner{session->session_id(), desk.manager_slot, desk.day_counter};
|
||||
const auto minutes = session->state().memory.u8(::bmh::layout::CareerSession_DispatchStrengths_ExecutableField);
|
||||
if (!process_timer_owner || *process_timer_owner != owner) {
|
||||
process_timer.start(minutes, process_source_seconds()); process_timer_owner = owner;
|
||||
} else if (process_timer.paused()) {
|
||||
process_timer.resume(minutes, process_source_seconds());
|
||||
}
|
||||
}
|
||||
// ExpireQuestion's held controls and Source calculator waits own their
|
||||
// release. The outer event8 is serviced after that owner returns.
|
||||
//1e06b paints its initial nation bank before the first2de66 poll.
|
||||
const auto picker_owner=national_picker_frame();
|
||||
if (picker_owner && picker_owner!=presented_national_picker) return;
|
||||
//50775 paints its accepted league before its first51135/OriginalMouseSound poll.
|
||||
const auto friendly_picker_owner=friendly_picker_frame();
|
||||
if (!friendly_picker_owner) presented_friendly_picker.reset();
|
||||
if (friendly_picker_owner && friendly_picker_owner!=presented_friendly_picker) return;
|
||||
//CalendarCell presents the initial calendar before its input loop.
|
||||
const auto calendar_owner=friendly_calendar_frame();
|
||||
if (calendar_owner && calendar_owner!=presented_friendly_calendar) return;
|
||||
const auto question_owner=stadium_question_frame();
|
||||
if (question_owner && question_owner!=presented_stadium_question) return;
|
||||
const auto friendly_question_owner=friendly_question_frame();
|
||||
if(!friendly_question_owner)presented_friendly_question.reset();
|
||||
if(friendly_question_owner&&friendly_question_owner!=presented_friendly_question)return;
|
||||
if (press || (flow.friendly_question_screen()&&flow.friendly_question_screen()->question_held())) {
|
||||
//ExpireQuestion still polls the clock while holding its button. Only
|
||||
//the timer row advances; the answer and frame ACK stay owned.
|
||||
if (question_owner || friendly_picker_owner || friendly_question_owner) poll_process_timer(!dirty,false);
|
||||
return;
|
||||
}
|
||||
// A clock repaint never re-enters a table/forecast draw or ACK.
|
||||
if (poll_process_timer(!dirty, false)) {
|
||||
int window_x=0,window_y=0;
|
||||
SDL_GetMouseState(&window_x,&window_y);
|
||||
float logical_x=0,logical_y=0;
|
||||
SDL_RenderWindowToLogical(renderer,window_x,window_y,&logical_x,&logical_y);
|
||||
const auto expired = flow.process_timer_expired(int(logical_x),int(logical_y));
|
||||
if (expired.request != ui::FlowRequest::none || expired.changed) handle(expired);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// App: the Sportschau (intro, replay scenes, fixtures, winner, awards, team info) and its waits.
|
||||
// (moved out of main.cpp unchanged; the class is declared in app/app.hpp)
|
||||
#include "app/app.hpp"
|
||||
|
||||
// Same acknowledgement wait as above, used by the Sportschau screens.
|
||||
auto App::wait_sportschau_ack() -> void {
|
||||
// Source SDLFlushEvents2 flushes pending mouse input, then accepts fresh
|
||||
// left/right input. Keyboard Escape is not an Original ACK here.
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
while (running) {
|
||||
SDL_Event event;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) return;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
// Waits `ticks` units of 20 ms; only a window close request interrupts it.
|
||||
auto App::source_tick_wait(unsigned ticks) -> void {
|
||||
for (unsigned i = 0; running && i < ticks; ++i) {
|
||||
SDL_Delay(20); // Source timer unit used by the traced intro path.
|
||||
SDL_PumpEvents();
|
||||
SDL_Event close;
|
||||
while (quit_confirmation.peep(&close, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0)
|
||||
running = false; // platform close is the only intro-loop escape
|
||||
}
|
||||
}
|
||||
|
||||
// Waits `count` original-display refresh periods using the high-resolution counter so
|
||||
// the pacing is the same on 60/120/144 Hz monitors; only a close request interrupts it.
|
||||
auto App::wait_source_retraces(unsigned count) -> void {
|
||||
// Keep the VGA cadence on 60/120/144-Hz host displays alike.
|
||||
constexpr auto refresh_hz = ui::kOriginalRefreshHz;
|
||||
const Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||
const Uint64 ticks_per_wait = (frequency + Uint64(refresh_hz) - 1) / Uint64(refresh_hz);
|
||||
for (unsigned i = 0; running && i < count; ++i) {
|
||||
const Uint64 started = SDL_GetPerformanceCounter();
|
||||
while (running && SDL_GetPerformanceCounter() - started < ticks_per_wait) {
|
||||
SDL_PumpEvents();
|
||||
SDL_Event close;
|
||||
while (quit_confirmation.peep(&close, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0)
|
||||
running = false; // platform close is the only animation-loop escape
|
||||
if (running) SDL_Delay(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Builds the render options (panel background, gradient text) for Sportschau screens.
|
||||
auto App::sportschau_context(const GameState& state) -> bmh::ui::SportschauReportContext {
|
||||
ui::SportschauReportContext context;
|
||||
context.solid_panel_background = state.memory.has(::bmh::layout::SolidPanelBackground) && state.memory.u8(::bmh::layout::SolidPanelBackground) != 0;
|
||||
context.gradient_text = state.memory.has(::bmh::layout::TextGradientDisabled) && state.memory.u8(::bmh::layout::TextGradientDisabled) == 0 &&
|
||||
season_exe.u8(::bmh::layout::TextGradientMode) == 2;
|
||||
return context;
|
||||
}
|
||||
|
||||
// --- presenters the engine calls through hooks (wired in run()): Sportschau, tax, promotion, the club
|
||||
// dialogs, the poach selection and the cup draw ---
|
||||
|
||||
// Plays the Sportschau intro animation frames with fanfare, then waits for a click.
|
||||
auto App::present_sportschau_intro(const GameState&, const SportschauIntroView&) -> void {
|
||||
if (!running) return;
|
||||
// PaletteOverride installs KB132's embedded palette; SportschauIntro restores the
|
||||
// normal palette on return. Keep the override local to intro frames.
|
||||
const auto& intro_palette = sportschau_intro.palette_override();
|
||||
const Palette* intro_colors = intro_palette ? &*intro_palette : nullptr;
|
||||
for (uint32_t frame = 0; running && frame < ui::SportschauIntro::frame_count; ++frame) {
|
||||
if (frame != 0) wait_source_retraces(5);
|
||||
if (!running) return;
|
||||
present_season(sportschau_intro.render_frame(frame), "OpenBMH - sportschau_intro", intro_colors);
|
||||
if (frame == 0) {
|
||||
source_tick_wait(70);
|
||||
app::original_audio_command(playback, 2); // SportschauIntro, Original S/2002 fanfare.
|
||||
source_tick_wait(45);
|
||||
}
|
||||
}
|
||||
if (!running) return;
|
||||
source_tick_wait(100);
|
||||
app::original_audio_command(playback, 1);
|
||||
if (!running) return;
|
||||
present_season(sportschau_intro.render_frame(ui::SportschauIntro::frame_count - 1),
|
||||
"OpenBMH - sportschau_intro_ack", intro_colors);
|
||||
wait_sportschau_ack();
|
||||
}
|
||||
|
||||
// Shows the matchday intro screen for a fixed time; a left click skips it.
|
||||
auto App::present_matchday_intro(const GameState&, const MatchdayIntroView& view) -> void {
|
||||
if (!running) return;
|
||||
present_season(matchday_intro.render(view), "OpenBMH - matchday_intro",
|
||||
matchday_intro.palette_override() ? &*matchday_intro.palette_override() : nullptr);
|
||||
// SDLGetTicks reads BIOS ticks at BDA46c (PIT1193182 /65536 Hz),
|
||||
// unlike the separate 20ms units of DecodeTaxAnimationScript2. Source waits36 ticks.
|
||||
// 36 ticks of the DOS BIOS timer (1193182 Hz / 65536) converted to milliseconds.
|
||||
constexpr Uint32 duration = (36ull * 65536 * 1000 + 1193181) / 1193182;
|
||||
const Uint32 start = SDL_GetTicks();
|
||||
SDL_FlushEvents(SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP);
|
||||
bool skipped = false;
|
||||
while (running && !skipped && SDL_GetTicks() - start < duration) {
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) running = false;
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_LEFT)
|
||||
skipped = true;
|
||||
}
|
||||
if (running && !skipped) SDL_Delay(1);
|
||||
}
|
||||
SDL_FlushEvents(SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP);
|
||||
}
|
||||
|
||||
// Shows one step of the report replay (log entries growing minute by minute).
|
||||
// Returns true when the replay should stop (quit) or be skipped by a left click.
|
||||
auto App::present_sportschau_replay_step(const GameState& state,
|
||||
const SportschauFixtureView& fixture, const SportschauReportStep& step) -> bool {
|
||||
if (!running) return true;
|
||||
if (step.visible_log_entries == 0 && step.progress_minute == 0) {
|
||||
app::original_match_audio_command(playback, state, 3);
|
||||
sportschau_replay_screen.emplace(data, fixture, sportschau_context(state));
|
||||
sportschau_step_index = 0;
|
||||
}
|
||||
if (!sportschau_replay_screen) throw FormatError("sportschau: missing report owner");
|
||||
bool skip = false;
|
||||
SDL_Event input;
|
||||
// Only minute pauses accept input; other steps just look for a close request.
|
||||
if (step.minute_wait) {
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) running = false;
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN && input.button.button == SDL_BUTTON_LEFT)
|
||||
skip = true;
|
||||
}
|
||||
} else {
|
||||
SDL_PumpEvents();
|
||||
while (quit_confirmation.peep(&input, 1, SDL_GETEVENT, SDL_QUIT, SDL_QUIT) > 0) running = false;
|
||||
}
|
||||
if (!running) return true;
|
||||
const std::string title = "OpenBMH - sportschau_replay_" + std::to_string(fixture.group) +
|
||||
"_" + std::to_string(fixture.fixture) + "_" + std::to_string(sportschau_step_index++);
|
||||
present_season(sportschau_replay_screen->render_report(step), title.c_str());
|
||||
const int raw = state.memory.has(::bmh::layout::Main_FormatError_RuntimeField4) ? state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField4) : 0;
|
||||
if (step.minute_wait) source_tick_wait(unsigned(raw < 6 ? raw / 2 : raw));
|
||||
if (step.chance_wait) source_tick_wait(50);
|
||||
return skip;
|
||||
}
|
||||
|
||||
// Plays one highlight (header, optional set piece, shot animation) of the replay, using
|
||||
// the memory-driven delays, then restores the report screen.
|
||||
auto App::present_sportschau_scene(const GameState& state,
|
||||
const SportschauFixtureView& fixture, const SportschauSceneView& scene) -> void {
|
||||
if (!running) return;
|
||||
ui::LiveMatchdayFrame frame;
|
||||
frame.gradient_text = sportschau_context(state).gradient_text;
|
||||
LiveChanceEvent event;
|
||||
event.group = 0; event.match = scene.shot.match; event.side = scene.shot.acting_side;
|
||||
event.minute = scene.shot.minute;
|
||||
const auto header = ui::live_chance_projection(event, scene.groups, state, season_exe);
|
||||
const auto backdrop = live_screen.render_sportschau_header(header,
|
||||
scene.home_goals_before, scene.away_goals_before, frame.gradient_text);
|
||||
const auto colors = live_screen.shot_palette(palette, scene.shot, scene.groups, state);
|
||||
const std::string id = std::to_string(fixture.group) + "_" + std::to_string(fixture.fixture) +
|
||||
"_" + std::to_string(scene.report_step.visible_log_entries);
|
||||
// Waits a configured number of ticks read from the game memory row (small values halved).
|
||||
const auto delay = [&](int row) {
|
||||
const uint32_t address = ::bmh::layout::Main_FormatError_ExecutableFieldUnsigned + uint32_t(row * 9);
|
||||
const int raw = state.memory.has(address) ? state.memory.u8(address) : 0;
|
||||
source_tick_wait(unsigned(raw < 6 ? raw / 2 : raw));
|
||||
};
|
||||
present_season(backdrop, ("OpenBMH - sportschau_scene_header_" + id).c_str(), &colors);
|
||||
delay(12); // AdvanceStep(12), header preview in ShotAnimation
|
||||
if (scene.set_piece) {
|
||||
const auto frames = live_screen.render_set_piece(frame, *scene.set_piece, &backdrop);
|
||||
for (size_t i = 0; running && i < frames.size(); ++i) {
|
||||
present_season(frames[i], ("OpenBMH - sportschau_set_piece_" + id + "_" +
|
||||
std::to_string(i)).c_str(), &colors);
|
||||
const unsigned retraces = i == 0 ? 40u :
|
||||
(state.memory.has(::bmh::layout::Main_FormatError_RuntimeField2) ? state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField2) : 0u);
|
||||
wait_source_retraces(retraces); // FirstThen: first40, then F8
|
||||
}
|
||||
}
|
||||
const auto frames = live_screen.render_shot(frame, scene.shot, &backdrop);
|
||||
for (size_t i = 0; running && i < frames.size(); ++i) {
|
||||
present_season(frames[i], ("OpenBMH - sportschau_shot_" + id + "_" +
|
||||
std::to_string(i)).c_str(), &colors);
|
||||
const int speed = state.memory.has(::bmh::layout::Main_FormatError_RuntimeField) ? int(int8_t(state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField))) : 0;
|
||||
wait_source_retraces(unsigned(std::max(0, speed)));
|
||||
}
|
||||
source_tick_wait(10); // LiveMatchdayFrame's final ten ticks
|
||||
if (!running) return;
|
||||
if (app::match_sound_enabled(state))
|
||||
app::original_audio_command(playback, scene.shot.miss ? 20 : 19); // SetPieceAnimation.
|
||||
if (state.memory.has(::bmh::layout::Main_FormatError_RuntimeField5) && state.memory.u8(::bmh::layout::Main_FormatError_RuntimeField5) == 0) {
|
||||
present_season(frames.back(), ("OpenBMH - sportschau_shot_ack_" + id).c_str(), &colors);
|
||||
wait_sportschau_ack();
|
||||
} else delay(15);
|
||||
if (!running) return;
|
||||
auto restored = scene.report_step; restored.chance_wait = false;
|
||||
present_season(sportschau_replay_screen->render_report(restored),
|
||||
("OpenBMH - sportschau_scene_restored_" + id).c_str());
|
||||
}
|
||||
|
||||
// Shows the full match report of a fixture and waits for acknowledgement.
|
||||
auto App::present_sportschau_fixture(const GameState& state, const SportschauFixtureView& fixture) -> void {
|
||||
if (!running) return;
|
||||
ui::SportschauMatchReport screen(data, fixture, sportschau_context(state));
|
||||
present_season(screen.render_report(fixture.log_events.size()), "OpenBMH - sportschau_report");
|
||||
wait_sportschau_ack();
|
||||
sportschau_replay_screen.reset();
|
||||
}
|
||||
|
||||
// Shows the competition winner screen.
|
||||
auto App::present_competition_winner(const GameState& state, const CompetitionWinnerView& view) -> void {
|
||||
if (!running) return;
|
||||
const auto& colors = competition_winner.palette_override(view.title);
|
||||
present_season(competition_winner.render(state, view),
|
||||
("OpenBMH - competition_winner_" + std::to_string(view.title) + "_" +
|
||||
std::to_string(view.team)).c_str(), colors ? &*colors : nullptr);
|
||||
wait_sportschau_ack(); // SDLFlushEvents2 waits for a mouse press; ESC is ignored.
|
||||
}
|
||||
|
||||
// Shows the team-of-the-matchday (eleven) screen.
|
||||
auto App::present_sportschau_awards(const GameState& state, const SportschauAwardsView& view) -> void {
|
||||
if (!running) return;
|
||||
present_season(sportschau_eleven.render(view, sportschau_context(state).gradient_text),
|
||||
("OpenBMH - sportschau_eleven_" + std::to_string(view.group)).c_str());
|
||||
wait_sportschau_ack();
|
||||
}
|
||||
|
||||
// Shows the team information screen.
|
||||
auto App::present_sportschau_team_info(const GameState& state, const SportschauTeamInfoView& view) -> void {
|
||||
if (!running) return;
|
||||
present_season(sportschau_team_info.render(view, sportschau_context(state).gradient_text),
|
||||
("OpenBMH - sportschau_teaminfo_" + std::to_string(view.group)).c_str());
|
||||
wait_sportschau_ack();
|
||||
}
|
||||
@@ -0,0 +1,652 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// App: transfers (incoming offers, decisions, pending offers, market sales, loan returns, poaching).
|
||||
// (moved out of main.cpp unchanged; the class is declared in app/app.hpp)
|
||||
#include "app/app.hpp"
|
||||
|
||||
// Converts the engine's transfer offer list into the UI's IncomingTransferDecisionView.
|
||||
auto App::transfer_view(const GameState& state, const TransferOfferListView& offers, int viewer_manager) -> bmh::ui::IncomingTransferDecisionView {
|
||||
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 = viewer_manager;
|
||||
view.preferred_bid_index = offers.preferred_bid_index;
|
||||
view.has_preferred_bid = offers.preferred_bid_index >= 0;
|
||||
view.preferred_bid_passed_random_check = offers.preferred_bid_passed_random_check;
|
||||
if (offers.seller != 0x0fff && offers.seller != kNoTeam) view.negotiator_name = state.club_name(offers.seller);
|
||||
view.asking_fee = offers.asking_fee;
|
||||
view.asking_monthly_salary = offers.asking_monthly_salary;
|
||||
view.quoted_fee = offers.quoted_fee;
|
||||
view.quoted_monthly_salary = offers.quoted_monthly_salary;
|
||||
view.quoted_years = offers.quoted_years;
|
||||
view.notice_text_address = offers.notice_text_address;
|
||||
for (size_t row = 0; row < view.offers.size(); ++row) {
|
||||
const auto& source = offers.offers[row];
|
||||
auto& slot = view.offers[row];
|
||||
slot.bid_index = source.bid_index;
|
||||
slot.buyer = source.buyer;
|
||||
slot.buyer_manager = source.buyer_manager;
|
||||
slot.fee = source.fee;
|
||||
slot.monthly_salary = source.monthly_salary;
|
||||
slot.fee_reference = source.fee_reference;
|
||||
slot.salary_reference = source.salary_reference;
|
||||
slot.contract_months = source.contract_months;
|
||||
slot.loan = source.loan;
|
||||
slot.transaction_supported = source.transaction_supported ||
|
||||
(source.loan && !source.loan_permitted);
|
||||
slot.present = source.present;
|
||||
slot.eligible = source.eligible;
|
||||
slot.bonuses = source.bonuses;
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
// Shows a yes/no/acknowledge dialog over a backdrop and runs a modal loop until answered.
|
||||
// Questions are bound to the process timer (expiry answers No); timed notices close
|
||||
// after 70*3*20 ms. Returns `unsupported` when the program is quitting.
|
||||
auto App::present_pending_dialog(const GameState& state, ui::TaxDialogProjection view,
|
||||
const Image& backdrop, const char* title,
|
||||
std::optional<ui::GameEndRenderOptions> effective_options) -> PendingOfferAnswer {
|
||||
if (!running) return PendingOfferAnswer::unsupported;
|
||||
const bool question = view.kind == ui::TaxDialogKind::question;
|
||||
if (question) press.reset(); // PresentManagerDialog owns the caller's input now.
|
||||
ui::GameEndTaxDialog screen(data, std::move(view),
|
||||
effective_options ? *effective_options : game_end_options(state), backdrop);
|
||||
const bool timed = screen.source_timed_notice();
|
||||
if (!question) app::original_audio_command(playback, timed ? 13 : 14); // PresentManagerDialog / SystemIdentity.
|
||||
const Uint32 started = SDL_GetTicks();
|
||||
auto pressed = ui::GameEndTaxDialog::Button::none;
|
||||
const auto show = [&] {
|
||||
std::string name = title;
|
||||
if (pressed == ui::GameEndTaxDialog::Button::yes) name += "_pressed_yes";
|
||||
else if (pressed == ui::GameEndTaxDialog::Button::no) name += "_pressed_no";
|
||||
else if (pressed == ui::GameEndTaxDialog::Button::acknowledge) name += "_pressed_ack";
|
||||
present_season(screen.render(pressed), name.c_str());
|
||||
};
|
||||
const auto complete = [&](PendingOfferAnswer answer) {
|
||||
present_season(screen.backdrop(), "OpenBMH - pending_offer_dialog_restored");
|
||||
return answer;
|
||||
};
|
||||
show();
|
||||
if (!state.memory.has(::bmh::layout::Main_Screen_RuntimeField2) || state.memory.u8(::bmh::layout::Main_Screen_RuntimeField2) == 0)
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
while (running) {
|
||||
// PresentManagerDialog polls2de66 after its initial Present.ExpireQuestion keeps
|
||||
// a held left control until its UP/leave while the clock runs.
|
||||
if (question && poll_process_timer(true,true) &&
|
||||
pressed == ui::GameEndTaxDialog::Button::none)
|
||||
return complete(PendingOfferAnswer::no);
|
||||
if (timed && Uint32(SDL_GetTicks() - started) >= 70 * 3 * 20)
|
||||
return complete(PendingOfferAnswer::yes);
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return PendingOfferAnswer::unsupported; }
|
||||
const bool question_deadline = question && poll_process_timer(true,true);
|
||||
if (question_deadline && pressed == ui::GameEndTaxDialog::Button::none)
|
||||
return complete(PendingOfferAnswer::no);
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN) {
|
||||
if (timed && (input.button.button == SDL_BUTTON_LEFT || input.button.button == SDL_BUTTON_RIGHT))
|
||||
return complete(PendingOfferAnswer::yes);
|
||||
// ExpireQuestion consumes the paired left release. Right/ESC
|
||||
// do not choose a question answer or interrupt that hold.
|
||||
if (!question && pressed == ui::GameEndTaxDialog::Button::none &&
|
||||
input.button.button == SDL_BUTTON_RIGHT)
|
||||
return complete(PendingOfferAnswer::yes);
|
||||
if (input.button.button != SDL_BUTTON_LEFT) continue;
|
||||
pressed = screen.hit_test(input.button.x, input.button.y);
|
||||
if (!question && pressed == ui::GameEndTaxDialog::Button::none)
|
||||
return complete(PendingOfferAnswer::yes);
|
||||
show();
|
||||
} else if (input.type == SDL_MOUSEMOTION &&
|
||||
pressed != ui::GameEndTaxDialog::Button::none &&
|
||||
screen.hit_test(input.motion.x, input.motion.y) != pressed) {
|
||||
if (!question) return complete(PendingOfferAnswer::yes);
|
||||
pressed = ui::GameEndTaxDialog::Button::none;
|
||||
show();
|
||||
} else if (input.type == SDL_MOUSEBUTTONUP && input.button.button == SDL_BUTTON_LEFT) {
|
||||
//PresentManagerDialog forces button1/No after4885b returns when the
|
||||
//signed Source deadline is negative, even after Yes UP.
|
||||
if (question_deadline) return complete(PendingOfferAnswer::no);
|
||||
const auto released = screen.hit_test(input.button.x, input.button.y);
|
||||
if (pressed != ui::GameEndTaxDialog::Button::none && released == pressed)
|
||||
return complete(pressed == ui::GameEndTaxDialog::Button::no
|
||||
? PendingOfferAnswer::no : PendingOfferAnswer::yes);
|
||||
if (!question && pressed != ui::GameEndTaxDialog::Button::none)
|
||||
return complete(PendingOfferAnswer::yes);
|
||||
pressed = ui::GameEndTaxDialog::Button::none;
|
||||
show();
|
||||
}
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return PendingOfferAnswer::unsupported;
|
||||
}
|
||||
|
||||
// Asks whether a loaned player should be returned. Returns 1 yes, 0 no, -1 cancelled.
|
||||
auto App::loan_return_presenter(GameState& state, WatcomRandom&, int manager,
|
||||
const std::string& question) -> int {
|
||||
if (!running) return -1;
|
||||
const Image backdrop = season_backdrop ? *season_backdrop : flow.render();
|
||||
const auto answer = present_pending_dialog(state,
|
||||
ui::loan_return_question_dialog(state, manager, question), backdrop,
|
||||
"OpenBMH - loan_return_question");
|
||||
if (answer == PendingOfferAnswer::yes) return 1;
|
||||
if (answer == PendingOfferAnswer::no) return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Builds the hooks that present pending transfer/contract offers over the given backdrop.
|
||||
auto App::make_pending_offer_hooks(Image backdrop) -> bmh::PendingOfferHooks {
|
||||
auto pending_backdrop = std::make_shared<Image>(std::move(backdrop));
|
||||
PendingOfferHooks hooks;
|
||||
hooks.answer = [&, pending_backdrop](const GameState& staged, const PendingOfferQuestion& question) {
|
||||
return present_pending_dialog(staged, ui::pending_offer_question_dialog(staged, question),
|
||||
*pending_backdrop, question.kind == PendingOfferQuestionKind::salary_demand
|
||||
? "OpenBMH - pending_offer_salary_question" : "OpenBMH - pending_offer_severance_question");
|
||||
};
|
||||
// Lets the player pick one of the incoming transfer bids (modal; reacts to mouse press).
|
||||
hooks.select_transfer = [&, pending_backdrop](const GameState& staged, const TransferOfferListView& offers) {
|
||||
ui::IncomingTransferScreen screen(data,
|
||||
ui::pending_offer_transfer_decision_from_game(staged, offers),
|
||||
staged.memory.u8(::bmh::layout::TextGradientDisabled) == 0);
|
||||
*pending_backdrop = screen.render();
|
||||
present_season(*pending_backdrop, "OpenBMH - pending_offer_transfer");
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP); // DecodeTaxAnimationScript/SDLFlushEvents redraw boundary
|
||||
while (running) {
|
||||
SDL_Event input;
|
||||
while (quit_confirmation.poll(&input)) {
|
||||
if (input.type == SDL_QUIT) { running = false; return PendingOfferTransferChoice{}; }
|
||||
std::optional<int> bid;
|
||||
if (input.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(input.button.button == SDL_BUTTON_LEFT || input.button.button == SDL_BUTTON_RIGHT))
|
||||
bid = screen.click(input.button.x, input.button.y,
|
||||
input.button.button == SDL_BUTTON_RIGHT);
|
||||
// IncomingTransferScreen reads event2/8 directly: release and
|
||||
// physical ESC never select or decline this row.
|
||||
if (bid) return PendingOfferTransferChoice{
|
||||
*bid < 0 ? PendingOfferTransferChoiceKind::decline : PendingOfferTransferChoiceKind::bid, *bid};
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return PendingOfferTransferChoice{};
|
||||
};
|
||||
hooks.notice = [&, pending_backdrop](const GameState& staged, const PendingOfferNotice& notice) {
|
||||
if (present_pending_dialog(staged, ui::pending_offer_notice_dialog(staged, notice),
|
||||
*pending_backdrop, "OpenBMH - pending_offer_notice") == PendingOfferAnswer::unsupported)
|
||||
throw std::runtime_error("pending offer presenter stopped");
|
||||
};
|
||||
// Shows a program-error screen and waits for a left or right press; throws on quit.
|
||||
hooks.program_error = [&, pending_backdrop](const GameState& staged, uint16_t code) {
|
||||
ui::ProgramErrorScreen screen(data,code,game_end_options(staged));
|
||||
// The modal loop owns the input now: drop any press recorded by the main loop.
|
||||
press.reset();
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION,SDL_MOUSEBUTTONUP);
|
||||
present_season(screen.render(),"OpenBMH - program_error");
|
||||
bool acknowledged=false;
|
||||
while(running && !acknowledged) {
|
||||
SDL_Event event;
|
||||
while(quit_confirmation.poll(&event)) {
|
||||
if(event.type==SDL_QUIT){running=false;break;}
|
||||
if(event.type==SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button==SDL_BUTTON_LEFT || event.button.button==SDL_BUTTON_RIGHT)) {
|
||||
acknowledged=true;break;
|
||||
}
|
||||
}
|
||||
if(!acknowledged && running)SDL_Delay(10);
|
||||
}
|
||||
if(!running)throw std::runtime_error("program-error acknowledgement interrupted");
|
||||
present_season(*pending_backdrop,"OpenBMH - pending_offer_dialog_restored");
|
||||
};
|
||||
return hooks;
|
||||
}
|
||||
|
||||
// Builds the hooks for transfer-market sales to a human buyer (only notices are shown).
|
||||
auto App::make_market_sale_hooks(Image backdrop) -> bmh::HumanBuyerSaleHooks {
|
||||
auto market_backdrop = std::make_shared<Image>(std::move(backdrop));
|
||||
HumanBuyerSaleHooks hooks;
|
||||
hooks.notice = [&, market_backdrop](const GameState& staged, const HumanBuyerSaleNotice& notice) {
|
||||
const PendingOfferNotice projection_notice{notice.manager, notice.raw_offer_slot,
|
||||
notice.source_text_address, notice.original_message};
|
||||
if (present_pending_dialog(staged, ui::pending_offer_notice_dialog(staged, projection_notice),
|
||||
*market_backdrop, "OpenBMH - transfer_market_notice") == PendingOfferAnswer::unsupported)
|
||||
throw std::runtime_error("transfer market presenter stopped");
|
||||
};
|
||||
// PresentManagerDialog yes/no question: poaching asks the selling manager whether the offered fee is
|
||||
// fine and the buyer whether he pays the fee the DFB sets. Without this hook the engine refuses a poaching
|
||||
// offer (the ANGEBOT button of the Abwerben dialog then does nothing).
|
||||
hooks.confirm = [&, market_backdrop](const GameState& staged, int manager, const std::string& text) {
|
||||
const auto answer = present_pending_dialog(staged, ui::loan_return_question_dialog(staged, manager, text),
|
||||
*market_backdrop, "OpenBMH - transfer_market_question");
|
||||
if (answer == PendingOfferAnswer::unsupported) throw std::runtime_error("transfer market presenter stopped");
|
||||
return answer == PendingOfferAnswer::yes;
|
||||
};
|
||||
return hooks;
|
||||
}
|
||||
|
||||
// Modal offer editor for a returned loan player. Returns -1 if unsupported or quitting,
|
||||
// 0 if cancelled, 1 once the offer was submitted/closed.
|
||||
auto App::loan_return_offer_presenter(GameState& staged, GameRandom& game_random,
|
||||
WatcomRandom& watcom_random, app::ClubModalServices& services,
|
||||
int manager, int source_slot, int list_entry,
|
||||
const HumanBuyerSaleHooks& sale_hooks) -> int {
|
||||
// Only valid for manager slots 0..3 and list entries 40..43; anything else is unsupported.
|
||||
if (!running || manager < 0 || manager >= 4 || list_entry < 40 || list_entry >= 44 ||
|
||||
source_slot != 2928 + list_entry || !staged.memory.has(::bmh::layout::EditorList + uint32_t(list_entry) * 0x58 + 0x57))
|
||||
return -1;
|
||||
const uint32_t row = ::bmh::layout::EditorList + uint32_t(list_entry) * 0x58;
|
||||
const int player = staged.squad_slots.at(size_t(source_slot)) & 0x0fff;
|
||||
const uint16_t seller_word = staged.memory.u16(row + 8);
|
||||
int bid_slot = -1;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const uint16_t word = staged.memory.u16(row + uint32_t(i) * 2);
|
||||
if (word == 0xffff || word == staged.manager_teams.at(size_t(manager))) { bid_slot = i; break; }
|
||||
}
|
||||
TransferOfferEditorRequest input;
|
||||
input.manager = manager;
|
||||
input.runtime_club = staged.manager_teams.at(size_t(manager));
|
||||
input.list_entry = list_entry;
|
||||
input.source_slot = source_slot;
|
||||
input.expected_player = player;
|
||||
input.expected_seller_word = seller_word;
|
||||
input.expected_bid_slot = bid_slot;
|
||||
input.loan = false;
|
||||
input.loan_return_entry = true;
|
||||
auto owner = open_transfer_offer_editor_source(staged, input, game_random, watcom_random);
|
||||
if (!owner.supported || owner.closed) return -1;
|
||||
ui::OutgoingTransferScreen screen(data, app::loan_return_offer_editor_projection(
|
||||
staged, owner, revision, (!staged.memory.has(::bmh::layout::TextGradientDisabled) || staged.memory.u8(::bmh::layout::TextGradientDisabled) == 0) && season_exe.u8(::bmh::layout::TextGradientMode) == 2));
|
||||
const Image backdrop = flow.render();
|
||||
const auto draw = [&] { present_season(screen.render(), "OpenBMH - loan_return_offer"); };
|
||||
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||
draw();
|
||||
while (running) {
|
||||
SDL_Event event;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return -1; }
|
||||
ui::OutgoingTransferRequest action;
|
||||
if (event.type == SDL_MOUSEMOTION) continue;
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN) {
|
||||
action = screen.click(event.button.x, event.button.y,
|
||||
// clicks > 1 tells the screen it is a double click.
|
||||
event.button.button == SDL_BUTTON_RIGHT, event.button.clicks > 1);
|
||||
} else if (event.type == SDL_KEYDOWN) {
|
||||
const char* name = SDL_GetKeyName(event.key.keysym.sym);
|
||||
std::string key = name ? name : "";
|
||||
std::transform(key.begin(), key.end(), key.begin(),
|
||||
[](unsigned char c) { return char(std::toupper(c)); });
|
||||
action = screen.key(key);
|
||||
} else if (event.type == SDL_TEXTINPUT) {
|
||||
(void)screen.text(event.text.text);
|
||||
}
|
||||
if (action.kind == ui::OutgoingTransferRequestKind::none) { draw(); continue; }
|
||||
if (action.kind == ui::OutgoingTransferRequestKind::cancel) {
|
||||
(void)cancel_transfer_offer_editor_source(staged, owner);
|
||||
return 0;
|
||||
}
|
||||
if (action.kind == ui::OutgoingTransferRequestKind::edit_field ||
|
||||
action.kind == ui::OutgoingTransferRequestKind::quote_change) {
|
||||
owner = app::edit_transfer_offer_from_ui(staged, owner, action,
|
||||
game_random, watcom_random);
|
||||
if (!owner.supported) return -1;
|
||||
screen.acknowledge(app::loan_return_offer_editor_projection(staged, owner, revision,
|
||||
(!staged.memory.has(::bmh::layout::TextGradientDisabled) || staged.memory.u8(::bmh::layout::TextGradientDisabled) == 0) && season_exe.u8(::bmh::layout::TextGradientMode) == 2));
|
||||
draw();
|
||||
continue;
|
||||
}
|
||||
if (action.kind == ui::OutgoingTransferRequestKind::team_info) {
|
||||
const auto validated = cancel_transfer_offer_editor_source(staged, owner);
|
||||
if (!validated.supported || !present_club_information ||
|
||||
!present_club_information(services, int(seller_word & 0x7fff))) return -1;
|
||||
owner = resume_transfer_offer_team_info_source(staged, owner, watcom_random);
|
||||
if (!owner.supported) return -1;
|
||||
screen.acknowledge(app::loan_return_offer_editor_projection(staged, owner, revision,
|
||||
(!staged.memory.has(::bmh::layout::TextGradientDisabled) || staged.memory.u8(::bmh::layout::TextGradientDisabled) == 0) && season_exe.u8(::bmh::layout::TextGradientMode) == 2));
|
||||
draw();
|
||||
continue;
|
||||
}
|
||||
if (action.kind == ui::OutgoingTransferRequestKind::player_info) {
|
||||
if (!present_player_detail) return -1;
|
||||
const auto selection = transfer_offer_player_info_selection_source(staged, owner);
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField, 1);
|
||||
if (!present_player_detail(services, selection, screen.render()).has_value()) return -1;
|
||||
owner = resume_transfer_offer_player_info_source(staged, owner,
|
||||
services.runtime_byte(::bmh::layout::CareerSession_DispatchTransferOffer_ExecutableField), services.runtime_byte(::bmh::layout::CareerSession_DispatchTransferOffer_ExecutableField2), watcom_random);
|
||||
if (!owner.supported) return -1;
|
||||
screen.acknowledge(app::loan_return_offer_editor_projection(staged, owner, revision,
|
||||
(!staged.memory.has(::bmh::layout::TextGradientDisabled) || staged.memory.u8(::bmh::layout::TextGradientDisabled) == 0) && season_exe.u8(::bmh::layout::TextGradientMode) == 2));
|
||||
draw();
|
||||
continue;
|
||||
}
|
||||
if (action.kind == ui::OutgoingTransferRequestKind::submit) {
|
||||
MinuteReport report;
|
||||
auto submitted = submit_transfer_offer_editor_source(staged, owner, watcom_random, sale_hooks, report);
|
||||
if (report.unsupported || submitted.action.status == TransferActionStatus::unsupported) return -1;
|
||||
if (submitted.editor.closed || submitted.action.status == TransferActionStatus::pending ||
|
||||
submitted.action.status == TransferActionStatus::rejected ||
|
||||
submitted.action.status == TransferActionStatus::insufficient_funds) return 1;
|
||||
owner = std::move(submitted.editor);
|
||||
screen.acknowledge(app::loan_return_offer_editor_projection(staged, owner, revision,
|
||||
(!staged.memory.has(::bmh::layout::TextGradientDisabled) || staged.memory.u8(::bmh::layout::TextGradientDisabled) == 0) && season_exe.u8(::bmh::layout::TextGradientMode) == 2));
|
||||
draw();
|
||||
}
|
||||
}
|
||||
// Keep audio streaming while idle, then yield the CPU briefly.
|
||||
if (playback.needs_pump()) playback.pump(audio_error);
|
||||
SDL_Delay(10);
|
||||
}
|
||||
(void)backdrop;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Callback for an incoming transfer offer: modal decision screen. Returns the chosen bid
|
||||
// index, or -1 for decline, nothing to choose or quit.
|
||||
auto App::choose_transfer_offer(const GameState& state, const TransferOfferListView& offers) -> int {
|
||||
if (!running) return -1;
|
||||
auto view = transfer_view(state, offers, offers.seller_manager);
|
||||
ui::IncomingTransferScreen offer_screen(data,
|
||||
ui::incoming_transfer_decision_from_game(state, view),
|
||||
state.memory.u8(::bmh::layout::TextGradientDisabled) == 0);
|
||||
SDL_SetWindowTitle(window, "OpenBMH - incoming_transfer");
|
||||
const Uint32 notice_started = SDL_GetTicks();
|
||||
bool offer_dirty = true;
|
||||
// Keep the original synchronous decision stack suspended here.
|
||||
// Only this modal's input is dispatched; desk actions and saves
|
||||
// cannot run against a partially processed calendar day.
|
||||
while (running) {
|
||||
// The introductory notice disappears after 4260 ms or on any key.
|
||||
if (offer_screen.notice_active() && SDL_GetTicks() - notice_started >= 4260)
|
||||
offer_dirty |= offer_screen.dismiss_notice();
|
||||
if (!offer_screen.notice_active() && offers.offer_count == 0) return -1;
|
||||
if (offer_dirty) {
|
||||
const auto image = offer_screen.render();
|
||||
outcome_backdrop = image;
|
||||
canvas.show(image, palette);
|
||||
offer_dirty = false;
|
||||
}
|
||||
SDL_Event event;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return -1; }
|
||||
std::optional<int> answer;
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || 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()) {
|
||||
offer_dirty |= offer_screen.dismiss_notice();
|
||||
} else if (event.key.keysym.sym == SDLK_ESCAPE) {
|
||||
answer = offer_screen.key("ESC");
|
||||
}
|
||||
}
|
||||
if (answer) return *answer;
|
||||
}
|
||||
if (playback.needs_pump()) playback.pump(audio_error);
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Callback that presents a transfer decision already settled by the engine: last-week
|
||||
// dialog, confirmation, or the animated evaluation of the bids. Clicks cannot change it.
|
||||
auto App::present_transfer_decision(const GameState& state, const TransferDecisionEvent& decision) -> void {
|
||||
if (!running) return;
|
||||
if (decision.kind == TransferDecisionEventKind::last_week) {
|
||||
auto view = ui::transfer_last_week_dialog(state, decision);
|
||||
const Image backdrop = outcome_backdrop ? *outcome_backdrop :
|
||||
ui::GameEndTaxDialog(data, view, game_end_options(state)).backdrop();
|
||||
if (present_pending_dialog(state, std::move(view), backdrop,
|
||||
"OpenBMH - transfer_last_week") ==
|
||||
PendingOfferAnswer::unsupported)
|
||||
running = false;
|
||||
return;
|
||||
}
|
||||
auto view = transfer_view(state, decision.offers, decision.viewer_manager);
|
||||
if (decision.kind == TransferDecisionEventKind::confirmation)
|
||||
view.notice_text_address = decision.result_text_address;
|
||||
ui::IncomingTransferScreen decision_screen(data,
|
||||
ui::incoming_transfer_decision_from_game(state, view),
|
||||
state.memory.u8(::bmh::layout::TextGradientDisabled) == 0);
|
||||
const bool confirmation = decision.kind == TransferDecisionEventKind::confirmation;
|
||||
if (confirmation) {
|
||||
const Image backdrop = outcome_backdrop ? *outcome_backdrop : decision_screen.render();
|
||||
decision_screen.show_confirmation(decision.result_text_address, backdrop);
|
||||
} else {
|
||||
decision_screen.begin_outcome(decision.offers.offer_count,
|
||||
decision.accepted ? decision.selected_bid_index : -1, state.memory.u8(::bmh::layout::OutcomeDelayDisabled));
|
||||
}
|
||||
SDL_SetWindowTitle(window, confirmation ? "OpenBMH - transfer_confirmation" : "OpenBMH - transfer_evaluation");
|
||||
const Uint32 started = SDL_GetTicks();
|
||||
uint64_t rendered_phase = UINT64_MAX;
|
||||
// The observer only presents the engine's settled decision. Keep
|
||||
// calendar/desk/save dispatch suspended until the original modal
|
||||
// input completes; clicks cannot select or reroll a bid here.
|
||||
while (running) {
|
||||
const uint64_t elapsed = Uint32(SDL_GetTicks() - started);
|
||||
const uint64_t phase = confirmation ? 0 : std::min(elapsed / ui::IncomingTransferScreen::outcome_phase_ms,
|
||||
decision_screen.outcome_duration_ms() / ui::IncomingTransferScreen::outcome_phase_ms);
|
||||
if (phase != rendered_phase) {
|
||||
const auto image = decision_screen.render_at_elapsed(elapsed);
|
||||
if (!confirmation) outcome_backdrop = image;
|
||||
canvas.show(image, palette);
|
||||
rendered_phase = phase;
|
||||
}
|
||||
SDL_Event event;
|
||||
while (quit_confirmation.poll(&event)) {
|
||||
if (event.type == SDL_QUIT) { running = false; return; }
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN &&
|
||||
(event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) {
|
||||
decision_screen.pointer_down(event.button.button == SDL_BUTTON_RIGHT);
|
||||
// OK of the confirmation looks pressed while the mouse button is held
|
||||
if (event.button.button == SDL_BUTTON_LEFT && confirmation &&
|
||||
decision_screen.press(event.button.x, event.button.y))
|
||||
rendered_phase = UINT64_MAX;
|
||||
} 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()) rendered_phase = UINT64_MAX;
|
||||
}
|
||||
}
|
||||
if (confirmation ? decision_screen.confirmation_dismissed() : decision_screen.outcome_dismissed()) return;
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
// Callback: shows the poaching attempt's notices one after another.
|
||||
auto App::present_poach_notices(const GameState& staged,const PoachStart& attempt,const Image& backdrop) -> void {
|
||||
for(const auto& message:attempt.messages)
|
||||
if(present_pending_dialog(staged,ui::poach_notice_from_game(staged,attempt,message),backdrop,
|
||||
"OpenBMH - poach_notice")==PendingOfferAnswer::unsupported)
|
||||
throw FormatError("poach: notice presenter stopped");
|
||||
}
|
||||
|
||||
|
||||
auto App::select_poach_player(app::CareerSession& staged,app::ClubModalServices&,int manager,
|
||||
uint64_t& selection_revision,const Image& transfer_backdrop) -> std::optional<ClubPlayerDetailSelection> {
|
||||
using Phase=app::CareerSession::TableDispatchPhase;
|
||||
press.reset(); // The synchronous Source player-selection loop owns its input.
|
||||
std::string error;
|
||||
auto page=staged.current_league_table_dispatch(error);
|
||||
if(!page)throw FormatError(error);
|
||||
// Local variant of present_season that throws if an SDL render call fails.
|
||||
const auto present=[&](const Image& frame,const std::string& title) {
|
||||
SDL_SetWindowTitle(window,title.c_str());season_backdrop=frame;
|
||||
const auto painted=process_timer_image(frame);
|
||||
for(size_t i=0;i<pixels.size();++i)pixels[i]=palette.argb[painted.pixels[i]];
|
||||
if(SDL_UpdateTexture(texture,nullptr,pixels.data(),320*4)!=0 ||
|
||||
SDL_RenderClear(renderer)!=0 || SDL_RenderCopy(renderer,texture,nullptr,nullptr)!=0)
|
||||
throw FormatError(std::string("poach renderer: ")+SDL_GetError());
|
||||
app::present(renderer);
|
||||
};
|
||||
std::unique_ptr<ui::LeagueTableScreen> table;
|
||||
// Rebuilds the league table screen from the current engine page.
|
||||
const auto rebuild=[&] {
|
||||
auto tables=ui::league_tables_from_game(staged.state(),manager);
|
||||
tables[size_t(page->identity.league)]=page->page;
|
||||
table=std::make_unique<ui::LeagueTableScreen>(data,std::move(tables),page->identity.league,
|
||||
ui::LeagueTableScreen::FamilyMode{page->identity,1});
|
||||
};
|
||||
// Presents the table; a freshly forecast page is acknowledged to the engine once shown.
|
||||
const auto show_table=[&] {
|
||||
present(table->render(),"OpenBMH - poach_table_"+std::to_string(page->identity.league));
|
||||
if(page->phase==Phase::forecast_pending_present) {
|
||||
ui::LeagueFamilyRequest ack;
|
||||
ack.identity=page->identity;ack.kind=ui::LeagueFamilyRequestKind::table_forecast_presented;
|
||||
ack.from_child=1;
|
||||
page=staged.acknowledge_league_forecast_present(ack,selection_revision,error);
|
||||
if(!page)throw FormatError(error);
|
||||
rebuild(); // Retain forecast pixels, refresh only the stale-request token.
|
||||
}
|
||||
};
|
||||
// Modal table range dialog. Digit, ENTER, BACKSPACE and SPACE keys are queued and fed to
|
||||
// the dialog only while it is ready for input; returns its accept/cancel outcome.
|
||||
const auto run_range=[&](Image backdrop,ui::TableRangeDialogProfile profile)
|
||||
-> ui::TableRangeDialogOutcome {
|
||||
ui::LeagueTableRangeDialog dialog(data,std::move(backdrop),std::move(profile));
|
||||
std::deque<std::string> keys;
|
||||
Uint32 clock_anchor=SDL_GetTicks();
|
||||
std::optional<ui::TableRangeDialogOutcome> outcome;
|
||||
const auto show=[&] {
|
||||
present(dialog.render(),"OpenBMH - poach_table_range");
|
||||
outcome=dialog.after_present();clock_anchor=SDL_GetTicks();
|
||||
};
|
||||
const auto expire_range=[&] {
|
||||
//BalanceFromGame polls raw event8 before its next input. Keep its
|
||||
//key/N waits and accepted value owner; expose cancellation
|
||||
//only after the restored backdrop has actually been shown.
|
||||
if(!dialog.source_input_ready() || !poll_process_timer(true,true) ||
|
||||
!dialog.cancel_from_source_event())return false;
|
||||
show();
|
||||
return true;
|
||||
};
|
||||
show();
|
||||
while(running&&!outcome) {
|
||||
if(expire_range())break;
|
||||
SDL_Event input;
|
||||
while(quit_confirmation.poll(&input)) {
|
||||
if(input.type==SDL_QUIT){running=false;break;}
|
||||
if(expire_range())break;
|
||||
bool changed=false;
|
||||
if(input.type==SDL_TEXTINPUT) {
|
||||
for(char c:std::string_view(input.text.text))if(c>='0'&&c<='9')keys.emplace_back(1,c);
|
||||
} else if(input.type==SDL_KEYDOWN) {
|
||||
if(input.key.keysym.sym==SDLK_RETURN)keys.push_back("ENTER");
|
||||
else if(input.key.keysym.sym==SDLK_BACKSPACE)keys.push_back("BACKSPACE");
|
||||
else if(input.key.keysym.sym==SDLK_SPACE)keys.push_back("SPACE");
|
||||
} else if(input.type==SDL_MOUSEMOTION)changed=dialog.move(input.motion.x,input.motion.y);
|
||||
else if(input.type==SDL_MOUSEBUTTONDOWN&&
|
||||
(input.button.button==SDL_BUTTON_LEFT||input.button.button==SDL_BUTTON_RIGHT))
|
||||
changed=dialog.pointer_down(input.button.x,input.button.y,input.button.button==SDL_BUTTON_RIGHT);
|
||||
else if(input.type==SDL_MOUSEBUTTONUP&&
|
||||
(input.button.button==SDL_BUTTON_LEFT||input.button.button==SDL_BUTTON_RIGHT))
|
||||
changed=dialog.pointer_up(input.button.x,input.button.y,input.button.button==SDL_BUTTON_RIGHT);
|
||||
// A drag-only release does not restart an existing Source wait.
|
||||
if(changed&&input.type!=SDL_MOUSEBUTTONUP)show();
|
||||
if(outcome)break;
|
||||
}
|
||||
if(!running||outcome)break;
|
||||
while(!keys.empty()&&dialog.source_input_ready()) {
|
||||
if(expire_range())break;
|
||||
const auto key=std::move(keys.front());keys.pop_front();
|
||||
if(dialog.key(key))show();
|
||||
if(outcome)break;
|
||||
}
|
||||
// Feed the dialog whole 20 ms source units elapsed since the last anchor.
|
||||
const Uint32 now=SDL_GetTicks(),units=Uint32(now-clock_anchor)/20;
|
||||
if(units) {
|
||||
clock_anchor+=units*20;
|
||||
if(dialog.tick_source_units(units))show();
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
if(!outcome)throw FormatError("poach: range presenter stopped");
|
||||
return *outcome;
|
||||
};
|
||||
rebuild();show_table();
|
||||
poach_selection_active=true;poach_card_selection.reset();
|
||||
struct ResetSelection { bool& active;~ResetSelection(){active=false;} } reset{poach_selection_active};
|
||||
// When the process timer runs out and no table action or release is pending, closes the
|
||||
// selection as if the close control had been used. Returns true if it did.
|
||||
const auto deadline_expired=[&] {
|
||||
if(table->pending_family_action() || table->source_mouse_wait_release_pending() ||
|
||||
!poll_process_timer(true,true))return false;
|
||||
//Move/4ffe0 selection owner must close before19c1c resumes.
|
||||
if(!table->pointer_down(0,0,true) || !table->pending_family_action() ||
|
||||
table->pending_family_action()->kind!=ui::LeagueFamilyRequestKind::close)
|
||||
throw FormatError("poach: timer close has no table owner");
|
||||
if(!staged.close_poach_table_selection(*table->pending_family_action(),error))
|
||||
throw FormatError(error);
|
||||
present(transfer_backdrop,"OpenBMH - poach_transfer_restored");
|
||||
return true;
|
||||
};
|
||||
while(running) {
|
||||
if(deadline_expired())return std::nullopt;
|
||||
SDL_Event input;
|
||||
while(quit_confirmation.poll(&input)) {
|
||||
if(input.type==SDL_QUIT){running=false;break;}
|
||||
if(deadline_expired())return std::nullopt;
|
||||
bool changed=false;
|
||||
if(input.type==SDL_MOUSEBUTTONDOWN&&
|
||||
(input.button.button==SDL_BUTTON_LEFT||input.button.button==SDL_BUTTON_RIGHT))
|
||||
changed=table->pointer_down(input.button.x,input.button.y,input.button.button==SDL_BUTTON_RIGHT);
|
||||
else if(input.type==SDL_MOUSEBUTTONUP&&input.button.button==SDL_BUTTON_LEFT)
|
||||
changed=table->click(input.button.x,input.button.y);
|
||||
else if(input.type==SDL_MOUSEMOTION)changed=table->move(input.motion.x,input.motion.y);
|
||||
if(!table->pending_family_action()) {if(changed)show_table();continue;}
|
||||
const auto request=*table->pending_family_action();
|
||||
if(request.kind==ui::LeagueFamilyRequestKind::close) {
|
||||
if(!staged.close_poach_table_selection(request,error))throw FormatError(error);
|
||||
present(transfer_backdrop,"OpenBMH - poach_transfer_restored");
|
||||
return std::nullopt;
|
||||
}
|
||||
if(request.kind==ui::LeagueFamilyRequestKind::select_league ||
|
||||
request.kind==ui::LeagueFamilyRequestKind::toggle_league_group) {
|
||||
const int prior_league=page->identity.league;
|
||||
if(!staged.select_league_family_page(request,selection_revision,error))throw FormatError(error);
|
||||
page=staged.current_league_table_dispatch(error);if(!page)throw FormatError(error);
|
||||
if(page->identity.league==prior_league) {
|
||||
table->acknowledge_same_league_selector(request,page->identity);
|
||||
if(request.kind==ui::LeagueFamilyRequestKind::toggle_league_group)show_table();
|
||||
} else {rebuild();show_table();}
|
||||
} else if(request.kind==ui::LeagueFamilyRequestKind::team_info) {
|
||||
poach_card_selection.reset();
|
||||
const auto identity=staged.dispatch_family_table_team_info(request,selection_revision,error,
|
||||
[&](app::ClubModalServices& services,int team,const Image&) {
|
||||
return present_club_information(services,team)&&running;
|
||||
},&poach_card_selection);
|
||||
if(!identity)throw FormatError(error);
|
||||
if(poach_card_selection) {
|
||||
present(transfer_backdrop,"OpenBMH - poach_transfer_restored");
|
||||
return poach_card_selection;
|
||||
}
|
||||
page=staged.current_league_table_dispatch(error);if(!page)throw FormatError(error);
|
||||
rebuild();show_table();
|
||||
} else if(request.kind==ui::LeagueFamilyRequestKind::control) {
|
||||
const auto modal_backdrop=table->render();
|
||||
page=staged.dispatch_league_table_control(request,selection_revision,error);
|
||||
if(!page)throw FormatError(error);
|
||||
while(page->dialog) {
|
||||
const auto stage=page->phase==Phase::range_start?ui::TableDialogStage::start:ui::TableDialogStage::end;
|
||||
const auto outcome=run_range(modal_backdrop,*page->dialog);
|
||||
ui::LeagueFamilyRequest reply;
|
||||
reply.identity=page->identity;reply.kind=ui::LeagueFamilyRequestKind::table_range_result;
|
||||
reply.from_child=1;reply.control_index=9;
|
||||
reply.table_dialog_reply=ui::TableDialogReply{stage,
|
||||
outcome.result==ui::TableRangeDialogResult::accept?ui::TableDialogOutcome::accept:ui::TableDialogOutcome::cancel,
|
||||
outcome.result==ui::TableRangeDialogResult::accept?int(outcome.value):0,outcome.x,outcome.y};
|
||||
page=staged.dispatch_league_table_range_reply(reply,selection_revision,error);
|
||||
if(!page)throw FormatError(error);
|
||||
}
|
||||
rebuild();show_table();
|
||||
}
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
throw FormatError("poach: player selection presenter stopped");
|
||||
}
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Glue between the original-audio engine (src/audio/playback.hpp) and the app: builds the
|
||||
// asset set from the game's sound containers and the frequency/operator tables read from the
|
||||
// executable, derives the music/click/match-sound options from the saved settings bytes of
|
||||
// the GameState, and sends sound commands only when the original sound path is ready.
|
||||
// OriginalMouseSound is an SDL event watch that plays the click sound on each real mouse
|
||||
// button press; it touches only the Playback object, never the GameState, because the
|
||||
// watch can run on SDL's event thread. Header-only.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The game picture on the window: the 320x240 canvas of palette indices is converted with a palette,
|
||||
// uploaded to the streaming texture and shown.
|
||||
//
|
||||
// src/app/main.cpp repeated these six statements at about twenty places (every presenter that shows
|
||||
// a picture). Canvas::show() is that sequence, in the same order and with the same disregard of SDL
|
||||
// errors as the copies had; presenters that check the SDL calls or update only a part of the texture
|
||||
// keep their own code. The members are the window objects main() creates; the pixel buffer stays
|
||||
// main()'s vector, because a few presenters fill parts of it themselves.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "app/robot.hpp"
|
||||
#include "formats/palette.hpp"
|
||||
#include "formats/vga.hpp"
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
struct Canvas {
|
||||
SDL_Renderer* renderer;
|
||||
SDL_Texture* texture;
|
||||
std::vector<uint32_t>& pixels; // 320 * 240 ARGB values
|
||||
|
||||
// Converts the picture with the palette, uploads it and shows it (clear, copy, present).
|
||||
void show(const Image& image, const Palette& palette) {
|
||||
for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, nullptr, nullptr);
|
||||
present(renderer);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace bmh::app
|
||||
+189
-7076
File diff suppressed because it is too large.
Load diff
@@ -38,6 +38,7 @@
|
||||
#include "game/pending_offer.hpp"
|
||||
#include "game/poach.hpp"
|
||||
#include "game/human_buyer_sale.hpp"
|
||||
#include "game/search_profile.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
#include "ui/flow.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
@@ -175,7 +176,23 @@ 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 = {});
|
||||
|
||||
// The search profile of a human manager (transfer market buttons "Suchen" and "Vorschlag", game/search_profile.hpp).
|
||||
// `search_profile` is the stored profile, `suggest_search_profile` the one the squad asks for (nothing is stored).
|
||||
// `dispatch_search_profile` stores an edited profile the way the closing dialog does (`cancelled` = left by right
|
||||
// click, which switches the profile off) and, with `apply`, lists the transfer-list entries that fit it right now.
|
||||
// The revision rises only when the stored profile changed.
|
||||
SearchProfile search_profile(int manager) const;
|
||||
SearchProfile suggest_search_profile(int manager, bool whole_squad) const;
|
||||
struct SearchProfileDispatch {
|
||||
SearchProfile profile{};
|
||||
bool active = false;
|
||||
std::vector<SearchProfileHit> hits;
|
||||
};
|
||||
std::optional<SearchProfileDispatch> dispatch_search_profile(int manager, const SearchProfile& profile, bool cancelled,
|
||||
bool apply, uint64_t& revision, std::string& error);
|
||||
|
||||
struct TransferMarketPreviewDispatch {
|
||||
ui::PreparationState preparation;
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// CareerSession: the club information dialogs (club, player list, player detail) and their services.
|
||||
// (moved out of career_session.cpp unchanged; the class is declared in app/career_session.hpp)
|
||||
#include "app/career_session_internal.hpp"
|
||||
|
||||
namespace bmh::app {
|
||||
// Club-information modal family (enter, change category, player redraw, national action,
|
||||
// pending offers): each member refuses to run while another modal owner is open and clears
|
||||
// 'error' first. The ones that change state work on copies and assign them back only after
|
||||
// success.
|
||||
// Enter: opens the club info entry for 'team'; nullopt plus 'error' on an invalid team.
|
||||
std::optional<ClubInfoEntry> CareerSession::enter_club_information(int team, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
try { return prepare_club_info_entry(g_, team); }
|
||||
catch (const std::invalid_argument& e) { error = e.what(); return std::nullopt; }
|
||||
}
|
||||
|
||||
// Switches the club info category for 'team'; nullopt plus 'error' when it is invalid.
|
||||
std::optional<uint8_t> CareerSession::change_club_information_category(int team, int requested,
|
||||
std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
try { return set_club_info_category(g_, team, requested); }
|
||||
catch (const std::invalid_argument& e) { error = e.what(); return std::nullopt; }
|
||||
}
|
||||
|
||||
// Redraws a player detail card; random generators advance only if the redraw succeeded.
|
||||
std::optional<ClubPlayerDetailRedraw> CareerSession::redraw_club_player_detail(
|
||||
const ClubPlayerDetailSelection& selection, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
auto next_game = game_;
|
||||
auto next_rand = rand_;
|
||||
try {
|
||||
auto redraw = club_player_detail_redraw(g_, selection, exe_, next_game, next_rand);
|
||||
game_ = next_game;
|
||||
rand_ = next_rand;
|
||||
return redraw;
|
||||
} catch (const std::invalid_argument& e) {
|
||||
error = e.what();
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
// Applies the national-team add/remove action of a player card on a staged copy; the copy is
|
||||
// committed only when the engine reports no reason. Returns whether the action was applied.
|
||||
std::optional<bool> CareerSession::dispatch_club_player_national_action(
|
||||
const ClubPlayerDetailSelection& selection, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
auto next_state = g_;
|
||||
auto next_rand = rand_;
|
||||
MinuteReport report;
|
||||
try {
|
||||
const bool applied = club_player_detail_national_action(next_state, selection, next_rand, report);
|
||||
if (!report.reason.empty()) { error = report.reason; return std::nullopt; }
|
||||
g_ = std::move(next_state);
|
||||
rand_ = next_rand;
|
||||
return applied; // Source still refreshes the lineup when an add finds a full squad.
|
||||
} catch (const std::invalid_argument& e) {
|
||||
error = e.what();
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
// Processes the pending transfer offers of a player card. Rejects a stale revision or a nested
|
||||
// pending-offer/market dispatch, works on copies and commits them when at least one offer was
|
||||
// processed. The revision is bumped here unless a calendar advance is active: then the outer
|
||||
// driver publishes the revision when it returns.
|
||||
std::optional<PendingOfferResult> CareerSession::dispatch_club_player_pending_offers(
|
||||
const ClubPlayerDetailSelection& selection, uint64_t expected_revision,
|
||||
const PendingOfferHooks& hooks, uint64_t& revision, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
if (expected_revision != revision || pending_offer_dispatch_active_ || market_dispatch_active_ ||
|
||||
revision == std::numeric_limits<uint64_t>::max()) {
|
||||
error = "pending offer: stale or nested player-card action";
|
||||
return std::nullopt;
|
||||
}
|
||||
auto next_state = g_;
|
||||
auto next_game = game_;
|
||||
auto next_rand = rand_;
|
||||
pending_offer_dispatch_active_ = true;
|
||||
struct Reset { bool& active; ~Reset() { active = false; } } reset{pending_offer_dispatch_active_};
|
||||
MinuteReport report;
|
||||
try {
|
||||
const auto result = process_player_card_pending_offers(
|
||||
next_state, selection, next_game, next_rand, pending_hooks_for_dispatch(hooks), report);
|
||||
if (report.unsupported || !result.completed) {
|
||||
error = report.reason.empty() ? "pending offer: manual decision incomplete" : report.reason;
|
||||
return std::nullopt;
|
||||
}
|
||||
if (result.processed != 0) {
|
||||
g_ = std::move(next_state);
|
||||
game_ = next_game;
|
||||
rand_ = next_rand;
|
||||
// A nested cup modal belongs to the current calendar transaction;
|
||||
// its outer driver publishes that revision when advancement returns.
|
||||
if (!calendar_advance_active_) ++revision;
|
||||
}
|
||||
return result;
|
||||
} catch (const std::exception& e) {
|
||||
error = e.what();
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
// Seeds the process-only byte map used by the club modals with their start values from the
|
||||
// executable; these values are never written to a save.
|
||||
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.
|
||||
for(uint32_t address:{::bmh::layout::CareerSession_DispatchTransferOffer_ExecutableFieldUnsigned,::bmh::layout::CareerSession_DispatchPoachUi_ExecutableFieldUnsigned,::bmh::layout::CareerSession_DispatchTransferOffer_ExecutableField2Unsigned,::bmh::layout::CareerSession_InitializeClubModalRuntime_ExecutableFieldUnsigned})
|
||||
club_modal_runtime_.emplace(address,exe_.u8(address));
|
||||
}
|
||||
|
||||
// Collects the executable bytes and rating tables the Sportschau screen reads.
|
||||
SportschauSourceOptions CareerSession::sportschau_source_options() const {
|
||||
return {source_runtime_byte(g_, club_modal_runtime_, exe_, ::bmh::layout::CareerSession_SportschauSourceOptions_ExecutableField),
|
||||
source_runtime_byte(g_, club_modal_runtime_, exe_, ::bmh::layout::CareerSession_DispatchTransferOffer_ExecutableField2), exe_.u16(::bmh::layout::TeamsWithSquads),
|
||||
sportschau_rating_tables(exe_)};
|
||||
}
|
||||
|
||||
// Builds the service callbacks of the club modal on a given (staged) state, generators and
|
||||
// runtime byte map, so the modal can run on a copy and be committed or dropped by the caller.
|
||||
ClubModalServices CareerSession::staged_club_modal_services(GameState& state,
|
||||
GameRandom& game,WatcomRandom& rand,std::map<uint32_t,uint8_t>& runtime) {
|
||||
ClubModalServices services;
|
||||
auto* g=&state; auto* gr=&game; auto* wr=&rand; auto* bytes=&runtime;
|
||||
services.state=[g]() -> GameState& { return *g; };
|
||||
services.enter_club=[g](int team) { return prepare_club_info_entry(*g,team); };
|
||||
services.change_category=[g](int team,int category) { return set_club_info_category(*g,team,category); };
|
||||
services.redraw_player=[this,g,gr,wr](const ClubPlayerDetailSelection& selection) {
|
||||
auto next_game=*gr; auto next_rand=*wr;
|
||||
auto result=club_player_detail_redraw(*g,selection,exe_,next_game,next_rand);
|
||||
*gr=next_game; *wr=next_rand; return result;
|
||||
};
|
||||
services.national_action=[g,wr](const ClubPlayerDetailSelection& selection) {
|
||||
auto next=*g; auto next_rand=*wr; MinuteReport report;
|
||||
const bool applied=club_player_detail_national_action(next,selection,next_rand,report);
|
||||
if(!report.reason.empty())throw FormatError(report.reason);
|
||||
*g=std::move(next); *wr=next_rand; return applied;
|
||||
};
|
||||
services.pending_offers=[this,g,gr,wr](const ClubPlayerDetailSelection& selection,const PendingOfferHooks& hooks) {
|
||||
auto next=*g; auto next_game=*gr; auto next_rand=*wr; MinuteReport report;
|
||||
auto result=process_player_card_pending_offers(next,selection,next_game,next_rand,
|
||||
pending_hooks_for_dispatch(hooks),report);
|
||||
if(report.unsupported||!result.completed)
|
||||
throw FormatError(report.reason.empty()?"TeamInfo: nested pending decision incomplete":report.reason);
|
||||
*g=std::move(next); *gr=next_game; *wr=next_rand; return result;
|
||||
};
|
||||
services.runtime_byte=[this,g,bytes](uint32_t address) {
|
||||
if(g->memory.has(address))return g->memory.u8(address);
|
||||
if(const auto at=bytes->find(address);at!=bytes->end())return at->second;
|
||||
// Explicit original initialization supplies the transient input owner.
|
||||
// Never serialize an absent BSS byte or infer Native absence as zero.
|
||||
return exe_.u8(address);
|
||||
};
|
||||
services.set_runtime_byte=[g,bytes](uint32_t address,uint8_t value) {
|
||||
if(g->memory.has(address))g->memory.set8(address,value);
|
||||
else (*bytes)[address]=value;
|
||||
};
|
||||
return services;
|
||||
}
|
||||
|
||||
// Same services bound to the live state (non-transactional); pending offers go through
|
||||
// dispatch_club_player_pending_offers. Throws when another modal owner is open.
|
||||
ClubModalServices CareerSession::live_club_modal_services(uint64_t& revision) {
|
||||
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_) throw FormatError("strengths_active");
|
||||
auto services=staged_club_modal_services(g_,game_,rand_,club_modal_runtime_);
|
||||
services.transactional=false;
|
||||
// Existing cup/club caller keeps its separately owned pending transaction.
|
||||
services.pending_offers=[this,&revision](const ClubPlayerDetailSelection& selection,const PendingOfferHooks& hooks) {
|
||||
std::string error;
|
||||
auto result=dispatch_club_player_pending_offers(selection,revision,hooks,revision,error);
|
||||
if(!result)throw FormatError(error);
|
||||
return *result;
|
||||
};
|
||||
return services;
|
||||
}
|
||||
|
||||
} // namespace bmh::app
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,164 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// Internal header of the career session: the includes and the helper functions that more than one of the
|
||||
// career_session*.cpp files uses. Included only by those files (the helpers have internal linkage).
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "game/calendar.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/career_session.hpp"
|
||||
#include "formats/league_visibility.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <system_error>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cctype>
|
||||
#include <bit>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
#include "formats/fbm.hpp"
|
||||
#include "formats/savestate.hpp"
|
||||
#include "game/career.hpp"
|
||||
#include "game/cup.hpp"
|
||||
#include "game/driver.hpp"
|
||||
#include "game/desk.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
#include "game/match.hpp"
|
||||
#include "game/messages.hpp"
|
||||
#include "game/prediction.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "game/bank_credit.hpp"
|
||||
#include "game/matchday_setup.hpp"
|
||||
#include "game/matchday.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
#include "game/month.hpp"
|
||||
#include "game/national.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "game/table.hpp"
|
||||
#include "game/table_forecast.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/season.hpp"
|
||||
#include "game/turn.hpp"
|
||||
#include "game/week.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
#include "ui/league_table.hpp"
|
||||
#include "ui/other_games_state.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
#include "ui/pending_offer.hpp"
|
||||
#include "ui/training.hpp"
|
||||
|
||||
namespace bmh::app {
|
||||
namespace {
|
||||
|
||||
// Reads one byte of the executable's data at 'address': from the game's memory image when the
|
||||
// address is mapped there, else from the runtime override map, else from the loaded EXE.
|
||||
uint8_t source_runtime_byte(const GameState& state,const std::map<uint32_t,uint8_t>& runtime,
|
||||
const LeImage& exe,uint32_t address) {
|
||||
if(state.memory.has(address))return state.memory.u8(address);
|
||||
const auto found=runtime.find(address);return found==runtime.end()?exe.u8(address):found->second;
|
||||
}
|
||||
|
||||
// Writes one byte to the memory image when the address is mapped there, otherwise into the
|
||||
// runtime override map (the EXE image itself is never modified).
|
||||
void source_runtime_set_byte(GameState& state,std::map<uint32_t,uint8_t>& runtime,
|
||||
uint32_t address,uint8_t value) {
|
||||
if(state.memory.has(address))state.memory.set8(address,value);
|
||||
else runtime[address]=value;
|
||||
}
|
||||
|
||||
// Little-endian 32-bit read built from four source_runtime_byte reads.
|
||||
uint32_t source_runtime_u32(const GameState& state,const std::map<uint32_t,uint8_t>& runtime,
|
||||
const LeImage& exe,uint32_t address) {
|
||||
return uint32_t(source_runtime_byte(state,runtime,exe,address)) |
|
||||
uint32_t(source_runtime_byte(state,runtime,exe,address+1))<<8 |
|
||||
uint32_t(source_runtime_byte(state,runtime,exe,address+2))<<16 |
|
||||
uint32_t(source_runtime_byte(state,runtime,exe,address+3))<<24;
|
||||
}
|
||||
|
||||
// Writes the process scratch bytes (league, group, date pieces, strength sums) that the
|
||||
// original leaves behind after drawing the pairings page, so later reads see the same values.
|
||||
// Bytes go to the memory image when mapped there, else to the runtime map.
|
||||
void pairings_runtime_draw(GameState& g,std::map<uint32_t,uint8_t>& runtime,
|
||||
const ui::LeaguePairingsState& page,const LeImage& exe) {
|
||||
const auto put=[&](uint32_t at,uint8_t v) {
|
||||
if(g.memory.has(at))g.memory.set8(at,v);else runtime[at]=v;
|
||||
};
|
||||
const uint32_t tip_preference=::bmh::layout::CareerSession_CloseLeagueFamily_ExecutableField+uint32_t(page.identity.manager);
|
||||
const bool computer_tip=page.source.owner.computer_tip_active;
|
||||
if(computer_tip)put(tip_preference,uint8_t(g.memory.u8(tip_preference)|0x10));
|
||||
// Actual5147b entry/input globals; these are process bytes, not invented FBM blocks.
|
||||
put(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_RuntimeField2,uint8_t(page.identity.league));put(::bmh::layout::CareerSession_AdvertisingSessionUnchanged_ExecutableField,page.source.owner.league_group);
|
||||
put(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField,0);put(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2,0);
|
||||
const auto date=[&](uint32_t counter) {
|
||||
if(counter==0xffff)return; //21258's Wettbewerb-gesperrt branch changes no date scratch.
|
||||
const auto d=ui::desk_date(counter,exe);
|
||||
int cycle=3;uint32_t n=counter;
|
||||
while(n>uint32_t(364+(cycle==4))) {if(cycle==4){cycle=0;--n;}n-=365;++cycle;}
|
||||
put(::bmh::layout::CareerSession_PairingsRuntimeDraw_ExecutableField,uint8_t(28+(cycle==4)));
|
||||
put(::bmh::layout::CareerSession_PairingsRuntimeDraw_ExecutableField4,uint8_t(d.day));put(::bmh::layout::CareerSession_PairingsRuntimeDraw_ExecutableField5,uint8_t(d.month));put(::bmh::layout::CareerSession_PairingsRuntimeDraw_ExecutableField6,uint8_t(d.weekday));
|
||||
put(::bmh::layout::CareerSession_PairingsRuntimeDraw_ExecutableField2,uint8_t(d.year));put(::bmh::layout::CareerSession_PairingsRuntimeDraw_ExecutableField3,uint8_t(d.year>>8));
|
||||
};
|
||||
const bool selected_filter=page.source.owner.filter_active&&page.source.owner.filter_team>=0;
|
||||
if(!selected_filter&&!page.source.owner.postponed_active)
|
||||
date(page.source.match_date); //333f3 is absent in selected Mode4 and Mode8.
|
||||
for(const auto& row:page.source.rows) {
|
||||
if(row.scheduled_date)date(*row.scheduled_date);
|
||||
else if(row.postponed_date)date(*row.postponed_date);
|
||||
const uint8_t displayed=row.computer_tip_result.value_or(row.raw_result);
|
||||
// In local28's referee phase, exact CC rows skip both 68164 calls.
|
||||
// Preserve prior scratch when every row takes that branch; a mixed
|
||||
// page leaves the last ordinary away-row value, in Source draw order.
|
||||
if(page.source.owner.active_phase&&displayed==0xcc)continue;
|
||||
//68164's final17295 call on the away team leaves Source CareerSession_FormatError_ExecutableField3.
|
||||
const auto strength=team_average(g,row.away.runtime_team,0x1ff);
|
||||
put(::bmh::layout::CareerSession_FormatError_ExecutableField3,uint8_t(strength.best_half_sum));put(::bmh::layout::CareerSession_FormatError_ExecutableField4,uint8_t(strength.best_half_sum>>8));
|
||||
}
|
||||
// Move clears its one-redraw local38 bit after the forecast has
|
||||
// been projected. The returned page retains the pressed Original button.
|
||||
if(computer_tip)put(tip_preference,uint8_t(g.memory.u8(tip_preference)&0xef));
|
||||
}
|
||||
|
||||
// Compares the runtime-only fields of two states (callbacks by target type); used to check the
|
||||
// strengths view left the game unchanged.
|
||||
bool same_strengths_runtime_state(const GameState& a,const GameState& b) {
|
||||
const auto same_callback=[](const auto& lhs,const auto& rhs) {
|
||||
return bool(lhs)==bool(rhs)&&(!lhs||lhs.target_type()==rhs.target_type());
|
||||
};
|
||||
return a.indoor==b.indoor&&a.currency_suffix==b.currency_suffix&&a.level==b.level&&
|
||||
a.chance_rain==b.chance_rain&&a.chance_temperature==b.chance_temperature&&
|
||||
a.last_shooter==b.last_shooter&&a.last_pick_quality==b.last_pick_quality&&
|
||||
a.live_scene==b.live_scene&&a.reality==b.reality&&a.live_matches==b.live_matches&&a.list_toggle==b.list_toggle&&
|
||||
a.lineups_frozen==b.lineups_frozen&&a.texts==b.texts&&a.date==b.date&&
|
||||
a.season_start==b.season_start&&a.development_balance==b.development_balance&&
|
||||
a.trend_rotation==b.trend_rotation&&a.season==b.season&&a.transfer_notice_suppressed==b.transfer_notice_suppressed&&
|
||||
a.offer_answer==b.offer_answer&&a.pools_open==b.pools_open&&a.autosave_months==b.autosave_months&&
|
||||
a.autosave_month==b.autosave_month&&same_callback(a.contract_screen,b.contract_screen)&&
|
||||
same_callback(a.loan_return_screen,b.loan_return_screen)&&
|
||||
same_callback(a.loan_return_offer_screen,b.loan_return_offer_screen)&&
|
||||
same_callback(a.transfer_decision,b.transfer_decision)&&
|
||||
same_callback(a.transfer_offer_selector,b.transfer_offer_selector)&&
|
||||
same_callback(a.transfer_decision_observer,b.transfer_decision_observer);
|
||||
}
|
||||
|
||||
// Reinterprets the low byte of 'value' as a signed byte.
|
||||
int8_t source_byte(int value) { return static_cast<int8_t>(uint8_t(value)); }
|
||||
|
||||
// True when a table request carries no stray fields (no target child, team, row or dialog reply;
|
||||
// league id only if the selector variant is allowed) and the expected control index.
|
||||
bool canonical_table_envelope(const ui::LeagueFamilyRequest& request,int control_index=-1,
|
||||
bool allow_selector_league=false) {
|
||||
return request.target_child==0&&request.runtime_team==-1&&request.expected_club_identity==-1&&
|
||||
request.table_row_index==-1&&(allow_selector_league||request.league_id==-1)&&
|
||||
request.control_index==control_index&&
|
||||
!request.table_dialog_reply;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace bmh::app
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,803 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// CareerSession: club management: training, training camp, bank, stadium, toto.
|
||||
// (moved out of career_session.cpp unchanged; the class is declared in app/career_session.hpp)
|
||||
#include "app/career_session_internal.hpp"
|
||||
|
||||
namespace bmh::app {
|
||||
namespace {
|
||||
|
||||
constexpr uint8_t kBlockSeat = 1;
|
||||
|
||||
constexpr uint8_t kBlockRoof = 2;
|
||||
|
||||
constexpr uint8_t kBlockFeatures = kBlockSeat | kBlockRoof;
|
||||
|
||||
// True for the stadium requests that belong to the block-expansion dialog (select, total,
|
||||
// feature toggle, cancel, confirm, answer tip).
|
||||
bool is_block_expansion_action(ui::StadiumRequestKind kind) {
|
||||
return kind == ui::StadiumRequestKind::expansion_select ||
|
||||
kind == ui::StadiumRequestKind::expansion_set_total ||
|
||||
kind == ui::StadiumRequestKind::expansion_toggle_feature ||
|
||||
kind == ui::StadiumRequestKind::expansion_cancel ||
|
||||
kind == ui::StadiumRequestKind::expansion_confirm ||
|
||||
kind == ui::StadiumRequestKind::expansion_answer_tip;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Training group: one request changes the types, areas, automation byte or one player's
|
||||
// intensity or focus of the active manager. The request carries the desired result; it is
|
||||
// validated against the current projection (stale manager, plan limits, expected values), applied
|
||||
// on a staged copy and committed with revision plus one. Manual edits clear the matching
|
||||
// assistant flag and never draw random numbers; initialize and enabling automation run the
|
||||
// automatic training. Returns false with a short error code in 'error' otherwise.
|
||||
bool CareerSession::dispatch_training(const ui::TrainingRequest& request, uint64_t& revision,
|
||||
std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return false; }
|
||||
const int active = int(g_.memory.u8(::bmh::layout::ActiveManager));
|
||||
if (request.manager_slot != active || request.manager_slot < 0 || request.manager_slot > 3 ||
|
||||
size_t(request.manager_slot) >= g_.manager_teams.size() ||
|
||||
request.runtime_club != g_.manager_teams[size_t(request.manager_slot)] || request.revision != revision) {
|
||||
error = "stale_manager_or_revision";
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const ui::TrainingState current = ui::training_from_game(g_, exe_, revision);
|
||||
if (current.manager_slot != request.manager_slot || current.runtime_club != request.runtime_club) {
|
||||
error = "stale_manager_or_revision";
|
||||
return false;
|
||||
}
|
||||
const size_t slot = size_t(request.manager_slot);
|
||||
const size_t rec = slot * 0xb0c;
|
||||
const size_t option_at = slot * 5 + 4;
|
||||
if (g_.manager_records.size() < rec + 0xb0c || g_.manager_options.size() <= option_at) {
|
||||
error = "invalid_training_state";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto valid_plan = [](const std::array<uint8_t, 4>& types, const std::array<uint8_t, 9>& areas) {
|
||||
int type_sum = 0, fitness = 0, skills = 0;
|
||||
for (uint8_t value : types) { if (value < 1 || value > 3) return false; type_sum += value; }
|
||||
for (size_t i = 0; i < areas.size(); ++i) {
|
||||
const uint8_t value = areas[i];
|
||||
if (value < 1 || value > 3) return false;
|
||||
if (i < 2) fitness += value; else skills += value;
|
||||
}
|
||||
return type_sum <= 8 && fitness <= 4 && skills <= 18;
|
||||
};
|
||||
if (!valid_plan(request.desired_types, request.desired_areas)) {
|
||||
error = "invalid_training_plan";
|
||||
return false;
|
||||
}
|
||||
|
||||
ui::TrainingRequestKind kind = request.kind;
|
||||
auto types = current.types;
|
||||
auto areas = current.areas;
|
||||
uint8_t automation = current.automation;
|
||||
bool run_automatic = false;
|
||||
// NeedsInitialization initializes an uninitialized screen via Initialize;
|
||||
// the four subordinate toggles exist only while the global flag is on.
|
||||
// NeedsInitialization2 calls that same deterministic routine after an enabled
|
||||
// automation toggle. Manual field edits only write their field and clear
|
||||
// the matching assistant flag; they do not run training or draw RNG.
|
||||
switch (kind) {
|
||||
case ui::TrainingRequestKind::initialize:
|
||||
if (!current.needs_initialization() || request.index != -1 || request.value != -1 ||
|
||||
request.player_id != -1 || request.desired_types != types || request.desired_areas != areas ||
|
||||
request.desired_automation != 0x9f) {
|
||||
error = "invalid_training_initialization";
|
||||
return false;
|
||||
}
|
||||
automation = 0x9f;
|
||||
run_automatic = true;
|
||||
break;
|
||||
case ui::TrainingRequestKind::set_type:
|
||||
if (current.needs_initialization() || request.index < 0 || request.index >= int(types.size()) ||
|
||||
request.value < 1 || request.value > 3 || request.player_id != -1 ||
|
||||
request.value == types[size_t(request.index)]) {
|
||||
error = "invalid_training_type";
|
||||
return false;
|
||||
}
|
||||
types[size_t(request.index)] = uint8_t(request.value);
|
||||
automation = uint8_t(automation & ~uint8_t(1u << 1));
|
||||
break;
|
||||
case ui::TrainingRequestKind::set_area:
|
||||
if (current.needs_initialization() || request.index < 0 || request.index >= int(areas.size()) ||
|
||||
request.value < 1 || request.value > 3 || request.player_id != -1 ||
|
||||
request.value == areas[size_t(request.index)]) {
|
||||
error = "invalid_training_area";
|
||||
return false;
|
||||
}
|
||||
areas[size_t(request.index)] = uint8_t(request.value);
|
||||
automation = uint8_t(automation & ~uint8_t(1u << 2));
|
||||
break;
|
||||
case ui::TrainingRequestKind::set_player_intensity:
|
||||
case ui::TrainingRequestKind::set_player_focus: {
|
||||
if (current.needs_initialization() || request.index < 0 || request.index >= current.squad_capacity ||
|
||||
request.player_id < 0 || request.player_id > 0x0ffe) {
|
||||
error = "invalid_training_player";
|
||||
return false;
|
||||
}
|
||||
const auto player = std::find_if(current.players.begin(), current.players.end(), [&](const auto& p) {
|
||||
return p.row == request.index && p.player_id == request.player_id;
|
||||
});
|
||||
const SquadRange squad = squad_range(request.runtime_club);
|
||||
if (player == current.players.end() || squad.count != size_t(current.squad_capacity) ||
|
||||
squad.first + size_t(request.index) >= g_.squad_slots.size() ||
|
||||
(g_.squad_slots[squad.first + size_t(request.index)] & 0x0fff) != request.player_id) {
|
||||
error = "stale_training_player";
|
||||
return false;
|
||||
}
|
||||
if (kind == ui::TrainingRequestKind::set_player_intensity) {
|
||||
if (request.value < 1 || request.value > 3 || request.value == player->intensity) {
|
||||
error = "invalid_training_intensity";
|
||||
return false;
|
||||
}
|
||||
automation = uint8_t(automation & ~uint8_t(1u << 3));
|
||||
} else if (request.value < 0 || request.value > 7 || request.value != (player->focus + 1) % 8) {
|
||||
error = "invalid_training_focus";
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ui::TrainingRequestKind::set_automation: {
|
||||
if (current.needs_initialization() || request.index < 0 || request.index > 4 ||
|
||||
(request.value != 0 && request.value != 1) || request.player_id != -1) {
|
||||
error = "invalid_training_automation";
|
||||
return false;
|
||||
}
|
||||
if (request.index != 0 && !(current.automation & 1)) {
|
||||
error = "training_automation_group_hidden";
|
||||
return false;
|
||||
}
|
||||
const uint8_t mask = uint8_t(1u << request.index);
|
||||
automation = uint8_t(automation ^ mask);
|
||||
if (((automation & mask) != 0) != (request.value != 0)) {
|
||||
error = "stale_training_automation";
|
||||
return false;
|
||||
}
|
||||
run_automatic = (automation & 1) != 0;
|
||||
break;
|
||||
}
|
||||
case ui::TrainingRequestKind::none:
|
||||
default:
|
||||
error = "unsupported_training_request";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (request.desired_types != types || request.desired_areas != areas ||
|
||||
request.desired_automation != automation) {
|
||||
error = "stale_training_projection";
|
||||
return false;
|
||||
}
|
||||
|
||||
GameState staged = g_;
|
||||
std::copy(types.begin(), types.end(), staged.manager_records.begin() + rec + 0xc5);
|
||||
std::copy(areas.begin(), areas.end(), staged.manager_records.begin() + rec + 0xc9);
|
||||
staged.manager_options[option_at] = automation;
|
||||
if (kind == ui::TrainingRequestKind::set_player_intensity ||
|
||||
kind == ui::TrainingRequestKind::set_player_focus) {
|
||||
const size_t board = slot * 0x840 + size_t(request.index) * 0x58 + 0x0a;
|
||||
if (board >= staged.tactics.size()) {
|
||||
error = "invalid_training_board";
|
||||
return false;
|
||||
}
|
||||
if (kind == ui::TrainingRequestKind::set_player_intensity)
|
||||
staged.tactics[board] = uint8_t((staged.tactics[board] & 0xfc) | request.value);
|
||||
else
|
||||
staged.tactics[board] = uint8_t((staged.tactics[board] & 0x03) | (request.value << 2));
|
||||
}
|
||||
if (run_automatic) auto_training(staged, request.manager_slot);
|
||||
g_ = std::move(staged);
|
||||
++revision;
|
||||
error.clear();
|
||||
return true;
|
||||
} catch (const std::exception&) {
|
||||
error = "invalid_training_state";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Training camp group: set_focus changes the four focus bytes of the active manager (an unchanged
|
||||
// or invalid focus is refused); book books a resort for the week after checking the focus the UI
|
||||
// saw, the weekly/visit limits and the funds (the booking draws random numbers). Refused while a
|
||||
// modal owner is open or when the manager slot, club or revision is stale; revision plus one on
|
||||
// success, short error codes in 'error' otherwise.
|
||||
bool CareerSession::dispatch_training_camp(const ui::TrainingCampRequest& request, uint64_t& revision,
|
||||
std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return false; }
|
||||
if (request.manager_slot < 0 || size_t(request.manager_slot) >= g_.manager_teams.size() ||
|
||||
request.manager_slot != int(g_.memory.u8(::bmh::layout::ActiveManager)) ||
|
||||
request.runtime_club != g_.manager_teams[size_t(request.manager_slot)] || request.revision != revision) {
|
||||
error = "stale_manager_or_revision";
|
||||
return false;
|
||||
}
|
||||
const size_t rec = size_t(request.manager_slot) * kManagerRecordSize;
|
||||
if (request.kind == ui::TrainingCampRequestKind::set_focus) {
|
||||
const std::array<uint8_t, 4> current{
|
||||
g_.manager_records.at(rec + 0xc1), g_.manager_records.at(rec + 0xc2),
|
||||
g_.manager_records.at(rec + 0xc3), g_.manager_records.at(rec + 0xc4)};
|
||||
if (request.focus == current) {
|
||||
error = "focus_unchanged";
|
||||
return false;
|
||||
}
|
||||
if (!set_training_camp_focus(g_, request.manager_slot, request.focus)) {
|
||||
error = "invalid_focus_request";
|
||||
return false;
|
||||
}
|
||||
++revision;
|
||||
return true;
|
||||
}
|
||||
if (request.kind == ui::TrainingCampRequestKind::book) {
|
||||
if (request.resort < 0 || request.resort >= kTrainingCampResorts) {
|
||||
error = "invalid_resort";
|
||||
return false;
|
||||
}
|
||||
const std::array<uint8_t, 4> current{
|
||||
g_.manager_records.at(rec + 0xc1), g_.manager_records.at(rec + 0xc2),
|
||||
g_.manager_records.at(rec + 0xc3), g_.manager_records.at(rec + 0xc4)};
|
||||
if (request.focus != current) {
|
||||
error = "stale_focus";
|
||||
return false;
|
||||
}
|
||||
switch (training_camp_booking_block(g_, request.manager_slot)) {
|
||||
case TrainingCampBookingBlock::booked_this_week: error = "booked_this_week"; return false;
|
||||
case TrainingCampBookingBlock::visit_limit: error = "visit_limit"; return false;
|
||||
case TrainingCampBookingBlock::invalid_request: error = "invalid_request"; return false;
|
||||
case TrainingCampBookingBlock::none: break;
|
||||
}
|
||||
if (!book_training_camp(g_, request.manager_slot, request.resort, rand_)) {
|
||||
error = "insufficient_funds";
|
||||
return false;
|
||||
}
|
||||
++revision;
|
||||
return true;
|
||||
}
|
||||
error = "unsupported_training_camp_request";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bank group: deposit moves, share and fund trades, stock tips and bank credit. Needs the active
|
||||
// manager, club and current revision and no modal owner open. Every branch validates amounts and
|
||||
// counts against the manager record and the stock/fund blocks, then applies the change to the
|
||||
// live state and bumps the revision once. The notices of the last property purchase or credit
|
||||
// refund are kept for the next projection. Returns false with a short error code otherwise.
|
||||
bool CareerSession::dispatch_bank(const ui::BankRequest& request, uint64_t& revision, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return false; }
|
||||
error.clear();
|
||||
if (revision == std::numeric_limits<uint64_t>::max()) {
|
||||
error = "revision_exhausted"; return false;
|
||||
}
|
||||
const int active = int(g_.memory.u8(::bmh::layout::ActiveManager));
|
||||
if (request.manager_slot != active ||
|
||||
request.manager_slot < 0 || size_t(request.manager_slot) >= g_.manager_teams.size() ||
|
||||
request.runtime_club != g_.manager_teams[size_t(request.manager_slot)] || request.revision != revision) {
|
||||
error = "stale_manager_or_revision"; return false;
|
||||
}
|
||||
const size_t rec = size_t(request.manager_slot) * kManagerRecordSize;
|
||||
std::optional<ui::BankState::PropertyNotice> property_notice;
|
||||
std::optional<ui::BankState::CreditNotice> credit_notice;
|
||||
const auto read_signed = [&](size_t offset) {
|
||||
const uint32_t v = uint32_t(g_.manager_records.at(rec + offset)) |
|
||||
uint32_t(g_.manager_records.at(rec + offset + 1)) << 8 |
|
||||
uint32_t(g_.manager_records.at(rec + offset + 2)) << 16 |
|
||||
uint32_t(g_.manager_records.at(rec + offset + 3)) << 24;
|
||||
return int32_t(v);
|
||||
};
|
||||
if (request.kind == ui::BankRequestKind::move_to_deposit) {
|
||||
if (!request.amount || request.asset_index != -1 || request.count != 0 ||
|
||||
int64_t(request.amount > 0 ? request.amount : -int64_t(request.amount)) > 99999999) {
|
||||
error = "invalid_amount"; return false;
|
||||
}
|
||||
const int64_t available = request.amount > 0 ? read_signed(0x314) : read_signed(0x318);
|
||||
if (available < 0 || int64_t(request.amount > 0 ? request.amount : -int64_t(request.amount)) > available) {
|
||||
error = "amount_unavailable"; return false;
|
||||
}
|
||||
move_to_deposit(g_, request.manager_slot, request.amount);
|
||||
} else if (request.kind == ui::BankRequestKind::buy_shares || request.kind == ui::BankRequestKind::sell_shares ||
|
||||
request.kind == ui::BankRequestKind::stock_tip) {
|
||||
if (request.asset_index < 0 || request.asset_index >= kStocks ||
|
||||
g_.stocks.size() < size_t(kStocks) * 0x5c) { error = "invalid_stock"; return false; }
|
||||
const size_t at = size_t(request.asset_index) * 0x5c;
|
||||
const int price = int(uint16_t(g_.stocks.at(at + 0x4e) | uint16_t(g_.stocks.at(at + 0x4f)) << 8));
|
||||
if (request.kind == ui::BankRequestKind::buy_shares) {
|
||||
if (request.count <= 0 || request.count > 9999 || price <= 0 ||
|
||||
request.count > max_shares_to_buy(g_, request.manager_slot, request.asset_index)) {
|
||||
error = "invalid_share_count"; return false;
|
||||
}
|
||||
const int64_t raw = int64_t(price) * request.count;
|
||||
const int64_t total = raw + raw * 15 / 1000;
|
||||
if (total > int64_t(read_signed(0x314)) + read_signed(0x31c)) {
|
||||
error = "insufficient_funds"; return false;
|
||||
}
|
||||
if (!buy_shares(g_, request.manager_slot, request.asset_index, request.count)) {
|
||||
error = "investment_limit"; return false;
|
||||
}
|
||||
} else if (request.kind == ui::BankRequestKind::sell_shares) {
|
||||
const size_t held_at = at + 0x50 + size_t(request.manager_slot) * 2;
|
||||
const int held = int(uint16_t(g_.stocks.at(held_at) | uint16_t(g_.stocks.at(held_at + 1)) << 8));
|
||||
if (request.count <= 0 || request.count > held) { error = "invalid_share_count"; return false; }
|
||||
sell_shares(g_, request.manager_slot, request.asset_index, request.count);
|
||||
} else {
|
||||
if (request.count != 0 || request.amount != 0) { error = "invalid_tip_request"; return false; }
|
||||
last_stock_tip_ = stock_tip(g_, request.manager_slot, request.asset_index, rand_);
|
||||
}
|
||||
} else if (request.kind == ui::BankRequestKind::buy_fund || request.kind == ui::BankRequestKind::sell_fund) {
|
||||
if (request.amount != 0 || request.asset_index < 0 || request.asset_index >= kFunds || request.count <= 0 || request.count > 10 ||
|
||||
g_.memory.u32(::bmh::layout::FundBlock + uint32_t(request.asset_index) * 0x1c) == 0) {
|
||||
error = "invalid_fund_request"; return false;
|
||||
}
|
||||
const uint32_t fund_at = ::bmh::layout::FundBlock + uint32_t(request.asset_index) * 0x1c;
|
||||
const uint16_t held = g_.memory.u16(fund_at + 0x14 + uint32_t(request.manager_slot) * 2);
|
||||
if (request.kind == ui::BankRequestKind::buy_fund) {
|
||||
if (request.count > max_fund_units(g_, request.manager_slot, request.asset_index)) {
|
||||
error = "invalid_fund_count"; return false;
|
||||
}
|
||||
const int32_t additional_cost = buy_fund_units(g_, request.manager_slot, request.asset_index, request.count, game_);
|
||||
if (request.asset_index != 0) {
|
||||
const std::string text = message_text(g_, ::bmh::layout::CareerSession_Int32T_TextPointer2) + format_number(g_, additional_cost, 0x101) +
|
||||
message_text(g_, ::bmh::layout::CareerSession_Int32T_TextPointer);
|
||||
property_notice = ui::BankState::PropertyNotice{request.asset_index, additional_cost, ui::original_to_utf8(text)};
|
||||
}
|
||||
} else {
|
||||
if (request.count > held) { error = "invalid_fund_count"; return false; }
|
||||
sell_fund_units(g_, request.manager_slot, request.asset_index, request.count);
|
||||
}
|
||||
} else if (request.kind == ui::BankRequestKind::bank_credit) {
|
||||
if (request.amount != 0 || request.asset_index != -1 || request.count != 0 || request.credit_edits.empty()) {
|
||||
error = "invalid_credit_request"; return false;
|
||||
}
|
||||
if (request.credit_counterparty != 0) {
|
||||
// Source case 5 scans configured human managers, excluding the borrower.
|
||||
// A runtime national-manager entry is not an additional human lender.
|
||||
const int configured = int(g_.memory.u8(::bmh::layout::ManagerCount));
|
||||
if (request.credit_counterparty < 1 || request.credit_counterparty > 4) {
|
||||
error = "invalid_credit_request"; return false;
|
||||
}
|
||||
const int lender = request.credit_counterparty - 1;
|
||||
if (configured < 1 || configured > 4 || request.manager_slot >= configured ||
|
||||
lender < 0 || lender >= configured || lender == request.manager_slot) {
|
||||
error = "invalid_credit_request"; return false;
|
||||
}
|
||||
}
|
||||
const auto result = commit_bank_credit(g_, exe_, request.manager_slot,
|
||||
request.expected_credit, request.credit_edits, request.accept_credit_fees, request.credit_counterparty);
|
||||
if (result.status != BankCreditStatus::accepted) {
|
||||
error = result.status == BankCreditStatus::no_change ? "credit_no_change" :
|
||||
result.status == BankCreditStatus::stale_request ? "stale_credit_request" :
|
||||
result.status == BankCreditStatus::confirmation_required ? "credit_confirmation_required" :
|
||||
"invalid_credit_request";
|
||||
return false;
|
||||
}
|
||||
if (result.refund != 0) {
|
||||
// "Die Bank" (CareerSession_Int32T_TextPointer3) or, in case 5, the lender's name (record +0xa8)
|
||||
const int lender = request.credit_counterparty - 1;
|
||||
std::string who = message_text(g_, ::bmh::layout::CareerSession_Int32T_TextPointer3);
|
||||
if (lender >= 0) {
|
||||
who.clear();
|
||||
for (size_t i = 0; i < 26; ++i) {
|
||||
const uint8_t ch = g_.manager_records.at(size_t(lender) * kManagerRecordSize + 0xa8 + i);
|
||||
if (!ch) break;
|
||||
who += char(ch);
|
||||
}
|
||||
}
|
||||
const std::string text = who + message_text(g_, ::bmh::layout::CareerSession_Int32T_TextPointer4) +
|
||||
format_number(g_, result.refund, 0x101) + message_text(g_, ::bmh::layout::CareerSession_Int32T_TextPointer5);
|
||||
credit_notice = ui::BankState::CreditNotice{result.refund, ui::original_to_utf8(text)};
|
||||
}
|
||||
} else {
|
||||
error = "unsupported_bank_request"; return false;
|
||||
}
|
||||
last_property_notice_ = std::move(property_notice);
|
||||
last_credit_notice_ = std::move(credit_notice);
|
||||
++revision;
|
||||
return true;
|
||||
}
|
||||
|
||||
// True when a construction tip dialog is open and the process timer (when running) has no time
|
||||
// left; read-only.
|
||||
bool CareerSession::stadium_tip_deadline_expired() const {
|
||||
if (!stadium_.opened || (!stadium_.tip &&
|
||||
(!stadium_.block_expansion || !stadium_.block_expansion->tip))) return false;
|
||||
const auto byte = [this](uint32_t address) {
|
||||
if (g_.memory.has(address)) return g_.memory.u8(address);
|
||||
const auto found = club_modal_runtime_.find(address);
|
||||
return found == club_modal_runtime_.end() ? exe_.u8(address) : found->second;
|
||||
};
|
||||
const auto word = [&byte](uint32_t address) {
|
||||
uint32_t value = 0;
|
||||
for (unsigned i = 0; i < 4; ++i) value |= uint32_t(byte(address + i)) << (8 * i);
|
||||
return value;
|
||||
};
|
||||
return word(::bmh::layout::CareerSession_DispatchStrengths_ExecutableField2) != 0 && int32_t(word(::bmh::layout::CareerSession_FormatError_ExecutableField2)) < 1;
|
||||
}
|
||||
|
||||
// Stadium group: an owner (stadium_) is opened with a scope id and every later request must echo
|
||||
// scope and sequence, the manager, club, stable club identity, game mode and revision. All
|
||||
// actions (data page, periphery quote/build, block expansion editor with its tip, investments)
|
||||
// run inside the apply lambda below; on failure the stadium checkpoint is restored, on success
|
||||
// revision, sequence and the owner's revision advance. Exceptions restore the checkpoint and
|
||||
// the revision and are rethrown. Short error codes in 'error' otherwise.
|
||||
// Older periphery callers send no scope envelope; a compatibility step fills it in for their four
|
||||
// original operations only.
|
||||
bool CareerSession::dispatch_stadium(const ui::StadiumRequest& supplied_request, uint64_t& revision, std::string& error,
|
||||
const ConstructionNoticeHook& notice_presenter,
|
||||
const SeasonTicketCompensationNoticeHook& compensation_presenter) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return false; }
|
||||
const int active = int(g_.memory.u8(::bmh::layout::ActiveManager));
|
||||
auto request = supplied_request;
|
||||
// Existing CLI periphery callers predate the UI scope envelope. Restrict
|
||||
// this compatibility adapter to their four original operations and an
|
||||
// entirely absent envelope; investments and close remain strictly owned.
|
||||
const bool legacy_periphery = !request.stable_club_identity && request.scope == 0 && request.sequence == 0 &&
|
||||
(request.kind == ui::StadiumRequestKind::open || request.kind == ui::StadiumRequestKind::quote_periphery ||
|
||||
request.kind == ui::StadiumRequestKind::decline_periphery || request.kind == ui::StadiumRequestKind::build_periphery);
|
||||
if (legacy_periphery && active >= 0 && active <= 3 && size_t(active) < g_.manager_teams.size() &&
|
||||
request.runtime_club >= 0 && size_t(request.runtime_club) < g_.club_ids.size()) {
|
||||
request.stable_club_identity = int(g_.club_ids[size_t(request.runtime_club)]);
|
||||
if (request.kind != ui::StadiumRequestKind::open) {
|
||||
request.scope = stadium_.scope; request.sequence = stadium_.sequence;
|
||||
}
|
||||
}
|
||||
const bool block_action = is_block_expansion_action(request.kind);
|
||||
if (!block_action && (request.block_slot != -1 || request.block_total_places != 0 ||
|
||||
request.block_features != 0 || request.expected_block_quote)) {
|
||||
error = "unexpected_block_expansion_fields"; return false;
|
||||
}
|
||||
if (request.manager_slot != active || active < 0 || active > 3 ||
|
||||
size_t(active) >= g_.manager_teams.size() || request.runtime_club != g_.manager_teams[size_t(active)] ||
|
||||
request.runtime_club < 0 || request.runtime_club >= 357 ||
|
||||
size_t(request.runtime_club) >= g_.club_ids.size() ||
|
||||
request.stable_club_identity != std::optional<int>(int(g_.club_ids[size_t(request.runtime_club)])) ||
|
||||
request.revision != revision || revision == UINT64_MAX || !g_.memory.has(::bmh::layout::GameMode)) {
|
||||
error = "stale_manager_or_revision"; return false;
|
||||
}
|
||||
const size_t record = size_t(active) * kManagerRecordSize;
|
||||
if (record + 0xb0c > g_.manager_records.size() ||
|
||||
(int(g_.manager_records[record + 0x290]) | int(g_.manager_records[record + 0x291]) << 8) != request.runtime_club) {
|
||||
error = "invalid_stadium_owner"; return false;
|
||||
}
|
||||
const int mode = g_.memory.u8(::bmh::layout::GameMode);
|
||||
if (mode < 1 || mode > 3) { error = "invalid_stadium_mode"; return false; }
|
||||
if (request.kind == ui::StadiumRequestKind::open) {
|
||||
const bool legacy_reentry = legacy_periphery && !stadium_.data_open && !stadium_.investment && !stadium_.tip &&
|
||||
!stadium_.block_expansion;
|
||||
if ((stadium_.opened && !legacy_reentry) || request.scope != 0 || request.sequence != 0 || request.object != -1 ||
|
||||
request.option != -1 || request.price != 0 || request.accept_tip || next_stadium_scope_ == UINT64_MAX) {
|
||||
error = "invalid_stadium_open"; return false;
|
||||
}
|
||||
} else if (!stadium_.opened || stadium_.manager != active || stadium_.club != request.runtime_club ||
|
||||
stadium_.stable_club != *request.stable_club_identity || stadium_.mode != mode ||
|
||||
stadium_.revision != revision || request.scope != stadium_.scope ||
|
||||
request.sequence != stadium_.sequence || stadium_.sequence == UINT64_MAX) {
|
||||
error = "stale_stadium_scope"; return false;
|
||||
}
|
||||
auto before = stadium_checkpoint();
|
||||
const uint64_t before_revision = revision;
|
||||
try {
|
||||
// Performs the validated stadium action and returns true on success; 'invalid' records the
|
||||
// reason and returns false.
|
||||
const auto apply = [&]() -> bool {
|
||||
const auto invalid = [&error](const char* reason) { error = reason; return false; };
|
||||
const auto plain = [&request](int object = -1) {
|
||||
return request.object == object && request.option == -1 && request.price == 0 && !request.accept_tip;
|
||||
};
|
||||
const auto clear_investment = [this] {
|
||||
stadium_.investment.reset(); stadium_.selection_status.reset(); stadium_.option.reset(); stadium_.tip.reset();
|
||||
stadium_.option_index = -1; stadium_.text_variant = -1;
|
||||
};
|
||||
StadiumInvestmentConstants constants;
|
||||
for (unsigned i = 0; i < 8; ++i) {
|
||||
constants.price[i] = exe_.u32(::bmh::layout::CareerSession_DispatchStadium_RuntimeField + i * 4);
|
||||
constants.weeks[i] = exe_.u8(::bmh::layout::CareerSession_DispatchStadium_RuntimeField2 + (14 + i) * 5);
|
||||
}
|
||||
const auto options = [&](StadiumInvestment investment) {
|
||||
return stadium_investment_options_source(g_, active, investment, stadium_.price_percent, constants);
|
||||
};
|
||||
const auto selected_valid = [&]() {
|
||||
if (!stadium_.investment || !stadium_.option || stadium_.option_index < 0) return false;
|
||||
const auto current = options(*stadium_.investment);
|
||||
return size_t(stadium_.option_index) < current.size() &&
|
||||
current[size_t(stadium_.option_index)] == *stadium_.option;
|
||||
};
|
||||
if (request.kind == ui::StadiumRequestKind::open) {
|
||||
StadiumRuntime opened;
|
||||
opened.opened = true; opened.manager = active; opened.club = request.runtime_club;
|
||||
opened.stable_club = *request.stable_club_identity; opened.mode = mode;
|
||||
opened.scope = next_stadium_scope_++;
|
||||
opened.price_percent = construction_price_percent(g_, active, game_);
|
||||
if (opened.price_percent < 1 || opened.price_percent > 427) return invalid("invalid_stadium_discount");
|
||||
stadium_ = std::move(opened);
|
||||
return true;
|
||||
}
|
||||
if (request.kind == ui::StadiumRequestKind::close) {
|
||||
if (stadium_.data_open || !plain() || stadium_.investment || stadium_.periphery_quote || stadium_.tip ||
|
||||
stadium_.block_expansion)
|
||||
return invalid("invalid_stadium_close");
|
||||
stadium_.opened = false; stadium_.periphery_quote.reset(); clear_investment();
|
||||
stadium_.feedback.clear(); return true;
|
||||
}
|
||||
const bool data_action = request.kind == ui::StadiumRequestKind::open_data ||
|
||||
request.kind == ui::StadiumRequestKind::toggle_data_curve ||
|
||||
request.kind == ui::StadiumRequestKind::toggle_data_scale ||
|
||||
request.kind == ui::StadiumRequestKind::set_data_ticket_price ||
|
||||
request.kind == ui::StadiumRequestKind::close_data;
|
||||
if (data_action) {
|
||||
if (stadium_.investment || stadium_.periphery_quote || stadium_.tip || stadium_.block_expansion ||
|
||||
request.option != -1 || request.price != 0 || request.accept_tip)
|
||||
return invalid("invalid_stadium_data_context");
|
||||
if (request.kind == ui::StadiumRequestKind::open_data) {
|
||||
if (stadium_.data_open || request.object != -1) return invalid("invalid_stadium_data_open");
|
||||
const uint32_t flags_at = ::bmh::layout::Flags + uint32_t(active) * 3 + 1;
|
||||
if (!g_.memory.has(flags_at)) return invalid("missing_stadium_data_flags");
|
||||
stadium_.data_flags = g_.memory.u8(flags_at);
|
||||
// Build the pure projection before accepting modal ownership.
|
||||
(void)ui::stadium_data_from_game(g_, exe_, active, stadium_.data_flags);
|
||||
stadium_.data_open = true;
|
||||
} else {
|
||||
if (!stadium_.data_open) return invalid("stadium_data_not_open");
|
||||
if (request.kind == ui::StadiumRequestKind::toggle_data_curve) {
|
||||
if (request.object < 0 || request.object > 5) return invalid("invalid_stadium_data_curve");
|
||||
stadium_.data_flags ^= uint8_t(1u << request.object);
|
||||
} else if (request.kind == ui::StadiumRequestKind::toggle_data_scale) {
|
||||
if (request.object < 0 || request.object > 1) return invalid("invalid_stadium_data_scale");
|
||||
stadium_.data_flags ^= 0xc0; // Either ABS or REL button toggles both Source bits.
|
||||
} else if (request.kind == ui::StadiumRequestKind::set_data_ticket_price) {
|
||||
if (request.object < 10 || request.object > 25) return invalid("invalid_stadium_data_ticket");
|
||||
g_.manager_records[record + 0x26e] = uint8_t(request.object);
|
||||
(void)ui::stadium_data_from_game(g_, exe_, active, stadium_.data_flags);
|
||||
} else {
|
||||
if (request.object != -1) return invalid("invalid_stadium_data_close");
|
||||
g_.memory.set8(::bmh::layout::Flags + uint32_t(active) * 3 + 1, stadium_.data_flags);
|
||||
stadium_.data_open = false;
|
||||
}
|
||||
}
|
||||
stadium_.feedback.clear();
|
||||
return true;
|
||||
}
|
||||
if (stadium_.data_open) return invalid("stadium_data_active");
|
||||
if (mode == 1 && !legacy_periphery &&
|
||||
(request.kind == ui::StadiumRequestKind::quote_periphery ||
|
||||
request.kind == ui::StadiumRequestKind::build_periphery ||
|
||||
request.kind == ui::StadiumRequestKind::decline_periphery))
|
||||
return invalid("stadium_periphery_disabled");
|
||||
if (request.kind == ui::StadiumRequestKind::quote_periphery) {
|
||||
if (stadium_.investment || stadium_.periphery_quote || stadium_.block_expansion || request.object < 0 ||
|
||||
request.object >= 14 || !plain(request.object)) return invalid("invalid_periphery_offer");
|
||||
const size_t object = size_t(request.object);
|
||||
const uint8_t level = g_.manager_records[record + object];
|
||||
if (g_.manager_records[record + 0x1e + object] != 0 || (object == 0 ? level >= 0xab : level != 0))
|
||||
return invalid("periphery_unavailable");
|
||||
const int32_t price = periphery_offer(g_, request.object, game_);
|
||||
if (price <= 0) return invalid("invalid_periphery_price");
|
||||
stadium_.periphery_quote = std::make_pair(request.object, price);
|
||||
stadium_.feedback.clear(); return true;
|
||||
}
|
||||
if (request.kind == ui::StadiumRequestKind::decline_periphery ||
|
||||
request.kind == ui::StadiumRequestKind::build_periphery) {
|
||||
if (stadium_.investment || stadium_.block_expansion || !stadium_.periphery_quote ||
|
||||
request.option != -1 || request.accept_tip ||
|
||||
request.object != stadium_.periphery_quote->first || request.price != stadium_.periphery_quote->second)
|
||||
return invalid("stale_periphery_offer");
|
||||
if (request.kind == ui::StadiumRequestKind::build_periphery) {
|
||||
const size_t object = size_t(request.object);
|
||||
const uint8_t level = g_.manager_records[record + object];
|
||||
if (g_.manager_records[record + 0x1e + object] != 0 || (object == 0 ? level >= 0xab : level != 0))
|
||||
return invalid("periphery_unavailable");
|
||||
// ConstructionPricePercent consumes this genuine JA even when PayConstruction's
|
||||
// payment fails. The Source presenter runs before the quote
|
||||
// is cleared; payment/sponsor effects are not rolled back.
|
||||
const bool built = build_periphery(g_, active, request.object,
|
||||
uint32_t(request.price), rand_, notice_presenter);
|
||||
stadium_.feedback = built || notice_presenter ? std::string{} : message_text(g_, ::bmh::layout::Advertising_FormatError_TextPointer18);
|
||||
}
|
||||
stadium_.periphery_quote.reset();
|
||||
if (request.kind == ui::StadiumRequestKind::decline_periphery) stadium_.feedback.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
// A–H uses its own quote/commit domain and remains available in
|
||||
// Source mode 1, where facilities are disabled. All request fields
|
||||
// outside the typed block envelope must stay neutral.
|
||||
if (block_action) {
|
||||
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");
|
||||
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);
|
||||
};
|
||||
if (request.kind == ui::StadiumRequestKind::expansion_select) {
|
||||
if (stadium_.investment || stadium_.periphery_quote || stadium_.block_expansion ||
|
||||
request.block_slot < 0 || request.block_slot >= 8 || request.block_total_places != 0 ||
|
||||
request.block_features != 0 || request.expected_block_quote)
|
||||
return invalid("invalid_block_expansion_selection");
|
||||
const auto slot = static_cast<StadiumBlockSlot>(request.block_slot);
|
||||
const uint8_t raw = g_.manager_records.at(record + 0x44 + size_t(request.block_slot));
|
||||
const uint32_t current = uint32_t(g_.manager_records.at(record + 0x4c + size_t(request.block_slot))) * 1000;
|
||||
auto quote = quote_block(slot, current, uint8_t(raw & kBlockFeatures));
|
||||
if (!quote) return invalid("block_expansion_unavailable");
|
||||
StadiumRuntime::BlockExpansion draft;
|
||||
draft.quote = *quote;
|
||||
draft.total_target_places = current;
|
||||
draft.desired_features = uint8_t(raw & kBlockFeatures);
|
||||
game_.set_seed(int32_t(g_.memory.u32(::bmh::layout::CareerSession_Invalid_RuntimeField2)));
|
||||
draft.header_text_variant = game_.range(3, 10); // Front, once on editor entry.
|
||||
stadium_.block_expansion = std::move(draft);
|
||||
stadium_.feedback.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!stadium_.block_expansion || stadium_.investment || stadium_.periphery_quote ||
|
||||
request.block_slot < 0 || request.block_slot >= 8 ||
|
||||
request.block_slot != int(stadium_.block_expansion->quote.slot) ||
|
||||
!request.expected_block_quote || *request.expected_block_quote != stadium_.block_expansion->quote)
|
||||
return invalid("stale_block_expansion_quote");
|
||||
auto& draft = *stadium_.block_expansion;
|
||||
if (draft.tip) {
|
||||
const auto& tip = *draft.tip;
|
||||
const bool valid_tip = tip.decision == StandBlockOfferDecision::Pending &&
|
||||
tip.base_price == draft.quote.base_price && tip.base_days == draft.quote.base_weeks &&
|
||||
tip.price == tip.base_price && tip.percent >= 6 && tip.percent <= 14 &&
|
||||
tip.offered_price == uint32_t(uint64_t(tip.base_price) * uint32_t(100 + tip.percent) / 100);
|
||||
if (!valid_tip) return invalid("stale_block_expansion_tip");
|
||||
}
|
||||
auto fresh = quote_block(draft.quote.slot, draft.total_target_places, draft.desired_features);
|
||||
if (!fresh || *fresh != draft.quote)
|
||||
return invalid("block_expansion_source_changed");
|
||||
|
||||
const auto matches_draft = [&] {
|
||||
return request.block_total_places == draft.total_target_places &&
|
||||
request.block_features == draft.desired_features;
|
||||
};
|
||||
switch (request.kind) {
|
||||
case ui::StadiumRequestKind::expansion_set_total: {
|
||||
if (draft.tip || request.block_features != draft.desired_features)
|
||||
return invalid("stale_block_expansion_draft");
|
||||
auto next_quote = quote_block(draft.quote.slot, request.block_total_places, draft.desired_features);
|
||||
if (!next_quote) return invalid("invalid_block_expansion_total");
|
||||
draft.total_target_places = request.block_total_places;
|
||||
draft.quote = *next_quote;
|
||||
stadium_.feedback.clear();
|
||||
return true;
|
||||
}
|
||||
case ui::StadiumRequestKind::expansion_toggle_feature: {
|
||||
const uint8_t changed = uint8_t(request.block_features ^ draft.desired_features);
|
||||
if (draft.tip || request.block_total_places != draft.total_target_places ||
|
||||
(request.block_features & uint8_t(~kBlockFeatures)) != 0 ||
|
||||
(changed != kBlockSeat && changed != kBlockRoof) ||
|
||||
(request.block_features & uint8_t(draft.quote.current_raw_flags & kBlockFeatures)) !=
|
||||
uint8_t(draft.quote.current_raw_flags & kBlockFeatures))
|
||||
return invalid("invalid_block_expansion_feature");
|
||||
auto next_quote = quote_block(draft.quote.slot, draft.total_target_places, request.block_features);
|
||||
if (!next_quote) return invalid("invalid_block_expansion_feature");
|
||||
draft.desired_features = request.block_features;
|
||||
draft.quote = *next_quote;
|
||||
stadium_.feedback.clear();
|
||||
return true;
|
||||
}
|
||||
case ui::StadiumRequestKind::expansion_cancel:
|
||||
if (draft.tip || !matches_draft()) return invalid("stale_block_expansion_cancel");
|
||||
stadium_.block_expansion.reset();
|
||||
stadium_.feedback.clear();
|
||||
return true;
|
||||
case ui::StadiumRequestKind::expansion_confirm: {
|
||||
if (draft.tip || !matches_draft()) return invalid("stale_block_expansion_confirm");
|
||||
if (draft.quote.base_price == 0) {
|
||||
stadium_.block_expansion.reset();
|
||||
stadium_.feedback.clear();
|
||||
return true;
|
||||
}
|
||||
auto tip = prepare_stand_block_offer(draft.quote.base_price, draft.quote.base_weeks, rand_);
|
||||
if (tip.offered_price > uint32_t(INT32_MAX))
|
||||
return invalid("block_expansion_tip_price_overflow");
|
||||
draft.tip = tip;
|
||||
stadium_.feedback.clear();
|
||||
return true;
|
||||
}
|
||||
case ui::StadiumRequestKind::expansion_answer_tip: {
|
||||
if (!draft.tip || !matches_draft() || request.accept_tip &&
|
||||
uint64_t(draft.tip->base_price) * uint32_t(100 + draft.tip->percent) >
|
||||
uint64_t(INT32_MAX))
|
||||
return invalid("invalid_block_expansion_tip_answer");
|
||||
StandBlockOffer resolved = *draft.tip;
|
||||
resolve_stand_block_offer(resolved, request.accept_tip, rand_);
|
||||
const bool built = build_stadium_block_expansion(g_, active, draft.quote.slot,
|
||||
block_constants, draft.quote, resolved, rand_, notice_presenter, compensation_presenter);
|
||||
stadium_.block_expansion.reset();
|
||||
stadium_.feedback = built || notice_presenter ? std::string{} : message_text(g_, ::bmh::layout::Advertising_FormatError_TextPointer18);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return invalid("unsupported_block_expansion_request");
|
||||
}
|
||||
}
|
||||
if (mode == 1) return invalid("stadium_investments_disabled");
|
||||
if (request.kind == ui::StadiumRequestKind::select_investment) {
|
||||
if (stadium_.investment || stadium_.periphery_quote || stadium_.block_expansion || request.object < 0 ||
|
||||
request.object >= 8 || !plain(request.object)) return invalid("invalid_investment_selection");
|
||||
const auto investment = static_cast<StadiumInvestment>(request.object);
|
||||
const auto current = options(investment);
|
||||
if (current.empty()) return invalid("investment_unavailable");
|
||||
game_.set_seed(int32_t(g_.memory.u32(::bmh::layout::CareerSession_Invalid_RuntimeField2)));
|
||||
stadium_.text_variant = game_.range(3, 10); // Front: exactly once at dialog entry.
|
||||
stadium_.investment = investment; stadium_.selection_status = current.front().current_status;
|
||||
stadium_.option_index = -1; stadium_.option.reset(); // Source iVar5=-1 until an explicit tier click.
|
||||
stadium_.feedback.clear(); return true;
|
||||
}
|
||||
if (request.kind == ui::StadiumRequestKind::cancel_investment) {
|
||||
if (!stadium_.investment || stadium_.tip || !plain(int(*stadium_.investment)))
|
||||
return invalid("stale_investment_selection");
|
||||
clear_investment(); stadium_.feedback.clear(); return true; // Initial Abbruch precedes W(6,14).
|
||||
}
|
||||
if (request.kind == ui::StadiumRequestKind::select_investment_option) {
|
||||
if (!stadium_.investment || stadium_.tip || request.object != int(*stadium_.investment) ||
|
||||
request.option < 0 || request.accept_tip || !stadium_.selection_status ||
|
||||
g_.manager_records[record + 0x3c + size_t(*stadium_.investment)] != *stadium_.selection_status)
|
||||
return invalid("stale_investment_selection");
|
||||
const auto current = options(*stadium_.investment);
|
||||
if (size_t(request.option) >= current.size() || request.price != int32_t(current[size_t(request.option)].base_price))
|
||||
return invalid("stale_investment_price");
|
||||
stadium_.option_index = request.option; stadium_.option = current[size_t(request.option)];
|
||||
return true; // Pure tier choice: neither Source generator advances.
|
||||
}
|
||||
if (request.kind == ui::StadiumRequestKind::confirm_investment) {
|
||||
if (stadium_.tip || !selected_valid() || request.object != int(*stadium_.investment) ||
|
||||
request.option != stadium_.option_index || request.accept_tip ||
|
||||
request.price != int32_t(stadium_.option->base_price)) return invalid("stale_investment_selection");
|
||||
stadium_.tip = prepare_stand_block_offer(stadium_.option->base_price, stadium_.option->base_weeks, rand_);
|
||||
if (stadium_.tip->offered_price > uint32_t(INT32_MAX)) return invalid("invalid_investment_tip_price");
|
||||
return true;
|
||||
}
|
||||
if (request.kind == ui::StadiumRequestKind::answer_construction_tip) {
|
||||
if (!stadium_.tip || !selected_valid() || request.object != int(*stadium_.investment) ||
|
||||
request.option != stadium_.option_index || request.price != int32_t(request.accept_tip ?
|
||||
stadium_.tip->offered_price : stadium_.tip->base_price)) return invalid("stale_construction_tip");
|
||||
auto resolved = *stadium_.tip;
|
||||
resolve_stand_block_offer(resolved, request.accept_tip, rand_);
|
||||
const bool built = build_stadium_investment_source(g_, active, *stadium_.investment,
|
||||
stadium_.price_percent, constants, *stadium_.option, resolved, rand_, notice_presenter);
|
||||
// A genuine PayConstruction/BookMoney2 refusal consumes the answer and
|
||||
// retains the sponsor share clearing and Source W draws.
|
||||
// Interactive callers have already shown Source's timed funds
|
||||
// notice; headless legacy callers retain their text feedback.
|
||||
clear_investment();
|
||||
stadium_.feedback = built || notice_presenter ? std::string{} : message_text(g_, ::bmh::layout::Advertising_FormatError_TextPointer18);
|
||||
return true;
|
||||
}
|
||||
return invalid("unsupported_stadium_request");
|
||||
};
|
||||
if (!apply()) { restore_stadium_checkpoint(std::move(before)); return false; }
|
||||
++revision; ++stadium_.sequence; stadium_.revision = revision;
|
||||
error.clear(); return true;
|
||||
} catch (...) {
|
||||
restore_stadium_checkpoint(std::move(before)); revision = before_revision; throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Submits a pools coupon for the active manager; only valid when the coupon has eleven matches.
|
||||
// Revision plus one; false with a short error code otherwise.
|
||||
bool CareerSession::dispatch_toto(const ui::TotoRequest& request, uint64_t& revision, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return false; }
|
||||
const int active = int(g_.memory.u8(::bmh::layout::ActiveManager));
|
||||
if (request.kind != ui::TotoRequestKind::submit || request.manager_slot != active || request.manager_slot < 0 ||
|
||||
size_t(request.manager_slot) >= g_.manager_teams.size() ||
|
||||
request.runtime_club != g_.manager_teams[size_t(request.manager_slot)] || request.revision != revision) {
|
||||
error = "stale_manager_or_revision"; return false;
|
||||
}
|
||||
if (g_.memory.u8(::bmh::layout::CareerSession_DispatchToto_RuntimeField) != 11) { error = "toto_coupon_requires_eleven_matches"; return false; }
|
||||
if (!submit_pools_coupon(g_, request.manager_slot, request.stake, request.tips)) {
|
||||
error = "invalid_toto_coupon"; return false;
|
||||
}
|
||||
++revision;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace bmh::app
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,669 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// CareerSession: transfers: offer editor, poaching, transfer market.
|
||||
// (moved out of career_session.cpp unchanged; the class is declared in app/career_session.hpp)
|
||||
#include "app/career_session_internal.hpp"
|
||||
|
||||
namespace bmh::app {
|
||||
namespace {
|
||||
|
||||
// Transfer editor / market group (helpers first). Projects the engine's transfer offer editor
|
||||
// owner into the UI state: the quote fields, calculator profiles and, unless the editor is
|
||||
// closed, the incoming-offer decision panel read from the four offer rows of the market list.
|
||||
ui::OutgoingTransferEditorState transfer_offer_projection(const GameState& game,
|
||||
const TransferOfferEditorState& owner, uint64_t revision, bool gradient) {
|
||||
ui::OutgoingTransferEditorState out;
|
||||
const auto& request = owner.request;
|
||||
out.manager_slot = request.manager; out.runtime_club = request.runtime_club;
|
||||
out.revision = revision; out.list_entry = request.list_entry; out.source_slot = request.source_slot;
|
||||
out.player = request.expected_player;
|
||||
out.seller = request.expected_seller_word == 0xffff ? 0x0fff : request.expected_seller_word & 0x7fff;
|
||||
out.bid_slot = owner.bid_slot; out.source_mode = owner.mode;
|
||||
out.editable = owner.editable; out.closed = owner.closed; out.quote_loan = owner.quote_loan;
|
||||
out.initial_action_loan = request.loan;
|
||||
out.gradient_text = gradient;
|
||||
out.fee = owner.fee; out.monthly_salary = owner.salary; out.duration_years = owner.years;
|
||||
out.bonuses = owner.bonuses;
|
||||
const auto copy_profile = [](const TransferOfferInputProfile& p) {
|
||||
return ui::OutgoingTransferCalculatorProfile{p.supported, p.currency, p.minimum, p.maximum,
|
||||
p.initial, p.source_text_address, p.presets};
|
||||
};
|
||||
for (size_t n = 0; n < 2; ++n) out.money_calculators[n] = copy_profile(owner.money_profiles[n]);
|
||||
for (size_t n = 0; n < 8; ++n) out.mode3_calculators[n] = copy_profile(owner.mode3_profiles[n]);
|
||||
if (owner.closed) return out; // No modal is constructed after Source cleanup.
|
||||
ui::IncomingTransferDecisionView view;
|
||||
view.source_outgoing_editor_context = true;
|
||||
view.valid = true; view.list_entry = request.list_entry; view.player = out.player;
|
||||
view.seller = out.seller; view.seller_manager = out.seller == 0x0fff ? -1 : game.manager_of(out.seller);
|
||||
view.viewer_manager = request.manager;
|
||||
view.asking_fee = owner.asking_fee; view.asking_monthly_salary = owner.asking_salary;
|
||||
view.quoted_fee = owner.quoted_fee; view.quoted_monthly_salary = owner.quoted_salary;
|
||||
view.quoted_years = owner.years;
|
||||
const uint32_t list = ::bmh::layout::EditorList + uint32_t(request.list_entry) * 0x58;
|
||||
for (uint32_t n = 0; n < 4; ++n) {
|
||||
auto& row = view.offers[n];
|
||||
const auto buyer = game.memory.u16(list + n * 2);
|
||||
row.bid_index = int(n); row.present = buyer != 0xffff;
|
||||
row.buyer = row.present ? int(buyer) : -1;
|
||||
row.buyer_manager = row.present ? game.manager_of(row.buyer) : -1;
|
||||
row.fee = game.memory.u32(list + 0x1c + n * 4);
|
||||
row.monthly_salary = game.memory.u32(list + 0x0c + n * 4);
|
||||
const auto raw_term = game.memory.u8(list + 0x34 + n);
|
||||
row.loan = (raw_term & 0x80) != 0; row.contract_months = raw_term & 0x7f;
|
||||
row.eligible = row.present;
|
||||
for (uint32_t k = 0; k < 7; ++k) row.bonuses[k] = game.memory.u8(list + 0x38 + n * 7 + k);
|
||||
}
|
||||
out.panel = ui::incoming_transfer_decision_from_game(game, view);
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Public wrapper so other code (loan return offers) can reuse the editor projection.
|
||||
ui::OutgoingTransferEditorState loan_return_offer_editor_projection(
|
||||
const GameState& game, const TransferOfferEditorState& owner, uint64_t revision, bool gradient) {
|
||||
return transfer_offer_projection(game, owner, revision, gradient);
|
||||
}
|
||||
|
||||
// Maps a UI field edit onto the engine's transfer offer editor edit and returns the new owner.
|
||||
TransferOfferEditorState edit_transfer_offer_from_ui(GameState& game,
|
||||
const TransferOfferEditorState& owner, const ui::OutgoingTransferRequest& request,
|
||||
GameRandom& game_random, WatcomRandom& watcom_random) {
|
||||
return edit_transfer_offer_editor_source(game, owner,
|
||||
{TransferOfferEditorField(uint8_t(request.field)), request.value, request.accepted},
|
||||
game_random, watcom_random);
|
||||
}
|
||||
|
||||
// Transfer market request family (open offer, poach, editor events, quote preview, market
|
||||
// actions): each entry validates the request revision, the active manager slot and the manager's
|
||||
// club, refuses nested modals (market_dispatch_active_ and the other owners), works on copies of
|
||||
// the state and both random generators and commits them only on success. The revision is
|
||||
// advanced only where something observable changed. Failures return an empty optional and an
|
||||
// error text.
|
||||
// Opens the buyer's offer editor for a marked market row after checking the row identity
|
||||
// against the market list in memory; the editor owner and its revision are stored on success.
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> CareerSession::open_transfer_offer(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
if (request.kind != ui::TransferMarketRequestKind::open_offer || transfer_offer_editor_ ||
|
||||
market_dispatch_active_ || pending_offer_dispatch_active_ || calendar_advance_active_ ||
|
||||
request.revision != revision || revision == std::numeric_limits<uint64_t>::max() ||
|
||||
request.manager_slot < 0 || request.manager_slot >= 4 ||
|
||||
size_t(request.manager_slot) >= g_.manager_teams.size() ||
|
||||
!g_.memory.has(::bmh::layout::ActiveManager) || g_.memory.u8(::bmh::layout::ActiveManager) != request.manager_slot ||
|
||||
request.runtime_club != g_.manager_teams[size_t(request.manager_slot)] ||
|
||||
request.bid.manager != request.manager_slot || request.bid.list_entry < 0 || request.bid.list_entry >= 40 ||
|
||||
request.bid.source_slot != 2928 + request.bid.list_entry || request.selected_players.size() > 1) {
|
||||
error = "transfer offer: stale, nested or unsupported marked opening";
|
||||
return std::nullopt;
|
||||
}
|
||||
const uint32_t list = ::bmh::layout::EditorList + uint32_t(request.bid.list_entry) * 0x58;
|
||||
if (!g_.memory.has(list + 0x57)) { error = "transfer offer: missing Native list row"; return std::nullopt; }
|
||||
const uint16_t seller_word = g_.memory.u16(list + 8);
|
||||
if (!request.selected_players.empty()) {
|
||||
const auto& selected = request.selected_players.front();
|
||||
const int seller = seller_word == 0xffff ? -1 : int(seller_word & 0x7fff);
|
||||
if (selected.squad_row != -1 || selected.source_slot != request.bid.source_slot ||
|
||||
selected.list_entry != request.bid.list_entry || selected.player != request.bid.player ||
|
||||
selected.seller != seller) {
|
||||
error = "transfer offer: selected row does not match the Native market identity";
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
int bid_slot = -1;
|
||||
for (int n = 0; n < 4; ++n) {
|
||||
const auto buyer = g_.memory.u16(list + uint32_t(n) * 2);
|
||||
if (buyer == 0xffff || buyer == request.runtime_club) { bid_slot = n; break; }
|
||||
}
|
||||
const TransferOfferEditorRequest input{request.manager_slot, request.runtime_club, request.bid.list_entry,
|
||||
request.bid.source_slot, request.bid.player, seller_word, bid_slot, request.offer_is_loan};
|
||||
auto next_state = g_; auto next_game = game_; auto next_rand = rand_;
|
||||
market_dispatch_active_ = true;
|
||||
struct Reset { bool& active; ~Reset() { active = false; } } reset{market_dispatch_active_};
|
||||
try {
|
||||
auto owner = open_transfer_offer_editor_source(next_state, input, next_game, next_rand);
|
||||
if (!owner.supported) { error = owner.reason; return std::nullopt; }
|
||||
// Opening has Source G-seeding/G92..108 even for a full read-only list.
|
||||
const auto next_revision = revision + 1;
|
||||
TransferOfferEditorDispatch result;
|
||||
result.preparation = preparation_projection(next_state, next_revision);
|
||||
result.editor = transfer_offer_projection(next_state, owner, next_revision, result.preparation.desktop.gradient_text);
|
||||
ui::OutgoingTransferScreen validate(data_directory_, result.editor);
|
||||
g_ = std::move(next_state); game_ = next_game; rand_ = next_rand;
|
||||
transfer_offer_editor_ = std::move(owner); transfer_offer_revision_ = next_revision; revision = next_revision;
|
||||
return result;
|
||||
} catch (const std::exception& e) { error = e.what(); return std::nullopt; }
|
||||
}
|
||||
|
||||
// Starts a poaching attempt for a squad slot: the attempt draws random numbers, so the revision
|
||||
// advances whenever the result is not invalid; a ready attempt also opens the offer editor on
|
||||
// the special poach row and remembers the attempt in poach_.
|
||||
std::optional<CareerSession::PoachDispatch> CareerSession::open_poach(
|
||||
int manager_slot, int squad_slot, uint64_t& revision, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
if (transfer_offer_editor_ || market_dispatch_active_ || pending_offer_dispatch_active_ || calendar_advance_active_ ||
|
||||
revision == std::numeric_limits<uint64_t>::max() || manager_slot < 0 || manager_slot >= 4 ||
|
||||
size_t(manager_slot) >= g_.manager_teams.size() || !g_.memory.has(::bmh::layout::ActiveManager) ||
|
||||
g_.memory.u8(::bmh::layout::ActiveManager) != manager_slot) {
|
||||
error = "poach: stale, nested or unsupported opening";
|
||||
return std::nullopt;
|
||||
}
|
||||
auto next_state = g_; auto next_game = game_; auto next_rand = rand_;
|
||||
market_dispatch_active_ = true;
|
||||
struct Reset { bool& active; ~Reset() { active = false; } } reset{market_dispatch_active_};
|
||||
try {
|
||||
PoachDispatch result;
|
||||
result.start = start_poach(next_state, manager_slot, squad_slot, next_rand);
|
||||
if (result.start.status == PoachStatus::ready) {
|
||||
const int row = 0x28 + result.start.offer_row;
|
||||
const TransferOfferEditorRequest input{manager_slot, g_.manager_teams[size_t(manager_slot)], row, 2928 + row,
|
||||
result.start.player, next_state.memory.u16(::bmh::layout::EditorList + uint32_t(row) * 0x58 + 8), 0, false, true};
|
||||
auto owner = open_transfer_offer_editor_source(next_state, input, next_game, next_rand);
|
||||
if (!owner.supported) { error = owner.reason; return std::nullopt; }
|
||||
const auto next_revision = revision + 1;
|
||||
TransferOfferEditorDispatch editor;
|
||||
editor.preparation = preparation_projection(next_state, next_revision);
|
||||
editor.editor = transfer_offer_projection(next_state, owner, next_revision, editor.preparation.desktop.gradient_text);
|
||||
result.editor = std::move(editor);
|
||||
transfer_offer_editor_ = std::move(owner);
|
||||
transfer_offer_revision_ = next_revision;
|
||||
poach_ = result.start;
|
||||
revision = next_revision;
|
||||
} else if (result.start.status != PoachStatus::invalid) {
|
||||
++revision; // draws, and "Transfermarkt überlastet" counts the attempt
|
||||
}
|
||||
g_ = std::move(next_state); game_ = next_game; rand_ = next_rand;
|
||||
return result;
|
||||
} catch (const std::exception& e) { error = e.what(); return std::nullopt; }
|
||||
}
|
||||
|
||||
// Closes the table opened only to choose a poach target: needs an unchanged table owner, then
|
||||
// restores the display word and drops the family owner without a family close. False with
|
||||
// 'error' if stale.
|
||||
bool CareerSession::close_poach_table_selection(const ui::LeagueFamilyRequest& request,std::string& error) {
|
||||
error.clear();
|
||||
if(!poach_table_selection_ || request.kind!=ui::LeagueFamilyRequestKind::close || request.from_child!=1 ||
|
||||
!canonical_table_envelope(request) || !league_family_owner_ || league_family_owner_->child!=1 ||
|
||||
league_family_owner_->identity!=request.identity || !league_family_owner_->table ||
|
||||
league_family_owner_->table->phase!=TableDispatchPhase::ready ||
|
||||
save_stream(g_)!=league_family_owner_->native || club_modal_runtime_!=league_family_owner_->runtime ||
|
||||
game_.seed()!=league_family_owner_->game_seed || game_.calls()!=league_family_owner_->game_calls ||
|
||||
rand_.seed()!=league_family_owner_->rand_seed || rand_.calls()!=league_family_owner_->rand_calls) {
|
||||
error="poach: stale Table selection close";return false;
|
||||
}
|
||||
const uint32_t at=::bmh::layout::LeagueTableDisplayModes+uint32_t(request.identity.manager)*2;
|
||||
uint16_t word=uint16_t(g_.memory.u16(at)&0x0f7f);
|
||||
if(source_runtime_byte(g_,club_modal_runtime_,exe_,::bmh::layout::CareerSession_AdvanceLeagueFamily_ExecutableField)!=0)word|=0x80;
|
||||
g_.memory.set16(at,word);
|
||||
if(g_.memory.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2))g_.memory.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2,0);else club_modal_runtime_[::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2]=0;
|
||||
// FriendlyMatchScreen returns directly to19c1c. No21213 family close.
|
||||
league_family_owner_.reset();return true;
|
||||
}
|
||||
|
||||
// Poach flow driven by UI callbacks: checks the request is a pristine open_poach request of the
|
||||
// current revision (320x240 backdrop, nothing else open), then reports attempts-used or
|
||||
// transfer-ban notices, or lets the player pick a squad player in a table on a cloned session
|
||||
// and opens the poach from that choice. The UI acknowledges through 'accept'; any failure,
|
||||
// including a session changed by the acknowledgement, restores the checkpoint and revision.
|
||||
bool CareerSession::dispatch_poach_ui(const ui::TransferMarketRequest& request,
|
||||
const Image& backdrop, const PoachPlayerSelector& select, const PoachUiAccept& accept,
|
||||
uint64_t& revision, std::string& error) {
|
||||
error.clear();
|
||||
if (!accept || request.kind!=ui::TransferMarketRequestKind::open_poach ||
|
||||
!g_.memory.has(::bmh::layout::GameMode) || g_.memory.u8(::bmh::layout::GameMode)!=3 ||
|
||||
request.revision!=revision || revision==UINT64_MAX || request.manager_slot<0 || request.manager_slot>3 ||
|
||||
!g_.memory.has(::bmh::layout::ActiveManager) || g_.memory.u8(::bmh::layout::ActiveManager)!=request.manager_slot ||
|
||||
size_t(request.manager_slot)>=g_.manager_teams.size() ||
|
||||
request.runtime_club!=g_.manager_teams[size_t(request.manager_slot)] ||
|
||||
request.bid.manager!=request.manager_slot || request.bid.list_entry!=-1 || request.bid.player!=-1 ||
|
||||
request.bid.source_slot!=-1 || request.bid.fee!=0 || request.bid.annual_salary!=0 ||
|
||||
request.bid.contract_years!=1 || request.bid.poach || std::any_of(request.bid.bonuses.begin(),request.bid.bonuses.end(),
|
||||
[](uint32_t n){return n!=0;}) || request.squad_row!=-1 || request.expected_player!=-1 ||
|
||||
request.preview_source_slot!=-1 || request.preview_seller!=-1 || request.preview_is_purchase ||
|
||||
request.preview_is_loan || !request.selected_players.empty() ||
|
||||
backdrop.width!=320 || backdrop.height!=240 || advertising_renewal_dispatch_active_ || pending_offer_dispatch_active_ || market_dispatch_active_ ||
|
||||
calendar_advance_active_ || transfer_offer_editor_ || poach_ || manager_join_ || contract_quote_ ||
|
||||
league_family_owner_ || league_pairings_draft_ || strengths_owner_ || top_scorers_owner_ ||
|
||||
other_games_owner_ || balance_draft_ || stadium_.opened ||
|
||||
(turn_driver_.stage!=TurnDriver::Stage::MatchdayDesks && turn_driver_.stage!=TurnDriver::Stage::SeasonEndDesk)) {
|
||||
error="poach: stale or competing selection";return false;
|
||||
}
|
||||
const auto checkpoint=advertising_session_checkpoint(revision);
|
||||
try {
|
||||
const int manager=request.manager_slot;
|
||||
const size_t record=size_t(manager)*kManagerRecordSize;
|
||||
PoachDispatch result;
|
||||
result.start.manager=manager;
|
||||
// These three notices precede the Table modal in Reset.
|
||||
if (record+0x8c0>g_.manager_records.size()) throw FormatError("poach: missing manager record");
|
||||
const bool attempts_used=(g_.manager_records[record+0x8be] |
|
||||
uint16_t(g_.manager_records[record+0x8bf])<<8)!=0xffff;
|
||||
if(attempts_used) {
|
||||
result.start.status=PoachStatus::attempts_used;
|
||||
result.start.messages.push_back(message_text(g_,::bmh::layout::CareerSession_DispatchPoachUi_TextPointer2));
|
||||
} else if(g_.manager_records[record+0x220]>>5==1) {
|
||||
result.start.status=PoachStatus::transfer_ban;
|
||||
result.start.messages.push_back(message_text(g_,::bmh::layout::CareerSession_DispatchPoachUi_TextPointer));
|
||||
} else if(request.offer_is_loan) {
|
||||
auto services=staged_club_modal_services(g_,game_,rand_,club_modal_runtime_);
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_AdvertisingSessionUnchanged_ExecutableField,0);
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_RuntimeField2,g_.manager_records[record+0x210]);
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField,2);
|
||||
result.start.messages.push_back(message_text(g_,::bmh::layout::CareerSession_DispatchPoachUi_TextPointer3));
|
||||
} else {
|
||||
if(!select) throw FormatError("poach: Source player selection presenter unavailable");
|
||||
// The cloned Session owns the existing50775 controls implementation.
|
||||
// begin_league_family(child1) itself does not call53435; only the
|
||||
// host Table owner is reused, never prepare/close-family effects.
|
||||
CareerSession staged=*this;
|
||||
staged.poach_table_selection_=true;
|
||||
uint64_t selection_revision=revision;
|
||||
auto services=staged.staged_club_modal_services(staged.g_,staged.game_,staged.rand_,staged.club_modal_runtime_);
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_AdvertisingSessionUnchanged_ExecutableField,0);
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_RuntimeField2,g_.manager_records[record+0x210]);
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField,2);
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField,0);services.set_runtime_byte(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2,0);
|
||||
//50775 control7 toggles this existing BSS byte. Materialize its
|
||||
// actual current value in the staged runtime, including when it
|
||||
// was read from the executable rather than persisted in Native.
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_AdvanceLeagueFamily_ExecutableField,services.runtime_byte(::bmh::layout::CareerSession_AdvanceLeagueFamily_ExecutableField));
|
||||
auto entry=staged.strengths_open_request(selection_revision);
|
||||
if(!entry)throw FormatError("poach: missing Table selection identity");
|
||||
entry->identity.league=g_.manager_records[record+0x210];entry->identity.league_group=0;
|
||||
if(!staged.begin_league_family(entry->identity,1,selection_revision,error))throw FormatError(error);
|
||||
market_dispatch_active_=true;
|
||||
const auto live_baseline=advertising_session_checkpoint(revision);
|
||||
const auto selection=select(staged,services,manager,selection_revision,backdrop);
|
||||
if(!advertising_session_unchanged(live_baseline,revision))
|
||||
throw FormatError("poach: selection changed the live session");
|
||||
auto& next=staged.g_;
|
||||
if(next.date!=g_.date || next.manager_teams!=g_.manager_teams ||
|
||||
!next.memory.has(::bmh::layout::ActiveManager) || next.memory.u8(::bmh::layout::ActiveManager)!=manager)
|
||||
throw FormatError("poach: selection changed its manager/calendar context");
|
||||
market_dispatch_active_=false;
|
||||
int slot=-1;
|
||||
if(selection) {
|
||||
if(selection->origin!=ClubPlayerDetailOrigin::squad || selection->human_loan_index!=-1)
|
||||
throw FormatError("poach: selection is not an ordinary squad row");
|
||||
const auto player=club_player_detail_context(next,*selection);
|
||||
slot=player.source_slot;
|
||||
if(slot<0 || slot>=0xb70 || slot_team(slot)!=selection->runtime_team ||
|
||||
(next.squad_slots.at(size_t(slot))&0xfff)!=selection->player_id)
|
||||
throw FormatError("poach: stale player selection");
|
||||
}
|
||||
// Preserve actual Table/ClubInfo/card effects, including a cancelled
|
||||
// selection. No LeagueScreenShown entry and no family-close RNG stir.
|
||||
g_=std::move(next);game_=staged.game_;rand_=staged.rand_;club_modal_runtime_=std::move(staged.club_modal_runtime_);
|
||||
if(selection) {
|
||||
auto opened=open_poach(manager,slot,revision,error);
|
||||
if(!opened) throw FormatError(error);
|
||||
result=std::move(*opened);
|
||||
}
|
||||
if(revision==checkpoint.revision) ++revision;
|
||||
}
|
||||
const auto accepted_baseline=advertising_session_checkpoint(revision);
|
||||
accept(result,preparation_projection(revision));
|
||||
if(!advertising_session_unchanged(accepted_baseline,revision))
|
||||
throw FormatError("poach: UI acknowledgement changed the session");
|
||||
return true;
|
||||
} catch(const std::exception& e) {
|
||||
restore_advertising_session_checkpoint(checkpoint);revision=checkpoint.revision;
|
||||
error=e.what();return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Applies one editor event (field quote change, submit, cancel, team info, player info) to the
|
||||
// open offer editor: identity and quote must match the owner and the posted row must equal the
|
||||
// single field change. Runs on copies; the revision rises only if state, runtime bytes or a
|
||||
// random generator actually changed. A closing editor ends a poach attempt and clears the owner.
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> CareerSession::dispatch_transfer_offer(
|
||||
const ui::OutgoingTransferRequest& request, const HumanBuyerSaleHooks& presenters,
|
||||
uint64_t& revision, std::string& error,
|
||||
const TransferOfferTeamInfoPresenter& team_info,
|
||||
const TransferOfferPlayerInfoPresenter& player_info) {
|
||||
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();
|
||||
if (!transfer_offer_editor_ || market_dispatch_active_ || pending_offer_dispatch_active_ || calendar_advance_active_ ||
|
||||
request.identity.revision != revision || transfer_offer_revision_ != revision ||
|
||||
revision == std::numeric_limits<uint64_t>::max()) {
|
||||
error = "transfer offer: stale or nested editor event"; return std::nullopt;
|
||||
}
|
||||
const auto& current = *transfer_offer_editor_;
|
||||
const auto& id = request.identity;
|
||||
const int seller = current.request.expected_seller_word == 0xffff ? 0x0fff : current.request.expected_seller_word & 0x7fff;
|
||||
if (id.manager_slot != current.request.manager || id.runtime_club != current.request.runtime_club ||
|
||||
id.list_entry != current.request.list_entry || id.source_slot != current.request.source_slot ||
|
||||
id.player != current.request.expected_player || id.seller != seller || id.bid_slot != current.bid_slot ||
|
||||
request.quoted_fee != current.quoted_fee || request.quoted_monthly_salary != current.quoted_salary ||
|
||||
request.quoted_years != current.years) {
|
||||
error = "transfer offer: mismatched editor identity or quote"; return std::nullopt;
|
||||
}
|
||||
uint32_t fee = current.fee, salary = current.salary;
|
||||
uint8_t years = current.years; auto bonuses = current.bonuses;
|
||||
bool quote_loan = current.quote_loan;
|
||||
const unsigned field = unsigned(request.field);
|
||||
if (request.kind == ui::OutgoingTransferRequestKind::quote_change) {
|
||||
if (field > unsigned(ui::OutgoingTransferField::quote_loan)) {
|
||||
error = "transfer offer: invalid editor field"; return std::nullopt;
|
||||
}
|
||||
if (request.accepted) {
|
||||
if (field == 0) fee = request.value;
|
||||
else if (field == 1) salary = request.value;
|
||||
else if (field == 2) years = uint8_t(request.value);
|
||||
else if (field < 10) bonuses[field - 3] = uint8_t(field < 6 ? request.value : request.value / 5);
|
||||
else quote_loan = !quote_loan;
|
||||
}
|
||||
} else if (request.kind != ui::OutgoingTransferRequestKind::submit && request.kind != ui::OutgoingTransferRequestKind::cancel &&
|
||||
request.kind != ui::OutgoingTransferRequestKind::team_info &&
|
||||
request.kind != ui::OutgoingTransferRequestKind::player_info) {
|
||||
error = "transfer offer: unsupported editor event"; return std::nullopt;
|
||||
}
|
||||
if (request.fee != fee || request.monthly_salary != salary || request.duration_years != years ||
|
||||
request.bonuses != bonuses || request.quote_loan != quote_loan) {
|
||||
error = "transfer offer: posted row differs from the single Source field event"; return std::nullopt;
|
||||
}
|
||||
if(request.kind==ui::OutgoingTransferRequestKind::team_info&&!team_info) {
|
||||
error="transfer offer: TeamInfo presenter unavailable"; return std::nullopt;
|
||||
}
|
||||
if(request.kind==ui::OutgoingTransferRequestKind::player_info&&!player_info) {
|
||||
error="transfer offer: PlayerInfo presenter unavailable"; return std::nullopt;
|
||||
}
|
||||
auto next_state = g_; auto next_game = game_; auto next_rand = rand_;
|
||||
auto next_runtime=club_modal_runtime_;
|
||||
auto owner = current; TransferActionResult action;
|
||||
auto hooks = presenters;
|
||||
switch (turn_driver_.transfer_allocator_context) {
|
||||
case PendingOfferAllocatorGate::zero: hooks.allocator_gate = HumanBuyerSaleAllocatorGate::zero; break;
|
||||
case PendingOfferAllocatorGate::blocked: hooks.allocator_gate = HumanBuyerSaleAllocatorGate::blocked; break;
|
||||
default: hooks.allocator_gate = HumanBuyerSaleAllocatorGate::unsupported; break;
|
||||
}
|
||||
hooks.direct_mode = HumanBuyerSaleDirectMode::ordinary_ai_purchase;
|
||||
hooks.before_accounts = {}; hooks.after_paid_accounts = {};
|
||||
market_dispatch_active_ = true;
|
||||
struct Reset { bool& active; ~Reset() { active = false; } } reset{market_dispatch_active_};
|
||||
try {
|
||||
if (request.kind == ui::OutgoingTransferRequestKind::quote_change) {
|
||||
owner = edit_transfer_offer_from_ui(next_state, current, request, next_game, next_rand);
|
||||
} else if (request.kind == ui::OutgoingTransferRequestKind::cancel) {
|
||||
owner = cancel_transfer_offer_editor_source(next_state, current);
|
||||
} else if(request.kind==ui::OutgoingTransferRequestKind::team_info) {
|
||||
// Validate the complete old Native row before any modal effect.
|
||||
const auto validation=cancel_transfer_offer_editor_source(next_state,current);
|
||||
if(!validation.supported) {error=validation.reason;return std::nullopt;}
|
||||
auto services=staged_club_modal_services(next_state,next_game,next_rand,next_runtime);
|
||||
const auto parent=transfer_offer_projection(next_state,current,revision,
|
||||
next_state.memory.u8(::bmh::layout::TextGradientDisabled)==0);
|
||||
const Image backdrop=ui::OutgoingTransferScreen(data_directory_,parent).render();
|
||||
if(!team_info(services,current.request.runtime_club,backdrop)) {
|
||||
error="transfer offer: TeamInfo presenter stopped";return std::nullopt;
|
||||
}
|
||||
owner=resume_transfer_offer_team_info_source(next_state,current,next_rand);
|
||||
} else if(request.kind==ui::OutgoingTransferRequestKind::player_info) {
|
||||
const auto selection=transfer_offer_player_info_selection_source(next_state,current);
|
||||
auto services=staged_club_modal_services(next_state,next_game,next_rand,next_runtime);
|
||||
const auto parent=transfer_offer_projection(next_state,current,revision,
|
||||
next_state.memory.u8(::bmh::layout::TextGradientDisabled)==0);
|
||||
const Image backdrop=ui::OutgoingTransferScreen(data_directory_,parent).render();
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField,1); // Source direct entry persists, unlike4f548.
|
||||
if(!player_info(services,selection,backdrop)) {
|
||||
error="transfer offer: PlayerInfo presenter stopped";return std::nullopt;
|
||||
}
|
||||
owner=resume_transfer_offer_player_info_source(next_state,current,
|
||||
services.runtime_byte(::bmh::layout::CareerSession_DispatchTransferOffer_ExecutableField),services.runtime_byte(::bmh::layout::CareerSession_DispatchTransferOffer_ExecutableField2),next_rand);
|
||||
} else {
|
||||
MinuteReport report;
|
||||
auto submitted = submit_transfer_offer_editor_source(next_state, current, next_rand, hooks, report);
|
||||
owner = std::move(submitted.editor); action = submitted.action;
|
||||
if (report.unsupported) { error = report.reason; return std::nullopt; }
|
||||
}
|
||||
if (!owner.supported) { error = owner.reason; return std::nullopt; }
|
||||
// a poaching editor that closes frees its special row and counts the attempt (Reset)
|
||||
if (owner.closed && poach_) finish_poach(next_state, *poach_);
|
||||
const bool changed = save_stream(next_state) != save_stream(g_) || next_runtime != club_modal_runtime_ ||
|
||||
next_game.seed() != game_.seed() || next_game.calls() != game_.calls() ||
|
||||
next_rand.seed() != rand_.seed() || next_rand.calls() != rand_.calls();
|
||||
const auto next_revision = revision + uint64_t(changed);
|
||||
TransferOfferEditorDispatch result;
|
||||
result.preparation = preparation_projection(next_state, next_revision);
|
||||
result.editor = transfer_offer_projection(next_state, owner, next_revision, result.preparation.desktop.gradient_text);
|
||||
result.action = action;
|
||||
if (!owner.closed) { ui::OutgoingTransferScreen validate(data_directory_, result.editor); }
|
||||
g_ = std::move(next_state); game_ = next_game; rand_ = next_rand;
|
||||
club_modal_runtime_=std::move(next_runtime);
|
||||
if (owner.closed) { transfer_offer_editor_.reset(); poach_.reset(); } else transfer_offer_editor_ = std::move(owner);
|
||||
transfer_offer_revision_ = next_revision; revision = next_revision;
|
||||
return result;
|
||||
} catch (const std::exception& e) { error = e.what(); return std::nullopt; }
|
||||
}
|
||||
|
||||
// Quotes a purchase, lender snapshot or squad row preview (the listing identity is re-checked)
|
||||
// using a copy of the W random stream; the stream and revision are updated only if the quote
|
||||
// and its projection both succeed.
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> CareerSession::preview_transfer_market(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return std::nullopt; }
|
||||
error.clear();
|
||||
if (request.kind != ui::TransferMarketRequestKind::preview_quote ||
|
||||
transfer_offer_editor_ || market_dispatch_active_ || pending_offer_dispatch_active_ || calendar_advance_active_ ||
|
||||
request.revision != revision || revision == std::numeric_limits<uint64_t>::max() ||
|
||||
request.manager_slot < 0 || request.manager_slot >= 4 ||
|
||||
size_t(request.manager_slot) >= g_.manager_teams.size() ||
|
||||
!g_.memory.has(::bmh::layout::ActiveManager) || g_.memory.u8(::bmh::layout::ActiveManager) != request.manager_slot ||
|
||||
request.runtime_club != g_.manager_teams[size_t(request.manager_slot)]) {
|
||||
error = "transfer market: stale or nested preview";
|
||||
return std::nullopt;
|
||||
}
|
||||
if (request.preview_is_purchase) {
|
||||
if (request.preview_snapshot_index != -1 || request.squad_row != -1 || request.bid.manager != request.manager_slot ||
|
||||
request.bid.list_entry < 0 || request.bid.list_entry >= 40 ||
|
||||
request.bid.source_slot != request.preview_source_slot ||
|
||||
request.preview_source_slot != 0xb70 + request.bid.list_entry ||
|
||||
request.bid.player != request.expected_player) {
|
||||
error = "transfer market: mismatched preview listing identity";
|
||||
return std::nullopt;
|
||||
}
|
||||
} else if (request.preview_snapshot_index >= 0) {
|
||||
const auto identity = transfer_market_snapshot_preview(g_, request.manager_slot,
|
||||
request.runtime_club, request.preview_snapshot_index);
|
||||
if (!identity || identity->displayed_row != request.squad_row || identity->player != request.expected_player ||
|
||||
identity->source_slot != request.preview_source_slot || request.preview_seller != request.runtime_club) {
|
||||
error = "transfer market: mismatched lender snapshot identity";
|
||||
return std::nullopt;
|
||||
}
|
||||
} else {
|
||||
const auto range = squad_range(request.runtime_club);
|
||||
if (request.preview_snapshot_index != -1 || request.squad_row < 0 || size_t(request.squad_row) >= range.count ||
|
||||
request.preview_source_slot != int(range.first + size_t(request.squad_row)) ||
|
||||
request.preview_seller != request.runtime_club) {
|
||||
error = "transfer market: mismatched preview roster identity";
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
auto next_rand = rand_;
|
||||
market_dispatch_active_ = true;
|
||||
struct Reset { bool& active; ~Reset() { active = false; } } reset{market_dispatch_active_};
|
||||
try {
|
||||
const TransferMarketPreviewRequest input{request.manager_slot, request.runtime_club,
|
||||
request.preview_source_slot, request.expected_player, request.preview_seller,
|
||||
request.preview_is_purchase, request.preview_is_loan, request.preview_snapshot_index};
|
||||
const auto result = quote_transfer_market_preview_source(g_, input, next_rand);
|
||||
if (!result.supported) {
|
||||
error = result.reason.empty() ? "transfer market: unsupported Source preview" : result.reason;
|
||||
return std::nullopt;
|
||||
}
|
||||
const bool changed = next_rand.seed() != rand_.seed() || next_rand.calls() != rand_.calls();
|
||||
const auto next_revision = revision + uint64_t(changed);
|
||||
TransferMarketPreviewDispatch dispatch;
|
||||
dispatch.preparation = preparation_projection(next_revision);
|
||||
if (!dispatch.preparation.transfer_market)
|
||||
throw FormatError("transfer market: preview has no ordinary projection");
|
||||
dispatch.quote = {request.manager_slot, request.runtime_club, request.preview_source_slot,
|
||||
request.expected_player, request.preview_seller, next_revision,
|
||||
result.delta, result.projected_balance, request.preview_is_purchase, request.preview_is_loan, request.preview_snapshot_index};
|
||||
// Projection construction can throw. Keep the live W stream and revision
|
||||
// unchanged until both the Source result and the projection are valid.
|
||||
rand_ = next_rand;
|
||||
revision = next_revision;
|
||||
return dispatch;
|
||||
} catch (const std::exception& e) {
|
||||
error = e.what();
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
// Direct market actions of a human manager: review offers, submit a bid, list a player. Needs
|
||||
// a request of the current revision for the active manager's club; loans and marked batches are
|
||||
// not accepted here. The allocator gate comes from the turn driver, never from the presenter.
|
||||
// The staged copy is committed (revision plus one) only if something changed.
|
||||
std::optional<TransferActionResult> CareerSession::dispatch_transfer_market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& presenters,
|
||||
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();
|
||||
if (transfer_offer_editor_ || market_dispatch_active_ || pending_offer_dispatch_active_ || calendar_advance_active_ ||
|
||||
request.revision != revision || revision == std::numeric_limits<uint64_t>::max() ||
|
||||
request.manager_slot < 0 || request.manager_slot >= 4 ||
|
||||
size_t(request.manager_slot) >= g_.manager_teams.size() ||
|
||||
!g_.memory.has(::bmh::layout::ActiveManager) || g_.memory.u8(::bmh::layout::ActiveManager) != request.manager_slot ||
|
||||
request.runtime_club != g_.manager_teams[size_t(request.manager_slot)]) {
|
||||
error = "transfer market: stale or nested request";
|
||||
return std::nullopt;
|
||||
}
|
||||
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(),
|
||||
[](uint32_t value) { return value > 255; })) {
|
||||
error = "transfer market: invalid buyer request";
|
||||
return std::nullopt;
|
||||
}
|
||||
} else if (request.kind == ui::TransferMarketRequestKind::list_player) {
|
||||
const auto range = squad_range(request.runtime_club);
|
||||
if (request.squad_row < 0 || size_t(request.squad_row) >= range.count ||
|
||||
range.first + size_t(request.squad_row) >= g_.squad_slots.size() ||
|
||||
request.expected_player < 0 || request.expected_player >= 0xfff ||
|
||||
(g_.squad_slots[range.first + size_t(request.squad_row)] & 0xfff) != request.expected_player) {
|
||||
error = "transfer market: stale seller row";
|
||||
return std::nullopt;
|
||||
}
|
||||
} else {
|
||||
error = "transfer market: unsupported action";
|
||||
return std::nullopt;
|
||||
}
|
||||
// Reset sends an owned marked player through the same Size2
|
||||
// listing for both VER-KAUFEN and VER-LEIHEN. Only a buyer's OpenTransferEditor
|
||||
// offer owns the actual loan term; listing does not create a loan record.
|
||||
if ((request.offer_is_loan && request.kind != ui::TransferMarketRequestKind::list_player) ||
|
||||
request.selected_players.size() > 1) {
|
||||
error = "transfer market: this caller does not own buyer loan or marked batch processing";
|
||||
return std::nullopt;
|
||||
}
|
||||
if (!request.selected_players.empty()) {
|
||||
const auto& selected = request.selected_players.front();
|
||||
const bool matches = request.kind == ui::TransferMarketRequestKind::list_player
|
||||
? selected.squad_row == request.squad_row && selected.player == request.expected_player &&
|
||||
selected.seller == request.runtime_club &&
|
||||
selected.source_slot == int(squad_range(request.runtime_club).first + size_t(request.squad_row))
|
||||
: selected.list_entry == request.bid.list_entry && selected.source_slot == request.bid.source_slot &&
|
||||
selected.player == request.bid.player && selected.squad_row == -1;
|
||||
if (!matches) {
|
||||
error = "transfer market: mismatched marked selection";
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
auto next_state = g_;
|
||||
auto next_game = game_;
|
||||
auto next_rand = rand_;
|
||||
auto hooks = presenters;
|
||||
// A presenter cannot supply the allocator gate or insert the special
|
||||
// pending caller's severance/ACK/news sequence into a direct purchase.
|
||||
switch (turn_driver_.transfer_allocator_context) {
|
||||
case PendingOfferAllocatorGate::zero: hooks.allocator_gate = HumanBuyerSaleAllocatorGate::zero; break;
|
||||
case PendingOfferAllocatorGate::blocked: hooks.allocator_gate = HumanBuyerSaleAllocatorGate::blocked; break;
|
||||
default: hooks.allocator_gate = HumanBuyerSaleAllocatorGate::unsupported; break;
|
||||
}
|
||||
// Reset -> OpenTransferEditor establishes DeskActions_EditorFail_RuntimeField2=0 at LAB1b67e before
|
||||
// resolving the AI seller. This explicitly selected App entry supplies
|
||||
// that transient ownership; a missing FBM byte is never the observation.
|
||||
hooks.direct_mode = HumanBuyerSaleDirectMode::ordinary_ai_purchase;
|
||||
hooks.before_accounts = {};
|
||||
hooks.after_paid_accounts = {};
|
||||
market_dispatch_active_ = true;
|
||||
struct Reset { bool& active; ~Reset() { active = false; } } reset{market_dispatch_active_};
|
||||
MinuteReport report;
|
||||
try {
|
||||
const auto before = save_stream(g_);
|
||||
TransferActionResult result;
|
||||
if (request.kind == ui::TransferMarketRequestKind::review_offers) {
|
||||
const auto view = project_transfer_offer_list(next_state, request.bid.list_entry);
|
||||
result.player = view.player; result.list_entry = view.list_entry;
|
||||
result.status = TransferActionStatus::pending;
|
||||
// VERKAUFEN on a listed player: "Wollen Sie <name> vom Transfermarkt holen?". Yes frees the list
|
||||
// slot (the player stays in the squad), no goes on to the offers.
|
||||
bool withdrawn = false;
|
||||
if (request.ask_withdraw && hooks.confirm) {
|
||||
const std::string question = message_text(next_state, ::bmh::layout::TransferMarket_WithdrawQuestion_TextPointer) +
|
||||
next_state.player_name(view.player) +
|
||||
message_text(next_state, ::bmh::layout::TransferMarket_WithdrawQuestion_TextPointer2);
|
||||
if (hooks.confirm(next_state, request.manager_slot, question)) {
|
||||
next_state.squad_slots.at(0xb70u + size_t(view.list_entry)) = 0xfff;
|
||||
withdrawn = true;
|
||||
}
|
||||
}
|
||||
const int selected = !withdrawn && view.offer_count ? review(next_state, view) : -1;
|
||||
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);
|
||||
if (report.unsupported || result.status == TransferActionStatus::unsupported) {
|
||||
error = report.reason.empty() ? "transfer market: unsupported Source sale" : report.reason;
|
||||
return std::nullopt;
|
||||
}
|
||||
const bool changed = save_stream(next_state) != before ||
|
||||
next_rand.seed() != rand_.seed() || next_rand.calls() != rand_.calls() ||
|
||||
next_game.seed() != game_.seed() || next_game.calls() != game_.calls();
|
||||
if (changed) {
|
||||
// Pure projections reject inconsistent squad/board/training state
|
||||
// before any staged notice effects become live.
|
||||
(void)ui::preparation_from_game(next_state, exe_, revision + 1);
|
||||
g_ = std::move(next_state);
|
||||
game_ = next_game;
|
||||
rand_ = next_rand;
|
||||
++revision;
|
||||
}
|
||||
return result;
|
||||
} catch (const std::exception& e) {
|
||||
error = e.what();
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace bmh::app
|
||||
+875
-164
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The controller: the one synchronous boundary between the UI flow (ui::StartupFlow) and
|
||||
// the engine session (CareerSession). The flow turns a click or key into a ui::FlowResult
|
||||
// that carries a request; serve_flow_request() validates it against the current revision,
|
||||
// calls the session, and acknowledges the outcome back to the flow. Everything the engine
|
||||
// needs from the front end (dialogs, live match presentation, notices) is passed in as
|
||||
// std::function "presenter" hooks, so tests can drive the same code without a window.
|
||||
// Pairs with controller.cpp; the real hooks are supplied by main.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Debug mode (command line -debug): a process-wide, mutex-protected log file plus numbered
|
||||
// automatic savegames, both kept in one folder. State is a function-local static; every
|
||||
// function is a no-op until init() has succeeded, so callers may log unconditionally.
|
||||
// init() also redirects stderr into the same folder. Header-only.
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace bmh::app::debug {
|
||||
|
||||
// The debug mode (command line -debug): a log with timestamps next to everything the game prints
|
||||
// to stderr, and a savegame after every played match day, both in one sub folder of the save
|
||||
// directory. Off by default; every function is a no-op until init() has run.
|
||||
struct State {
|
||||
bool enabled = false;
|
||||
std::filesystem::path directory;
|
||||
unsigned saves = 0;
|
||||
std::mutex mutex;
|
||||
};
|
||||
inline State& state() { static State s; return s; }
|
||||
|
||||
inline bool enabled() { return state().enabled; }
|
||||
inline const std::filesystem::path& directory() { return state().directory; }
|
||||
|
||||
inline std::string timestamp() {
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
const std::time_t t = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm parts{};
|
||||
#ifdef _WIN32
|
||||
localtime_s(&parts, &t);
|
||||
#else
|
||||
localtime_r(&t, &parts);
|
||||
#endif
|
||||
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count() % 1000;
|
||||
char text[40];
|
||||
std::snprintf(text, sizeof text, "%04d-%02d-%02d %02d:%02d:%02d.%03d", parts.tm_year + 1900, parts.tm_mon + 1,
|
||||
parts.tm_mday, parts.tm_hour, parts.tm_min, parts.tm_sec, int(ms));
|
||||
return text;
|
||||
}
|
||||
|
||||
// One line, flushed at once so that a crash or a hang loses nothing.
|
||||
inline void log(const std::string& line) {
|
||||
auto& s = state();
|
||||
if (!s.enabled) return;
|
||||
std::lock_guard<std::mutex> lock(s.mutex);
|
||||
std::ofstream out(s.directory / "openbmh-debug.log", std::ios::app);
|
||||
if (out) out << timestamp() << " " << line << '\n';
|
||||
}
|
||||
|
||||
// Creates the folder and redirects stderr into the same folder, so the messages the game
|
||||
// prints on its own (for example the live overview errors) are kept as well.
|
||||
inline bool init(const std::filesystem::path& directory) {
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(directory, ec);
|
||||
if (ec || !std::filesystem::is_directory(directory)) return false;
|
||||
auto& s = state();
|
||||
s.directory = directory;
|
||||
s.enabled = true;
|
||||
const auto errors = (directory / "openbmh-stderr.log").string();
|
||||
if (std::FILE* redirected = std::freopen(errors.c_str(), "a", stderr)) std::setvbuf(redirected, nullptr, _IONBF, 0);
|
||||
log("debug mode on, folder " + directory.string());
|
||||
return true;
|
||||
}
|
||||
|
||||
// The file name of the next automatic savegame: DBG00001.FBM, DBG00002.FBM, ... (8.3 like the original).
|
||||
inline std::filesystem::path next_save_path() {
|
||||
auto& s = state();
|
||||
char name[16];
|
||||
std::snprintf(name, sizeof name, "DBG%05u.FBM", ++s.saves);
|
||||
return s.directory / name;
|
||||
}
|
||||
|
||||
} // namespace bmh::app::debug
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the desk-level action facades declared in desktop_actions.hpp. Each
|
||||
// method checkpoints the relevant session owner, runs the request through CareerSession,
|
||||
// lets the accept callback acknowledge the result to the UI, and rolls everything back via
|
||||
// detail::apply_window if the callback returns false or throws. Errors are returned through
|
||||
// the std::string& error parameter. The request/acknowledge flow as a whole is described
|
||||
// at the top of controller.cpp.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/desktop_actions.hpp"
|
||||
#include "app/action_transaction.hpp"
|
||||
@@ -7,6 +13,8 @@
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
// Builds the desk request that opens menu `kind` for the observed manager; the item id is
|
||||
// taken from the desk item of that kind.
|
||||
ui::DeskRequest DesktopActions::menu(const ui::DeskState& observed, int kind) {
|
||||
ui::DeskRequest request;
|
||||
request.kind = ui::DeskRequestKind::open_menu;
|
||||
@@ -18,6 +26,8 @@ ui::DeskRequest DesktopActions::menu(const ui::DeskState& observed, int kind) {
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction on the desk settings owner; the checkpoint is restored
|
||||
// if the action fails.
|
||||
bool DeskSettingsActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.desk_settings_checkpoint(revision),
|
||||
[&](CareerSession::DeskSettingsCheckpoint before) {
|
||||
@@ -25,6 +35,7 @@ bool DeskSettingsActions::apply(uint64_t& revision, const std::function<bool()>&
|
||||
}, action);
|
||||
}
|
||||
|
||||
// Opens the desk settings screen; `acknowledge` receives the projection on success.
|
||||
std::optional<CareerSession::DeskSettingsProjection> DeskSettingsActions::open(
|
||||
const ui::DeskRequest& request, uint64_t& revision, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<CareerSession::DeskSettingsProjection> result;
|
||||
@@ -37,6 +48,7 @@ std::optional<CareerSession::DeskSettingsProjection> DeskSettingsActions::open(
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends any settings action (write, file, close) to the session in one transaction.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::dispatch(
|
||||
const CareerSession::DeskSettingsAction& request, uint64_t& revision, std::string& error,
|
||||
const Accept& acknowledge) {
|
||||
@@ -50,16 +62,19 @@ std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::dispatch
|
||||
return result;
|
||||
}
|
||||
|
||||
// Dispatches a settings write for the owner identified by `sequence`.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::write(uint64_t sequence,
|
||||
const ui::SettingsWriteRequest& request, uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
return dispatch(CareerSession::DeskSettingsWrite{sequence, request}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
// Dispatches a settings file (save/load) request for the owner `sequence`.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::file(uint64_t sequence,
|
||||
const ui::SaveLoadRequest& request, uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
return dispatch(CareerSession::DeskSettingsFile{sequence, request}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
// Dispatches the close of the settings owner, built from the observed desk request.
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::close(uint64_t sequence,
|
||||
uint64_t owner_revision, const ui::DeskRequest& observed, uint64_t& revision, std::string& error,
|
||||
const Accept& acknowledge) {
|
||||
@@ -67,6 +82,8 @@ std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::close(ui
|
||||
return dispatch(CareerSession::DeskSettingsClose{owner}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
// Applies one edit (row, column, operation) to the settings cells; the request carries
|
||||
// the observed cells so that a stale view is detected.
|
||||
bool DeskSettingsActions::edit(const ui::SettingsState& observed, int row, int column, ui::SettingsEdit operation,
|
||||
uint64_t& revision, std::string& error) {
|
||||
ui::SettingsWriteRequest request;
|
||||
@@ -79,11 +96,13 @@ bool DeskSettingsActions::edit(const ui::SettingsState& observed, int row, int c
|
||||
return apply(revision, [&] { return session_.dispatch_settings(request, revision, error); });
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the balance checkpoint on failure.
|
||||
bool BalanceActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.balance_checkpoint(),
|
||||
[&](CareerSession::BalanceCheckpoint before) { session_.restore_balance_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the balance (finance plan) screen over `underlay`.
|
||||
std::optional<ui::BalanceState> BalanceActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::BalanceState> result;
|
||||
@@ -96,6 +115,7 @@ std::optional<ui::BalanceState> BalanceActions::open(const ui::DeskRequest& requ
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends a balance screen request to the session in one transaction.
|
||||
std::optional<CareerSession::BalanceDispatch> BalanceActions::dispatch(const ui::BalanceRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::BalanceDispatch> result;
|
||||
@@ -108,13 +128,20 @@ std::optional<CareerSession::BalanceDispatch> BalanceActions::dispatch(const ui:
|
||||
return result;
|
||||
}
|
||||
|
||||
// Draft helpers for the console balance plan (thin wrappers around the game functions):
|
||||
// open a draft for a manager,
|
||||
BalancePlanDraft BalanceActions::open_draft(int manager) const { return bmh::open_balance_plan(session_.state(), manager); }
|
||||
// switch its view,
|
||||
void BalanceActions::cycle_draft(BalancePlanDraft& draft) const { cycle_balance_view(session_.state(), draft); }
|
||||
// reset it,
|
||||
void BalanceActions::reset_draft(BalancePlanDraft& draft) const { reset_balance_plan(session_.state(), draft); }
|
||||
// and edit one row.
|
||||
BalanceEditStatus BalanceActions::edit_draft(BalancePlanDraft& draft, int row, int32_t value) const {
|
||||
return edit_balance_plan(session_.state(), draft, row, value);
|
||||
}
|
||||
|
||||
// Closes the draft inside a transaction and always increases the revision. Returns the
|
||||
// warning flag reported by the close.
|
||||
bool BalanceActions::close_draft(const BalancePlanDraft& draft, uint64_t& revision) {
|
||||
bool warning = false;
|
||||
apply(revision, [&] {
|
||||
@@ -125,11 +152,13 @@ bool BalanceActions::close_draft(const BalancePlanDraft& draft, uint64_t& revisi
|
||||
return warning;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the other-games checkpoint on failure.
|
||||
bool OtherGamesActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.other_games_checkpoint(),
|
||||
[&](CareerSession::OtherGamesCheckpoint before) { session_.restore_other_games_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the other-games screen over `underlay`.
|
||||
std::optional<ui::OtherGamesState> OtherGamesActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::OtherGamesState> result;
|
||||
@@ -142,6 +171,8 @@ std::optional<ui::OtherGamesState> OtherGamesActions::open(const ui::DeskRequest
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends an other-games request to the session; `team_info` presents club information
|
||||
// when the screen asks for it.
|
||||
std::optional<CareerSession::OtherGamesDispatch> OtherGamesActions::dispatch(const ui::OtherGamesRequest& request,
|
||||
uint64_t& revision, std::string& error, const TransferOfferTeamInfoPresenter& team_info, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::OtherGamesDispatch> result;
|
||||
@@ -154,11 +185,13 @@ std::optional<CareerSession::OtherGamesDispatch> OtherGamesActions::dispatch(con
|
||||
return result;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the top scorers checkpoint on failure.
|
||||
bool TopScorersActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.top_scorers_checkpoint(),
|
||||
[&](CareerSession::TopScorersCheckpoint before) { session_.restore_top_scorers_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the top scorers screen over `underlay`; the revision is increased on opening.
|
||||
std::optional<ui::TopScorersState> TopScorersActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::TopScorersState> result;
|
||||
@@ -172,6 +205,7 @@ std::optional<ui::TopScorersState> TopScorersActions::open(const ui::DeskRequest
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends a top scorers request to the session in one transaction.
|
||||
std::optional<CareerSession::TopScorersDispatch> TopScorersActions::dispatch(const ui::TopScorersRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::TopScorersDispatch> result;
|
||||
@@ -184,11 +218,13 @@ std::optional<CareerSession::TopScorersDispatch> TopScorersActions::dispatch(con
|
||||
return result;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the opportunities checkpoint on failure.
|
||||
bool OpportunitiesActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.opportunities_checkpoint(),
|
||||
[&](CareerSession::OpportunitiesCheckpoint before) { session_.restore_opportunities_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Opens the opportunities screen over `underlay`; the revision is increased on opening.
|
||||
std::optional<ui::OpportunitiesState> OpportunitiesActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, bool national_source_case,
|
||||
int stable_identity, const OpenAccept& acknowledge) {
|
||||
@@ -203,6 +239,7 @@ std::optional<ui::OpportunitiesState> OpportunitiesActions::open(const ui::DeskR
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends an opportunities request to the session in one transaction.
|
||||
std::optional<CareerSession::OpportunitiesDispatch> OpportunitiesActions::dispatch(const ui::OpportunitiesRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::OpportunitiesDispatch> result;
|
||||
@@ -215,6 +252,8 @@ std::optional<CareerSession::OpportunitiesDispatch> OpportunitiesActions::dispat
|
||||
return result;
|
||||
}
|
||||
|
||||
// Stores a changed statistics display preference (expected flags to target flags) and
|
||||
// increases the revision; throws if the revision counter is exhausted.
|
||||
bool OpportunitiesActions::preference(const ui::AnalyticsRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -227,15 +266,18 @@ bool OpportunitiesActions::preference(const ui::AnalyticsRequest& request, uint6
|
||||
});
|
||||
}
|
||||
|
||||
// Builds the request that closes the observed opportunities screen.
|
||||
ui::OpportunitiesRequest OpportunitiesActions::close_request(const ui::OpportunitiesState& observed) {
|
||||
return {observed.identity, ui::OpportunitiesAction::close, observed.mode};
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the manager join checkpoint on failure.
|
||||
bool ManagerJoinActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.manager_join_checkpoint(),
|
||||
[&](CareerSession::ManagerJoinCheckpoint before) { session_.restore_manager_join_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Commits a new manager joining the career; `acknowledge` receives the initialization result.
|
||||
bool ManagerJoinActions::commit(uint64_t& revision, std::string& error,
|
||||
const std::function<void(ui::CareerInitializationResult&)>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -246,6 +288,7 @@ bool ManagerJoinActions::commit(uint64_t& revision, std::string& error,
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a mailbox action (via the native transaction wrapper) and acknowledges it.
|
||||
bool MailboxActions::dispatch(const ui::MailboxActionRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
@@ -255,6 +298,7 @@ bool MailboxActions::dispatch(const ui::MailboxActionRequest& request, uint64_t&
|
||||
});
|
||||
}
|
||||
|
||||
// Acknowledges the closing of the mailbox.
|
||||
bool MailboxActions::close(const ui::MailboxCloseRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
@@ -264,6 +308,7 @@ bool MailboxActions::close(const ui::MailboxCloseRequest& request, uint64_t& rev
|
||||
});
|
||||
}
|
||||
|
||||
// Builds a mailbox action request for the observed message (entry index and raw entry).
|
||||
ui::MailboxActionRequest MailboxActions::request(int manager, uint64_t revision,
|
||||
ui::MailboxActionKind kind, const ui::MailboxMessage& observed) {
|
||||
ui::MailboxActionRequest request;
|
||||
@@ -275,6 +320,7 @@ ui::MailboxActionRequest MailboxActions::request(int manager, uint64_t revision,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Sends a menu layout save/load request and acknowledges it.
|
||||
bool MenuLayoutActions::dispatch(const ui::SaveLoadRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
@@ -284,16 +330,22 @@ bool MenuLayoutActions::dispatch(const ui::SaveLoadRequest& request, uint64_t& r
|
||||
});
|
||||
}
|
||||
|
||||
// Sets one environment item through set_impl (normal UI path).
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set(const ui::EnvironmentRequest& request,
|
||||
uint64_t& revision, std::string& error, const Notice& notice, const std::function<void(bool)>& acknowledge) {
|
||||
return set_impl(request, revision, error, notice, acknowledge, false);
|
||||
}
|
||||
|
||||
// Console variant of set(): the staged state is published even if nothing changed.
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set_console(const ui::EnvironmentView& observed,
|
||||
int item, int level, uint64_t& revision, std::string& error, const Notice& notice) {
|
||||
return set_impl(request(observed, item, level), revision, error, notice, {}, true);
|
||||
}
|
||||
|
||||
// Shared implementation. The request must match the current revision, manager slot
|
||||
// (0..3), active manager and club, otherwise error is "stale_environment_owner". The change
|
||||
// is made on a staged copy; a notice callback may abort it. The revision increases only
|
||||
// when something changed. Returns nothing if the transaction was not accepted.
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set_impl(const ui::EnvironmentRequest& request,
|
||||
uint64_t& revision, std::string& error, const Notice& notice, const std::function<void(bool)>& acknowledge,
|
||||
bool publish_console_result) {
|
||||
@@ -333,6 +385,7 @@ std::optional<EnvironmentResult> EnvironmentActions::set_impl(const ui::Environm
|
||||
return result;
|
||||
}
|
||||
|
||||
// Builds a set_item request for `item` and `level` bound to the observed view.
|
||||
ui::EnvironmentRequest EnvironmentActions::request(const ui::EnvironmentView& observed, int item, int level) {
|
||||
ui::EnvironmentRequest request;
|
||||
request.kind = ui::EnvironmentRequestKind::set_item;
|
||||
@@ -345,10 +398,12 @@ ui::EnvironmentRequest EnvironmentActions::request(const ui::EnvironmentView& ob
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` through the native transaction wrapper.
|
||||
bool RescheduleActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_native(session_, revision, action);
|
||||
}
|
||||
|
||||
// Moves a league match to `day` or undoes a move; any other combination is invalid.
|
||||
RescheduleStatus RescheduleActions::change(GameState& state, int manager, const LeagueMatchRef& match,
|
||||
int day, ui::RescheduleActionKind kind) {
|
||||
if (kind == ui::RescheduleActionKind::move) return reschedule_league_match(state, manager, match, day);
|
||||
@@ -356,6 +411,9 @@ RescheduleStatus RescheduleActions::change(GameState& state, int manager, const
|
||||
return RescheduleStatus::invalid_match;
|
||||
}
|
||||
|
||||
// Handles a UI reschedule action: the owner must be the open menu 7 for the current
|
||||
// revision and active manager, and the match must be among the eligible (or already moved)
|
||||
// matches. The state changes only when the move succeeds.
|
||||
RescheduleStatus RescheduleActions::dispatch(const ui::RescheduleAction& request, uint64_t& revision,
|
||||
const std::function<void()>& acknowledge) {
|
||||
auto status = RescheduleStatus::invalid_match;
|
||||
@@ -379,6 +437,7 @@ RescheduleStatus RescheduleActions::dispatch(const ui::RescheduleAction& request
|
||||
return status;
|
||||
}
|
||||
|
||||
// Moves a match directly (console path); the revision increases on success.
|
||||
RescheduleStatus RescheduleActions::move(int manager, const LeagueMatchRef& match, int day, uint64_t& revision) {
|
||||
auto status = RescheduleStatus::invalid_match;
|
||||
apply(revision, [&] {
|
||||
@@ -390,6 +449,7 @@ RescheduleStatus RescheduleActions::move(int manager, const LeagueMatchRef& matc
|
||||
return status;
|
||||
}
|
||||
|
||||
// Console undo; the revision always increases, whatever the result of the undo.
|
||||
void RescheduleActions::undo_console(int manager, int day, uint64_t& revision) {
|
||||
apply(revision, [&] {
|
||||
// Keep the Console's existing accepted-command revision after its own
|
||||
@@ -400,6 +460,8 @@ void RescheduleActions::undo_console(int manager, int day, uint64_t& revision) {
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a contract request to the session. If an exception follows an accepted request,
|
||||
// the pending contract quote is cleared before rethrowing.
|
||||
bool ContractActions::dispatch(const ui::ContractRequest& request, uint64_t& revision,
|
||||
ui::ContractActionResult& result, std::string& error, const std::function<void()>& acknowledge) {
|
||||
bool accepted = false;
|
||||
@@ -417,6 +479,7 @@ bool ContractActions::dispatch(const ui::ContractRequest& request, uint64_t& rev
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a contract request of `kind` bound to the observed manager, club and revision.
|
||||
ui::ContractRequest ContractActions::bind(const ui::ContractsState& observed,
|
||||
ui::ContractActionKind kind, uint64_t request_id) {
|
||||
ui::ContractRequest request;
|
||||
@@ -428,6 +491,7 @@ ui::ContractRequest ContractActions::bind(const ui::ContractsState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for a player's contract demands (row and player id).
|
||||
ui::ContractRequest ContractActions::demands(const ui::ContractsState& observed,
|
||||
const ui::ContractPlayer& player, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::request_demands, request_id);
|
||||
@@ -436,6 +500,7 @@ ui::ContractRequest ContractActions::demands(const ui::ContractsState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request that sets team bonus `index` to `percent`, keeping the other proposed premiums.
|
||||
ui::ContractRequest ContractActions::team_bonus(const ui::ContractsState& observed,
|
||||
int index, uint8_t percent, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::submit_bonuses, request_id);
|
||||
@@ -444,6 +509,7 @@ ui::ContractRequest ContractActions::team_bonus(const ui::ContractsState& observ
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request to insure a player (quote, insurance form in the term column, months).
|
||||
ui::ContractRequest ContractActions::insurance(const ui::ContractsState& observed, int row,
|
||||
int player, uint64_t quote, uint8_t form, uint8_t months, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::insure_player, request_id);
|
||||
@@ -452,6 +518,8 @@ ui::ContractRequest ContractActions::insurance(const ui::ContractsState& observe
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for a contract offer. With years > 0 it is an offer for that term (salary and
|
||||
// the matching demand); with 0 years only the bonuses are submitted.
|
||||
ui::ContractRequest ContractActions::offer(const ui::ContractsState& observed, int row,
|
||||
int player, uint64_t quote, const std::array<uint8_t,7>& bonuses, int years, uint32_t salary,
|
||||
const std::array<uint32_t,4>& demands, uint64_t request_id) {
|
||||
@@ -466,10 +534,12 @@ ui::ContractRequest ContractActions::offer(const ui::ContractsState& observed, i
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` through the native transaction wrapper.
|
||||
bool FriendlyActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_native(session_, revision, action);
|
||||
}
|
||||
|
||||
// Converts the UI's friendly match request into the engine's booking request.
|
||||
FriendlyBookingRequest FriendlyActions::booking_request(const ui::FriendlyMatchRequest& observed) {
|
||||
FriendlyBookingQuote quote;
|
||||
quote.status = FriendlyQuoteStatus::quoted;
|
||||
@@ -487,6 +557,7 @@ FriendlyBookingRequest FriendlyActions::booking_request(const ui::FriendlyMatchR
|
||||
observed.accept_cost, observed.approving_manager};
|
||||
}
|
||||
|
||||
// Builds the acknowledgement for the UI from the booking outcome and the new revision.
|
||||
ui::FriendlyBookingAck FriendlyActions::acknowledgement(const ui::FriendlyMatchRequest& request,
|
||||
const FriendlyBookingResult& outcome, uint64_t revision) const {
|
||||
ui::FriendlyBookingAck ack;
|
||||
@@ -499,6 +570,9 @@ ui::FriendlyBookingAck FriendlyActions::acknowledgement(const ui::FriendlyMatchR
|
||||
return ack;
|
||||
}
|
||||
|
||||
// Books a friendly match (club or national). The request must be a book request for the
|
||||
// current revision, otherwise the quote is stale. After booking, the planner count must
|
||||
// have grown by 2, else the booking is rolled back and planner_mismatch is set.
|
||||
FriendlyActions::Booking FriendlyActions::book(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, bool national, const Accept& acknowledge) {
|
||||
Booking result;
|
||||
@@ -526,11 +600,14 @@ FriendlyActions::Booking FriendlyActions::book(const ui::FriendlyMatchRequest& r
|
||||
return result;
|
||||
}
|
||||
|
||||
// Books a club friendly.
|
||||
FriendlyActions::Booking FriendlyActions::book_club(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, const Accept& acknowledge) { return book(request, revision, false, acknowledge); }
|
||||
// Books a national team friendly.
|
||||
FriendlyActions::Booking FriendlyActions::book_national(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, const Accept& acknowledge) { return book(request, revision, true, acknowledge); }
|
||||
|
||||
// Console booking from an existing quote; the revision increases when it was booked.
|
||||
FriendlyBookingResult FriendlyActions::book_console(const FriendlyBookingQuote& quote, uint16_t day,
|
||||
bool accept_opponent, int consenting_manager, bool accept_cost, int approving_manager, uint64_t& revision) {
|
||||
FriendlyBookingResult result;
|
||||
@@ -544,19 +621,25 @@ FriendlyBookingResult FriendlyActions::book_console(const FriendlyBookingQuote&
|
||||
return result;
|
||||
}
|
||||
|
||||
// Quote functions (thin wrappers over the game functions): club friendly quote,
|
||||
FriendlyBookingQuote FriendlyActions::quote(int manager, int opponent, bool home) const {
|
||||
return quote_friendly_match(session_.state(), manager, opponent, home);
|
||||
}
|
||||
// national friendly quote (uses the random generator),
|
||||
NationalFriendlyQuote FriendlyActions::national_quote(const NationalFriendlyOwner& owner, int opponent, bool home) {
|
||||
return quote_national_friendly_match(session_.state(), owner, opponent, home, session_.rand());
|
||||
}
|
||||
// whether a club friendly can be played on a day,
|
||||
FriendlyDateStatus FriendlyActions::date_status(const FriendlyBookingQuote& quote, uint16_t day) const {
|
||||
return friendly_match_date_status(session_.state(), quote, day);
|
||||
}
|
||||
// the same for a national friendly,
|
||||
FriendlyDateStatus FriendlyActions::national_date_status(const NationalFriendlyQuote& quote,
|
||||
const NationalFriendlyOwner& owner, uint16_t day) const {
|
||||
return national_friendly_match_date_status(session_.state(), quote, owner, session_.rand(), day);
|
||||
}
|
||||
// and the owner identity of a national friendly built from the request (the last two
|
||||
// fields are fixed constants).
|
||||
NationalFriendlyOwner FriendlyActions::national_owner(const ui::FriendlyMatchRequest& request) {
|
||||
return {request.quote_id, request.revision, request.manager_slot, 0x165, 6};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Application-boundary facades for desk-level windows: one small class per owner (desk
|
||||
// settings, balance plan, other games, top scorers, opportunities, manager join, mailbox,
|
||||
// menu layout, environment, reschedule, contracts, friendly matches). Each wraps a
|
||||
// CareerSession reference; its apply() runs an action under a rollback transaction (see
|
||||
// action_transaction.hpp), and open()/dispatch() take the UI request plus the shared
|
||||
// revision counter and an optional "accept" callback that carries the front end's
|
||||
// acknowledgement. Implemented in desktop_actions.cpp; window_actions.hpp holds the club windows.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// SDL event helpers for the live match-day presentation, which runs while the engine is
|
||||
// synchronously paused in its observer hook. live_matchday_board_side() turns a mouse press
|
||||
// into a side (0 or 1) of the board only at the allowed minutes and screen intervals;
|
||||
// pump_live_matchday_events() drains the SDL queue, reports a quit request and an ESC skip
|
||||
// through its return value / out-parameter, and re-queues only non-interactive system events.
|
||||
// Header-only; owns no state.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
+81
-3760
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Mouse pointer for the pitch page. SDL owns the pointer position; the UI only hands over
|
||||
// the original 11x11 pixel bitmap (121 ARGB values). PitchPointer builds an SDL colour
|
||||
// cursor from it, enlarged by an integer scale derived from the window size in points, and
|
||||
// caches it until the pixels or the scale change. set_default() sets the bitmap used on all
|
||||
// other pages. Header-only; the cursor is freed in clear() / the destructor.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
#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. Everywhere but on the
|
||||
// pitch page the pointer is the original's default 11x11 bitmap (set_default); the pitch page
|
||||
// passes the same bitmap with its position-colour fill.
|
||||
class PitchPointer {
|
||||
public:
|
||||
~PitchPointer() { clear(); }
|
||||
void clear() {
|
||||
if (cursor_) {
|
||||
SDL_SetCursor(SDL_GetDefaultCursor());
|
||||
SDL_FreeCursor(cursor_);
|
||||
cursor_ = nullptr;
|
||||
}
|
||||
pixels_.reset();
|
||||
}
|
||||
void set_default(const std::optional<std::array<uint32_t,121>>& pixels) { default_ = pixels; }
|
||||
void show(const std::optional<std::array<uint32_t,121>>& requested, SDL_Renderer* renderer) {
|
||||
const auto& pixels = requested ? requested : default_;
|
||||
if (!pixels) { SDL_SetCursor(SDL_GetDefaultCursor()); return; }
|
||||
// Cursor bitmaps are sized in window points, not in pixels: on a high-DPI display (macOS
|
||||
// Retina) the renderer's output is larger than the window, and a bitmap scaled to it would
|
||||
// show twice as large. SDL_GetWindowSize gives the points.
|
||||
int width = 320, height = 240;
|
||||
if (SDL_Window* window = SDL_RenderGetWindow(renderer)) SDL_GetWindowSize(window, &width, &height);
|
||||
else SDL_GetRendererOutputSize(renderer, &width, &height);
|
||||
const int scale = std::max(1, std::min(width / 320, height / 240));
|
||||
if (!cursor_ || pixels != pixels_ || scale != scale_) {
|
||||
std::vector<uint32_t> enlarged(size_t(11 * scale) * size_t(11 * scale));
|
||||
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_, default_;
|
||||
int scale_ = 1;
|
||||
};
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -1,10 +1,17 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Quit confirmation (a deliberate deviation from the original): a native message box in
|
||||
// German or English whose default button is "Cancel". poll() and peep() wrap
|
||||
// SDL_PollEvent / SDL_PeepEvents and drop SDL_QUIT events the user does not confirm. The
|
||||
// dialog is shown from the UI thread only, and a dialog that fails to open counts as "not
|
||||
// confirmed". The presenter is injectable (defaults to SDL_ShowMessageBox). Header-only.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
#include "app/robot.hpp"
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
// OpenBMH deviates from the original: confirms application exit with a localized native dialog, with cancellation selected by default.
|
||||
@@ -42,6 +49,15 @@ public:
|
||||
while (SDL_PollEvent(event)) {
|
||||
if (event->type != SDL_QUIT || confirm()) return 1;
|
||||
}
|
||||
// No input waiting: a robot run (app/robot.hpp, inactive in normal play) may queue the
|
||||
// events of its next script command now.
|
||||
Robot& robot = Robot::instance();
|
||||
if (robot.active()) {
|
||||
robot.idle();
|
||||
while (SDL_PollEvent(event)) {
|
||||
if (event->type != SDL_QUIT || confirm()) return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The robot: a test hook that plays the real game program from an input script, without a person.
|
||||
//
|
||||
// Purpose. The window program (src/app/main.cpp) owns the SDL loop, the modal presentation loops
|
||||
// and the timers; the headless tools (ui_walk, season_sim) bypass all of that. The robot covers it:
|
||||
// started with
|
||||
//
|
||||
// OPENBMH_ROBOT=<script file> OPENBMH_ROBOT_LOG=<output file>
|
||||
//
|
||||
// (usually together with SDL_VIDEODRIVER=dummy and SDL_AUDIODRIVER=dummy, so that no window and no
|
||||
// sound device are needed), the program reads the script instead of waiting for the mouse. After
|
||||
// every command the robot waits until the picture has stopped changing and writes one line
|
||||
//
|
||||
// <number> <command> -> <fingerprint of the settled picture> [unsettled]
|
||||
//
|
||||
// A refactoring of the window program must reproduce that file. Without the two environment
|
||||
// variables the robot is inactive and costs one branch per frame and per empty event poll.
|
||||
//
|
||||
// How it hooks in (both hooks are called on the UI thread only):
|
||||
// - present(renderer) replaces SDL_RenderPresent in main.cpp: the robot reads the rendered
|
||||
// picture back and remembers its fingerprint;
|
||||
// - QuitConfirmation::poll calls idle() when SDL has no event: once the picture is settled the
|
||||
// robot pushes the events of the next command into SDL's queue (so they take exactly the path
|
||||
// of real input, including SDL's conversion to the 320x240 logical coordinates).
|
||||
//
|
||||
// Script: one command per line, '#' starts a comment. Coordinates are the game's 320x240 units.
|
||||
// left X Y | right X Y a click (press, 120 ms, release)
|
||||
// key NAME RETURN, ESCAPE, BACKSPACE, SPACE or one letter/digit
|
||||
// text T typed text
|
||||
// wait MS nothing for MS milliseconds (then the settled picture is logged)
|
||||
// quit closes the program (the quit question is answered with yes)
|
||||
// OPENBMH_ROBOT_SHOTS=<directory> additionally saves the settled picture of every command as a BMP.
|
||||
// The time a command may take to settle is limited (OPENBMH_ROBOT_TIMEOUT_MS, default 15000); a
|
||||
// screen that keeps animating is logged as "unsettled" with the picture shown at that moment.
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
class Robot {
|
||||
public:
|
||||
static Robot& instance() {
|
||||
static Robot robot;
|
||||
return robot;
|
||||
}
|
||||
bool active() const { return active_; }
|
||||
|
||||
// Reads the environment; called once the window exists.
|
||||
void start(SDL_Window* window) {
|
||||
const char* script = std::getenv("OPENBMH_ROBOT");
|
||||
const char* log = std::getenv("OPENBMH_ROBOT_LOG");
|
||||
if (!script || !log) return;
|
||||
std::ifstream in(script);
|
||||
if (!in) { std::fprintf(stderr, "robot: cannot read %s\n", script); return; }
|
||||
std::string line;
|
||||
while (std::getline(in, line)) {
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
const auto first = line.find_first_not_of(" \t");
|
||||
if (first == std::string::npos || line[first] == '#') continue;
|
||||
commands_.push_back(line.substr(first));
|
||||
}
|
||||
log_ = std::fopen(log, "wb");
|
||||
if (!log_) { std::fprintf(stderr, "robot: cannot write %s\n", log); return; }
|
||||
if (const char* settle = std::getenv("OPENBMH_ROBOT_SETTLE_MS")) settle_ms_ = Uint32(std::atoi(settle));
|
||||
if (const char* timeout = std::getenv("OPENBMH_ROBOT_TIMEOUT_MS")) timeout_ms_ = Uint32(std::atoi(timeout));
|
||||
if (const char* shots = std::getenv("OPENBMH_ROBOT_SHOTS")) shots_ = shots;
|
||||
window_ = window;
|
||||
active_ = true;
|
||||
last_change_ = command_time_ = SDL_GetTicks();
|
||||
}
|
||||
|
||||
// A picture is about to be shown: fingerprint it (FNV-1a over the rendered ARGB pixels).
|
||||
void frame(SDL_Renderer* renderer) {
|
||||
if (!active_) return;
|
||||
int w = 0, h = 0;
|
||||
if (SDL_GetRendererOutputSize(renderer, &w, &h) != 0 || w <= 0 || h <= 0) return;
|
||||
pixels_.resize(size_t(w) * size_t(h) * 4);
|
||||
width_ = w, height_ = h;
|
||||
if (SDL_RenderReadPixels(renderer, nullptr, SDL_PIXELFORMAT_ARGB8888, pixels_.data(), w * 4) != 0) return;
|
||||
uint64_t hash = 0xcbf29ce484222325ull;
|
||||
for (uint8_t byte : pixels_) hash = (hash ^ byte) * 0x100000001b3ull;
|
||||
if (hash != picture_) {
|
||||
picture_ = hash;
|
||||
++pictures_;
|
||||
last_change_ = SDL_GetTicks();
|
||||
}
|
||||
}
|
||||
|
||||
// SDL has no event: issue the release of a click, or the next command once the picture is settled.
|
||||
void idle() {
|
||||
if (!active_) return;
|
||||
const Uint32 now = SDL_GetTicks();
|
||||
if (release_pending_) {
|
||||
if (now - command_time_ < 120) return;
|
||||
push_button(SDL_MOUSEBUTTONUP, release_button_);
|
||||
release_pending_ = false;
|
||||
last_change_ = now; // (the release may change the picture: settle again from here)
|
||||
return;
|
||||
}
|
||||
if (now < wait_until_) return;
|
||||
const bool settled = now - last_change_ >= settle_ms_ && now - command_time_ >= settle_ms_;
|
||||
const bool timed_out = now - command_time_ >= timeout_ms_;
|
||||
if (!settled && !timed_out) return;
|
||||
// the previous command is done: log it with the picture now on screen
|
||||
if (issued_ > 0 && !logged_) {
|
||||
// (the number of pictures in between depends on the clock and is not written)
|
||||
// A picture that was still changing at the time limit (a running live match, an animation) depends
|
||||
// on the clock: only the fact is written, not its fingerprint.
|
||||
if (settled) std::fprintf(log_, "%zu %s -> %016llx\n", issued_, commands_[issued_ - 1].c_str(), static_cast<unsigned long long>(picture_));
|
||||
else std::fprintf(log_, "%zu %s -> unsettled\n", issued_, commands_[issued_ - 1].c_str());
|
||||
std::fflush(log_);
|
||||
save_shot();
|
||||
logged_ = true;
|
||||
}
|
||||
if (issued_ >= commands_.size()) {
|
||||
if (!finished_) { finished_ = true; std::fclose(log_); log_ = nullptr; }
|
||||
return;
|
||||
}
|
||||
issue(commands_[issued_++]);
|
||||
logged_ = false;
|
||||
pictures_ = 0;
|
||||
command_time_ = last_change_ = SDL_GetTicks();
|
||||
}
|
||||
|
||||
// The quit question of a robot run is answered with "quit".
|
||||
static int confirm_quit(const SDL_MessageBoxData*, int* selected) {
|
||||
if (selected) *selected = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
// OPENBMH_ROBOT_SHOTS=<directory>: the settled picture of every command as <number>.bmp (for
|
||||
// writing scripts and for looking at a run; not needed for the comparison).
|
||||
void save_shot() {
|
||||
if (shots_.empty() || pixels_.empty()) return;
|
||||
SDL_Surface* surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels_.data(), width_, height_, 32, width_ * 4,
|
||||
SDL_PIXELFORMAT_ARGB8888);
|
||||
if (!surface) return;
|
||||
char name[32];
|
||||
std::snprintf(name, sizeof name, "/%04zu.bmp", issued_);
|
||||
SDL_SaveBMP(surface, (shots_ + name).c_str());
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
void push_button(Uint32 type, Uint8 button) {
|
||||
SDL_Event e{};
|
||||
e.type = type;
|
||||
e.button.windowID = SDL_GetWindowID(window_);
|
||||
e.button.button = button;
|
||||
e.button.state = type == SDL_MOUSEBUTTONDOWN ? SDL_PRESSED : SDL_RELEASED;
|
||||
e.button.clicks = 1;
|
||||
e.button.x = window_x_;
|
||||
e.button.y = window_y_;
|
||||
SDL_PushEvent(&e);
|
||||
}
|
||||
void push_motion() {
|
||||
SDL_Event e{};
|
||||
e.type = SDL_MOUSEMOTION;
|
||||
e.motion.windowID = SDL_GetWindowID(window_);
|
||||
e.motion.x = window_x_;
|
||||
e.motion.y = window_y_;
|
||||
SDL_PushEvent(&e);
|
||||
}
|
||||
void push_key(SDL_Keycode key) {
|
||||
for (const Uint32 type : {Uint32(SDL_KEYDOWN), Uint32(SDL_KEYUP)}) {
|
||||
SDL_Event e{};
|
||||
e.type = type;
|
||||
e.key.windowID = SDL_GetWindowID(window_);
|
||||
e.key.state = type == SDL_KEYDOWN ? SDL_PRESSED : SDL_RELEASED;
|
||||
e.key.keysym.sym = key;
|
||||
e.key.keysym.scancode = SDL_GetScancodeFromKey(key);
|
||||
SDL_PushEvent(&e);
|
||||
}
|
||||
}
|
||||
void issue(const std::string& command) {
|
||||
std::istringstream row(command);
|
||||
std::string name;
|
||||
row >> name;
|
||||
if (name == "left" || name == "right") {
|
||||
int x = 0, y = 0;
|
||||
row >> x >> y;
|
||||
// the middle of the logical pixel in window coordinates (SDL converts back)
|
||||
int w = 960, h = 720;
|
||||
SDL_GetWindowSize(window_, &w, &h);
|
||||
window_x_ = x * w / 320 + w / 640;
|
||||
window_y_ = y * h / 240 + h / 480;
|
||||
// (the warp moves SDL's own pointer state too, which the program reads in a few places, and
|
||||
// queues the motion event)
|
||||
SDL_WarpMouseInWindow(window_, window_x_, window_y_);
|
||||
release_button_ = name == "left" ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT;
|
||||
push_button(SDL_MOUSEBUTTONDOWN, release_button_);
|
||||
release_pending_ = true;
|
||||
} else if (name == "key") {
|
||||
std::string key;
|
||||
row >> key;
|
||||
SDL_Keycode code = SDLK_UNKNOWN;
|
||||
if (key == "RETURN" || key == "ENTER") code = SDLK_RETURN;
|
||||
else if (key == "ESCAPE" || key == "ESC") code = SDLK_ESCAPE;
|
||||
else if (key == "BACKSPACE") code = SDLK_BACKSPACE;
|
||||
else if (key == "SPACE") code = SDLK_SPACE;
|
||||
else if (key.size() == 1) code = SDL_Keycode(key[0] >= 'A' && key[0] <= 'Z' ? key[0] - 'A' + 'a' : key[0]);
|
||||
if (code != SDLK_UNKNOWN) push_key(code);
|
||||
} else if (name == "text") {
|
||||
std::string text;
|
||||
std::getline(row, text);
|
||||
if (!text.empty() && text[0] == ' ') text.erase(0, 1);
|
||||
SDL_Event e{};
|
||||
e.type = SDL_TEXTINPUT;
|
||||
e.text.windowID = SDL_GetWindowID(window_);
|
||||
SDL_strlcpy(e.text.text, text.c_str(), sizeof(e.text.text));
|
||||
SDL_PushEvent(&e);
|
||||
} else if (name == "wait") {
|
||||
int ms = 0;
|
||||
row >> ms;
|
||||
wait_until_ = SDL_GetTicks() + Uint32(ms > 0 ? ms : 0);
|
||||
} else if (name == "quit") {
|
||||
SDL_Event e{};
|
||||
e.type = SDL_QUIT;
|
||||
SDL_PushEvent(&e);
|
||||
}
|
||||
}
|
||||
|
||||
bool active_ = false, release_pending_ = false, logged_ = true, finished_ = false;
|
||||
SDL_Window* window_ = nullptr;
|
||||
std::FILE* log_ = nullptr;
|
||||
std::vector<std::string> commands_;
|
||||
std::vector<uint8_t> pixels_;
|
||||
size_t issued_ = 0;
|
||||
uint64_t picture_ = 0;
|
||||
unsigned pictures_ = 0;
|
||||
Uint32 last_change_ = 0, command_time_ = 0, wait_until_ = 0;
|
||||
Uint32 settle_ms_ = 400, timeout_ms_ = 15000;
|
||||
int window_x_ = 0, window_y_ = 0, width_ = 0, height_ = 0;
|
||||
std::string shots_;
|
||||
Uint8 release_button_ = SDL_BUTTON_LEFT;
|
||||
};
|
||||
|
||||
// Shows the rendered picture (SDL_RenderPresent), letting the robot see it first.
|
||||
inline void present(SDL_Renderer* renderer) {
|
||||
Robot& robot = Robot::instance();
|
||||
if (robot.active()) robot.frame(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of StartScreen (start_screen.hpp): decodes the embedded JPEG
|
||||
// (start_screen_data.hpp) with stb_image into an RGB24 texture, switches the renderer's
|
||||
// logical size to the image size while presenting and restores the previous logical size in
|
||||
// the destructor. Errors are reported as std::runtime_error; the stb_image implementation
|
||||
// is compiled into this file only (JPEG decoding, no stdio).
|
||||
#include "app/start_screen.hpp"
|
||||
#include "app/start_screen_data.hpp"
|
||||
#include <SDL.h>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#define STBI_ONLY_JPEG
|
||||
#define STBI_NO_STDIO
|
||||
#define STBI_NO_HDR
|
||||
#define STBI_NO_LINEAR
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "app/third_party/stb_image.h"
|
||||
namespace bmh::app {
|
||||
StartScreen::StartScreen(SDL_Renderer* renderer):renderer_(renderer) {
|
||||
if(!renderer_)throw std::runtime_error("Start screen: missing renderer");
|
||||
SDL_RenderGetLogicalSize(renderer_,&previous_width_,&previous_height_);
|
||||
int channels=0;
|
||||
const std::unique_ptr<unsigned char,decltype(&stbi_image_free)> pixels(
|
||||
stbi_load_from_memory(start_screen_jpeg,int(start_screen_jpeg_size),&width_,&height_,&channels,3),stbi_image_free);
|
||||
if(!pixels)throw std::runtime_error("Start screen: embedded artwork could not be decoded");
|
||||
texture_=SDL_CreateTexture(renderer_,SDL_PIXELFORMAT_RGB24,SDL_TEXTUREACCESS_STATIC,width_,height_);
|
||||
if(!texture_)throw std::runtime_error(SDL_GetError());
|
||||
if(SDL_UpdateTexture(texture_,nullptr,pixels.get(),width_*3)!=0||SDL_SetTextureScaleMode(texture_,SDL_ScaleModeLinear)!=0) {
|
||||
const std::string error=SDL_GetError();SDL_DestroyTexture(texture_);texture_=nullptr;throw std::runtime_error(error);
|
||||
}
|
||||
}
|
||||
StartScreen::~StartScreen() {
|
||||
SDL_DestroyTexture(texture_);
|
||||
SDL_RenderSetLogicalSize(renderer_,previous_width_,previous_height_);
|
||||
}
|
||||
void StartScreen::present() {
|
||||
if(SDL_RenderSetLogicalSize(renderer_,width_,height_)!=0)throw std::runtime_error(SDL_GetError());
|
||||
Uint8 r=0,g=0,b=0,a=0;SDL_GetRenderDrawColor(renderer_,&r,&g,&b,&a);
|
||||
SDL_SetRenderDrawColor(renderer_,0,0,0,255);
|
||||
const int cleared=SDL_RenderClear(renderer_);SDL_SetRenderDrawColor(renderer_,r,g,b,a);
|
||||
if(cleared!=0||SDL_RenderCopy(renderer_,texture_,nullptr,nullptr)!=0)throw std::runtime_error(SDL_GetError());
|
||||
SDL_RenderPresent(renderer_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Start screen shown before the game data is loaded: one embedded picture drawn with its
|
||||
// own renderer logical size, independent of the indexed game canvas. Owns the SDL
|
||||
// texture; non-copyable. Implemented in start_screen.cpp, the image bytes come from
|
||||
// start_screen_data.hpp.
|
||||
#pragma once
|
||||
struct SDL_Renderer;
|
||||
struct SDL_Texture;
|
||||
namespace bmh::app {
|
||||
// Owned, embedded artwork, rendered independently of the indexed game canvas.
|
||||
// Destruction restores the caller's logical size and therefore its input mapping.
|
||||
class StartScreen {
|
||||
public:
|
||||
explicit StartScreen(SDL_Renderer*);
|
||||
~StartScreen();
|
||||
StartScreen(const StartScreen&)=delete;
|
||||
StartScreen& operator=(const StartScreen&)=delete;
|
||||
void present();
|
||||
int width()const{return width_;}
|
||||
int height()const{return height_;}
|
||||
private:
|
||||
SDL_Renderer* renderer_;
|
||||
SDL_Texture* texture_=nullptr;
|
||||
int width_=0,height_=0,previous_width_=0,previous_height_=0;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Declares the embedded start screen artwork (JPEG bytes and their size); the definitions
|
||||
// live in a separate data translation unit. Consumed only by start_screen.cpp.
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
namespace bmh::app {
|
||||
extern const unsigned char start_screen_jpeg[];
|
||||
extern const std::size_t start_screen_jpeg_size;
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
# stb_image
|
||||
|
||||
Unmodified upstream stb_image 2.30 header, commit `013ac3beddff3dbffafd5177e7972067cd2b5083`.
|
||||
Source: [013ac3beddff3dbffafd5177e7972067cd2b5083](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h).
|
||||
SHA256: `594c2fe35d49488b4382dbfaec8f98366defca819d916ac95becf3e75f4200b3`.
|
||||
|
||||
Only JPEG decoding is compiled. The complete dual MIT/public-domain license
|
||||
is retained in the header and in `docs/licenses/stb_image.txt`.
|
||||
Vendored
+7988
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// RAII guard for SDL video: SDL_Init(SDL_INIT_VIDEO) in the constructor (throws
|
||||
// std::runtime_error on failure) and SDL_Quit in the destructor. It must exist before any
|
||||
// native file picker is opened (see the comment on the class). Non-copyable, header-only.
|
||||
#pragma once
|
||||
#include <SDL.h>
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the club and league window facades declared in window_actions.hpp. Each
|
||||
// method validates the UI request against the session state, runs it on the CareerSession
|
||||
// inside an apply() transaction (state, RNG and revision are restored on rejection or an
|
||||
// exception) and hands the result to the front end's acknowledgement callback. Errors come
|
||||
// back through the std::string& error parameter; see controller.cpp for the overall model.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/window_actions.hpp"
|
||||
#include "app/action_transaction.hpp"
|
||||
@@ -11,6 +16,9 @@
|
||||
namespace bmh::app {
|
||||
using detail::apply_window;
|
||||
|
||||
// Runs `action` as a transaction on the league family state. Returns true if the action
|
||||
// succeeded; if it returns false or throws, the checkpoint and the revision are restored
|
||||
// (an exception is rethrown).
|
||||
bool LeagueFamilyActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
auto before = session_.league_family_checkpoint();
|
||||
const auto old_revision = revision;
|
||||
@@ -26,6 +34,8 @@ bool LeagueFamilyActions::apply(uint64_t& revision, const std::function<bool()>&
|
||||
return false;
|
||||
}
|
||||
|
||||
// Opens the league pairings screen from the desk (menu kind 1, using the desk item of
|
||||
// kind 1). Returns its state, or nothing with `error` set if the session refused.
|
||||
std::optional<ui::LeaguePairingsState> LeagueFamilyActions::open_pairings(
|
||||
const ui::DeskState& observed, uint64_t& revision, std::string& error) {
|
||||
ui::DeskRequest request;
|
||||
@@ -43,6 +53,7 @@ std::optional<ui::LeaguePairingsState> LeagueFamilyActions::open_pairings(
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends one pairings screen event (kind and value) to the session inside a transaction.
|
||||
std::optional<CareerSession::LeaguePairingsDispatch> LeagueFamilyActions::pairings(
|
||||
const ui::LeaguePairingsIdentity& observed, LeaguePairingsAction kind, int value,
|
||||
uint64_t& revision, std::string& error) {
|
||||
@@ -58,16 +69,19 @@ std::optional<CareerSession::LeaguePairingsDispatch> LeagueFamilyActions::pairin
|
||||
return result;
|
||||
}
|
||||
|
||||
// Builds the desk request that opens menu 1 (pairings) for the manager of `identity`.
|
||||
ui::DeskRequest LeagueFamilyActions::pairings_entry(const ui::StrengthsIdentity& identity,
|
||||
uint64_t revision) {
|
||||
return {ui::DeskRequestKind::open_menu, identity.manager, 0, 1, -1, revision};
|
||||
}
|
||||
|
||||
// Builds the pairings request that selects `league`.
|
||||
ui::LeaguePairingsRequest LeagueFamilyActions::pairings_selection(
|
||||
const ui::LeaguePairingsIdentity& identity, int league) {
|
||||
return {identity, {LeaguePairingsAction::select_league, league, -1}};
|
||||
}
|
||||
|
||||
// Turns a fresh strengths request into an `open` request bound to `identity`.
|
||||
ui::StrengthsRequest LeagueFamilyActions::strengths_entry(const ui::StrengthsRequest& fresh,
|
||||
const ui::StrengthsIdentity& identity) {
|
||||
auto request = fresh;
|
||||
@@ -76,6 +90,9 @@ ui::StrengthsRequest LeagueFamilyActions::strengths_entry(const ui::StrengthsReq
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction on the transfer state. Before it, the game state, random
|
||||
// generators, offer editor, poach state, club modal runtime and revision are copied; they
|
||||
// are all restored if the action returns false or throws (then rethrown).
|
||||
bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
auto state = session_.g_;
|
||||
const auto game = session_.game_;
|
||||
@@ -85,6 +102,7 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
|
||||
const auto owner_revision = session_.transfer_offer_revision_;
|
||||
auto runtime = session_.club_modal_runtime_;
|
||||
const auto old_revision = revision;
|
||||
// Puts every saved piece back into the session.
|
||||
const auto restore = [&] {
|
||||
session_.g_ = std::move(state);
|
||||
session_.game_ = game;
|
||||
@@ -105,15 +123,21 @@ bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& act
|
||||
return false;
|
||||
}
|
||||
|
||||
// Handles a transfer market request. In the normal interactive policy the session does
|
||||
// the work (with the sale hooks and the review callback). The other policy is an older
|
||||
// path that only allows listing a player and submitting a bid; it bumps the revision
|
||||
// only if the state or random stream really changed. `acknowledge` is called on success.
|
||||
std::optional<TransferActions::MarketDispatch> TransferActions::market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, HumanBuyerMarketEntryPolicy policy,
|
||||
const MarketAccept& acknowledge) {
|
||||
const MarketAccept& acknowledge,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review) {
|
||||
std::optional<MarketDispatch> result;
|
||||
// Body of the transaction; returning false rolls everything back.
|
||||
apply(revision, [&] {
|
||||
const auto old_revision = revision;
|
||||
if (policy == HumanBuyerMarketEntryPolicy::normal_interactive) {
|
||||
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 {
|
||||
@@ -150,6 +174,9 @@ std::optional<TransferActions::MarketDispatch> TransferActions::market(
|
||||
return result;
|
||||
}
|
||||
|
||||
// Checks a market request against the current state. Returns a German error text if the
|
||||
// request is stale or invalid, or an empty string if it may proceed. Bonus values may be
|
||||
// at most 255 (interactive policy) or 100 (legacy policy).
|
||||
std::string TransferActions::rejection(const ui::TransferMarketRequest& request,
|
||||
uint64_t revision, HumanBuyerMarketEntryPolicy policy) const {
|
||||
const auto& state = session_.state();
|
||||
@@ -174,11 +201,14 @@ 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 &&
|
||||
request.kind != ui::TransferMarketRequestKind::store_search_profile)
|
||||
return "Diese Transferaktion ist nicht verfügbar.";
|
||||
return {};
|
||||
}
|
||||
|
||||
// Opens the transfer offer editor for a market request (one transaction).
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::open_offer(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error,
|
||||
const OfferAccept& acknowledge) {
|
||||
@@ -192,6 +222,7 @@ std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::open_
|
||||
return result;
|
||||
}
|
||||
|
||||
// Asks the session for a preview (quote) of a market request without committing it.
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> TransferActions::preview(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error,
|
||||
const PreviewAccept& acknowledge) {
|
||||
@@ -205,6 +236,8 @@ std::optional<CareerSession::TransferMarketPreviewDispatch> TransferActions::pre
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sends an action of the outgoing offer editor to the session; the team and player
|
||||
// information presenters are used when it opens those screens.
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::offer(
|
||||
const ui::OutgoingTransferRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, const TransferOfferTeamInfoPresenter& team_info,
|
||||
@@ -219,6 +252,7 @@ std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::offer
|
||||
return result;
|
||||
}
|
||||
|
||||
// Starts a poaching attempt for the given manager and squad slot.
|
||||
std::optional<CareerSession::PoachDispatch> TransferActions::poach(int manager, int slot,
|
||||
uint64_t& revision, std::string& error) {
|
||||
std::optional<CareerSession::PoachDispatch> result;
|
||||
@@ -229,6 +263,8 @@ std::optional<CareerSession::PoachDispatch> TransferActions::poach(int manager,
|
||||
return result;
|
||||
}
|
||||
|
||||
// Builds the request to list the squad player `item` on the market (as a loan if `loan`),
|
||||
// bound to the observed state's manager, club and revision.
|
||||
ui::TransferMarketRequest TransferActions::listing(const ui::TransferMarketState& observed,
|
||||
const ui::TransferMarketSquadItem& item, bool loan) {
|
||||
ui::TransferMarketRequest request;
|
||||
@@ -244,6 +280,8 @@ ui::TransferMarketRequest TransferActions::listing(const ui::TransferMarketState
|
||||
return request;
|
||||
}
|
||||
|
||||
// Builds the request to open an offer for the market entry `item`; an existing own bid
|
||||
// is used as the starting point.
|
||||
ui::TransferMarketRequest TransferActions::opening(const ui::TransferMarketState& observed,
|
||||
const ui::TransferMarketItem& item, bool loan) {
|
||||
ui::TransferMarketRequest request;
|
||||
@@ -261,6 +299,7 @@ ui::TransferMarketRequest TransferActions::opening(const ui::TransferMarketState
|
||||
return request;
|
||||
}
|
||||
|
||||
// Builds a request from the offer editor's current state plus the changed field and value.
|
||||
ui::OutgoingTransferRequest TransferActions::editor(const ui::OutgoingTransferEditorState& observed,
|
||||
ui::OutgoingTransferRequestKind kind, ui::OutgoingTransferField field, uint32_t value) {
|
||||
ui::OutgoingTransferRequest request;
|
||||
@@ -280,11 +319,13 @@ ui::OutgoingTransferRequest TransferActions::editor(const ui::OutgoingTransferEd
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the bank checkpoint on failure.
|
||||
bool BankActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.bank_checkpoint(),
|
||||
[&](CareerSession::BankCheckpoint before) { session_.restore_bank_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Sends a bank request to the session; `acknowledge` is called when it was accepted.
|
||||
bool BankActions::dispatch(const ui::BankRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -294,6 +335,7 @@ bool BankActions::dispatch(const ui::BankRequest& request, uint64_t& revision, s
|
||||
});
|
||||
}
|
||||
|
||||
// Creates a bank request of `kind` bound to the observed manager, club and revision.
|
||||
ui::BankRequest BankActions::bind(const ui::BankState& observed, ui::BankRequestKind kind) {
|
||||
ui::BankRequest request;
|
||||
request.kind = kind;
|
||||
@@ -303,12 +345,14 @@ ui::BankRequest BankActions::bind(const ui::BankState& observed, ui::BankRequest
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request to move `amount` to the deposit account.
|
||||
ui::BankRequest BankActions::savings(const ui::BankState& observed, int32_t amount) {
|
||||
auto request = bind(observed, ui::BankRequestKind::move_to_deposit);
|
||||
request.amount = amount;
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for an investment action on asset index `asset` with `count` units.
|
||||
ui::BankRequest BankActions::investment(const ui::BankState& observed, ui::BankRequestKind kind,
|
||||
int asset, int count) {
|
||||
auto request = bind(observed, kind);
|
||||
@@ -317,6 +361,8 @@ ui::BankRequest BankActions::investment(const ui::BankState& observed, ui::BankR
|
||||
return request;
|
||||
}
|
||||
|
||||
// Request for a bank credit: carries the saved credit, the player's edits, whether the
|
||||
// fees are accepted and the counterparty.
|
||||
ui::BankRequest BankActions::credit(const ui::BankState& observed, const BankCreditContext& context,
|
||||
const BankCreditDraft& draft, bool accept_fees, int counterparty) {
|
||||
auto request = bind(observed, ui::BankRequestKind::bank_credit);
|
||||
@@ -327,11 +373,14 @@ ui::BankRequest BankActions::credit(const ui::BankState& observed, const BankCre
|
||||
return request;
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the stadium checkpoint on failure.
|
||||
bool StadiumActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.stadium_checkpoint(),
|
||||
[&](CareerSession::StadiumCheckpoint before) { session_.restore_stadium_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Sends a stadium request to the session with the notice hooks; `acknowledge` is called
|
||||
// when it was accepted.
|
||||
bool StadiumActions::dispatch(const ui::StadiumRequest& request, uint64_t& revision, std::string& error,
|
||||
const ConstructionNoticeHook& construction, const SeasonTicketCompensationNoticeHook& compensation,
|
||||
const std::function<void()>& acknowledge) {
|
||||
@@ -342,6 +391,7 @@ bool StadiumActions::dispatch(const ui::StadiumRequest& request, uint64_t& revis
|
||||
});
|
||||
}
|
||||
|
||||
// Creates a stadium request bound to the observed club, revision, scope and sequence.
|
||||
ui::StadiumRequest StadiumActions::request(const ui::StadiumState& observed, ui::StadiumRequestKind kind,
|
||||
int object, int option, int32_t price, bool accept_tip) {
|
||||
ui::StadiumRequest request;
|
||||
@@ -359,6 +409,8 @@ ui::StadiumRequest StadiumActions::request(const ui::StadiumState& observed, ui:
|
||||
return request;
|
||||
}
|
||||
|
||||
// Sets the ticket price for the observed desk's club; the stable club identity is filled
|
||||
// in when the club index is valid.
|
||||
bool DeskActions::ticket_price(const ui::DeskState& observed, int price,
|
||||
uint64_t& revision, std::string& error) {
|
||||
TicketPriceRequest request;
|
||||
@@ -371,11 +423,13 @@ bool DeskActions::ticket_price(const ui::DeskState& observed, int price,
|
||||
return session_.dispatch_ticket_price(request, revision, error);
|
||||
}
|
||||
|
||||
// Runs `action` as a transaction restoring the lineup checkpoint on failure.
|
||||
bool LineupActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.lineup_checkpoint(),
|
||||
[&](CareerSession::LineupCheckpoint before) { session_.restore_lineup_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
// Sends a lineup request to the session; `acknowledge` is called when accepted.
|
||||
bool LineupActions::lineup(const ui::LineupRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -385,6 +439,7 @@ bool LineupActions::lineup(const ui::LineupRequest& request, uint64_t& revision,
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a pitch request to the session; `acknowledge` is called when accepted.
|
||||
bool LineupActions::pitch(const ui::PitchRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
@@ -394,10 +449,13 @@ bool LineupActions::pitch(const ui::PitchRequest& request, uint64_t& revision, s
|
||||
});
|
||||
}
|
||||
|
||||
// Sends a pitch swap request to the session as one transaction.
|
||||
bool LineupActions::pitch_swap(const ui::PitchRequest& request, uint64_t& revision, std::string& error) {
|
||||
return apply(revision, [&] { return session_.dispatch_pitch_swap(request, revision, error); });
|
||||
}
|
||||
|
||||
// Changes one order value (`aspect`) of a player. Only valid for the observed revision;
|
||||
// on success the revision is increased.
|
||||
bool LineupActions::order(const ui::LineupState& observed, const ui::LineupPlayer& player,
|
||||
int aspect, int value, uint64_t& revision) {
|
||||
return apply(revision, [&] {
|
||||
@@ -408,6 +466,9 @@ bool LineupActions::order(const ui::LineupState& observed, const ui::LineupPlaye
|
||||
});
|
||||
}
|
||||
|
||||
// Tries the requested pitch move on a copy of the state and tells whether the player ends
|
||||
// up paired with `second_row` (requested), with another player (other_pair) or whether the
|
||||
// move is invalid.
|
||||
LineupActions::PairTarget LineupActions::pair_target(const ui::PitchRequest& request, int second_row) const {
|
||||
auto preview = session_.state();
|
||||
if (!move_pitch_player_source(preview, request.manager_slot, request.runtime_club,
|
||||
@@ -419,6 +480,7 @@ LineupActions::PairTarget LineupActions::pair_target(const ui::PitchRequest& req
|
||||
? PairTarget::requested : PairTarget::other_pair;
|
||||
}
|
||||
|
||||
// Creates a lineup request that prepares the lineup of the observed state.
|
||||
ui::LineupRequest LineupActions::prepare(const ui::LineupState& observed) {
|
||||
ui::LineupRequest request;
|
||||
request.kind = ui::LineupRequestKind::prepare_lineup;
|
||||
@@ -428,6 +490,7 @@ ui::LineupRequest LineupActions::prepare(const ui::LineupState& observed) {
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to swap two players of the lineup.
|
||||
ui::LineupRequest LineupActions::swap(const ui::LineupState& observed,
|
||||
const ui::LineupPlayer& first, const ui::LineupPlayer& second) {
|
||||
auto request = prepare(observed);
|
||||
@@ -438,6 +501,8 @@ ui::LineupRequest LineupActions::swap(const ui::LineupState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a pitch request of `kind` bound to the observed lineup. The observed live mode
|
||||
// must be known, otherwise a FormatError is thrown.
|
||||
ui::PitchRequest LineupActions::bind_pitch(const ui::PreparationState& observed, ui::PitchRequestKind kind) {
|
||||
if (!observed.pitch || !observed.pitch->indoor.has_value())
|
||||
throw FormatError("pitch: missing observed live mode");
|
||||
@@ -450,6 +515,7 @@ ui::PitchRequest LineupActions::bind_pitch(const ui::PreparationState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to swap two players on the pitch (including their current positions).
|
||||
ui::PitchRequest LineupActions::swap_pitch(const ui::PreparationState& observed,
|
||||
const ui::LineupPlayer& first, const ui::LineupPlayer& second) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::swap_players);
|
||||
@@ -459,6 +525,7 @@ ui::PitchRequest LineupActions::swap_pitch(const ui::PreparationState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to switch the pitch page (toggles the 0x000c bits of the display word).
|
||||
ui::PitchRequest LineupActions::page(const ui::PreparationState& observed) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::select_pitch_page);
|
||||
request.expected_mode = uint8_t(observed.pitch->mode);
|
||||
@@ -470,6 +537,8 @@ ui::PitchRequest LineupActions::page(const ui::PreparationState& observed) {
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to load or save a formation in `slot`; saving copies the position
|
||||
// bytes of the 11 players on the pitch.
|
||||
ui::PitchRequest LineupActions::formation(const ui::PreparationState& observed,
|
||||
ui::PitchRequestKind kind, int slot) {
|
||||
auto request = bind_pitch(observed, kind);
|
||||
@@ -485,6 +554,7 @@ ui::PitchRequest LineupActions::formation(const ui::PreparationState& observed,
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request to move a player to the given depth and lane.
|
||||
ui::PitchRequest LineupActions::move(const ui::PreparationState& observed, const ui::LineupPlayer& player,
|
||||
int depth, int lane) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::move_player);
|
||||
@@ -495,6 +565,8 @@ ui::PitchRequest LineupActions::move(const ui::PreparationState& observed, const
|
||||
return request;
|
||||
}
|
||||
|
||||
// Creates a request that advances one of the three automatic weights (index 0..2) by one
|
||||
// step; each weight is a 2-bit value that wraps around after 3.
|
||||
ui::PitchRequest LineupActions::weight(const ui::PreparationState& observed, int index) {
|
||||
if (index < 0 || index > 2) throw FormatError("pitch: invalid automatic weight index");
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::set_automatic_weight);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Application-boundary facades for the club and league windows: league table/pairings/
|
||||
// strengths, transfer market and offers, bank, stadium, desk actions and lineup. Same pattern
|
||||
// as desktop_actions.hpp: a class per owner that wraps a CareerSession, offers apply() as a
|
||||
// rollback transaction and takes the shared revision counter plus an acknowledgement
|
||||
// callback from the front end. Implemented in window_actions.cpp, called from controller.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
@@ -38,7 +43,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&,
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of container.hpp: parse_container() checks the FORM/ALPTRAUM header and
|
||||
// walks the adjacent little-endian chunks (no alignment byte) with bounds checks, filling
|
||||
// a Container of offsets; decode_sample() and decode_original_cue() convert the bounded
|
||||
// sample data to PCM. Pure functions on byte spans, no state; failures are reported through
|
||||
// the std::string& error argument and a false result.
|
||||
#include "container.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Reader for the original sound container (a FORM/ALPTRAUM chunk wrapper) and for the PCM
|
||||
// samples inside it. A Container only lists chunk ids and payload offsets; the payload bytes
|
||||
// stay in the caller's buffer, which must outlive any use of the offsets. decode_sample()
|
||||
// turns unsigned 8-bit samples into signed 16-bit mono PCM; decode_original_cue() resolves
|
||||
// only the PCM-backed effects (original ids 17..22). Pairs with container.cpp; the PCM types
|
||||
// are shared by mixer, playback, semantic cues and the music fallback.
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of Mixer (mixer.hpp). Incoming PCM is resampled to the output rate with
|
||||
// range and overflow checks and a total/per-voice byte ceiling (2 MiB overall, an eighth of
|
||||
// that per voice); mix_block() sums music and active voices into the output block, applies
|
||||
// the volume and advances the cursors (the music loops).
|
||||
#include "mixer.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Small PCM mixer used by the software (non-original) playback path: one looping music
|
||||
// buffer plus up to 8 one-shot voices, all converted to the output rate when added.
|
||||
// start_music_loop()/add_voice() may allocate; mix_block() only reads the prepared buffers
|
||||
// and writes into caller-owned storage, so it is safe to call from the audio path. Owned
|
||||
// by Playback (playback.hpp); the byte limits are in mixer.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the synthetic matchday loop (music_fallback.hpp): a fixed 22050 Hz,
|
||||
// 108 bpm, 8-bar sequence of bass, chord and lead notes defined by constant MIDI tables,
|
||||
// rendered to mono PCM16. No game state or randomness is involved, so the output is the
|
||||
// same on every run.
|
||||
#include "music_fallback.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Synthetic fallback matchday music: a deterministic 8-bar loop generated in code. It is
|
||||
// presentation filler, not decoded original music and not tied to any original sound id.
|
||||
// The result is a PcmSample that Playback::start_music_loop() can play; implemented in
|
||||
// music_fallback.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of OriginalSynth (original.hpp). The hidden State holds the parsed
|
||||
// songs, tracks, channels, sample banks and the Nuked-OPL3 chip core (src/audio/third_party);
|
||||
// tick() runs one sequencer step of the original timer interrupt, render() produces output
|
||||
// samples from the chip and the PCM channel. load() validates every input and fails
|
||||
// cleanly on malformed data; the register and sample observers exist only for offline
|
||||
// validation (original_validation.cpp, sound_driver.cpp).
|
||||
#include "original.hpp"
|
||||
#include "container.hpp"
|
||||
#include "third_party/nuked-opl3/opl3.h"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Emulation of the original game's sound system (MIDI-style sequencer, OPL FM instruments
|
||||
// and one Sound Blaster PCM channel) as OriginalSynth. The application reads the sound
|
||||
// containers (S/2000..2003) and the frequency/operator tables from the user's executable
|
||||
// and hands them in as OriginalAssets; this module knows nothing about game state, file
|
||||
// layout, the simulation clock or random generators. command() takes the original sound ids
|
||||
// (0 title, 1 desk, 2 intro, 3 crowd, 8 stop, 10..22 effects); render() fills PCM blocks
|
||||
// without allocating. Implemented in original.cpp, driven by Playback and the audio tools.
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Validation executable for the original-sound emulation (original.hpp, playback.hpp). It
|
||||
// needs the user's game data directory as its single argument, loads the executable tables
|
||||
// and sound containers from it, and runs oracle checks on song/effect output, transitions,
|
||||
// malformed input, option and mute handling, effect priorities and the audio callback
|
||||
// lifecycle. With an empty argument it prints SKIP and exits with 77 (test skipped).
|
||||
// Contains no game assets itself.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "original.hpp"
|
||||
#include "playback.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of Playback (playback.hpp): opens the SDL audio device, feeds either the
|
||||
// OriginalSynth from the SDL callback (original mode) or bounded blocks from the Mixer via
|
||||
// pump() (software mode), and maps original ids and semantic cues to sound played on the
|
||||
// device. Duplicate or out-of-order event ids are rejected before anything is played;
|
||||
// shutdown() releases the device.
|
||||
#include "playback.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Audio output device wrapper (SDL) and the single audio object the application uses.
|
||||
// Playback owns the SDL device, a software Mixer (PCM effects, optional music loop) and the
|
||||
// OriginalSynth (the full original driver, streamed from SDL's audio callback so modal
|
||||
// windows cannot starve it). Cue requests carry a session id and an increasing event id
|
||||
// chosen by the controller; submit() consumes each event once and returns a CueStatus.
|
||||
// Mute and volume apply to both paths. Pairs with playback.cpp and app/audio.hpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of synthesize_semantic_cue() (semantic_cues.hpp): builds each cue in code
|
||||
// (the whistles from frequency sweeps with attack and release shaping) at 22050 Hz and
|
||||
// clamps the result to 16-bit PCM. Pure and deterministic.
|
||||
#include "semantic_cues.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Semantic sound cues (kickoff whistle, goal, full-time whistle) synthesized in code for
|
||||
// use when no verified original effect is available. They are labels of intent, never
|
||||
// original sound ids. The generator is deterministic mono PCM16 at 22050 Hz and has no
|
||||
// dependency on game state, randomness or rendering; implemented in semantic_cues.cpp.
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Command line tool openbmh_sound for the audio module. It works either on one sound
|
||||
// container file (play or export a sample, a test tone, or an original effect id as WAV) or,
|
||||
// with --original DATA_DIR, on the user's game data through OriginalSynth (export a song or
|
||||
// effect to WAV, or play ids through the real device). It also plays or exports the
|
||||
// synthetic semantic cues and the fallback music loop. Own state only: parsed arguments.
|
||||
// Bounds on seconds, loops and ids are checked before anything runs.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "container.hpp"
|
||||
#include "music_fallback.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Self-contained checks for the audio module that need no game data: container parsing
|
||||
// against authored fixtures, sample and cue decoding, the mixer, the playback request
|
||||
// rules and the synthetic music fallback. The fixtures are built in code and are not
|
||||
// copied from any game asset. Returns non-zero on the first failed CHECK; companion of
|
||||
// original_validation.cpp, which covers the original-driver emulation.
|
||||
#include "container.hpp"
|
||||
#include "music_fallback.hpp"
|
||||
#include "playback.hpp"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of the console line parser (parser.hpp): trimming, top-level splitting of
|
||||
// the argument list (commas inside quotes or brackets do not split), parsing of one
|
||||
// argument (positional or name=value), canonical name comparison that ignores case, '.' and
|
||||
// '_', line classification, and the integer/bool converters for arguments. Pure functions;
|
||||
// no console state. The console (console.cpp, windows_*.cpp) checks the argument types.
|
||||
#include "cli/console/parser.hpp"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
@@ -427,7 +427,7 @@ void Console::finish_kickoff(const ui::DeskState& before, const TurnAdvanceResul
|
||||
name = ui::league_table_from_game(session_->state(), active_slot(), *group.league_id).league_name;
|
||||
// (the indoor tournament, 0xb, has a runtime name: TEXTD only holds the placeholder
|
||||
// "...xxx"; the projection already carries the name frozen for these results)
|
||||
else if (group.cup_id && *group.cup_id >= 0 && *group.cup_id < 13 && (*group.cup_id != 0xb || bmh::kEnglishCompetitions))
|
||||
else if (group.cup_id && *group.cup_id >= 0 && *group.cup_id < 13 && (*group.cup_id != 0xb || bmh::league_system().english_competitions))
|
||||
name = text(kCompetitionNames + *group.cup_id);
|
||||
if (group.matches.empty()) continue;
|
||||
emit('i', name + ":");
|
||||
|
||||
@@ -36,7 +36,7 @@ constexpr int kHighscorePrefix = 889; // the high score file prefix ("high/h.")
|
||||
|
||||
void Console::register_info_commands() {
|
||||
// --- TopScorers (05-information 7, menu 20) -------------------------------------------
|
||||
// Codex's read-only port of TopScorersFromGame (game/top_scorers.hpp): the best ten of the own
|
||||
// The read-only port of TopScorersFromGame (game/top_scorers.hpp): the best ten of the own
|
||||
// league by goals, assists or both (one point each), for the whole league or only the
|
||||
// managers' clubs. No state changes and no random draws, so the console reads it directly.
|
||||
struct ScorerView {
|
||||
@@ -133,7 +133,7 @@ void Console::register_info_commands() {
|
||||
if (window_ == "Fixtures" && pairings_) fixtures_action(LeaguePairingsAction::close);
|
||||
std::string error;
|
||||
ClubInfoEntry entry;
|
||||
if (team < int(exe_.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField))) { // league teams get the entry step (as the app does)
|
||||
if (team < int(exe_.u16(::bmh::layout::LeagueClubCount))) { // league teams get the entry step (as the app does)
|
||||
const auto prepared = session_->enter_club_information(team, error);
|
||||
if (!prepared) fail("E_RULE", "club information: " + error);
|
||||
entry = *prepared;
|
||||
|
||||
@@ -166,7 +166,7 @@ void Console::register_squad_commands() {
|
||||
});
|
||||
// Moving a player, the formations and the automatic weights: the requests the SDL pitch
|
||||
// screen builds (src/ui/pitch.cpp click / save_formation), dispatched through
|
||||
// CareerSession::dispatch_pitch (PitchScreen pitch branch, Codex's source port).
|
||||
// CareerSession::dispatch_pitch (PitchScreen pitch branch, the source port).
|
||||
auto pitch_context = [this] {
|
||||
const auto p = prep();
|
||||
if (!p.pitch || !p.pitch->indoor.has_value()) fail("E_ENGINE_GAP", "no pitch mode projection");
|
||||
|
||||
@@ -90,7 +90,7 @@ Json mailbox_record(const ui::MailboxState& m) {
|
||||
|
||||
} // namespace
|
||||
|
||||
// --- Advice and Scoreboard (for agents that learn: docs/CLI_CONCEPT/16-playbook.md) -------
|
||||
// --- Advice and Scoreboard (for agents that learn: docs/CLI_CONCEPT/10-agenten-und-tests.md) -------
|
||||
// Advice names what needs a decision now, from the engine's own data; it judges nothing
|
||||
// the player could not see on his screens, it only collects it. Scoreboard compares the
|
||||
// human managers. Both read only.
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "cli/console/detail.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
#include "game/human_buyer_sale.hpp"
|
||||
#include "game/messages.hpp"
|
||||
#include "game/poach.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "ui/club_info.hpp"
|
||||
@@ -160,6 +161,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 +178,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");
|
||||
@@ -420,7 +459,7 @@ void Console::register_transfer_commands() {
|
||||
Arg a;
|
||||
a.text = number;
|
||||
const auto id = to_int(a);
|
||||
if (!id || *id < 0 || *id >= runtime_dimensions.league_teams) fail("E_BAD_ARGUMENT", "club is club:<n> (ListPoachClubs)");
|
||||
if (!id || *id < 0 || *id >= world_layout().league_teams) fail("E_BAD_ARGUMENT", "club is club:<n> (ListPoachClubs)");
|
||||
return int(*id);
|
||||
};
|
||||
Param club = detail::text("club");
|
||||
@@ -478,8 +517,76 @@ void Console::register_transfer_commands() {
|
||||
show_offer();
|
||||
});
|
||||
|
||||
// --- the search profile (buttons Suchen / Vorschlag of the market, game/search_profile.hpp) ---------------
|
||||
// The 18 values of the profile in the order of the original dialog; the console shows and takes them as a list.
|
||||
static const char* const kProfileLabels[18] = {
|
||||
"Goalkeeper", "Defender", "Midfielder", "Forward", "AgeMin(16+)", "AgeMax(16+)", "StrengthMin", "StrengthMax",
|
||||
"AttrCondition", "AttrTechnique", "AttrForm", "Side1", "Side2", "Side3", "Side4", "PriceLow", "PriceMid", "PriceHigh"};
|
||||
auto show_profile = [this](const SearchProfile& p, const char* heading) {
|
||||
std::vector<std::vector<std::string>> rows;
|
||||
for (size_t i = 0; i < p.size(); ++i)
|
||||
rows.push_back({kProfileLabels[i], std::to_string(i == 0 ? p[i] & ~kSearchProfileOff : p[i])});
|
||||
emit_table({heading, "Value"}, rows);
|
||||
std::string list;
|
||||
for (size_t i = 0; i < p.size(); ++i) list += (i ? "," : "") + std::to_string(i == 0 ? p[i] & ~kSearchProfileOff : p[i]);
|
||||
emit('i', std::string("profile ") + (p[0] & kSearchProfileOff ? "OFF" : "active") + "; as SetSearchProfile([" + list + "])");
|
||||
};
|
||||
auto manager_slot = [market] { return market().manager_slot; };
|
||||
add({"Transfer", "ShowSearchProfile", {}, "SUCHEN: your search profile (18 values; positions, age, strength, attributes, sides, price classes)", false},
|
||||
[this, manager_slot, show_profile](const Values&) { show_profile(session_->search_profile(manager_slot()), "Search profile"); });
|
||||
add({"Transfer", "SuggestSearchProfile", {boolean("whole", true), boolean("apply", true)},
|
||||
"VORSCHLAG: the profile your squad asks for (whole = count the substitutes); apply = store it and list the matches", false},
|
||||
[this, manager_slot, show_profile, flush_notices](const Values& v) {
|
||||
const int manager = manager_slot();
|
||||
const auto suggestion = session_->suggest_search_profile(manager, v.boolean("whole", false));
|
||||
show_profile(suggestion, "Suggestion");
|
||||
if (v.boolean("apply", false)) {
|
||||
std::string error;
|
||||
const auto result = session_->dispatch_search_profile(manager, suggestion, false, true, revision_, error);
|
||||
if (!result) require_engine(false, "search profile", error);
|
||||
emit('i', utf8(message_text(session_->state(), ::bmh::layout::Month_SearchProfileNews_TextPointer4)));
|
||||
emit('+', std::to_string(result->hits.size()) + " listed player(s) fit the profile");
|
||||
for (const auto& hit : result->hits) emit('i', utf8(hit.message));
|
||||
}
|
||||
});
|
||||
Param profile_values = detail::text("values");
|
||||
profile_values.display = "values:[18 numbers] (see ShowSearchProfile)";
|
||||
add({"Transfer", "SetSearchProfile", {profile_values, boolean("apply", true)},
|
||||
"SUCHEN: store the search profile (the 18 values of ShowSearchProfile, switches 0/1, age 0..24 = 16..40, strength 0..99); apply = list the matches now", false},
|
||||
[this, manager_slot, show_profile](const Values& v) {
|
||||
std::string list = v.text("values");
|
||||
if (list.size() >= 2 && list.front() == '[' && list.back() == ']') list = list.substr(1, list.size() - 2);
|
||||
SearchProfile profile{};
|
||||
size_t count = 0, start = 0;
|
||||
while (start <= list.size()) {
|
||||
const size_t comma = list.find(',', start);
|
||||
std::string item = list.substr(start, comma == std::string::npos ? std::string::npos : comma - start);
|
||||
item.erase(0, item.find_first_not_of(' '));
|
||||
item.erase(item.find_last_not_of(' ') + 1);
|
||||
if (item.empty() || item.find_first_not_of("0123456789") != std::string::npos || item.size() > 3)
|
||||
fail("E_BAD_ARGUMENT", "the profile values are numbers separated by commas");
|
||||
if (count >= profile.size()) fail("E_BAD_ARGUMENT", "the profile has 18 values");
|
||||
profile[count++] = uint8_t(std::min(255, std::stoi(item)));
|
||||
if (comma == std::string::npos) break;
|
||||
start = comma + 1;
|
||||
}
|
||||
if (count != profile.size()) fail("E_BAD_ARGUMENT", "the profile has 18 values, not " + std::to_string(count));
|
||||
if (!search_profile_valid(profile))
|
||||
fail("E_BAD_ARGUMENT", "switches are 0 or 1, the age values 0..24 and the strength values 0..99");
|
||||
std::string error;
|
||||
const auto result = session_->dispatch_search_profile(manager_slot(), profile, false, v.boolean("apply", true), revision_, error);
|
||||
if (!result) require_engine(false, "search profile", error);
|
||||
emit('+', result->active ? "search profile stored"
|
||||
: "search profile stored but switched off (all values 0 or all 1 count as no search)");
|
||||
if (v.boolean("apply", true)) {
|
||||
emit('i', utf8(message_text(session_->state(), ::bmh::layout::Month_SearchProfileNews_TextPointer4)));
|
||||
emit('+', std::to_string(result->hits.size()) + " listed player(s) fit the profile");
|
||||
for (const auto& hit : result->hits) emit('i', utf8(hit.message));
|
||||
}
|
||||
});
|
||||
|
||||
// the rest of the market (06-verein 5): later steps of stage 3 or engine gaps
|
||||
for (const char* name : {"SetSquadView", "SetSquadSheet", "SetMarketVisible", "ShowPlayer", "OpenOffers", "OpenSearch",
|
||||
for (const char* name : {"SetSquadView", "SetSquadSheet", "SetMarketVisible", "ShowPlayer", "OpenOffers",
|
||||
"ShowTransferNews", "ShowTeamInfo"})
|
||||
add({"Transfer", name, {}, "not in the console yet", false},
|
||||
[name](const Values&) { fail("E_ENGINE_GAP", std::string(name) + " is not in the console yet"); });
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Implementation of parse_json()/dump_json() (json.hpp): a small recursive-descent Parser
|
||||
// over a string_view that reports the byte position in JsonError messages, UTF-8 handling
|
||||
// for string escapes, and a serializer for the Json variant. No state beyond the parser's
|
||||
// position in the input.
|
||||
#include "cli/json.hpp"
|
||||
|
||||
#include <charconv>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Minimal JSON value type for the CLI protocol (no external library). A Json holds null,
|
||||
// bool, a 64-bit integer, string, array or object (std::map) in one std::variant; the
|
||||
// accessors return null pointers when the type does not match, so callers must check.
|
||||
// Numbers are integers only. parse_json() throws JsonError on bad input; dump_json() writes
|
||||
// compact text. Used by protocol.*, seat_hub.cpp and main.cpp; implemented in json.cpp.
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Entry point of openbmh_cli, the headless front end without a window. Besides parsing the
|
||||
// command line (Arguments) it offers several modes on top of the same engine: the JSON
|
||||
// protocol on stdin/stdout (protocol.hpp) with --log/--replay, the console language
|
||||
// (docs/CLI_CONCEPT) as plain session, replay, mailbox server (--serve), multi-seat server
|
||||
// (--seats, SeatHub), TCP listener on 127.0.0.1 (--listen), and --send to hand one block to
|
||||
// a running mailbox session. --data may be a game directory, the game's EXE or an archive
|
||||
// (src/launch resolves it). All game logic stays in the engine; this file only moves lines.
|
||||
#include "cli/protocol.hpp"
|
||||
#include "cli/console/console.hpp"
|
||||
#include "cli/seat_hub.hpp"
|
||||
|
||||
Loaded 100 of 560 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user