// SPDX-License-Identifier: GPL-3.0-only #include "formats/executable_layout.hpp" #include "modern/content/transfer_market.hpp" #include #include using namespace bmh; namespace { void check(bool yes, const char *why) { if (!yes) throw std::runtime_error(why); } } // namespace int main() try { for (const bool expanded : {false, true}) { auto layout = classic_world_layout(); if (expanded) { uint32_t at = 0; for (size_t i = 0; i < layout.squad_size.size(); ++i) { layout.squad_start[i] = at; layout.squad_size[i] = 24; at += 24; } layout.transfer_list = at; layout.free_agents = at + 44; layout.foreign_offers = at + 124; layout.pool_end = at + 144; layout.total_slots = layout.pool_end + 102; } set_world_layout(layout); modern::ModernState g; g.manager_teams = {0}; g.manager_records.resize(0xb0c); g.club_ids = {0}; g.club_names = {'T', 0}; g.player_name_offsets = {0, 0, 0}; g.player_names = {'P', 0}; g.players.resize(3); g.players[2].w35c = 80 | (70 << 7) | (60 << 14); g.players[2].w364 = 2 | (10 << 21); g.squad_slots.assign(layout.total_slots, 0xfff); g.squad_slots[0] = 2; g.squad_slots[0xb70] = 1; g.squad_slots[layout.transfer_list] = 2; g.memory.add_block(::bmh::layout::ActiveManager, 1); g.memory.add_block(::bmh::layout::EditorList, 40 * 0x58); for (int i = 0; i < 4; ++i) g.memory.set16(::bmh::layout::EditorList + uint32_t(i) * 2, 0xffff); g.memory.set16(::bmh::layout::EditorList + 8, 0); g.memory.set32(::bmh::layout::EditorList + 0x2c, 800000); g.memory.set32(::bmh::layout::EditorList + 0x30, 12000); const auto slots = g.squad_slots; const auto records = g.manager_records; const auto memory = g.memory.blocks(); auto v = modern::project_transfer_market(g, 17); check(v.items.size() == 1 && v.items[0].player == 2 && v.items[0].source_slot == int(layout.transfer_list), "projection read Classic pool in an expanded world"); check(v.squad.size() == 1 && v.squad[0].already_listed, "actual own list membership missing"); check(v.items[0].own_listing && v.items[0].asking_fee == 1000000, "actual seller/fee missing"); check(v.revision == 17 && v.active_strengths[2] == g.players[2].strength(), "identity/positional strength changed"); check(g.squad_slots == slots && g.manager_records == records && g.memory.blocks() == memory, "read mutated state"); g.memory.set16(::bmh::layout::EditorList, 0); g.memory.set8(::bmh::layout::EditorList + 0x34, 0x80 | 24); for (int i = 0; i < 7; ++i) g.memory.set8(::bmh::layout::EditorList + 0x38 + uint32_t(i), uint8_t(i + 1)); v = modern::project_transfer_market(g, 18); check(v.items[0].own_bid && v.items[0].own_bid->loan && v.items[0].own_bid->contract_years == 2 && v.items[0].own_bid->bonuses[6] == 7, "saved bid term/bonuses lost"); } set_world_layout(classic_world_layout()); std::cout << "world-relative transfer pool, actual list membership, bid and " "pure reads passed\n"; return 0; } catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }