Complete original edition rules, season safety and verified 1.0 releases (by Codex)
This commit is contained in:
1 parent
e432f20ae7
commit
f0ef79a119
21 files changed
+563
-30
No files matched your search
@@ -0,0 +1,72 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/lineup.hpp"
|
||||
#include "game/match.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace {
|
||||
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
|
||||
void enabled(bool value) {
|
||||
auto exe = bmh::LeImage::from_bytes(bmh::layout::ForeignPlayerLimitEnabled, bmh::Bytes{uint8_t(value)});
|
||||
bmh::install_lineup_rules(exe);
|
||||
}
|
||||
bmh::GameState fixture(int team, bool human = false, bool all_foreign = false) {
|
||||
bmh::GameState g;
|
||||
const auto range = bmh::squad_range(team);
|
||||
g.squad_slots.assign(3096, 0xfff);
|
||||
g.players.resize(range.count); g.player_bonus.resize(range.count); g.player_cards.resize(range.count, 0x9a00);
|
||||
g.team_flags.resize(138); g.formations.resize(0x160);
|
||||
g.formations[0] = 0;
|
||||
for (int p = 1; p < 11; ++p) g.formations[size_t(p)] = 7;
|
||||
const int country = bmh::team_region(team);
|
||||
for (size_t i = 0; i < range.count; ++i) {
|
||||
g.squad_slots[range.first+i] = uint16_t(i);
|
||||
auto& player = g.players[i];
|
||||
const int strength = i < 6 ? 95 : 60;
|
||||
player.w35c = 60u | uint32_t(strength) << 7 | uint32_t(strength) << 14;
|
||||
player.w364 = i == 0 || i == 11 ? 0 : 1;
|
||||
player.w368 = uint32_t(i < 6 || all_foreign ? country + 1 : country) << 27;
|
||||
}
|
||||
if (human) {
|
||||
g.manager_teams = {team}; g.manager_options = {1,0,0,0,0};
|
||||
g.manager_records.resize(0xb0c); g.tactics.resize(0x840);
|
||||
for (size_t i = 0; i < range.count; ++i) g.tactics[i*0x58+0x50] = uint8_t(i+1);
|
||||
}
|
||||
return g;
|
||||
}
|
||||
int foreign_starters(const bmh::GameState& g, int team) {
|
||||
int count = 0; const auto r = bmh::squad_range(team);
|
||||
for (int row = 0; row < 11; ++row) {
|
||||
const auto entry = g.squad_slots[r.first+size_t(row)];
|
||||
if ((entry & 0x8000) && bmh::nationality(g, entry & 0xfff) != bmh::team_region(team)) ++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
int main() try {
|
||||
enabled(false); auto unrestricted = fixture(0); bmh::auto_lineup(unrestricted,0,100);
|
||||
check(foreign_starters(unrestricted,0)==6,"disabled edition changed foreign selection");
|
||||
enabled(true);
|
||||
for (int team : {0,90}) {
|
||||
auto g = fixture(team); bmh::auto_lineup(g,team,100);
|
||||
check(foreign_starters(g,team)==(team==0?3:2),"original domestic/foreign league limit not enforced");
|
||||
}
|
||||
auto human = fixture(0,true); bmh::auto_lineup(human,0,100);
|
||||
check(foreign_starters(human,0)==3,"human assistant ignored original limit");
|
||||
for (int row=0;row<24;++row) {
|
||||
const auto entry=human.squad_slots[size_t(row)];const size_t id=entry&0xfff;
|
||||
check(human.tactics[size_t(row)*0x58+0x50]==id+1,"player salary board lost during foreign swap");
|
||||
if(entry&0xc000)check((human.player_cards[id]&31)==row,"card row index not updated after foreign swap");
|
||||
if(row<11)check(human.tactics[size_t(row)*0x58+0x41]==(row?7:0),"formation coordinate moved with replaced player");
|
||||
}
|
||||
auto shortage = fixture(0,false,true); bmh::auto_lineup(shortage,0,100);
|
||||
check(foreign_starters(shortage,0)==3,"shortage of domestic reserves did not terminate with a legal partial lineup");
|
||||
enabled(false); auto restored=fixture(0);bmh::auto_lineup(restored,0,100);
|
||||
check(restored.squad_slots==unrestricted.squad_slots && restored.player_cards==unrestricted.player_cards,
|
||||
"switching back to disabled edition did not restore unchanged selection");
|
||||
std::cout<<"Original foreign lineup limits, board swaps and edition switching passed\n";
|
||||
return 0;
|
||||
} catch(const std::exception&e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/season.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
@@ -29,6 +30,18 @@ void run(bmh::GameState& g, bmh::GameRandom& game, bmh::WatcomRandom& rand) {
|
||||
}
|
||||
}
|
||||
int main() try {
|
||||
{
|
||||
auto g = fixture(2928, 20);
|
||||
constexpr uint32_t entry = bmh::layout::CupTable + 14 * 0x28;
|
||||
g.memory.set8(entry, 0x7f);
|
||||
bmh::initialize_european_qualification_seed(g);
|
||||
check(g.memory.u16(entry + 0x22) == 357 && g.memory.u16(entry + 0x24) == 358 &&
|
||||
g.memory.u8(entry) == 0x7f, "empty EM seeds did not become national teams without changing descriptor data");
|
||||
g.memory.set16(entry + 0x22, 361); g.memory.set16(entry + 0x24, 364);
|
||||
bmh::initialize_european_qualification_seed(g);
|
||||
check(g.memory.u16(entry + 0x22) == 361 && g.memory.u16(entry + 0x24) == 364,
|
||||
"existing original national qualification seeds were overwritten");
|
||||
}
|
||||
for (const auto [slot, foreign] : {std::pair{2928, false}, {2971, false}, {2972, false}, {3071, true}}) {
|
||||
auto g = fixture(slot, 47, foreign);
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
@@ -49,6 +62,16 @@ int main() try {
|
||||
check(game.calls() == 0 && rand.calls() == 1,
|
||||
"unchanged club ageing consumed additional random draws");
|
||||
}
|
||||
{
|
||||
auto g = fixture(0, 20);
|
||||
g.squad_slots[2968] = 0; // Cached contract/offer row still references this club player.
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() == 21 && g.squad_slots[0] == 0 && g.squad_slots[2968] == 0,
|
||||
"cached offer aged or recycled a player still owned by his club");
|
||||
check(game.calls() == 0 && rand.calls() == 1,
|
||||
"cached offer consumed a second retirement draw for its club player");
|
||||
}
|
||||
{
|
||||
auto g = fixture(3072, 47);
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
@@ -20,6 +23,7 @@
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
#include "game/matchday.hpp"
|
||||
#include "game/month.hpp"
|
||||
@@ -71,6 +75,37 @@ void check_state(const GameState& g, const std::string& when, Checks& c) {
|
||||
}
|
||||
}
|
||||
|
||||
// Optional private investigation: snapshots use their own save-envelope RNG;
|
||||
// observing a failure never consumes either gameplay stream.
|
||||
bool capture_duplicate(const GameState& before, const GameState& after,
|
||||
const std::filesystem::path& directory) {
|
||||
std::set<int> seen;
|
||||
int duplicate = -1;
|
||||
for (size_t slot = 0; slot < 2928 && slot < after.squad_slots.size(); ++slot) {
|
||||
const int id = after.squad_slots[slot] & 0xfff;
|
||||
if (id != 0xfff && !seen.insert(id).second) { duplicate = id; break; }
|
||||
}
|
||||
if (duplicate < 0) return false;
|
||||
std::filesystem::create_directories(directory);
|
||||
WatcomRandom envelope(1);
|
||||
write_savegame(directory / "before_duplicate.FBM", make_savegame(before, envelope));
|
||||
write_savegame(directory / "after_duplicate.FBM", make_savegame(after, envelope));
|
||||
std::ofstream report(directory / "duplicate.txt");
|
||||
report << "player=" << duplicate << " before_day=" << before.date << " after_day=" << after.date << '\n';
|
||||
for (const auto* state : {&before, &after}) {
|
||||
report << "day=" << state->date << " age=" << state->players.at(size_t(duplicate)).age() << '\n';
|
||||
for (size_t slot = 0; slot < state->squad_slots.size(); ++slot)
|
||||
if ((state->squad_slots[slot] & 0xfff) == duplicate)
|
||||
report << "slot=" << slot << " team=" << slot_team(int(slot)) << " flags=" << (state->squad_slots[slot] & 0xf000) << '\n';
|
||||
for (uint32_t row = 0; row < 200; ++row) {
|
||||
const auto value = state->memory.u32(layout::Career_RemoveJoinLoans_RuntimeField + row * 4);
|
||||
if (value && (value & 0xfff) == uint32_t(duplicate))
|
||||
report << "loan_row=" << row << " raw=" << value << '\n';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// The matchday just played. Cup phase 2 stores the shoot-out goals added to the
|
||||
// match score (legacy routine). The total-12 plausibility check cannot apply to that
|
||||
// combined display score: Original week40_capture.jsonl:241 records 11:10.
|
||||
@@ -150,6 +185,8 @@ int main(int argc, char** argv) {
|
||||
Checks checks;
|
||||
std::string gap;
|
||||
int played = 0, goals = 0, matches = 0, seasons = 0;
|
||||
const char* duplicate_directory = std::getenv("SIM_DUPLICATE_DIR");
|
||||
bool duplicate_captured = false;
|
||||
try {
|
||||
app::CareerSession session(argv[1], argc > 4 ? uint32_t(std::stoul(argv[4])) : 1u);
|
||||
ui::SetupOptions options; // 5 seasons, level 2, one manager, mode III, league and world
|
||||
@@ -305,6 +342,8 @@ int main(int argc, char** argv) {
|
||||
if (offer.status == TransferActionStatus::pending || offer.status == TransferActionStatus::accepted) break;
|
||||
}
|
||||
}
|
||||
std::optional<GameState> duplicate_before;
|
||||
if (duplicate_directory && !duplicate_captured) duplicate_before = g;
|
||||
ui::DeskRequest kickoff;
|
||||
kickoff.kind = ui::DeskRequestKind::advance_turn;
|
||||
kickoff.manager_slot = int(g.memory.u8(::bmh::layout::ActiveManager));
|
||||
@@ -314,6 +353,8 @@ int main(int argc, char** argv) {
|
||||
gap = r.reason.empty() ? error : r.reason;
|
||||
break;
|
||||
}
|
||||
if (duplicate_before && capture_duplicate(*duplicate_before, g, duplicate_directory))
|
||||
duplicate_captured = true;
|
||||
if (r.kind == TurnDeskKind::CareerComplete) {
|
||||
++played;
|
||||
std::printf("turn %d (day %u): career complete\n", played, r.date);
|
||||
|
||||
Reference in new issue
Block a user