Bind squad and lineup views to confirmed engine player swaps (by Codex)

This commit is contained in:
Codex committed 2026-10-28 09:01:14 +01:00
1 parent 94dc5ecbc4
commit 7d3b3f1101
15 files changed
+340 -36

No files matched your search

+19 -1
View File
@@ -8,7 +8,7 @@ using namespace bmh;
using namespace bmh::modern_ui;
int main(int argc, char **argv) {
try {
if (argc != 4 || (std::string(argv[1]) != "prepare" && std::string(argv[1]) != "verify")) throw std::runtime_error("usage: modern_engine_bridge_probe prepare|verify <world.obw> <new-output-directory>");
if (argc != 4 || (std::string(argv[1]) != "prepare" && std::string(argv[1]) != "verify" && std::string(argv[1]) != "verify-lineup")) throw std::runtime_error("usage: modern_engine_bridge_probe prepare|verify|verify-lineup <world.obw> <new-output-directory>");
const fs::path world = argv[2], out = argv[3]; fs::create_directories(out);
const auto write = [&](const char *file, const Json &j) { editor::write_atomic(out / file, j.dump(2)); };
if (std::string(argv[1]) == "prepare") {
@@ -39,6 +39,24 @@ int main(int argc, char **argv) {
link = EngineBridge::open(world, out / "booked.obs"); const auto loaded = link->snapshot(); write("loaded.json", loaded);
if (loaded.at("desktop").at("data").at("accounts") != after.at("desktop").at("data").at("accounts") || !loaded.at("camps").at("data").at("bookedThisWeek").get<bool>()) throw std::runtime_error("OBS round trip lost booking");
}
if (std::string(argv[1]) == "verify-lineup") {
(void)engine_lineup_projection(before);
auto order = before.at("lineup").at("data").at("order");
std::swap(order[0], order[11]);
const auto request = engine_lineup_command(before, order, "request:lineup-probe");
const auto response = link->command(request); write("lineup-command.json", request); write("lineup-response.json", response);
if (response.value("messageType", "") != "command_result") throw std::runtime_error(response.dump());
if (link->command(request) != response) throw std::runtime_error("lineup request replay changed response");
const auto after = link->snapshot(); write("lineup-after.json", after);
if (after.at("lineup").at("data").at("order") != order || after.at("desktop").at("data").at("accounts") != before.at("desktop").at("data").at("accounts"))
throw std::runtime_error("lineup order not applied exactly or account changed");
auto stale = request; stale["requestId"] = "request:stale-lineup";
const auto rejected = link->command(stale); write("lineup-rejected.json", rejected);
if (rejected.value("code", "") != "stale_revision" || link->snapshot() != after) throw std::runtime_error("stale lineup changed engine state");
write("lineup-saved.json", link->save_copy(out / "lineup.obs")); link.reset();
link = EngineBridge::open(world, out / "lineup.obs"); const auto loaded = link->snapshot(); write("lineup-loaded.json", loaded);
if (loaded.at("lineup").at("data").at("order") != order) throw std::runtime_error("lineup lost during OBS round trip");
}
std::cout << "engine bridge " << argv[1] << " passed\n"; return 0;
} catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }
}