mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-16 07:50:28 +02:00
CoreTiming: Grow the event table for events a savestate lacks
Taking the highest unused slot instead could steal one that a state event restores later, as VBlankWake did to MicBlockingResume, which then had nowhere to go. Also name the event in the assert. AGENTS.md: When a savestate fails to load, suspect the branch first. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d86896bed9
commit
54e4be47aa
2 files changed
+8
-9
No files matched your search
+4
-9
@@ -193,16 +193,11 @@ void RestoreRegisterEvent(int &event_type, const char *name, TimedCallback callb
|
||||
if (event_type == -1)
|
||||
event_type = nextEventTypeRestoreId++;
|
||||
if (event_type >= (int)event_types.size()) {
|
||||
// Give it any unused event id starting from the end.
|
||||
// Older save states with messed up ids have gaps near the end.
|
||||
for (int i = (int)event_types.size() - 1; i >= 0; --i) {
|
||||
if (usedEventTypes.count(i) == 0) {
|
||||
event_type = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// An event the state doesn't have. Grow the table: an unused slot below may still belong to
|
||||
// a state event whose module restores it later.
|
||||
event_types.resize(event_type + 1, EventType{ AntiCrashCallback, "INVALID EVENT" });
|
||||
}
|
||||
_assert_msg_(event_type >= 0 && event_type < (int)event_types.size(), "Invalid event type %d", event_type);
|
||||
_assert_msg_(event_type >= 0 && event_type < (int)event_types.size(), "Invalid event type %d (%s, of %d)", event_type, name, (int)event_types.size());
|
||||
event_types[event_type] = EventType{ callback, name };
|
||||
usedEventTypes.insert(event_type);
|
||||
restoredEventTypes.insert(event_type);
|
||||
|
||||
Reference in new issue
Block a user