Added on state loaded callback function to core so that driver code can be notified of a new state being loaded. In Qt driver, emit a signal on state loads that objects can connect to. For a resync of all netplay clients when server detects a new state load.
This commit is contained in:
parent
2ff6084935
commit
cc234ae04b
|
@ -274,6 +274,17 @@ consoleWin_t::consoleWin_t(QWidget *parent)
|
|||
aviDiskThread = new AviRecordDiskThread_t(this);
|
||||
|
||||
scrHandlerConnected = false;
|
||||
|
||||
// Register State Load Callback with Emulation Core
|
||||
auto stateLoadCallback = []( bool loadSuccess )
|
||||
{
|
||||
//printf("State Loaded: %i \n", loadSuccess );
|
||||
if (loadSuccess && (consoleWindow != nullptr) )
|
||||
{
|
||||
emit consoleWindow->stateLoaded();
|
||||
}
|
||||
};
|
||||
FCEUSS_SetLoadCallback( stateLoadCallback );
|
||||
}
|
||||
|
||||
consoleWin_t::~consoleWin_t(void)
|
||||
|
|
|
@ -328,6 +328,7 @@ class consoleWin_t : public QMainWindow
|
|||
public:
|
||||
signals:
|
||||
void romLoaded(void);
|
||||
void stateLoaded(void);
|
||||
void nesResetOccurred(void);
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -176,6 +176,7 @@ NetPlayServer::NetPlayServer(QObject *parent)
|
|||
connect(this, SIGNAL(newConnection(void)), this, SLOT(newConnectionRdy(void)));
|
||||
|
||||
connect(consoleWindow, SIGNAL(romLoaded(void)), this, SLOT(onRomLoad(void)));
|
||||
connect(consoleWindow, SIGNAL(stateLoaded(void)), this, SLOT(onStateLoad(void)));
|
||||
connect(consoleWindow, SIGNAL(nesResetOccurred(void)), this, SLOT(onNesReset(void)));
|
||||
|
||||
FCEU_WRAPPER_LOCK();
|
||||
|
@ -454,9 +455,26 @@ void NetPlayServer::onRomLoad()
|
|||
FCEU_WRAPPER_UNLOCK();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void NetPlayServer::onStateLoad()
|
||||
{
|
||||
//printf("New State Loaded!\n");
|
||||
FCEU_WRAPPER_LOCK();
|
||||
|
||||
inputClear();
|
||||
inputFrameCount = static_cast<uint32_t>(currFrameCounter);
|
||||
|
||||
// New State has been loaded by server, signal clients to load and sync
|
||||
for (auto& client : clientList )
|
||||
{
|
||||
//sendRomLoadReq( client );
|
||||
sendStateSyncReq( client );
|
||||
}
|
||||
FCEU_WRAPPER_UNLOCK();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void NetPlayServer::onNesReset()
|
||||
{
|
||||
//printf("New ROM Loaded!\n");
|
||||
//printf("NES Reset Event!\n");
|
||||
FCEU_WRAPPER_LOCK();
|
||||
|
||||
inputClear();
|
||||
|
|
|
@ -175,6 +175,7 @@ class NetPlayServer : public QTcpServer
|
|||
public slots:
|
||||
void newConnectionRdy(void);
|
||||
void onRomLoad(void);
|
||||
void onStateLoad(void);
|
||||
void onNesReset(void);
|
||||
};
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ using namespace std;
|
|||
|
||||
static void (*SPreSave)(void) = NULL;
|
||||
static void (*SPostSave)(void) = NULL;
|
||||
static void (*SPostLoad)(bool) = NULL;
|
||||
|
||||
static int SaveStateStatus[10];
|
||||
static int StateShow;
|
||||
|
@ -640,8 +641,8 @@ int FCEUSS_LoadFP_old(EMUFILE* is, ENUM_SSLOADPARAMS params)
|
|||
}
|
||||
|
||||
#ifdef __QT_DRIVER__
|
||||
// Qt Driver NetPlay state load handler. This is to control state loading,
|
||||
// only hosts can load states and clients can request loads.
|
||||
// Qt Driver NetPlay state load handler. This is to control state loading
|
||||
// during netplay, only hosts can load states and clients can request loads.
|
||||
bool NetPlayStateLoadReq(EMUFILE* is);
|
||||
#endif
|
||||
|
||||
|
@ -730,9 +731,18 @@ bool FCEUSS_LoadFP(EMUFILE* is, ENUM_SSLOADPARAMS params)
|
|||
FCEUSS_LoadFP(&msBackupSavestate,SSLOADPARAM_NOBACKUP);
|
||||
}
|
||||
|
||||
// Post state load callback that is used to notify driver code that a new state load occurred.
|
||||
if (SPostLoad != NULL)
|
||||
{
|
||||
SPostLoad(x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
void FCEUSS_SetLoadCallback( void (*cb)(bool) )
|
||||
{
|
||||
SPostLoad = cb;
|
||||
}
|
||||
|
||||
bool FCEUSS_Load(const char *fname, bool display_message)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ enum ENUM_SSLOADPARAMS
|
|||
|
||||
void FCEUSS_Save(const char *, bool display_message=true);
|
||||
bool FCEUSS_Load(const char *, bool display_message=true);
|
||||
void FCEUSS_SetLoadCallback( void (*cb)(bool) );
|
||||
|
||||
//zlib values: 0 (none) through 9 (max) or -1 (default)
|
||||
bool FCEUSS_SaveMS(EMUFILE* outstream, int compressionLevel);
|
||||
|
|
Loading…
Reference in New Issue