diff --git a/CMakeLists.txt b/CMakeLists.txt index dbbca81..7171780 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -340,6 +340,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) diff --git a/docs/COMPATIBILITY.md b/docs/COMPATIBILITY.md index 7cab596..fa37de9 100644 --- a/docs/COMPATIBILITY.md +++ b/docs/COMPATIBILITY.md @@ -53,3 +53,18 @@ Older drawing gates retain their own behaviour; no external crest pack is needed The automatic lineup installs the supplied foreign-player rule switch alongside the career tables. Where enabled, it restores the original three/two-player limit, reserve swaps with board-coordinate preservation and the short-lineup outcome when domestic reserves are unavailable. This does not consume additional random draws. New careers correct the original all-zero EM qualification placeholders to the original national-team placeholders. Supplied nonzero seeds and restored savegame state are not rewritten by this initialization. + +## Stadium extension in1.0.3 + +The user-requested stadium extension raises standard A–H maxima to14/24/14/20/ +14/24/14/20thousand places (144,000total), keeping larger supplied custom limits +where the saved byte fields can represent them. Original unit prices remain +edition-owned. Each stand's base build period is at least two weeks per1,000 +places of its expanded maximum and never shorter than the edition's original +period. Contractor shortening remains unchanged. + +The original Diamond3.6/3.7 table's14k stands really used25weeks versus30weeks +for8k and37weeks for18k. That was original data, not a mistaken timer. Expanded +limits/time policy is an intentional improvement. The UI now validates quotes +against the actual edition and this shared policy rather than hardcoded Diamond +prices and sizes. Existing eight capacity/construction bytes and saves are retained. diff --git a/src/app/career_session.cpp b/src/app/career_session.cpp index 006ece8..356d9cd 100644 --- a/src/app/career_session.cpp +++ b/src/app/career_session.cpp @@ -8105,12 +8105,7 @@ bool CareerSession::dispatch_stadium(const ui::StadiumRequest& supplied_request, if (request.object != -1 || request.option != -1 || request.price != 0 || (request.kind != ui::StadiumRequestKind::expansion_answer_tip && request.accept_tip)) return invalid("invalid_block_expansion_envelope"); - StadiumBlockExpansionConstants block_constants; - for (unsigned i = 0; i < 8; ++i) { - block_constants.price_per_1000[i] = exe_.u32(::bmh::layout::CareerSession_DispatchStadium_RuntimeField + (i + 8) * 4); - block_constants.weeks[i] = exe_.u8(::bmh::layout::CareerSession_DispatchStadium_RuntimeField2 + (i + 22) * 5); - block_constants.max_places[i] = uint32_t(exe_.u8(::bmh::layout::CareerSession_Invalid_RuntimeField + i)) * 1000; - } + const auto block_constants=stadium_block_expansion_constants(exe_); const auto quote_block = [&](StadiumBlockSlot slot, uint32_t total, uint8_t features) { return quote_stadium_block_expansion(g_, active, slot, total, features, stadium_.price_percent, block_constants); diff --git a/src/game/stadium_blocks.cpp b/src/game/stadium_blocks.cpp index 4d392e1..0960975 100644 --- a/src/game/stadium_blocks.cpp +++ b/src/game/stadium_blocks.cpp @@ -2,6 +2,7 @@ #include "game/stadium_blocks.hpp" #include "game/matchday.hpp" +#include "formats/le.hpp" #include #include @@ -63,6 +64,19 @@ bool valid_resolved_offer(const StandBlockOffer& offer, const StadiumBlockExpans } } // namespace +StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage& image){ + static constexpr std::array minima{14000,24000,14000,20000,14000,24000,14000,20000}; + StadiumBlockExpansionConstants out;uint32_t total=0; + for(size_t i=0;i<8;++i){out.price_per_1000[i]=image.u32(layout::CareerSession_DispatchStadium_RuntimeField+uint32_t((i+8)*4)); + const auto original=uint32_t(image.u8(layout::CareerSession_Invalid_RuntimeField+uint32_t(i)))*1000; + out.max_places[i]=std::max(original,minima[i]);total+=out.max_places[i]; + const auto source_weeks=image.u8(layout::CareerSession_DispatchStadium_RuntimeField2+uint32_t((i+22)*5)); + const auto weeks=std::max(source_weeks,2*(out.max_places[i]/1000)); + if(weeks>255)throw FormatError("stadium: expanded construction period exceeds saved byte");out.weeks[i]=uint8_t(weeks); + } + if(total>255000)throw FormatError("stadium: combined stand limits exceed saved capacity byte");return out; +} + std::optional quote_stadium_block_expansion( const GameState& g, int manager, StadiumBlockSlot slot, uint32_t total_target_places, uint8_t desired_features, int company_price_percent, diff --git a/src/game/stadium_blocks.hpp b/src/game/stadium_blocks.hpp index 671ea06..8da2a94 100644 --- a/src/game/stadium_blocks.hpp +++ b/src/game/stadium_blocks.hpp @@ -20,6 +20,10 @@ struct StadiumBlockExpansionConstants { std::array max_places{}; }; +// OpenBMH1.0.3 expands standard A-H limits to at least144k total. Prices +// still come from the edition; larger blocks have at least2weeks per1000places. +StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage&); + // An immutable quote binds the Source owner and every record/table value that // affects the quote. Commit recomputes this value before it touches money. struct StadiumBlockExpansionQuote { diff --git a/src/ui/stadium.cpp b/src/ui/stadium.cpp index 552cee2..9813075 100644 --- a/src/ui/stadium.cpp +++ b/src/ui/stadium.cpp @@ -181,12 +181,8 @@ bool same_block_quote_owner(const StadiumBlockExpansionQuote& a, a.max_places == b.max_places && a.base_weeks == b.base_weeks; } bool canonical_block_quote(const StadiumBlockExpansionQuote& q, uint32_t total, - uint8_t features) { - static constexpr std::array prices{ - 300000, 375000, 300000, 350000, 300000, 375000, 300000, 350000}; - static constexpr std::array maxima{ - 8000, 18000, 8000, 14000, 8000, 18000, 8000, 14000}; - static constexpr std::array weeks{30, 37, 30, 25, 30, 37, 30, 25}; + uint8_t features,const StadiumBlockExpansionConstants& constants) { + const auto& prices=constants.price_per_1000;const auto& maxima=constants.max_places;const auto& weeks=constants.weeks; const size_t slot = static_cast(q.slot); if (slot >= prices.size() || q.manager < 0 || q.manager_club < 0 || q.current_build_weeks != 0 || (q.current_raw_flags & ~uint8_t(3)) != 0 || @@ -220,11 +216,11 @@ bool canonical_block_quote(const StadiumBlockExpansionQuote& q, uint32_t total, q.undiscounted_cost == sum && q.base_price == uint32_t(sum * uint32_t(q.company_price_percent) / 100u); } -bool valid_editor_projection(const StadiumBlockExpansionEditor& editor) { +bool valid_editor_projection(const StadiumBlockExpansionEditor& editor,const StadiumBlockExpansionConstants& constants) { return editor.total_target_places == editor.quote.total_target_places && editor.desired_features == editor.quote.desired_features && editor.header_text_variant >= 3 && editor.header_text_variant <= 10 && - canonical_block_quote(editor.quote, editor.total_target_places, editor.desired_features); + canonical_block_quote(editor.quote, editor.total_target_places, editor.desired_features,constants); } bool same_block_overviews(const std::array& a, const std::array& b) { @@ -946,7 +942,7 @@ Image StadiumScreen::render_scene() const { const std::string current = format_number(GameState{}, int32_t(available * 1000), 0x85) + texts_[text_id(::bmh::layout::Stadium_FormatError_ExecutableField3)]; text_at(out, 221, row_y + 15, current, 0x51); - const auto max_places = uint32_t(exe_.u8(::bmh::layout::CareerSession_Invalid_RuntimeField + i)) * 1000; + const auto max_places = stadium_block_expansion_constants(exe_).max_places[i]; const std::string maximum = texts_[text_id(::bmh::layout::Stadium_Out_TextPointer5)] + format_number(GameState{}, int32_t(max_places), 5) + exe_.cstring(::bmh::layout::Stadium_Out_ExecutableField); @@ -1805,7 +1801,7 @@ void StadiumScreen::acknowledge(StadiumState updated) { if (!old_editor || req.block_slot != int(old_editor->quote.slot) || old_editor->quote.manager != req.manager_slot || old_editor->quote.manager_club != req.runtime_club || !req.expected_block_quote || - *req.expected_block_quote != old_editor->quote || !valid_editor_projection(*old_editor) || + *req.expected_block_quote != old_editor->quote || !valid_editor_projection(*old_editor,stadium_block_expansion_constants(exe_)) || ((req.kind != StadiumRequestKind::expansion_set_total && req.kind != StadiumRequestKind::expansion_toggle_feature) && (req.block_total_places != old_editor->total_target_places || @@ -1894,7 +1890,7 @@ void StadiumScreen::acknowledge(StadiumState updated) { quote.new_places == 0 && editor.total_target_places == quote.total_target_places && editor.desired_features == quote.desired_features && - valid_editor_projection(editor) && + valid_editor_projection(editor,stadium_block_expansion_constants(exe_)) && !editor.offer && !updated.construction_tip_dialog && same_block_overviews(state_.blocks, updated.blocks) && updated.balance == state_.balance && !updated.selected_investment && !updated.quoted_object; @@ -1908,7 +1904,7 @@ void StadiumScreen::acknowledge(StadiumState updated) { valid = total >= minimum && total <= old_editor->quote.max_places && req.block_features == old_editor->desired_features && same_block_quote_owner(old_editor->quote, next.quote) && - canonical_block_quote(next.quote, total, req.block_features) && + canonical_block_quote(next.quote, total, req.block_features,stadium_block_expansion_constants(exe_)) && next.quote.total_target_places == total && next.quote.desired_features == req.block_features && next.total_target_places == total && next.desired_features == req.block_features && !next.offer && !updated.construction_tip_dialog && @@ -1922,7 +1918,7 @@ void StadiumScreen::acknowledge(StadiumState updated) { valid = (req.block_features & ~uint8_t(3)) == 0 && (changed == 1 || changed == 2) && !(old_editor->quote.current_raw_flags & changed) && same_block_quote_owner(old_editor->quote, next.quote) && - canonical_block_quote(next.quote, old_editor->total_target_places, req.block_features) && + canonical_block_quote(next.quote, old_editor->total_target_places, req.block_features,stadium_block_expansion_constants(exe_)) && next.quote.total_target_places == old_editor->total_target_places && next.quote.desired_features == req.block_features && next.total_target_places == old_editor->total_target_places && @@ -1951,7 +1947,7 @@ void StadiumScreen::acknowledge(StadiumState updated) { req.manager_slot >= 0 && req.manager_slot <= 3 && updated.construction_tip_dialog->source_flags == 0x204 && next.offer->decision == StandBlockOfferDecision::Pending && - valid_editor_projection(next) && next.offer->percent >= 6 && next.offer->percent <= 14 && + valid_editor_projection(next,stadium_block_expansion_constants(exe_)) && next.offer->percent >= 6 && next.offer->percent <= 14 && next.offer->base_price == old_editor->quote.base_price && next.offer->price == old_editor->quote.base_price && next.offer->construction_days == old_editor->quote.base_weeks && @@ -1971,7 +1967,7 @@ void StadiumScreen::acknowledge(StadiumState updated) { state_.construction_tip_dialog->source_manager_flags == req.manager_slot && req.manager_slot >= 0 && req.manager_slot <= 3 && state_.construction_tip_dialog->source_flags == 0x204 && - valid_editor_projection(*old_editor) && old_editor->offer->percent >= 6 && old_editor->offer->percent <= 14 && + valid_editor_projection(*old_editor,stadium_block_expansion_constants(exe_)) && old_editor->offer->percent >= 6 && old_editor->offer->percent <= 14 && old_editor->offer->base_price == old_editor->quote.base_price && old_editor->offer->price == old_editor->quote.base_price && old_editor->offer->construction_days == old_editor->quote.base_weeks && diff --git a/tests/stadium_block_app_tests.cpp b/tests/stadium_block_app_tests.cpp index 77edac1..bb21217 100644 --- a/tests/stadium_block_app_tests.cpp +++ b/tests/stadium_block_app_tests.cpp @@ -230,8 +230,8 @@ void test_preview_cancel_zero_and_cross_family(const std::filesystem::path& data page.block_expansion->quote.current_capacity_thousands==10&& page.block_expansion->header_text_variant==expected_header_value, "accepted B editor binds the live capacity and draws its header variant once"); - check(page.block_expansion->quote.price_per_1000==375000&&page.block_expansion->quote.base_weeks==37, - "B uses the literal Source A-H table entries 9 and 23"); + check(page.block_expansion->quote.price_per_1000==375000&&page.block_expansion->quote.base_weeks==48, + "B retains the edition price and uses the expanded24k construction period"); const auto& initial_block=*page.block_expansion; const auto amount_text=[&](uint32_t amount) { return format_number(session->state(),int32_t(amount),0x181)+source_exe.cstring(::bmh::layout::CareerSession_FormatNumber_ExecutableField); @@ -385,8 +385,8 @@ void test_literal_eight_block_tables(const std::filesystem::path& data) { page=stadium_state(*session,revision); const auto& quote=page.block_expansion->quote; check(quote.price_per_1000==executable.u32(layout::CareerSession_DispatchStadium_RuntimeField + (size_t(slot)+8)*4)&& - quote.base_weeks==executable.u8(layout::CareerSession_DispatchStadium_RuntimeField2 + (size_t(slot)+22)*5), - "each A-H slot matches its externally supplied executable table"); + quote.base_weeks==stadium_block_expansion_constants(executable).weeks[size_t(slot)], + "each A-H slot matches edition prices and expanded construction policy"); auto cancel=request_from(page,ui::StadiumRequestKind::expansion_cancel,slot, quote.total_target_places,quote.desired_features); check(session->dispatch_stadium(cancel,revision,error)&&error.empty(),"each table quote cancels cleanly"); diff --git a/tests/stadium_extended_limits_tests.cpp b/tests/stadium_extended_limits_tests.cpp new file mode 100644 index 0000000..51e7707 --- /dev/null +++ b/tests/stadium_extended_limits_tests.cpp @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include "game/stadium_blocks.hpp" +#include "formats/le.hpp" +#include +#include +#include +namespace { +void check(bool value,const char* message){if(!value)throw std::runtime_error(message);} +} +int main()try{ + using namespace bmh; + auto image=LeImage::from_bytes(0xa3600,Bytes(0x1000)); + 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{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{30,48,30,40,30,48,30,40},"larger block duration is not scaled with size"); + check(constants.price_per_1000[0]==300000&&constants.price_per_1000[7]==300000,"edition unit prices were replaced"); + const uint8_t custom=20;image.patch(layout::CareerSession_Invalid_RuntimeField,&custom,1);check(stadium_block_expansion_constants(image).max_places[0]==20000,"larger supplied custom stand was reduced"); + const uint8_t unsupported=255;image.patch(layout::CareerSession_Invalid_RuntimeField,&unsupported,1);bool rejected=false;try{stadium_block_expansion_constants(image);}catch(const FormatError&){rejected=true;}check(rejected,"unrepresentable capacity/duration accepted"); + std::cout<<"144k stadium policy, edition prices, capacity-based weeks, custom floors and saved byte limits passed\n"; +}catch(const std::exception& error){std::cerr<