Added client pause flag to status message for net play.
This commit is contained in:
parent
6832eaa964
commit
015f6a0acd
|
@ -26,6 +26,7 @@
|
||||||
#include "../../movie.h"
|
#include "../../movie.h"
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
#include "utils/crc32.h"
|
#include "utils/crc32.h"
|
||||||
|
#include "utils/StringUtils.h"
|
||||||
#include "Qt/main.h"
|
#include "Qt/main.h"
|
||||||
#include "Qt/dface.h"
|
#include "Qt/dface.h"
|
||||||
#include "Qt/input.h"
|
#include "Qt/input.h"
|
||||||
|
@ -287,7 +288,7 @@ int NetPlayServer::sendRomLoadReq( NetPlayClient *client )
|
||||||
|
|
||||||
msg.hdr.msgSize += fileSize;
|
msg.hdr.msgSize += fileSize;
|
||||||
msg.fileSize = fileSize;
|
msg.fileSize = fileSize;
|
||||||
strncpy( msg.fileName, GameInfo->filename, sizeof(msg.fileName) );
|
Strlcpy( msg.fileName, GameInfo->filename, sizeof(msg.fileName) );
|
||||||
|
|
||||||
printf("Sending ROM Load Request: %s %lu\n", filepath, fileSize );
|
printf("Sending ROM Load Request: %s %lu\n", filepath, fileSize );
|
||||||
FCEUI_SetEmulationPaused(EMULATIONPAUSED_PAUSED);
|
FCEUI_SetEmulationPaused(EMULATIONPAUSED_PAUSED);
|
||||||
|
@ -440,6 +441,8 @@ void NetPlayServer::serverProcessMessage( NetPlayClient *client, void *msgBuf, s
|
||||||
client->gpData[2] = msg->ctrlState[2];
|
client->gpData[2] = msg->ctrlState[2];
|
||||||
client->gpData[3] = msg->ctrlState[3];
|
client->gpData[3] = msg->ctrlState[3];
|
||||||
|
|
||||||
|
client->setPaused( (msg->flags & netPlayClientState::PAUSE_FLAG) ? true : false );
|
||||||
|
|
||||||
NetPlayFrameData data;
|
NetPlayFrameData data;
|
||||||
if ( (msg->opsFrame == 0) || netPlayFrameData.find( msg->opsFrame, data ) )
|
if ( (msg->opsFrame == 0) || netPlayFrameData.find( msg->opsFrame, data ) )
|
||||||
{
|
{
|
||||||
|
@ -498,6 +501,7 @@ void NetPlayServer::update(void)
|
||||||
uint32_t lagFrame = 0;
|
uint32_t lagFrame = 0;
|
||||||
uint8_t localGP[4] = { 0 };
|
uint8_t localGP[4] = { 0 };
|
||||||
uint8_t gpData[4] = { 0 };
|
uint8_t gpData[4] = { 0 };
|
||||||
|
int numClientsPaused = 0;
|
||||||
|
|
||||||
if (currFrame > maxLead)
|
if (currFrame > maxLead)
|
||||||
{
|
{
|
||||||
|
@ -537,6 +541,11 @@ void NetPlayServer::update(void)
|
||||||
{
|
{
|
||||||
gpData[client->role] = client->gpData[client->role];
|
gpData[client->role] = client->gpData[client->role];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client->isPaused())
|
||||||
|
{
|
||||||
|
numClientsPaused++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -561,7 +570,7 @@ void NetPlayServer::update(void)
|
||||||
shouldRunFrame = (clientMinFrame != 0xFFFFFFFF) &&
|
shouldRunFrame = (clientMinFrame != 0xFFFFFFFF) &&
|
||||||
(clientMinFrame >= lagFrame ) &&
|
(clientMinFrame >= lagFrame ) &&
|
||||||
(clientMaxFrame < leadFrame) &&
|
(clientMaxFrame < leadFrame) &&
|
||||||
(currFrame > lastFrame);
|
(currFrame > lastFrame) && (numClientsPaused == 0);
|
||||||
|
|
||||||
//printf("Client Frame: Min:%u Max:%u\n", clientMinFrame, clientMaxFrame);
|
//printf("Client Frame: Min:%u Max:%u\n", clientMinFrame, clientMaxFrame);
|
||||||
|
|
||||||
|
@ -798,7 +807,7 @@ void NetPlayClient::update(void)
|
||||||
statusMsg.flags = 0;
|
statusMsg.flags = 0;
|
||||||
if (FCEUI_EmulationPaused())
|
if (FCEUI_EmulationPaused())
|
||||||
{
|
{
|
||||||
statusMsg.flags |= 0x0001;
|
statusMsg.flags |= netPlayClientState::PAUSE_FLAG;
|
||||||
}
|
}
|
||||||
statusMsg.frameRdy = inputFrameBack();
|
statusMsg.frameRdy = inputFrameBack();
|
||||||
statusMsg.frameRun = currFrame;
|
statusMsg.frameRun = currFrame;
|
||||||
|
@ -915,8 +924,8 @@ void NetPlayClient::clientProcessMessage( void *msgBuf, size_t msgSize )
|
||||||
{
|
{
|
||||||
netPlayAuthResp msg;
|
netPlayAuthResp msg;
|
||||||
msg.playerId = role;
|
msg.playerId = role;
|
||||||
strncpy( msg.userName, userName.toLocal8Bit().constData(), sizeof(msg.userName));
|
Strlcpy( msg.userName, userName.toLocal8Bit().constData(), sizeof(msg.userName));
|
||||||
strncpy( msg.pswd, password.toLocal8Bit().constData(), sizeof(msg.pswd) );
|
Strlcpy( msg.pswd, password.toLocal8Bit().constData(), sizeof(msg.pswd) );
|
||||||
|
|
||||||
printf("Authentication Request Received\n");
|
printf("Authentication Request Received\n");
|
||||||
msg.toNetworkByteOrder();
|
msg.toNetworkByteOrder();
|
||||||
|
|
|
@ -207,6 +207,8 @@ class NetPlayClient : public QObject
|
||||||
bool isAuthenticated();
|
bool isAuthenticated();
|
||||||
bool isPlayerRole();
|
bool isPlayerRole();
|
||||||
bool shouldDestroy(){ return needsDestroy; }
|
bool shouldDestroy(){ return needsDestroy; }
|
||||||
|
bool isPaused(){ return paused; }
|
||||||
|
void setPaused(bool value){ paused = value; }
|
||||||
|
|
||||||
QString userName;
|
QString userName;
|
||||||
QString password;
|
QString password;
|
||||||
|
@ -230,6 +232,7 @@ class NetPlayClient : public QObject
|
||||||
bool disconnectPending = false;
|
bool disconnectPending = false;
|
||||||
bool needsDestroy = false;
|
bool needsDestroy = false;
|
||||||
bool _connected = false;
|
bool _connected = false;
|
||||||
|
bool paused = false;
|
||||||
|
|
||||||
std::list <NetPlayFrameInput> input;
|
std::list <NetPlayFrameInput> input;
|
||||||
FCEU::mutex inputMtx;
|
FCEU::mutex inputMtx;
|
||||||
|
|
|
@ -237,6 +237,8 @@ struct netPlayClientState
|
||||||
uint32_t ramChkSum;
|
uint32_t ramChkSum;
|
||||||
uint8_t ctrlState[4];
|
uint8_t ctrlState[4];
|
||||||
|
|
||||||
|
static constexpr uint32_t PAUSE_FLAG = 0x0001;
|
||||||
|
|
||||||
netPlayClientState(void)
|
netPlayClientState(void)
|
||||||
: hdr(NETPLAY_CLIENT_STATE, sizeof(netPlayClientState)), flags(0),
|
: hdr(NETPLAY_CLIENT_STATE, sizeof(netPlayClientState)), flags(0),
|
||||||
frameRdy(0), frameRun(0), opsChkSum(0), ramChkSum(0)
|
frameRdy(0), frameRun(0), opsChkSum(0), ramChkSum(0)
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "../../fceu.h"
|
#include "../../fceu.h"
|
||||||
#include "../../cheat.h"
|
#include "../../cheat.h"
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
|
#include "utils/StringUtils.h"
|
||||||
|
|
||||||
#include "Qt/main.h"
|
#include "Qt/main.h"
|
||||||
#include "Qt/dface.h"
|
#include "Qt/dface.h"
|
||||||
|
@ -375,7 +376,8 @@ void RamWatchDialog_t::updateRamWatchDisplay(void)
|
||||||
int idx=0;
|
int idx=0;
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
std::list < ramWatch_t * >::iterator it;
|
std::list < ramWatch_t * >::iterator it;
|
||||||
char addrStr[32], valStr1[16], valStr2[16];
|
FCEU::FixedString<32> addrStr;
|
||||||
|
FCEU::FixedString<16> valStr1, valStr2;
|
||||||
ramWatch_t *rw;
|
ramWatch_t *rw;
|
||||||
|
|
||||||
for (it = ramWatchList.ls.begin (); it != ramWatchList.ls.end (); it++)
|
for (it = ramWatchList.ls.begin (); it != ramWatchList.ls.end (); it++)
|
||||||
|
@ -397,17 +399,17 @@ void RamWatchDialog_t::updateRamWatchDisplay(void)
|
||||||
}
|
}
|
||||||
if ( rw->isSep || (rw->addr < 0) )
|
if ( rw->isSep || (rw->addr < 0) )
|
||||||
{
|
{
|
||||||
strcpy (addrStr, "--------");
|
addrStr = "--------";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( rw->size > 1 )
|
if ( rw->size > 1 )
|
||||||
{
|
{
|
||||||
snprintf (addrStr, sizeof(addrStr), "$%04X-$%04X", rw->addr, rw->addr + rw->size - 1);
|
addrStr.sprintf("$%04X-$%04X", rw->addr, rw->addr + rw->size - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf (addrStr, sizeof(addrStr), "$%04X", rw->addr);
|
addrStr.sprintf("$%04X", rw->addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,8 +417,7 @@ void RamWatchDialog_t::updateRamWatchDisplay(void)
|
||||||
|
|
||||||
if ( rw->isSep || (rw->addr < 0) )
|
if ( rw->isSep || (rw->addr < 0) )
|
||||||
{
|
{
|
||||||
strcpy( valStr1, "--------");
|
valStr1 = valStr2 = "--------";
|
||||||
strcpy( valStr2, "--------");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -424,37 +425,37 @@ void RamWatchDialog_t::updateRamWatchDisplay(void)
|
||||||
{
|
{
|
||||||
if (rw->type == 's')
|
if (rw->type == 's')
|
||||||
{
|
{
|
||||||
snprintf (valStr1, sizeof(valStr1), "%i", rw->val.i32);
|
valStr1.sprintf("%i", rw->val.i32);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf (valStr1, sizeof(valStr1), "%u", rw->val.u32);
|
valStr1.sprintf("%u", rw->val.u32);
|
||||||
}
|
}
|
||||||
snprintf (valStr2, sizeof(valStr2), "0x%08X", rw->val.u32);
|
valStr2.sprintf("0x%08X", rw->val.u32);
|
||||||
}
|
}
|
||||||
else if (rw->size == 2)
|
else if (rw->size == 2)
|
||||||
{
|
{
|
||||||
if (rw->type == 's')
|
if (rw->type == 's')
|
||||||
{
|
{
|
||||||
snprintf (valStr1, sizeof(valStr1), "%6i", rw->val.i16);
|
valStr1.sprintf("%6i", rw->val.i16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf (valStr1, sizeof(valStr1), "%6u", rw->val.u16);
|
valStr1.sprintf("%6u", rw->val.u16);
|
||||||
}
|
}
|
||||||
snprintf (valStr2, sizeof(valStr2), "0x%04X", rw->val.u16);
|
valStr2.sprintf("0x%04X", rw->val.u16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (rw->type == 's')
|
if (rw->type == 's')
|
||||||
{
|
{
|
||||||
snprintf (valStr1, sizeof(valStr1), "%6i", rw->val.i8);
|
valStr1.sprintf("%6i", rw->val.i8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf (valStr1, sizeof(valStr1), "%6u", rw->val.u8);
|
valStr1.sprintf("%6u", rw->val.u8);
|
||||||
}
|
}
|
||||||
snprintf (valStr2, sizeof(valStr2), "0x%02X", rw->val.u8);
|
valStr2.sprintf("0x%02X", rw->val.u8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,9 +495,9 @@ void RamWatchDialog_t::updateRamWatchDisplay(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item->setFirstColumnSpanned(false);
|
item->setFirstColumnSpanned(false);
|
||||||
item->setText( 0, tr(addrStr) );
|
item->setText( 0, tr(addrStr.c_str()) );
|
||||||
item->setText( 1, tr(valStr1) );
|
item->setText( 1, tr(valStr1.c_str()) );
|
||||||
item->setText( 2, tr(valStr2) );
|
item->setText( 2, tr(valStr2.c_str()) );
|
||||||
item->setText( 3, tr(rw->name.c_str()) );
|
item->setText( 3, tr(rw->name.c_str()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue