Add a mechanism to restore event callback ptrs.
Ugh, more duplicates. Maybe can find a good way to refactor.
This commit is contained in:
parent
570e8c812b
commit
fbe4fd396e
5 changed files with 37 additions and 4 deletions
|
@ -36,6 +36,11 @@ namespace CoreTiming
|
|||
|
||||
struct EventType
|
||||
{
|
||||
EventType() {}
|
||||
|
||||
EventType(TimedCallback cb, const char *n)
|
||||
: callback(cb), name(n) {}
|
||||
|
||||
TimedCallback callback;
|
||||
const char *name;
|
||||
};
|
||||
|
@ -125,13 +130,24 @@ void FreeTsEvent(Event* ev)
|
|||
|
||||
int RegisterEvent(const char *name, TimedCallback callback)
|
||||
{
|
||||
EventType type;
|
||||
type.name = name;
|
||||
type.callback = callback;
|
||||
event_types.push_back(type);
|
||||
event_types.push_back(EventType(callback, name));
|
||||
return (int)event_types.size() - 1;
|
||||
}
|
||||
|
||||
void AntiCrashCallback(u64 userdata, int cyclesLate)
|
||||
{
|
||||
ERROR_LOG(CPU, "Savestate broken: an unregistered event was called.");
|
||||
Core_Halt("invalid timing events");
|
||||
}
|
||||
|
||||
void RestoreEvent(int event_type, const char *name, TimedCallback callback)
|
||||
{
|
||||
if (event_type >= event_types.size())
|
||||
event_types.resize(event_type + 1, EventType(AntiCrashCallback, "INVALID EVENT"));
|
||||
|
||||
event_types[event_type] = EventType(callback, name);
|
||||
}
|
||||
|
||||
void UnregisterAllEvents()
|
||||
{
|
||||
if (first)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue