Preserve human manager identity through national coach record swaps (by Codex)

This commit is contained in:
Codex committed 2026-10-29 01:56:31 +01:00
1 parent ce1535fe2d
commit 693744a961
16 files changed
+203 -21

No files matched your search

+22
View File
@@ -221,6 +221,28 @@ void set_manager_count(ModernState& g, int managers) {
} // namespace
int ModernState::human_manager_slot(int runtime_slot) const {
if (runtime_slot < 0 || !memory.has(::bmh::layout::CoachActive) || memory.u8(::bmh::layout::CoachActive) == 0) return runtime_slot;
if (runtime_slot == 4) return 0;
if (runtime_slot != 0) return runtime_slot;
const int count = memory.u8(::bmh::layout::OriginalManagerCount);
if (count == 1 || memory.u32(::bmh::layout::CompetitionSelection) == 2) return 0;
// The source chose the first eligible original record. While coaching,
// record four preserves original human zero; the other records are frozen.
// Read those flags, rather than guessing from a possibly duplicated name.
for (int human = 0; human < count && human < 4; ++human) {
const size_t record = size_t(human == 0 ? 4 : human) * kManagerRecord;
if (record + 0x21c < manager_records.size() && manager_records[record + 0x21c] != 0) return human;
}
throw FormatError("national coach identity is unavailable");
}
int ModernState::manager_record_slot(int human_slot) const {
if (!memory.has(::bmh::layout::CoachActive) || memory.u8(::bmh::layout::CoachActive) == 0) return human_slot;
const int coach = human_manager_slot(0);
if (human_slot == coach) return 0;
return human_slot == 0 ? 4 : human_slot;
}
void national_coach_take_over(ModernState& g, int active_manager, uint16_t source_season_day) {
StaticMemory& mem = g.memory;
int managers = int(g.manager_teams.size());