diff --git a/src/app/controller.cpp b/src/app/controller.cpp index 83175a9..e12292c 100644 --- a/src/app/controller.cpp +++ b/src/app/controller.cpp @@ -542,6 +542,34 @@ void serve_transfer_action(ui::StartupFlow& flow, CareerSession& session, } return; } + // Search dialog closed (Suchen / Vorschlag): store the profile; with apply, the listings that fit are announced one + // by one through the notice presenter, like the original's message boxes. Only a changed profile raises the revision. + if (request.kind == ui::TransferMarketRequestKind::store_search_profile) { + if (entry_policy != HumanBuyerMarketEntryPolicy::normal_interactive) { + flow.reject_preparation_action("Der Original-Suchdialog ist in diesem Einstieg nicht verfügbar."); + return; + } + std::string error; + const uint64_t before = revision; + const bool stored = TransferActions(session).apply(revision, [&] { + const auto result = session.dispatch_search_profile(request.manager_slot, request.search_profile, + request.search_cancelled, request.search_apply, revision, error); + if (!result) return false; + if (presenters.notice) + for (const auto& hit : result->hits) + presenters.notice(session.state(), HumanBuyerSaleNotice{request.manager_slot, hit.entry, -1, + ::bmh::layout::Month_SearchProfileNews_TextPointer3, hit.message, 0x40}); + return true; + }); + if (!stored) { + flow.reject_preparation_action("Das Suchprofil konnte nicht gespeichert werden."); + } else if (revision != before) { + flow.acknowledge_preparation(session.preparation_projection(revision), {}); + } else { + flow.acknowledge_unchanged_transfer_market(); + } + return; + } // All other kinds (bid, list, review offers): run through TransferActions::market with the // sale hooks. The notice presenter is wrapped to remember whether a notice was shown, so the // callback can keep the original notice/acknowledge order. diff --git a/src/app/window_actions.cpp b/src/app/window_actions.cpp index 6e81675..0bd5ea0 100644 --- a/src/app/window_actions.cpp +++ b/src/app/window_actions.cpp @@ -202,7 +202,8 @@ std::string TransferActions::rejection(const ui::TransferMarketRequest& request, } else if (request.kind != ui::TransferMarketRequestKind::open_offer && request.kind != ui::TransferMarketRequestKind::preview_quote && request.kind != ui::TransferMarketRequestKind::open_poach && - request.kind != ui::TransferMarketRequestKind::review_offers) + request.kind != ui::TransferMarketRequestKind::review_offers && + request.kind != ui::TransferMarketRequestKind::store_search_profile) return "Diese Transferaktion ist nicht verfügbar."; return {}; } diff --git a/src/formats/executable_layout.hpp b/src/formats/executable_layout.hpp index d0ff68b..41ec7ad 100644 --- a/src/formats/executable_layout.hpp +++ b/src/formats/executable_layout.hpp @@ -1916,6 +1916,10 @@ inline constexpr auto TransferMarket_Rect_TextPointer2 = 0xa0045; inline constexpr auto TransferMarket_Rect_TextPointer3 = 0xae148; inline constexpr auto TransferMarket_Rect_TextPointer4 = 0xae14c; inline constexpr auto TransferMarket_Rect_TextPointer5 = 0xae150; +// Search dialog (buttons Suchen / Vorschlag): seven 5-byte rows (y, step in px, cells, slider flag, profile offset) +// and the text pointer of its confirm button. +inline constexpr auto TransferMarket_SearchRows_RuntimeField = 0xa20fb; +inline constexpr auto TransferMarket_SearchButton_TextPointer = 0xae144; inline constexpr auto TransferMarket_Rect_TextPointer6 = 0xaecac; inline constexpr auto TransferMarket_Rect_TextPointer7 = 0xaf250; inline constexpr auto TransferMarket_Render_TextPointer = 0xaf264; diff --git a/src/game/search_profile.cpp b/src/game/search_profile.cpp index f1caaf3..0c23f40 100644 --- a/src/game/search_profile.cpp +++ b/src/game/search_profile.cpp @@ -56,13 +56,18 @@ bool search_profile_valid(SearchProfile profile) { return true; } +bool search_profile_active(SearchProfile profile, bool cancelled) { + profile[0] &= 0x3F; + int sum = 0; + for (uint8_t value : profile) sum += value; + return !(sum == 0 || sum == 18 || cancelled); +} + bool set_search_profile(GameState& g, int manager, SearchProfile profile, bool cancelled) { if (manager < 0 || size_t(manager) >= g.manager_teams.size() || (size_t(manager) + 1) * kRecord > g.manager_records.size() || !search_profile_valid(profile)) return false; profile[0] &= 0x3F; - int sum = 0; - for (uint8_t value : profile) sum += value; - if (sum == 0 || sum == 18 || cancelled) profile[0] |= kSearchProfileOff; + if (!search_profile_active(profile, cancelled)) profile[0] |= kSearchProfileOff; for (size_t i = 0; i < profile.size(); ++i) g.manager_records.at(size_t(manager) * kRecord + kSearchProfileOffset + i) = profile[i]; return (profile[0] & kSearchProfileOff) == 0; diff --git a/src/game/search_profile.hpp b/src/game/search_profile.hpp index 3308d81..5ba9f52 100644 --- a/src/game/search_profile.hpp +++ b/src/game/search_profile.hpp @@ -28,6 +28,11 @@ SearchProfile search_profile(const GameState& g, int manager); // ignored in byte 0), the age bar has 25 cells (bytes 4 and 5 are 0..24) and the strength bar 100 (bytes 6 and 7 are 0..99). bool search_profile_valid(SearchProfile profile); +// Whether a profile closed with `cancelled` (right click) or not counts as an active search: the "off" bit of +// byte 0 is ignored, every value 0 or every value 1 (the sum is 0 or 18) switches the search off, and so does +// leaving the dialog by right click. The dialog uses the result for the button state, the engine for the stored bit. +bool search_profile_active(SearchProfile profile, bool cancelled); + // Stores the profile the way the original dialog does when it is closed: a profile with every value 0 or // every value 1 is switched off (bit 0x40), and so is any profile that was left by right click // (`cancelled`). Returns whether the stored profile is active. Fails (false, nothing stored) for an diff --git a/src/ui/transfer_market.cpp b/src/ui/transfer_market.cpp index e2eb506..c7aaffa 100644 --- a/src/ui/transfer_market.cpp +++ b/src/ui/transfer_market.cpp @@ -134,8 +134,9 @@ TransferMarketState transfer_market_from_game(const GameState& g, uint64_t revis item.seller_name = g.club_name(item.seller); item.own_listing = item.seller == state.runtime_club; } - // Asking fee as stored in the list entry, scaled as the original does (value/10000 times 0x30d4); must fit in int32. - const uint64_t fee = uint64_t(g.memory.u32(entry + 0x2c) / 10000) * 0x30d4; + // Asking fee as stored in the list entry, rounded down to whole 10000 as the original does (sub_3C940 of Diamond 3.7: + // value/10000 times 10000; the older build scaled it by 0x30d4 = 1.25); must fit in int32. + const uint64_t fee = uint64_t(g.memory.u32(entry + 0x2c) / 10000) * 10000; if (fee > uint64_t(std::numeric_limits::max())) throw FormatError("transfer market: asking fee out of range"); item.asking_fee = int32_t(fee); item.salary_reference = g.memory.u32(entry + 0x30); @@ -171,6 +172,11 @@ TransferMarketState transfer_market_from_game(const GameState& g, uint64_t revis state.decorated_background=!g.memory.has(::bmh::layout::PlainBackground)||g.memory.u8(::bmh::layout::PlainBackground)==0; state.textured_panes=!g.memory.has(::bmh::layout::SolidPanelBackground)||g.memory.u8(::bmh::layout::SolidPanelBackground)==0; state.source_market_mode=g.memory.has(::bmh::layout::GameMode)?g.memory.u8(::bmh::layout::GameMode):uint8_t(0); + // The search profile and the two suggestions of "Vorschlag" (a national coach has no market, so no profile). + if(state.runtime_club!=kNoTeam) { + state.search_profile=search_profile(g,manager); + for(int whole=0;whole<2;++whole)state.search_suggestion[size_t(whole)]=suggest_search_profile(g,manager,whole!=0); + } if(g.memory.has(::bmh::layout::ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField)&&g.memory.has(::bmh::layout::ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField2))state.currency=std::pair{int32_t(g.memory.u32(::bmh::layout::CurrencyMultiplier)),int32_t(g.memory.u32(::bmh::layout::CurrencyDivisor))}; // Roster block shown on the left side of the screen (same data as the club info screen). state.roster.runtime_team=state.runtime_club;state.roster.original_club_name=state.club_name; @@ -319,7 +325,8 @@ std::string transfer_market_request_json(const TransferMarketRequest& r) { r.kind == TransferMarketRequestKind::open_offer ? "open_offer" : r.kind == TransferMarketRequestKind::preview_quote ? "preview_quote" : r.kind == TransferMarketRequestKind::open_poach ? "open_poach" : - r.kind == TransferMarketRequestKind::review_offers ? "review_offers" : "none"; + r.kind == TransferMarketRequestKind::review_offers ? "review_offers" : + r.kind == TransferMarketRequestKind::store_search_profile ? "store_search_profile" : "none"; std::ostringstream out; out << "{\"kind\":\"" << kind << "\",\"manager_slot\":" << r.manager_slot << ",\"runtime_club\":" << r.runtime_club << ",\"revision\":" << r.revision @@ -333,7 +340,11 @@ std::string transfer_market_request_json(const TransferMarketRequest& r) { << ",\"fee\":" << r.bid.fee << ",\"annual_salary\":" << r.bid.annual_salary << ",\"contract_years\":" << unsigned(r.bid.contract_years) << ",\"bonuses\":["; for (size_t i = 0; i < r.bid.bonuses.size(); ++i) { if (i) out << ','; out << r.bid.bonuses[i]; } - out << "],\"selected_players\":["; + out << "],\"search_profile\":["; + for (size_t i = 0; i < r.search_profile.size(); ++i) { if (i) out << ','; out << unsigned(r.search_profile[i]); } + out << "],\"search_cancelled\":" << (r.search_cancelled ? "true" : "false") + << ",\"search_apply\":" << (r.search_apply ? "true" : "false"); + out << ",\"selected_players\":["; for(size_t n=0;n 40) throw FormatError("transfer market: too many list rows"); @@ -585,6 +599,7 @@ Image TransferMarketScreen::render() const { sprite_font_.draw(out,SpriteFont::centered_title_x(sprite_font_.text_width(title)),13,title); sprite_font_.draw(out,5,235,original_to_utf8(state_.club_name)); draw_market_overview(out); + if (search_open_) draw_search(out); if (!feedback_.empty()) { rect(out, 1, 227, 318, 12, 0x39); auto line = feedback_; @@ -701,7 +716,7 @@ TransferMarketRequest TransferMarketScreen::make_open_offer(bool loan) { // Selection by position over the market rows (x 201..297, y 25..115, 15 px per row) or the roster // names (x 9..60). A new selection requests a quote preview unless Komplett is on. TransferMarketRequest TransferMarketScreen::move(int x,int y) { - if(pending_||close_requested_)return {}; + if(pending_||close_requested_||search_open_)return {}; if(!(view_flags_&1)&&x>=201&&x<=297&&y>=25&&y<115) { const auto order=market_order();const size_t first=order.empty()?0:std::min(market_page_,(order.size()-1)/6)*6,index=first+size_t((y-25)/15); if(index=254 means loan). TransferMarketRequest TransferMarketScreen::click(int x,int y,bool right) { if(pending_||close_requested_)return {}; + if(search_open_)return click_search(x,y,right); if(right) { if(!(view_flags_&1)&&x>=185&&x<=319&&y>=21&&y<=163) { const auto rows=market_order();market_page_+=1; @@ -743,6 +759,14 @@ TransferMarketRequest TransferMarketScreen::click(int x,int y,bool right) { // Reset's logical4 follows Data and the three leading market // buttons: its physical EXE/TransferMarket_Click_RuntimeField entry3 is Abwerben. const int px=exe_.u16(::bmh::layout::TransferMarket_Click_RuntimeField + 3*6),py=exe_.u16(::bmh::layout::TransferMarket_Click_RuntimeField2+3*6),pw=exe_.u16(::bmh::layout::TransferMarket_Click_RuntimeField3+3*6); + // The two buttons before Abwerben (Source entries 1 and 2): Suchen opens the search dialog with the stored + // profile, Vorschlag with the profile the squad asks for (Source sub_19409; the dialog is local UI state). + for(int search_button=1;search_button<=2&&state_.source_market_mode==3;++search_button) { + const int sx=exe_.u16(::bmh::layout::TransferMarket_Click_RuntimeField + search_button*6),sy=exe_.u16(::bmh::layout::TransferMarket_Click_RuntimeField2+search_button*6),sw=exe_.u16(::bmh::layout::TransferMarket_Click_RuntimeField3+search_button*6); + if(xsx+sw||ysy+10)continue; + open_search(search_button==1?state_.search_profile:state_.search_suggestion[(view_flags_&0x400)?1:0]); + return {}; + } if(state_.source_market_mode==3&&x>=px&&x<=px+pw&&y>=py&&y<=py+10) { TransferMarketRequest request; request.kind=TransferMarketRequestKind::open_poach; @@ -797,10 +821,90 @@ TransferMarketRequest TransferMarketScreen::click(int x,int y,bool right) { } return {}; } +// --- search dialog (Source sub_19409) -------------------------------------------------------------------------- +// Opens the dialog on a copy of `profile` (without the "off" bit of byte 0, as the Source dialog starts). +void TransferMarketScreen::open_search(SearchProfile profile) { + profile[0] &= 0x3F; + search_edit_ = profile; + search_open_ = true; +} + +// Draws the dialog: the 136x135 panel at (184,20), the seven bars (a dark stripe per row and the selected cells or the +// range in the highlight colour), the price estimate of the profile and the confirm button. +void TransferMarketScreen::draw_search(Image& out) const { + copy(out, search_panel_, 0, 0, 184, 20, 136, 135); + for (int row = 0; row < 7; ++row) { + const uint32_t at = ::bmh::layout::TransferMarket_SearchRows_RuntimeField + uint32_t(row) * 5; + const int y = exe_.u8(at), step = exe_.u8(at + 1), cells = exe_.u8(at + 2), slider = exe_.u8(at + 3), offset = exe_.u8(at + 4); + rect(out, 217, y, 100, 2, 0x42); // Source rectangle (217,y)-(316,y+1) + if (slider) { + const int low = 100 * search_edit_.at(size_t(offset)) / cells, high = 100 * search_edit_.at(size_t(offset) + 1) / cells; + rect(out, 217 + low, y, high - low + 1, 2, 0xF7); + } else { + for (int cell = 0, x = 217; cell < cells; ++cell, x += step) + if (search_edit_.at(size_t(offset) + size_t(cell))) rect(out, x + 3, y, step - 5, 2, 0xF7); + } + } + // Price estimate: five times the (inverted) age midpoint plus five times the strength midpoint, limited to 12..620. + int value = 5 * (31 - (search_edit_[4] + search_edit_[5]) / 2) + 5 * ((search_edit_[7] + search_edit_[6]) / 2); + value = std::clamp(value, 12, 620); + value = value * (value >> 2) * ((value >> 3) + 100) / 10; + auto price = original_money(10000 * (value / 10000)); + price.erase(0, price.find_first_not_of('%')); + original_text(out, 216, 148, price, 0x7A); + button(out, 277, 140, 40, texts_[text_id(::bmh::layout::TransferMarket_SearchButton_TextPointer)], false); +} + +// A click inside the dialog: the confirm button closes it and applies the profile, the right button closes it and +// switches the search off, a click on a bar row edits that row (Source: a switch toggles its cell; on a slider the +// click moves the nearer end of the range, and the two ends never become equal). +TransferMarketRequest TransferMarketScreen::click_search(int x, int y, bool right) { + if (right) return close_search(true); + if (x >= 277 && x <= 317 && y >= 140 && y <= 150) return close_search(false); + if (x < 216 || x > 317) return {}; + for (int row = 0; row < 7; ++row) { + const uint32_t at = ::bmh::layout::TransferMarket_SearchRows_RuntimeField + uint32_t(row) * 5; + const int row_y = exe_.u8(at), step = exe_.u8(at + 1), cells = exe_.u8(at + 2), slider = exe_.u8(at + 3), offset = exe_.u8(at + 4); + if (y < row_y - 2 || y > row_y + 3) continue; + int value = (x - 217) / step; + if (slider) { + auto& low = search_edit_.at(size_t(offset)); + auto& high = search_edit_.at(size_t(offset) + 1); + if ((int(low) + int(high)) / 2 < value && value != 0) { + if (value > cells - 1) value = cells - 1; + high = uint8_t(value); + } else { + low = uint8_t(std::max(0, value)); + } + if (low == high) { if (low) --low; else ++high; } + } else if (value >= 0 && value < cells) { // (the Source also toggles the byte after the row for a click on its last pixel column) + search_edit_.at(size_t(offset) + size_t(value)) ^= 1; + } + } + return {}; +} + +// Leaves the dialog and posts the profile to the session. Source sets view-flag bit 1 (the Suchen button) to whether +// the closed profile is an active search. +TransferMarketRequest TransferMarketScreen::close_search(bool cancelled) { + search_open_ = false; + view_flags_ = uint16_t((view_flags_ & ~2u) | (search_profile_active(search_edit_, cancelled) ? 2u : 0u)); + TransferMarketRequest request; + request.kind = TransferMarketRequestKind::store_search_profile; + request.manager_slot = state_.manager_slot; request.runtime_club = state_.runtime_club; request.revision = state_.revision; + request.search_profile = search_edit_; request.search_cancelled = cancelled; request.search_apply = !cancelled; + pending_ = request; feedback_.clear(); + return request; +} + // Keyboard shortcuts: Esc closes, B or Enter opens an offer for the selected market item, // V or Enter lists the selected squad player. TransferMarketRequest TransferMarketScreen::key(std::string_view key) { if(pending_||close_requested_)return {}; + if(search_open_) { // the dialog only knows the mouse; Esc counts as the right button + if(key=="ESC"||key=="ESCAPE")return close_search(true); + return {}; + } if(key=="ESC"||key=="ESCAPE"){close_requested_=true;return {};} if(key=="B"&&selected_item_)return make_open_offer(); if(key=="V"&&selected_squad_)return make_listing(); @@ -889,7 +993,9 @@ std::string TransferMarketScreen::state_json() const { << ",\"active_field\":" << active_field_ << ",\"numeric_input\":" << json_quote(numeric_input_) << ",\"pending\":" << (pending_ ? transfer_market_request_json(*pending_) : "null") << ",\"feedback\":" << json_quote(feedback_) - << ",\"preview\":"; + << ",\"search_open\":" << (search_open_ ? "true" : "false") << ",\"search_edit\":["; + for (size_t i = 0; i < search_edit_.size(); ++i) out << (i ? "," : "") << unsigned(search_edit_[i]); + out << "],\"preview\":"; if (preview_) { out << "{\"source_slot\":" << preview_->source_slot << ",\"player\":" << preview_->player << ",\"seller\":" << preview_->seller << ",\"revision\":" << preview_->revision diff --git a/src/ui/transfer_market.hpp b/src/ui/transfer_market.hpp index f552652..79aca5c 100644 --- a/src/ui/transfer_market.hpp +++ b/src/ui/transfer_market.hpp @@ -18,6 +18,7 @@ #include "game/poach.hpp" #include "ui/sprite_font.hpp" #include "game/desk_actions.hpp" +#include "game/search_profile.hpp" #include "ui/manager.hpp" #include "ui/setup.hpp" @@ -63,13 +64,18 @@ struct TransferMarketState { uint8_t source_market_mode = 0; // Unknown is not an inferred Mode III. std::optional> currency; std::array active_strengths{},team_strengths{}; + // Search profile of the manager (buttons Suchen / Vorschlag): the stored profile and the two suggestions the squad + // asks for (index 0 = first eleven, 1 = whole squad, chosen by the Komplett-style view flag 0x400). + SearchProfile search_profile{}; + std::array search_suggestion{}; }; TransferMarketState transfer_market_from_game(const GameState&, uint64_t revision); std::string transfer_market_state_json(const TransferMarketState&); TaxDialogProjection poach_notice_from_game(const GameState&,const PoachStart&,std::string original_message); -enum class TransferMarketRequestKind { none, submit_bid, list_player, open_offer, preview_quote, open_poach, review_offers }; +enum class TransferMarketRequestKind { none, submit_bid, list_player, open_offer, preview_quote, open_poach, review_offers, + store_search_profile }; struct TransferMarketSelection { int list_entry=-1,source_slot=-1,player=-1,seller=-1,squad_row=-1; }; @@ -86,6 +92,10 @@ struct TransferMarketRequest { int preview_snapshot_index = -1; bool offer_is_loan = false; std::vector selected_players; + // store_search_profile: the edited profile when the search dialog is closed; `search_cancelled` = left by right click + // (the profile is kept but switched off), `search_apply` = closed with the "Suchen" button (list the matches). + SearchProfile search_profile{}; + bool search_cancelled = false, search_apply = false; }; std::string transfer_market_request_json(const TransferMarketRequest&); @@ -112,6 +122,9 @@ public: TransferMarketRequest key(std::string_view); bool text(std::string_view); bool close_requested() const { return close_requested_; } + // The search dialog (buttons Suchen / Vorschlag) is open: it owns every click until it is closed. + bool search_open() const { return search_open_; } + const SearchProfile& search_edit() const { return search_edit_; } const TransferMarketState& state() const { return state_; } const std::optional& pending() const { return pending_; } void acknowledge(TransferMarketState, std::string notice = {}); @@ -129,7 +142,7 @@ private: LeImage exe_; TextDb texts_; SpriteFont sprite_font_; - Image background_, frame_, widgets_, atlas_, flags_, market_widgets_; + Image background_, frame_, widgets_, atlas_, flags_, market_widgets_, search_panel_; uint16_t view_flags_ = 0x1f0; bool data_b_ = false; size_t market_page_ = 0; @@ -149,6 +162,12 @@ private: std::string numeric_input_, feedback_; // feedback is UTF-8, like host notices. int active_field_ = 0; bool close_requested_ = false; + bool search_open_ = false; + SearchProfile search_edit_{}; + void open_search(SearchProfile profile); + void draw_search(Image&) const; + TransferMarketRequest click_search(int x, int y, bool right); + TransferMarketRequest close_search(bool cancelled); void draw_text(Image&, int x, int y, std::string_view, uint8_t color) const; void commit_numeric_field(); TransferMarketRequest make_review(const TransferMarketItem&); diff --git a/tests/app_controller_tests.cpp b/tests/app_controller_tests.cpp index 8a73ba3..c110a2d 100644 --- a/tests/app_controller_tests.cpp +++ b/tests/app_controller_tests.cpp @@ -517,6 +517,76 @@ void check_transfer_market_controller(const std::filesystem::path& data) { check(listed_again, "the declined player stands on the transfer list again"); } + { // the search dialog behind the buttons Suchen and Vorschlag (Source sub_19409) + flow.send_key("ESC"); + flow.attach_preparation_context(session->preparation_projection(revision)); + const auto menu = std::find_if(flow.desktop()->state().items.begin(), flow.desktop()->state().items.end(), + [](const DeskItem& item) { return item.kind == 17 && !item.disabled; }); + check(menu != flow.desktop()->state().items.end(), "the desktop offers the market for the search dialog"); + flow.click(menu->x + menu->width / 2, menu->y + menu->height / 2); + const auto exe = load_le(asset_path(data, "BMH.exe")); + const auto button_at = [&](int n) { + return std::pair{exe.u16(::bmh::layout::TransferMarket_Click_RuntimeField + uint32_t(n) * 6) + 2, + exe.u16(::bmh::layout::TransferMarket_Click_RuntimeField2 + uint32_t(n) * 6) + 2}; + }; + HumanBuyerSaleHooks hooks; + hooks.allocator_gate = HumanBuyerSaleAllocatorGate::zero; + hooks.direct_mode = HumanBuyerSaleDirectMode::ordinary_ai_purchase; + std::vector boxes; + hooks.notice = [&](const GameState&, const HumanBuyerSaleNotice& notice) { boxes.push_back(notice.original_message); }; + const auto serve_search = [&](const FlowResult& result) { + return app::serve_flow_request(flow, result, session, data, data, 0x1789abcd, revision, playback, audio_session, false, + {}, {}, {}, {}, {}, {}, {}, {}, {}, app::PendingOfferEntryPolicy::legacy_unpresented, hooks, + app::HumanBuyerMarketEntryPolicy::normal_interactive); + }; + const int manager = initial.manager_slot; + // Suchen: opens locally with the stored profile (the career starts with an inactive one: every value 1) + const auto [search_x, search_y] = button_at(1); + check(flow.click(search_x, search_y).request == FlowRequest::none && + flow.state_json().find("\"search_open\":true") != std::string::npos, "Suchen opens the dialog without a request"); + check(flow.state_json().find("\"search_edit\":[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]") != std::string::npos, + "the dialog shows the stored profile (a new career: off bit, otherwise all 1) without its off bit"); + flow.click(272, 25); // switch the midfielder cell off (row y 25, 25 px cells) + flow.click(316, 42); // age slider: the upper end to the right edge + flow.click(316, 58); // strength slider: the upper end to 99 + check(flow.render().width == 320, "the market with the open search dialog renders"); + flow.move_action(200, 100); // the pointer moves under an open dialog are ignored + const auto confirm = flow.click(285, 145); // the confirm button + check(confirm.request == FlowRequest::submenu_action && std::holds_alternative(confirm.submenu_action) && + std::get(confirm.submenu_action).kind == TransferMarketRequestKind::store_search_profile, + "the confirm button posts the profile"); + const auto& stored_request = std::get(confirm.submenu_action); + check(stored_request.search_apply && !stored_request.search_cancelled && stored_request.search_profile[2] == 0 && + stored_request.search_profile[5] == 24 && stored_request.search_profile[7] == 99, + "the posted profile carries the edits"); + const uint64_t before_store = revision; + check(serve_search(confirm).empty(), "the profile is stored by the production controller"); + const auto stored = search_profile(game, manager); + check(revision == before_store + 1 && !(stored[0] & kSearchProfileOff) && stored[2] == 0 && stored[5] == 24 && stored[7] == 99, + "the stored profile is active and has the edits"); + check(boxes.size() == search_profile_hits(game, manager).size() && !boxes.empty(), + "every listing that fits is announced through the notice presenter"); + check(flow.state_json().find("\"search_open\":false") != std::string::npos && !flow.pending_transfer_market(), + "the dialog is closed and the request settled"); + // Vorschlag opens with the profile the squad asks for; leaving by right click keeps it but switches the search off + const auto [suggest_x, suggest_y] = button_at(2); + check(flow.click(suggest_x, suggest_y).request == FlowRequest::none && + flow.state_json().find("\"search_open\":true") != std::string::npos, "Vorschlag opens the dialog"); + const auto expected = suggest_search_profile(game, manager, false); + std::string expected_json = "\"search_edit\":["; + for (size_t i = 0; i < expected.size(); ++i) expected_json += (i ? "," : "") + std::to_string(i == 0 ? expected[i] & 0x3f : expected[i]); + check(flow.state_json().find(expected_json) != std::string::npos, "the dialog shows the suggestion of the squad"); + boxes.clear(); + const auto leave = flow.click(100, 100, true); + check(leave.request == FlowRequest::submenu_action && + std::get(leave.submenu_action).search_cancelled && + !std::get(leave.submenu_action).search_apply, "the right button posts a cancelled profile"); + check(serve_search(leave).empty(), "the cancelled profile is stored"); + const auto switched_off = search_profile(game, manager); + check((switched_off[0] & kSearchProfileOff) && switched_off[1] == expected[1] && boxes.empty(), + "the suggestion is kept, switched off, and nothing is announced"); + } + // The old KB23 editor/legacy heuristic is no longer the ordinary GUI route. // Keep its controller capability checks on real Source KB31 events, with // the Core owner as the integration reference (not an independent EXE oracle). diff --git a/tests/human_buyer_market_app_tests.cpp b/tests/human_buyer_market_app_tests.cpp index 7ccff61..ebc9d5e 100644 --- a/tests/human_buyer_market_app_tests.cpp +++ b/tests/human_buyer_market_app_tests.cpp @@ -131,7 +131,7 @@ struct OrdinaryInput { if ((candidate.squad_slots.at(0xb70u + size_t(entry)) & 0xfff) != player || (candidate.memory.u16(at + 8) & 0x7fff) != team || candidate.memory.u16(at) != 0xffff) continue; - const uint32_t fee_base = (candidate.memory.u32(at + 0x2c) / 10000u) * 0x30d4u; + const uint32_t fee_base = (candidate.memory.u32(at + 0x2c) / 10000u) * 10000u; const uint32_t salary_base = ((100u * candidate.memory.u32(at + 0x30)) / 10000u) * 100u; const uint32_t cash = read32(candidate.manager_records, 0x314); if (!fee_base || !salary_base || fee_base > cash / 3 || salary_base > 0x3fffffffu) continue; diff --git a/tests/human_buyer_market_tests.cpp b/tests/human_buyer_market_tests.cpp index e05bb5f..2d53756 100644 --- a/tests/human_buyer_market_tests.cpp +++ b/tests/human_buyer_market_tests.cpp @@ -1059,7 +1059,7 @@ int main(int argc,char** argv) try { const uint32_t list=c.request.list_address; TransferBidRequest bid;bid.manager=c.buyer_manager;bid.list_entry=c.request.list_entry; bid.player=c.player;bid.source_slot=int(c.request.source_pool_slot);bid.contract_years=2;bid.loan=true; - const uint32_t fee_base=(g.memory.u32(list+0x2c)/10000u)*0x30d4u; + const uint32_t fee_base=(g.memory.u32(list+0x2c)/10000u)*10000u; const uint32_t salary_base=((120u*g.memory.u32(list+0x30))/10000u)*100u; bid.fee=int32_t(fee_base*2u);bid.annual_salary=int32_t(salary_base*2u); for(size_t n=0;n<7;++n)bid.bonuses[n]=uint32_t(n+3); diff --git a/tests/human_buyer_pending_app_tests.cpp b/tests/human_buyer_pending_app_tests.cpp index b018149..67e8d25 100644 --- a/tests/human_buyer_pending_app_tests.cpp +++ b/tests/human_buyer_pending_app_tests.cpp @@ -44,7 +44,7 @@ struct ControlInput { "real seller listing helper"); const uint32_t ordinary=::bmh::layout::EditorList+uint32_t(listing.list_entry)*0x58; TransferBidRequest bid;bid.manager=1;bid.list_entry=listing.list_entry;bid.player=listing.player; - bid.fee=int32_t((state.memory.u32(ordinary+0x2c)/10000u)*0x30d4u); + bid.fee=int32_t((state.memory.u32(ordinary+0x2c)/10000u)*10000u); bid.annual_salary=int32_t(((100u*state.memory.u32(ordinary+0x30))/10000u)*200u); bid.contract_years=1; check(submit_transfer_bid(state,bid,helper).status==TransferActionStatus::pending, diff --git a/tests/human_buyer_pending_offer_tests.cpp b/tests/human_buyer_pending_offer_tests.cpp index dc6eb29..820458f 100644 --- a/tests/human_buyer_pending_offer_tests.cpp +++ b/tests/human_buyer_pending_offer_tests.cpp @@ -453,7 +453,7 @@ Control make_control(GameState& g,int free_row=-1,bool buyer_full=false,bool sal c.player=listing.player;c.seller_row=player_row(g,c.seller,c.player); check(c.seller_row>=0,"listed player remains in a concrete seller row"); const uint32_t ordinary=::bmh::layout::EditorList+uint32_t(listing.list_entry)*0x58; - const uint32_t fee_base=(g.memory.u32(ordinary+0x2c)/10000)*0x30d4; + const uint32_t fee_base=(g.memory.u32(ordinary+0x2c)/10000)*10000; const uint32_t salary_base=((100u*g.memory.u32(ordinary+0x30))/10000)*100; TransferBidRequest bid;bid.manager=1;bid.list_entry=listing.list_entry;bid.player=listing.player; bid.fee=int32_t(fee_base);bid.annual_salary=int32_t(salary_base*2);bid.contract_years=1;