Merge main into foundation (stadium limits, test fixtures)

This commit is contained in:
Claude committed 2026-11-10 14:23:41 +01:00
commit e174f99594
8 files changed
+52 -54

No files matched your search

+2 -2
View File
@@ -397,8 +397,8 @@ PreparationState flow_fixture(const LeImage& exe) {
PreparationState state;
auto& d = state.desktop;
d.source = "engine_projection"; d.revision = 7;
d.manager_slot = 0; d.runtime_club = 12; d.club_name = "BAYERN"; d.manager_name = "Nobody";
d.manager_teams = {12}; d.managers = {{12,12,0,0,0,"Nobody"}};
d.manager_slot = 0; d.runtime_club = 12; d.club_name = "BAYERN"; d.manager_name = "OpenBMH"; // the default name the manager dialog offers
d.manager_teams = {12}; d.managers = {{12,12,0,0,0,"OpenBMH"}};
d.league = 0; d.portrait = 0; d.date = desk_date(0, exe); d.strength = 80;
d.options.managers = 1; d.options.world = false; d.options.league = true;
d.automation[4] = 0x9f;
+17 -17
View File
@@ -139,10 +139,10 @@ void assert_key_source_cell(const StadiumScreen& screen, const std::filesystem::
constexpr std::array<uint32_t, 8> kPrices{300000, 375000, 300000, 350000,
300000, 375000, 300000, 350000};
// Match the retained 144k expansion policy and size-aware construction periods.
constexpr std::array<uint32_t, 8> kMaxima{14000, 24000, 14000, 20000,
14000, 24000, 14000, 20000};
constexpr std::array<uint8_t, 8> kWeeks{30, 48, 30, 40, 30, 48, 30, 40};
// The limits and construction periods of Diamond 3.7 (96,000 places in total).
constexpr std::array<uint32_t, 8> kMaxima{8000, 18000, 8000, 14000,
8000, 18000, 8000, 14000};
constexpr std::array<uint8_t, 8> kWeeks{30, 37, 30, 25, 30, 37, 30, 25};
StadiumBlockExpansionEditor editor_for(uint8_t slot = 1, uint32_t total = 8000,
uint8_t features = 0, uint8_t raw_flags = 0) {
@@ -293,7 +293,7 @@ void row_hit_tests(const std::filesystem::path& data) {
StadiumScreen screen(data, state);
const auto request = screen.click(250, 22 + slot * 24 + 3);
check(request.kind == StadiumRequestKind::expansion_select && request.block_slot == slot,
"the eight Source block rows map to the eight A–H slots");
"the eight Source block rows map to the eight A–H slots");
check(!request.expected_block_quote && request.block_total_places == 0 && request.block_features == 0,
"Source entry carries only the selected slot before the App quote projection");
}
@@ -304,7 +304,7 @@ void row_hit_tests(const std::filesystem::path& data) {
check(screen.click(140, 219).kind == StadiumRequestKind::none,
"the current/future footer control is a local presentation action");
check(screen.click(250, 22 + 2 * 24 + 3).kind == StadiumRequestKind::expansion_select,
"future-information view leaves idle A–H rows editable");
"future-information view leaves idle A–H rows editable");
auto select_state = overview_state();
select_state.blocks[1].capacity_level = 8; select_state.blocks[1].capacity = 8;
@@ -419,7 +419,7 @@ void source_textd_stadium_caption_tests(const std::filesystem::path& data) {
assert_text_pixels(editor_image, font, 5, 130, text(::bmh::layout::Stadium_RenderBlockExpansion_TextPointer9), 0x6a,
"block editor paints the Original TEXTD total-cost label");
const std::string duration = format_number(GameState{}, 48, 0x82) + text(::bmh::layout::Stadium_FormatError_RuntimeField) +
const std::string duration = format_number(GameState{}, 37, 0x82) + text(::bmh::layout::Stadium_FormatError_RuntimeField) +
exe.cstring(::bmh::layout::Stadium_FormatError_ExecutableField) + exe.cstring(::bmh::layout::CareerSession_FormatNumber_ExecutableField);
const int duration_x = 148 - font.text_width(duration);
assert_text_pixels(editor_image, font, duration_x, 54, duration, 0x6c,
@@ -646,7 +646,7 @@ void source_table_and_ack_tests(const std::filesystem::path& data) {
auto returned = cancelled.state(); next_identity(returned); returned.block_expansion.reset();
cancelled.acknowledge(returned);
check(cancel.kind == StadiumRequestKind::expansion_cancel && !cancelled.state().block_expansion,
"a valid quote-bound cancel ACK returns to the A–H overview");
"a valid quote-bound cancel ACK returns to the A–H overview");
}
void calculator_tests(const std::filesystem::path& data) {
@@ -690,7 +690,7 @@ void calculator_tests(const std::filesystem::path& data) {
check(screen.calculator_open(), "host can query calculator visibility without reading or mutating Native");
assert_readout_source_text(screen, data, format_number(GameState{}, 0, 7),
"initial calculator readout matches Original width-seven FNT3 glyphs");
assert_preset_source_cell(screen, data, exe, 7, 24000);
assert_preset_source_cell(screen, data, exe, 7, 18000);
const Image before = screen.render();
check(screen.pointer_down(116, 36), "the calculator header starts a Source drag");
screen.pointer_move(1000, 1000);
@@ -760,7 +760,7 @@ void calculator_tests(const std::filesystem::path& data) {
"preset selection changes the value without the keypad's invented pressed phase");
const auto preset_accept = keyboard_return_after_source_phase(preset);
check(preset_accept.kind == StadiumRequestKind::expansion_set_total &&
preset_accept.block_total_places == 24000,
preset_accept.block_total_places == 18000,
"a preset value remains usable through the timed Source J action");
StadiumScreen low_total(data, detail_state());
@@ -775,7 +775,7 @@ void calculator_tests(const std::filesystem::path& data) {
high_total.click(50, 80);
check(high_total.text("999999"), "large typed input is accepted and clamped to Source maximum");
const auto maximum = keyboard_return_after_source_phase(high_total);
check(maximum.kind == StadiumRequestKind::expansion_set_total && maximum.block_total_places == 24000,
check(maximum.kind == StadiumRequestKind::expansion_set_total && maximum.block_total_places == 18000,
"calculator input never exceeds the slot-B maximum");
StadiumScreen reopened(data, detail_state(1, 15333, 1));
@@ -783,7 +783,7 @@ void calculator_tests(const std::filesystem::path& data) {
check(reopened.text("1"), "reopened calculator accepts another appended digit");
const auto appended = keyboard_return_after_source_phase(reopened);
check(appended.kind == StadiumRequestKind::expansion_set_total &&
appended.block_total_places == 24000,
appended.block_total_places == 18000,
"reopening starts from D=7333 and appends instead of replacing it with the first digit");
StadiumScreen zeroes(data, detail_state());
@@ -904,12 +904,12 @@ void offer_ack_tests(const std::filesystem::path& data) {
auto no_build = no_screen.state(); next_identity(no_build);
const auto no_quote = no_build.block_expansion->quote;
no_build.block_expansion.reset(); no_build.construction_tip_dialog.reset();
no_build.blocks[1].construction_weeks = 48;
no_build.blocks[1].construction_weeks = 37;
no_build.blocks[1].flags = uint8_t(no_build.blocks[1].flags | 0x10);
no_build.blocks[1].capacity = 15;
no_build.balance -= int32_t(no_quote.base_price);
no_screen.acknowledge(no_build);
check(!no_screen.pending() && no_screen.state().blocks[1].construction_weeks == 48,
check(!no_screen.pending() && no_screen.state().blocks[1].construction_weeks == 37,
"a valid NO decision constructs at the original base price and full duration");
auto poor = initial;
@@ -1035,7 +1035,7 @@ void source_compensation_ack_tests(const std::filesystem::path& data) {
"negative-week compensation path can take the ordinary NO construction");
const auto no_offer = *negative_weeks.state().block_expansion->offer;
const int32_t negative_compensation = -66000; // 11,000 * (17-20) * rate 2.
negative_weeks.acknowledge(completed_build_state(negative_weeks, 48,
negative_weeks.acknowledge(completed_build_state(negative_weeks, 37,
late.balance - int32_t(no_offer.base_price) - negative_compensation, 14000));
check(negative_weeks.state().balance == late.balance - int32_t(no_offer.base_price) + 66000,
"negative Source weeks credit the account while the ticket cap still applies");
@@ -1047,7 +1047,7 @@ void source_compensation_ack_tests(const std::filesystem::path& data) {
check(!no_account_booking.click(210, 171).accept_tip,
"level-zero Source path can accept a normal NO construction");
const auto level_zero_offer = *no_account_booking.state().block_expansion->offer;
no_account_booking.acknowledge(completed_build_state(no_account_booking, 48,
no_account_booking.acknowledge(completed_build_state(no_account_booking, 37,
level_zero.balance, 14000));
check(no_account_booking.state().balance == level_zero.balance &&
no_account_booking.state().season_tickets == 14000 &&
@@ -1213,7 +1213,7 @@ int main(int argc, char** argv) try {
calculator_tests(data);
offer_ack_tests(data);
source_compensation_ack_tests(data);
std::cout << "Source-valid A–H tables, calculator phases, compensation ACKs, and plain-manager tip retry checks passed\n";
std::cout << "Source-valid A–H tables, calculator phases, compensation ACKs, and plain-manager tip retry checks passed\n";
return 0;
} catch (const std::exception& e) {
std::cerr << "stadium_block_ui_tests: " << e.what() << '\n';
+9 -6
View File
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
// The stadium block limits come from the edition unchanged (Diamond 3.7: 96,000 places in total).
// The file keeps its historical name: until 1.0.12 it tested the withdrawn 144,000 place extension.
#include "game/stadium_blocks.hpp"
#include "formats/le.hpp"
#include <iostream>
@@ -13,11 +15,12 @@ int main()try{
const uint8_t original_max[]={8,18,8,14,8,18,8,14},original_weeks[]={30,37,30,25,30,37,30,25};
for(uint32_t i=0;i<8;++i){image.patch(layout::CareerSession_Invalid_RuntimeField+i,original_max+i,1);image.patch(layout::CareerSession_DispatchStadium_RuntimeField2+(i+22)*5,original_weeks+i,1);const uint8_t price[]={0xe0,0x93,0x04,0};image.patch(layout::CareerSession_DispatchStadium_RuntimeField+(i+8)*4,price,4);}
const auto constants=stadium_block_expansion_constants(image);
check(constants.max_places==std::array<uint32_t,8>{14000,24000,14000,20000,14000,24000,14000,20000},"expanded block limits differ");
check(std::accumulate(constants.max_places.begin(),constants.max_places.end(),0u)==144000,"full stadium does not reach144k");
check(constants.weeks==std::array<uint8_t,8>{30,48,30,40,30,48,30,40},"larger block duration is not scaled with size");
check(constants.max_places==std::array<uint32_t,8>{8000,18000,8000,14000,8000,18000,8000,14000},"block limits are not the edition's");
check(std::accumulate(constants.max_places.begin(),constants.max_places.end(),0u)==96000,"a full Diamond 3.7 stadium does not have 96,000 places");
check(constants.weeks==std::array<uint8_t,8>{30,37,30,25,30,37,30,25},"construction weeks are not the edition's");
check(constants.price_per_1000[0]==300000&&constants.price_per_1000[7]==300000,"edition unit prices were replaced");
const uint8_t custom=20;image.patch(layout::CareerSession_Invalid_RuntimeField,&custom,1);check(stadium_block_expansion_constants(image).max_places[0]==20000,"larger supplied custom stand was reduced");
const uint8_t unsupported=255;image.patch(layout::CareerSession_Invalid_RuntimeField,&unsupported,1);bool rejected=false;try{stadium_block_expansion_constants(image);}catch(const FormatError&){rejected=true;}check(rejected,"unrepresentable capacity/duration accepted");
std::cout<<"144k stadium policy, edition prices, capacity-based weeks, custom floors and saved byte limits passed\n";
// an edition (or edited data) with other limits is taken as supplied
const uint8_t custom=20;image.patch(layout::CareerSession_Invalid_RuntimeField,&custom,1);check(stadium_block_expansion_constants(image).max_places[0]==20000,"a supplied custom limit was changed");
const uint8_t unsupported=255;image.patch(layout::CareerSession_Invalid_RuntimeField,&unsupported,1);bool rejected=false;try{stadium_block_expansion_constants(image);}catch(const FormatError&){rejected=true;}check(rejected,"limits beyond the saved capacity byte accepted");
std::cout<<"96,000 place stadium of the edition, edition prices and weeks, custom limits and saved byte limit passed\n";
}catch(const std::exception& error){std::cerr<<error.what()<<'\n';return 1;}