Added ROM loaded and NES reset signals to allow for net play to reconfigure accordingly during those events.
This commit is contained in:
parent
145fc1614f
commit
d212b894a7
|
@ -323,6 +323,11 @@ class consoleWin_t : public QMainWindow
|
|||
|
||||
QString findHelpFile(void);
|
||||
|
||||
public:
|
||||
signals:
|
||||
void romLoaded(void);
|
||||
void nesResetOccurred(void);
|
||||
|
||||
public slots:
|
||||
void openDebugWindow(void);
|
||||
void openHexEditor(void);
|
||||
|
|
|
@ -144,6 +144,9 @@ NetPlayServer::NetPlayServer(QObject *parent)
|
|||
instance = this;
|
||||
|
||||
connect(this, SIGNAL(newConnection(void)), this, SLOT(newConnectionRdy(void)));
|
||||
|
||||
connect(consoleWindow, SIGNAL(romLoaded(void)), this, SLOT(onRomLoad(void)));
|
||||
connect(consoleWindow, SIGNAL(nesResetOccurred(void)), this, SLOT(onNesReset(void)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -329,6 +332,7 @@ int NetPlayServer::sendStateSyncReq( NetPlayClient *client )
|
|||
sendMsg( client, em.buf(), em.size() );
|
||||
|
||||
opsCrc32 = 0;
|
||||
inputClear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -366,6 +370,29 @@ bool NetPlayServer::claimRole(NetPlayClient* client, int _role)
|
|||
return success;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void NetPlayServer::onRomLoad()
|
||||
{
|
||||
//printf("New ROM Loaded!\n");
|
||||
|
||||
// New ROM has been loaded by server, signal clients to load and sync
|
||||
for (auto& client : clientList )
|
||||
{
|
||||
sendRomLoadReq( client );
|
||||
sendStateSyncReq( client );
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void NetPlayServer::onNesReset()
|
||||
{
|
||||
//printf("New ROM Loaded!\n");
|
||||
|
||||
// NES Reset has occurred on server, signal clients sync
|
||||
for (auto& client : clientList )
|
||||
{
|
||||
sendStateSyncReq( client );
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
static void serverMessageCallback( void *userData, void *msgBuf, size_t msgSize )
|
||||
{
|
||||
NetPlayServer *server = NetPlayServer::GetInstance();
|
||||
|
@ -587,7 +614,8 @@ void NetPlayServer::update(void)
|
|||
shouldRunFrame = (clientMinFrame != 0xFFFFFFFF) &&
|
||||
(clientMinFrame >= lagFrame ) &&
|
||||
(clientMaxFrame < leadFrame) &&
|
||||
(currFrame > lastFrame) && (numClientsPaused == 0);
|
||||
( (currFrame > lastFrame) || (lastFrame == 0) ) &&
|
||||
(numClientsPaused == 0);
|
||||
|
||||
//printf("Client Frame: Min:%u Max:%u\n", clientMinFrame, clientMaxFrame);
|
||||
|
||||
|
@ -613,10 +641,8 @@ void NetPlayServer::update(void)
|
|||
|
||||
runFrameReq.toNetworkByteOrder();
|
||||
|
||||
for (auto it = clientList.begin(); it != clientList.end(); it++)
|
||||
for (auto& client : clientList )
|
||||
{
|
||||
NetPlayClient *client = *it;
|
||||
|
||||
if (client->state > 0)
|
||||
{
|
||||
sendMsg( client, &runFrameReq, sizeof(runFrameReq) );
|
||||
|
@ -635,10 +661,8 @@ void NetPlayServer::update(void)
|
|||
ping.hostTimeStamp = ts.toMilliSeconds();
|
||||
ping.toNetworkByteOrder();
|
||||
|
||||
for (auto it = clientList.begin(); it != clientList.end(); it++)
|
||||
for (auto& client : clientList )
|
||||
{
|
||||
NetPlayClient *client = *it;
|
||||
|
||||
if (client->state > 0)
|
||||
{
|
||||
sendMsg( client, &ping, sizeof(ping) );
|
||||
|
@ -649,10 +673,8 @@ void NetPlayServer::update(void)
|
|||
bool shouldFlushOutput = true;
|
||||
if (shouldFlushOutput)
|
||||
{
|
||||
for (auto it = clientList.begin(); it != clientList.end(); it++)
|
||||
for (auto& client : clientList )
|
||||
{
|
||||
NetPlayClient *client = *it;
|
||||
|
||||
client->flushData();
|
||||
}
|
||||
}
|
||||
|
@ -1051,6 +1073,7 @@ void NetPlayClient::clientProcessMessage( void *msgBuf, size_t msgSize )
|
|||
|
||||
opsCrc32 = 0;
|
||||
netPlayFrameData.reset();
|
||||
inputClear();
|
||||
}
|
||||
break;
|
||||
case NETPLAY_RUN_FRAME_REQ:
|
||||
|
|
|
@ -113,6 +113,12 @@ class NetPlayServer : public QTcpServer
|
|||
return frame;
|
||||
}
|
||||
|
||||
void inputClear()
|
||||
{
|
||||
FCEU::autoScopedLock alock(inputMtx);
|
||||
input.clear();
|
||||
}
|
||||
|
||||
int sendMsg( NetPlayClient *client, void *msg, size_t msgSize);
|
||||
int sendRomLoadReq( NetPlayClient *client );
|
||||
int sendStateSyncReq( NetPlayClient *client );
|
||||
|
@ -143,6 +149,8 @@ class NetPlayServer : public QTcpServer
|
|||
|
||||
public slots:
|
||||
void newConnectionRdy(void);
|
||||
void onRomLoad(void);
|
||||
void onNesReset(void);
|
||||
};
|
||||
|
||||
class NetPlayClient : public QObject
|
||||
|
@ -209,6 +217,12 @@ class NetPlayClient : public QObject
|
|||
return frame;
|
||||
}
|
||||
|
||||
void inputClear()
|
||||
{
|
||||
FCEU::autoScopedLock alock(inputMtx);
|
||||
input.clear();
|
||||
}
|
||||
|
||||
bool isAuthenticated();
|
||||
bool isPlayerRole();
|
||||
bool shouldDestroy(){ return needsDestroy; }
|
||||
|
|
|
@ -467,7 +467,11 @@ int LoadGame(const char *path, bool silent)
|
|||
//}
|
||||
isloaded = 1;
|
||||
|
||||
//FCEUD_NetworkConnect();
|
||||
// Signal to listeners that a new ROM was loaded
|
||||
if ( consoleWindow )
|
||||
{
|
||||
emit consoleWindow->romLoaded();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -560,6 +564,11 @@ int fceuWrapperSoftReset(void)
|
|||
if ( isloaded )
|
||||
{
|
||||
ResetNES();
|
||||
|
||||
if (consoleWindow != nullptr)
|
||||
{
|
||||
emit consoleWindow->nesResetOccurred();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue