Handle unframed desktop admission and automation controls (by Codex)

This commit is contained in:
Codex committed 2026-11-02 17:37:26 +01:00
1 parent bea5478433
commit f44de65e22
4 files changed
+59 -33

No files matched your search

+2 -2
View File
@@ -5630,11 +5630,11 @@ bool CareerSession::dispatch_desk_widget(const ui::DeskRequest& request, uint64_
if (!price && request.kind != ui::DeskRequestKind::change_option) {
error = "unsupported_desk_widget"; return false;
}
// Keep SDL requests bound to a visible, open and enabled MEN drawer/item.
// Keep SDL requests bound to a visible and enabled MEN drawer/item; the frame bit is optional.
const auto desk = desktop_projection(revision);
const int expected_kind = price ? 55 : 64;
const auto item = std::find_if(desk.items.begin(), desk.items.end(), [&](const ui::DeskItem& item) {
return item.id == request.item_id && item.kind == expected_kind && item.open && !item.disabled;
return item.id == request.item_id && item.kind == expected_kind && !item.disabled;
});
if (request.menu_kind != expected_kind || item == desk.items.end()) {
error = "stale_or_closed_desk_widget"; return false;
+7 -6
View File
@@ -400,9 +400,9 @@ DeskRequest DesktopScreen::pointer_down(int x, int y, bool right) {
}
if (right && !state_.drawer_handles) return {};
if (right && bin_mode_ && item.kind!=12) return {};
if (!right && item.kind==55 && item.open && !state_.national_team &&
x-item.x-4>34 && x-item.x-4<87) return {}; // Original ticket-price scale.
if (!right && item.kind==64 && item.open) return {}; // Source automation controls remain clicks.
if (!right && item.kind==55 && !state_.national_team &&
x-item.x-(item.open?4:0)>34 && x-item.x-(item.open?4:0)<87) return {}; // Original ticket-price scale.
if (!right && item.kind==64) return {}; // Source automation controls remain clicks.
const bool drawer_handle=item.kind>=50&&state_.drawer_handles&&x<=item.x+3&&y<=item.y+3;
if (!right) return {}; // LMB closes/activates; RMB alone starts a drag.
layout_drag_ = LayoutDrag{item.id, x - item.x, y - item.y, item.x, item.y, -1, false, false, drawer_handle, right};
@@ -659,9 +659,10 @@ DeskRequest DesktopScreen::click(int x, int y, bool right) {
return close_drawer(item);
// The date remains an advance control with or without its optional frame.
if (item.kind == 58) return request(DeskRequestKind::advance_turn, item);
if (item.kind == 55 && item.open && !state_.national_team && x - item.x - 4 > 34 && x - item.x - 4 < 87)
return request(DeskRequestKind::change_ticket_price, item, (x - item.x - 4 - 35) / 3 + 8);
if (item.kind == 64 && item.open) return request(DeskRequestKind::change_option, item, std::clamp((x - item.x - 4) / 33, 0, 4));
const int content_x = item.x + (item.open ? 4 : 0);
if (item.kind == 55 && !state_.national_team && x - content_x > 34 && x - content_x < 87)
return request(DeskRequestKind::change_ticket_price, item, (x - content_x - 35) / 3 + 8);
if (item.kind == 64) return request(DeskRequestKind::change_option, item, std::clamp((x - content_x) / 33, 0, 4));
return {}; // Noninteractive status fields must not invent layout/game changes.
}
return {};
+23
View File
@@ -1177,6 +1177,29 @@ int main(int argc, char** argv) {
check(date_drag.pointer_up(40,60,true).layout_operation==DeskLayoutOperation::move_item,
"unframed date retains right-button movement");
check(desk.render().pixels == pixels,"commands cannot mutate the saved game view");
for(bool framed : {true,false}) {
auto controls=d;
controls.items={{1,20,80,98,36,55,0,0,framed,false},
{2,20,130,173,38,64,0,0,framed,false}};
const int origin=20+(framed?4:0);
for(int offset : {34,35,86,87}) {
DesktopScreen price_control(data,controls);
price_control.pointer_down(origin+offset,90);
const auto price_action=price_control.pointer_up(origin+offset,90);
check(price_action.kind==((offset==35||offset==86)?
DeskRequestKind::change_ticket_price:DeskRequestKind::none),
"framed and unframed admission controls use the rendered Source endpoints");
if(offset==35||offset==86)
check(price_action.value==(offset==35?8:25),"admission endpoint preserves its exact value");
}
for(int offset : {32,33,65,66,98,99,131,132}) {
DesktopScreen automation_control(data,controls);
automation_control.pointer_down(origin+offset,140);
const auto option_action=automation_control.pointer_up(origin+offset,140);
check(option_action.kind==DeskRequestKind::change_option && option_action.value==offset/33,
"automation cell boundaries follow the optional frame offset");
}
}
desk.reject_action("unsupported_menu");
check(!desk.pending() && desk.render().pixels == pixels,"rejected command preserves state");
check(desk.key("A").menu_kind == 3,"original A hotkey opens lineup");
+27 -25
View File
@@ -2402,33 +2402,33 @@ void check_semantic_desk_settings(const std::filesystem::path& data) {
check(session.finish(init,error),"semantic setting fixture reaches a real desk");
revision=init.desktop.revision;
const int manager=game.memory.u8(::bmh::layout::ActiveManager); const size_t rec=size_t(manager)*0xb0c;
const auto default_desk=session.desktop_projection(revision);
check(std::none_of(default_desk.items.begin(),default_desk.items.end(),[](const auto& item) {
return item.kind==64&&item.open&&!item.disabled;
}),"parent failure uses the actual default closed automation drawer");
// Typed settings remain independent of hidden desktop presentation records.
int automation_item=-1,price_item=-1;
for(int i=0;i<54;++i) {
const auto at=::bmh::layout::DesktopsUnsigned+uint32_t(manager)*0x360+uint32_t(i)*16;
const auto kind=game.memory.u8(at+12);
if(kind==64)automation_item=i;
if(kind==64) {
automation_item=i;
game.memory.set16(at,uint16_t(game.memory.u16(at)|0x1000));
}
if(kind==55) {
price_item=i;
game.memory.set8(at+13,uint8_t(game.memory.u8(at+13)&~0x80));
game.memory.set16(at,uint16_t(game.memory.u16(at)|0x1000));
}
}
check(automation_item>=0&&price_item>=0,"Original MEN contains both setting drawers");
DeskRequest legacy{DeskRequestKind::change_option,manager,automation_item,64,1,revision};
reject([&]{return session.dispatch_desk_widget(legacy,revision,error);},
"original SDL dispatcher still rejects default closed automation");
check(error=="stale_or_closed_desk_widget","closed widget fails at the retained SDL item guard");
"SDL dispatcher rejects a hidden automation item");
check(error=="stale_or_closed_desk_widget","hidden widget fails at the retained SDL item guard");
for(int value:{8,25,17}) {
price={identity(),value}; auto expected=game; expected.manager_records[rec+0x26e]=uint8_t(value);
accept([&]{return session.dispatch_ticket_price(price,revision,error);},expected,
"typed price works with a closed drawer and changes only admission, never cash or credit");
"typed price works with a hidden drawer and changes only admission, never cash or credit");
}
reject([&]{return session.dispatch_ticket_price(price,revision,error);},"stale price replay is wholly neutral");
legacy={DeskRequestKind::change_ticket_price,manager,price_item,55,12,revision};
reject([&]{return session.dispatch_desk_widget(legacy,revision,error);},"typed price does not unlock the SDL drawer");
reject([&]{return session.dispatch_desk_widget(legacy,revision,error);},"typed price does not unhide the SDL drawer");
for(int value:{7,26}) {
price={identity(),value};
reject([&]{return session.dispatch_ticket_price(price,revision,error);},"typed price rejects outside Original endpoints");
@@ -2581,7 +2581,8 @@ void check_semantic_desk_settings(const std::filesystem::path& data) {
std::filesystem::remove_all(directory);
}
void check_desk_widgets(const std::filesystem::path& data) {
void check_desk_widgets_for_frame(const std::filesystem::path& data, bool framed) {
const int content_x=20+(framed?4:0);
StartupFlow flow(data);
flow.click(150, 215); flow.click(5, 225, true); flow.click(5, 225, true);
flow.click(90, 169);
@@ -2604,7 +2605,7 @@ void check_desk_widgets(const std::filesystem::path& data) {
game.memory.set8(at + 4, uint8_t(i == 1 ? 36 : 38));
game.memory.set8(at + 5, uint8_t(i == 1 ? 2 : 0));
game.memory.set8(at + 12, uint8_t(i == 1 ? 55 : 64));
game.memory.set8(at + 13, 0x80);
game.memory.set8(at + 13, framed?0x80:0);
}
init.desktop = session->desktop_projection(revision);
init.preparation = session->preparation_projection(revision);
@@ -2629,22 +2630,22 @@ void check_desk_widgets(const std::filesystem::path& data) {
const auto ws = session->rand().seed();
const auto gc = session->game().calls(), wc = session->rand().calls();
const auto rev = revision;
const auto price = flow.click(20 + 4 + 86, 90);
const auto price = flow.click(content_x + 86, 90);
check(price.desk_action.value == 25, "rightmost original price hitbox maps to 25");
check(flow.click(20 + 4 + 35, 90).request == FlowRequest::none, "pending widget blocks a duplicate");
check(flow.click(content_x + 35, 90).request == FlowRequest::none, "pending widget blocks a duplicate");
execute(price);
auto changed_records = records;
changed_records[0x26e] = 25;
check(game.manager_records == changed_records && game.manager_options == options && revision == rev + 1,
"price changes only the active manager's admission byte");
execute(flow.click(20 + 4 + 35, 90));
execute(flow.click(content_x + 35, 90));
check(game.manager_records[0x26e] == 8, "leftmost original price hitbox maps to 8");
check(flow.click(20 + 4 + 34, 90).request == FlowRequest::none &&
flow.click(20 + 4 + 87, 90).request == FlowRequest::none,
check(flow.click(content_x + 34, 90).request == FlowRequest::none &&
flow.click(content_x + 87, 90).request == FlowRequest::none,
"outside price endpoints remain read-only");
for (int index : {1, 2, 3, 4}) {
const auto before = game.manager_options;
execute(flow.click(20 + 4 + index * 33 + 10, 140));
execute(flow.click(content_x + index * 33 + 10, 140));
auto expected = before;
expected[size_t(index)] ^= 1;
check(game.manager_options == expected, "automation toggles only its Original bit including training high flags");
@@ -2654,12 +2655,12 @@ void check_desk_widgets(const std::filesystem::path& data) {
game.manager_records[0x219] = 0x02; // Indoor: only formation 2.
game.manager_options[0] = 0;
for (int value : {3, 8, 0}) {
execute(flow.click(20 + 4 + 10, 140));
execute(flow.click(content_x + 10, 140));
check(game.manager_options[0] == value, "outdoor automation skips unavailable stored formations and wraps to off");
}
game.indoor = true;
for (int value : {2, 0}) {
execute(flow.click(20 + 4 + 10, 140));
execute(flow.click(content_x + 10, 140));
check(game.manager_options[0] == value, "indoor automation uses the separate saved formation mask");
}
game.indoor = false;
@@ -2686,9 +2687,6 @@ void check_desk_widgets(const std::filesystem::path& data) {
unchanged(invalid);
}
for (int value : {7, 26}) unchanged(DeskRequest{DeskRequestKind::change_ticket_price, 0, 1, 55, value, revision});
game.memory.set8(::bmh::layout::Desktops + 2 * 16 + 13, 0);
unchanged(request);
game.memory.set8(::bmh::layout::Desktops + 2 * 16 + 13, 0x80);
game.memory.set16(::bmh::layout::Desktops + 2 * 16, 20 | 0x1000);
unchanged(request);
game.memory.set16(::bmh::layout::Desktops + 2 * 16, 20);
@@ -2706,7 +2704,7 @@ void check_desk_widgets(const std::filesystem::path& data) {
const auto national = session->desktop_projection(revision);
check(national.national_team, "widget fixture projects a national coach");
DesktopScreen national_screen(data, national);
check(national_screen.click(20 + 4 + 35, 90).kind == DeskRequestKind::none,
check(national_screen.click(content_x + 35, 90).kind == DeskRequestKind::none,
"national admission control does not emit a price request");
unchanged(DeskRequest{DeskRequestKind::change_ticket_price, 0, 1, 55, 10, revision});
request.value = 4;
@@ -2722,6 +2720,10 @@ void check_desk_widgets(const std::filesystem::path& data) {
"every drawer action preserves both RNG streams, date, board and squad");
}
void check_desk_widgets(const std::filesystem::path& data) {
for(bool framed : {true,false}) check_desk_widgets_for_frame(data,framed);
}
void check_league_only_national_coach_handoff(const std::filesystem::path& data) {
StartupFlow flow(data);
flow.click(150, 215); // League-only setup; world competition remains disabled.
@@ -7102,7 +7104,7 @@ int main(int argc, char** argv) {
if (argc != 2 && argc != 3 && argc != 4) throw std::runtime_error("app_controller_tests requires data directory [optional Original save]");
const std::filesystem::path data = argv[1];
if(argc==3 && std::string_view(argv[2])=="--desktop-input-only") {
check_date_widget_controller(data); check_menu_layout_session_io(data); return 0;
check_date_widget_controller(data); check_menu_layout_session_io(data); check_desk_widgets(data); return 0;
}
if(argc==3 && std::string_view(argv[2])=="--environment-only") {
check_environment_controller(data);return 0;