Reschedule undo clears the calendar replay bit (#16)
UndoReschedule of the original clears bit 0x4000 of the calendar day (high byte & 0xbf) when no replay of another club stays on it; the engine kept the bit, so the day and its neighbour were no longer offered as targets after a move was taken back. The test checks the same target days after the undo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b879d5be00
commit
c8f04d0099
3 files changed
+15
-3
No files matched your search
@@ -228,15 +228,22 @@ bool undo_reschedule(GameState& g, int manager, int day) {
|
||||
if (std::none_of(moved.begin(), moved.end(), [&](const LeagueMatchRef& m) { return m.day == day; })) return false;
|
||||
const int team = manager_team(g, manager);
|
||||
// UndoReschedule(day, 1, team): every replay of the club on that day, whatever its league
|
||||
int kept = 0; // local_18: the replays of other clubs that stay on the day
|
||||
for (int e = 0; e < kPostponedEntries; e++) {
|
||||
const uint32_t at = kPostponed + uint32_t(e) * 6;
|
||||
if (g.memory.u16(at) != uint16_t(day)) continue;
|
||||
const int league = g.memory.u8(at + 3), round = g.memory.u8(at + 2), m = g.memory.u8(at + 4);
|
||||
const Fixture f = round_fixtures(league, round).at(size_t(m));
|
||||
if (f.home != team && f.away != team) continue;
|
||||
if (f.home != team && f.away != team) { ++kept; continue; }
|
||||
g.results.at(result_at(league, round, m)) = kNotPlayed;
|
||||
g.memory.set16(at, 0);
|
||||
}
|
||||
// with no replay left the day loses its replay bit 0x4000 again (calendar high byte & 0xbf),
|
||||
// so it can be a target once more
|
||||
if (kept == 0) {
|
||||
const uint32_t high = kCalendar + uint32_t(day) * 2 + 1;
|
||||
g.memory.set8(high, uint8_t(g.memory.u8(high) & 0xbf));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
// matchday the 0xCE turns into 0xCD (matchday_setup) and the match is played on the
|
||||
// new day like a winter postponement.
|
||||
// 4. A click on the new day of a moved match takes the move back (UndoReschedule(day, 1,
|
||||
// team)): the entry is freed and the result byte is 0xCC again. The calendar keeps bit
|
||||
// 0x4000, as in the original.
|
||||
// team)): the entry is freed and the result byte is 0xCC again. When no replay of another
|
||||
// club stays on that day, the day loses bit 0x4000 again and can be a target once more.
|
||||
//
|
||||
// Everything here works on the saved GameState only: no random numbers are drawn, so a
|
||||
// rescheduled career stays deterministic.
|
||||
|
||||
Reference in new issue
Block a user