Use the common 3.7 environment model and source-language contract tabs (by Codex)

This commit is contained in:
Codex committed 2026-11-02 23:15:49 +01:00
1 parent 249bdca1a8
commit 048f617395
11 files changed
+72 -17

No files matched your search

+4
View File
@@ -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)
+1 -1
View File
@@ -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.
+1
View File
@@ -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.
+10 -12
View File
@@ -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<kEnvironmentStep.size();++i) {
const uint32_t at=layout::EnvironmentBudgetSteps+uint32_t(i);
if (!exe.contains(at) || exe.u8(at)==0) { supported_environment=false; return; }
kEnvironmentStep[i]=int32_t(exe.u8(at))*1000;
// OpenBMH deviates from the original: the common Diamond 3.7 monthly
// environment model applies to every supported source-data edition.
// Numeric steps are data; an edition's original instructions are not run.
auto steps=kEnvironmentStep;
for(size_t i=0;i<steps.size();++i) {
const auto at=layout::EnvironmentBudgetSteps+uint32_t(i);
if(!exe.contains(at)||exe.u8(at)==0){supported_environment=false;return;}
steps[i]=int32_t(exe.u8(at))*1000;
}
uint64_t fingerprint = 14695981039346656037ull;
for (const auto [first,last] : {std::pair{layout::EnvironmentVerifiedCodeBegin,layout::EnvironmentVerifiedCodeEnd},std::pair{layout::EnvironmentVerifiedHookBegin,layout::EnvironmentVerifiedHookEnd}}) {
if (!exe.contains(first) || !exe.contains(last-1)) { supported_environment=false; return; }
for (uint32_t at=first;at<last;++at) fingerprint=(fingerprint ^ exe.u8(at))*1099511628211ull;
}
// Fingerprints identify verified behaviour, not filenames, dates or artwork.
supported_environment = fingerprint==0xc2488a656f340e99ull || fingerprint==0x19adba7ef3eda507ull;
kEnvironmentStep=steps;supported_environment=true;
}
bool environment_rules_supported() { return supported_environment; }
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
@@ -57,7 +55,7 @@ bool environment_academy_active(const GameState& g, int manager) {
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= 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) {
+2 -2
View File
@@ -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<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
struct EnvironmentState {
std::array<int32_t, kEnvironmentItems> monthly{};
+7
View File
@@ -3,6 +3,7 @@
#include "launch/fltd.hpp"
#include <algorithm>
#include <array>
#include <cstring>
#include <fstream>
#include <stdexcept>
@@ -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<uint32_t,3>{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<count;++i)put(to+i,en(from+i));
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
return out;
}
+1 -1
View File
@@ -379,7 +379,7 @@ ResolvedGame resolve_game(const fs::path& input, const fs::path& cache) {
const fs::path marker = prepared / ".openbmh-english";
// the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built
// by another version is built again
constexpr const char* kTranslation = "english translation 16"; // 16: overwrite question pointer (15: original pitch affinity tables and pointer bitmap)
constexpr const char* kTranslation = "english translation 17"; // 17: English monthly environment tables (16: overwrite question)
std::string built;
{
std::ifstream in(marker);
+1 -1
View File
@@ -396,7 +396,7 @@ Image ContractsScreen::render() const {
}
const auto selected = std::find_if(state_.players.begin(), state_.players.end(),
[&](const auto& p) { return p.row == state_.selected_row; });
static constexpr std::array<std::string_view, 4> tabs{"DATEN-A", "DATEN-B", "GEHALT", "TEAM-PRÄMIEN"};
const std::array<std::string,4> 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);}
+17
View File
@@ -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 <stdexcept>
@@ -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;pixel<expected.pixels.size();++pixel)if(expected.pixels[pixel]!=0xfd){check(frame.pixels[pixel]==expected.pixels[pixel],"contract tab does not render its authoritative source-language caption");++ink;}
check(ink>10,"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);
+2
View File
@@ -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<kEnvironmentItems;++item){const int x=exe_.u8(layout::Environment_FormatError_RuntimeField+item),y=exe_.u8(layout::Environment_FormatError_RuntimeField2+item);
if(x<9||x+0x36>=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,
+26
View File
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include <iostream>
#include <stdexcept>
using namespace bmh;
namespace {void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}}
int main()try {
const std::array<uint8_t,6> 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<int32_t,6>{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<<e.what()<<'\n';return 1;}