diff --git a/CMakeLists.txt b/CMakeLists.txt index 757d754..d528312 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -964,6 +964,7 @@ bmh_add_data_test(NAME league_views_data_tests COMMAND league_views_data_tests " # FLTD is translated by launch_check/the launcher first. Do not point these # tests at the raw DOS directory: the shared UI consumes the prepared image. set(BMH_ENGLISH_DATA "" CACHE PATH "Prepared Football Limited game-data directory") +bmh_add_data_test(NAME english_environment_controller_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND app_controller_tests "${BMH_ENGLISH_DATA}" --environment-only) bmh_add_data_test(NAME english_edition_startup_app_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND edition_startup_app_tests "${BMH_ENGLISH_DATA}") bmh_add_data_test(NAME english_pairings_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_pairings_data_tests "${BMH_ENGLISH_DATA}") bmh_add_data_test(NAME english_desktop_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND desktop_data_tests "${BMH_ENGLISH_DATA}" --english) @@ -1149,6 +1150,9 @@ foreach(dependency IN ITEMS SDL2 miniz lzma_sdk nfd) endforeach() file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/package-dependencies.json" CONTENT "${package_dependencies}\n") +add_executable(environment_profile_tests tests/environment_profile_tests.cpp) +target_link_libraries(environment_profile_tests PRIVATE bmhcore) +add_test(NAME environment_profile_tests COMMAND environment_profile_tests) add_executable(classic_rules_unit_tests tests/classic_rules_unit_tests.cpp) target_link_libraries(classic_rules_unit_tests PRIVATE bmhcore) add_test(NAME classic_rules_unit_tests COMMAND classic_rules_unit_tests) diff --git a/docs/COMPATIBILITY.md b/docs/COMPATIBILITY.md index dc8838b..bb31068 100644 --- a/docs/COMPATIBILITY.md +++ b/docs/COMPATIBILITY.md @@ -27,7 +27,7 @@ normal completed-career handling remains separate. 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. 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. diff --git a/docs/DIFFERENCES.md b/docs/DIFFERENCES.md index a7fbf9f..afa46f4 100644 --- a/docs/DIFFERENCES.md +++ b/docs/DIFFERENCES.md @@ -13,6 +13,7 @@ describe deliberate changes; they are not a list of every known compatibility li - [src/game/desk_actions.cpp](../src/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields. - [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): supports designated set-piece records and the supported transfer-editor rules. - [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): a seller may accept an existing bid before expiry. +- [src/game/environment.cpp](../src/game/environment.cpp): the common Diamond 3.7 monthly environment model applies to every supported source-data edition. - [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image. - [src/game/lineup.hpp](../src/game/lineup.hpp): supports owner-bound designated set-piece selection. - [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules. diff --git a/src/game/environment.cpp b/src/game/environment.cpp index ecd537d..dbd36dd 100644 --- a/src/game/environment.cpp +++ b/src/game/environment.cpp @@ -33,18 +33,16 @@ uint32_t academy_paid(const GameState& g, int manager) { } } void install_environment_rules(const LeImage& exe) { - for (size_t i=0;i= value); } EnvironmentState environment_state(const GameState& g, int manager) { - if (!supported_environment) throw FormatError("environment: this original program variant is not verified"); + if (!supported_environment) throw FormatError("environment: monthly budget steps are missing or invalid"); validate_manager(g, manager); EnvironmentState result; for (int i = 0; i < kEnvironmentItems; ++i) { diff --git a/src/game/environment.hpp b/src/game/environment.hpp index 120d227..9f99e66 100644 --- a/src/game/environment.hpp +++ b/src/game/environment.hpp @@ -8,13 +8,13 @@ #include "game/state.hpp" namespace bmh { -// Verified original-program capability; unknown environment variants are not guessed. +// Install validated numeric steps for the common Diamond 3.7 monthly model. void install_environment_rules(const LeImage&); bool environment_rules_supported(); constexpr int kEnvironmentItems = 6; enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2, kCoTrainer = 3, kDoctor = 4, kPhysio = 5 }; -// Monthly environment model verified in the supported CD and Diamond 3.6/3.7 programs. +// Canonical monthly environment model; source editions supply compatible data. inline std::array kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000}; struct EnvironmentState { std::array monthly{}; diff --git a/src/launch/fltd.cpp b/src/launch/fltd.cpp index 669b0da..488e0fb 100644 --- a/src/launch/fltd.cpp +++ b/src/launch/fltd.cpp @@ -3,6 +3,7 @@ #include "launch/fltd.hpp" #include +#include #include #include #include @@ -129,6 +130,12 @@ LeImage translate_fltd(const fs::path& fltd_exe) { for (uint32_t i = 0; i < 11 * 11; ++i) put(::bmh::layout::OriginalPointerPixels + i, en(::bmh::layout::EnglishOriginalPointerPixels + i)); + // Copy the actual English six-budget geometry, numeric steps and suffixes + // for the common monthly environment model. + for(const auto [to,from,count]:{std::array{layout::Environment_FormatError_RuntimeField,0x6d230,6}, + {layout::Environment_FormatError_RuntimeField2,0x6d238,6},{layout::EnvironmentYouthColors,0x6d240,3}, + {layout::EnvironmentBudgetSteps,0x6d244,6},{layout::EnvironmentYouthPositionSuffix,0x6d24a,5}, + {layout::EnvironmentCostSuffix,0x6d24f,2}})for(uint32_t i=0;i tabs{"DATEN-A", "DATEN-B", "GEHALT", "TEAM-PRÄMIEN"}; + const std::array tabs{original_to_utf8(texts_[117]),original_to_utf8(texts_[118]),original_to_utf8(texts_[119]),original_to_utf8(texts_[120])}; for (int i = 0; i < (state_.mode_three?4:3); ++i) { const int x = i * 60 + 2, w = i == 3 ? 71 : 51; if(i!=tab_) {fill(out,x+2,225,w,2,0x40);fill(out,x+w,217,2,10,0x40);} diff --git a/src/ui/contracts_tests.cpp b/src/ui/contracts_tests.cpp index 7455e0e..2c491fd 100644 --- a/src/ui/contracts_tests.cpp +++ b/src/ui/contracts_tests.cpp @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only #include "ui/contracts.hpp" #include "ui/source_notice_test_helpers.hpp" +#include "ui/manager.hpp" +#include "formats/executable_layout.hpp" +#include "formats/textd.hpp" #include @@ -23,6 +26,20 @@ int main(int argc, char** argv) { state.club_name = "UNIT FOOTBALL CLUB"; state.players.push_back({0, 150, "TORWART", 25, 0, 8, 180000}); state.players.push_back({1, 151, "STÜRMER", 21, 3, 14, 90000}); + { + auto language_state=state;language_state.mode_three=true; + ContractsScreen language(argv[1],language_state);const auto frame=language.render(); + const auto data=std::filesystem::path(argv[1]);const auto exe=bmh::load_le(asset_path(data,"BMH.exe")); + const auto texts=bmh::load_textd(asset_path(data,"TEXTD.BLK"));SpriteFont source_font(data); + for(int tab=0;tab<4;++tab) { + const auto caption=original_to_utf8(texts[size_t(117+tab)]);const int width=tab==3?71:51; + const int x=tab*60+2+(tab==2?2:0),y=215+(tab==2?2:0); + bmh::Image expected(320,240,0xfd); + source_font.draw(expected,x+width/2-source_font.text_width(caption)/2,y+7,caption,exe.u8(bmh::layout::Advertising_Button_RuntimeField+(tab==2))); + size_t ink=0;for(size_t pixel=0;pixel10,"source-language contract tab oracle contains no glyphs"); + } + } auto blocked_state = state; blocked_state.players[0].offer_blocked = true; ContractsScreen blocked(argv[1], blocked_state); diff --git a/src/ui/environment.cpp b/src/ui/environment.cpp index b7fd281..c8a42da 100644 --- a/src/ui/environment.cpp +++ b/src/ui/environment.cpp @@ -157,6 +157,8 @@ EnvironmentScreen::EnvironmentScreen(const std::filesystem::path& data, Environm background_.height != 240 || tiles_.width != 306 || tiles_.height != 111 || panel_.width <= 0 || texts_.strings.size() != TEXT_COUNT) throw FormatError("environment: unsupported owner or Original assets"); + for(int item=0;item=320||y<10||y+0x31+(item<3?6:0)>=240)throw FormatError("environment: tile geometry outside Original screen");} } void EnvironmentScreen::text(Image& out, int x, int baseline, std::string_view value, diff --git a/tests/environment_profile_tests.cpp b/tests/environment_profile_tests.cpp new file mode 100644 index 0000000..2069125 --- /dev/null +++ b/tests/environment_profile_tests.cpp @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include "formats/executable_layout.hpp" +#include "game/environment.hpp" +#include +#include + +using namespace bmh; +namespace {void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}} +int main()try { + const std::array source{2,4,5,5,5,5}; + auto image=LeImage::from_bytes(layout::EnvironmentBudgetSteps,Bytes(source.begin(),source.end())); + install_environment_rules(image); + check(environment_rules_supported()&&kEnvironmentStep==std::array{2000,4000,5000,5000,5000,5000}, + "valid source steps require the common model without original instructions"); + const auto previous=kEnvironmentStep; + auto missing=LeImage::from_bytes(layout::EnvironmentBudgetSteps,Bytes(source.begin(),source.end()-1)); + install_environment_rules(missing);check(!environment_rules_supported()&&kEnvironmentStep==previous,"missing final step partially installed"); + auto malformed=image;const uint8_t changed=9;malformed.patch(layout::EnvironmentBudgetSteps,&changed,1);const uint8_t zero=0;malformed.patch(layout::EnvironmentBudgetSteps+3,&zero,1); + install_environment_rules(malformed);check(!environment_rules_supported()&&kEnvironmentStep==previous,"zero step partially installed"); + install_environment_rules(image);check(environment_rules_supported()&&kEnvironmentStep==previous,"valid profile could not recover after rejected input"); + GameState state;state.memory.add_block(layout::Spending,4*0x24); + state.memory.set32(layout::Spending,12000);state.memory.set32(layout::Spending+4,24000); + check(environment_monthly_cost(state,0,0)==12000&&environment_monthly_cost(state,0,1)==24000,"common profile changed owned monthly budgets"); + std::cout<<"Common Diamond3.7 monthly model accepts valid data without instruction provenance and rejects malformed numeric steps atomically\n"; + return 0; +}catch(const std::exception& e){std::cerr<