Added more netplay status data to host status dialog.
This commit is contained in:
parent
94975d7dbe
commit
84b823ffa7
|
@ -865,7 +865,7 @@ void NetPlayServer::serverProcessMessage( NetPlayClient *client, void *msgBuf, s
|
||||||
client->gpData[3] = msg->ctrlState[3];
|
client->gpData[3] = msg->ctrlState[3];
|
||||||
|
|
||||||
client->setPaused( (msg->flags & netPlayClientState::PauseFlag ) ? true : false );
|
client->setPaused( (msg->flags & netPlayClientState::PauseFlag ) ? true : false );
|
||||||
client->setDesync( (msg->flags & netPlayClientState::DesyncFlag) ? true : false );
|
//client->setDesync( (msg->flags & netPlayClientState::DesyncFlag) ? true : false );
|
||||||
|
|
||||||
client->romMatch = (romCrc32 == msg->romCrc32);
|
client->romMatch = (romCrc32 == msg->romCrc32);
|
||||||
|
|
||||||
|
@ -885,8 +885,16 @@ void NetPlayServer::serverProcessMessage( NetPlayClient *client, void *msgBuf, s
|
||||||
{
|
{
|
||||||
printf("Client %s Frame:%u is NOT in Sync: OPS:%i RAM:%i\n",
|
printf("Client %s Frame:%u is NOT in Sync: OPS:%i RAM:%i\n",
|
||||||
client->userName.toLocal8Bit().constData(), msg->frameRun, opsSync, ramSync);
|
client->userName.toLocal8Bit().constData(), msg->frameRun, opsSync, ramSync);
|
||||||
|
|
||||||
|
if (0 == client->desyncCount)
|
||||||
|
{
|
||||||
|
client->desyncSinceReset++;
|
||||||
|
client->totalDesyncCount++;
|
||||||
|
}
|
||||||
client->desyncCount++;
|
client->desyncCount++;
|
||||||
|
|
||||||
|
client->setDesync(true);
|
||||||
|
|
||||||
if (client->desyncCount > forceResyncCount)
|
if (client->desyncCount > forceResyncCount)
|
||||||
{
|
{
|
||||||
FCEU_WRAPPER_LOCK();
|
FCEU_WRAPPER_LOCK();
|
||||||
|
@ -904,6 +912,7 @@ void NetPlayServer::serverProcessMessage( NetPlayClient *client, void *msgBuf, s
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
client->setDesync(false);
|
||||||
client->desyncCount = 0;
|
client->desyncCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1682,11 +1691,21 @@ int NetPlayClient::requestSync(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void NetPlayClient::recordPingResult( uint64_t delay_ms )
|
void NetPlayClient::recordPingResult( const uint64_t delay_ms )
|
||||||
{
|
{
|
||||||
pingNumSamples++;
|
pingNumSamples++;
|
||||||
pingDelayLast = delay_ms;
|
pingDelayLast = delay_ms;
|
||||||
pingDelaySum += delay_ms;
|
pingDelaySum += delay_ms;
|
||||||
|
|
||||||
|
if (delay_ms < pingDelayMin)
|
||||||
|
{
|
||||||
|
pingDelayMin = delay_ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delay_ms > pingDelayMax)
|
||||||
|
{
|
||||||
|
pingDelayMax = delay_ms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void NetPlayClient::resetPingData()
|
void NetPlayClient::resetPingData()
|
||||||
|
@ -1694,6 +1713,8 @@ void NetPlayClient::resetPingData()
|
||||||
pingNumSamples = 0;
|
pingNumSamples = 0;
|
||||||
pingDelayLast = 0;
|
pingDelayLast = 0;
|
||||||
pingDelaySum = 0;
|
pingDelaySum = 0;
|
||||||
|
pingDelayMax = 0;
|
||||||
|
pingDelayMin = 1000;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
double NetPlayClient::getAvgPingDelay()
|
double NetPlayClient::getAvgPingDelay()
|
||||||
|
@ -2864,6 +2885,40 @@ void NetPlayClientTreeItem::updateData()
|
||||||
setText( 1, QObject::tr(roleString) );
|
setText( 1, QObject::tr(roleString) );
|
||||||
setText( 2, state);
|
setText( 2, state);
|
||||||
setText( 3, QString::number(client->currentFrame) );
|
setText( 3, QString::number(client->currentFrame) );
|
||||||
|
|
||||||
|
if (isExpanded())
|
||||||
|
{
|
||||||
|
FCEU::FixedString<256> infoLine;
|
||||||
|
const int numChildren = childCount();
|
||||||
|
|
||||||
|
//printf("Calculating Expanded Item\n");
|
||||||
|
|
||||||
|
for (int i=0; i<numChildren; i++)
|
||||||
|
{
|
||||||
|
auto* item = static_cast<NetPlayClientTreeItem*>( child(i) );
|
||||||
|
switch (item->type)
|
||||||
|
{
|
||||||
|
case NetPlayClientTreeItem::PingInfo:
|
||||||
|
{
|
||||||
|
infoLine.sprintf("Ping ms: Avg %.2f Min: %llu Max: %llu",
|
||||||
|
client->getAvgPingDelay(), client->getMinPingDelay(), client->getMaxPingDelay() );
|
||||||
|
item->setFirstColumnSpanned(true);
|
||||||
|
item->setText( 0, QObject::tr(infoLine.c_str()) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NetPlayClientTreeItem::DesyncInfo:
|
||||||
|
{
|
||||||
|
infoLine.sprintf("Desync Count: Since Last Sync: %u Total: %u",
|
||||||
|
client->desyncSinceReset, client->totalDesyncCount );
|
||||||
|
item->setFirstColumnSpanned(true);
|
||||||
|
item->setText( 0, QObject::tr(infoLine.c_str()) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -2889,11 +2944,22 @@ void NetPlayHostStatusDialog::loadClientTree()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QFont font;
|
||||||
|
|
||||||
|
font.setFamily("Courier New");
|
||||||
|
font.setStyle( QFont::StyleNormal );
|
||||||
|
font.setStyleHint( QFont::Monospace );
|
||||||
|
|
||||||
auto* serverTopLvlItem = new NetPlayClientTreeItem();
|
auto* serverTopLvlItem = new NetPlayClientTreeItem();
|
||||||
|
|
||||||
serverTopLvlItem->server = server;
|
serverTopLvlItem->server = server;
|
||||||
serverTopLvlItem->updateData();
|
serverTopLvlItem->updateData();
|
||||||
|
|
||||||
|
serverTopLvlItem->setFont( 0, font );
|
||||||
|
serverTopLvlItem->setFont( 1, font );
|
||||||
|
serverTopLvlItem->setFont( 2, font );
|
||||||
|
serverTopLvlItem->setFont( 3, font );
|
||||||
|
|
||||||
clientTree->addTopLevelItem( serverTopLvlItem );
|
clientTree->addTopLevelItem( serverTopLvlItem );
|
||||||
|
|
||||||
auto& clientList = server->getClientList();
|
auto& clientList = server->getClientList();
|
||||||
|
@ -2905,6 +2971,23 @@ void NetPlayHostStatusDialog::loadClientTree()
|
||||||
clientTopLvlItem->client = client;
|
clientTopLvlItem->client = client;
|
||||||
clientTopLvlItem->updateData();
|
clientTopLvlItem->updateData();
|
||||||
|
|
||||||
|
auto* clientPingInfo = new NetPlayClientTreeItem();
|
||||||
|
clientPingInfo->setFont( 0, font );
|
||||||
|
clientPingInfo->type = NetPlayClientTreeItem::PingInfo;
|
||||||
|
clientPingInfo->setFirstColumnSpanned(true);
|
||||||
|
clientTopLvlItem->addChild( clientPingInfo );
|
||||||
|
|
||||||
|
auto* clientDesyncInfo = new NetPlayClientTreeItem();
|
||||||
|
clientDesyncInfo->setFont( 0, font );
|
||||||
|
clientDesyncInfo->type = NetPlayClientTreeItem::DesyncInfo;
|
||||||
|
clientDesyncInfo->setFirstColumnSpanned(true);
|
||||||
|
clientTopLvlItem->addChild( clientDesyncInfo );
|
||||||
|
|
||||||
|
clientTopLvlItem->setFont( 0, font );
|
||||||
|
clientTopLvlItem->setFont( 1, font );
|
||||||
|
clientTopLvlItem->setFont( 2, font );
|
||||||
|
clientTopLvlItem->setFont( 3, font );
|
||||||
|
|
||||||
clientTree->addTopLevelItem( clientTopLvlItem );
|
clientTree->addTopLevelItem( clientTopLvlItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ class NetPlayServer : public QTcpServer
|
||||||
int role = -1;
|
int role = -1;
|
||||||
int roleMask = 0;
|
int roleMask = 0;
|
||||||
NetPlayClient* clientPlayer[4] = { nullptr };
|
NetPlayClient* clientPlayer[4] = { nullptr };
|
||||||
int forceResyncCount = 10;
|
uint32_t forceResyncCount = 10;
|
||||||
uint32_t cycleCounter = 0;
|
uint32_t cycleCounter = 0;
|
||||||
uint32_t maxLeadFrames = 10u;
|
uint32_t maxLeadFrames = 10u;
|
||||||
uint32_t clientWaitCounter = 0;
|
uint32_t clientWaitCounter = 0;
|
||||||
|
@ -281,16 +281,21 @@ class NetPlayClient : public QObject
|
||||||
void setPaused(bool value){ paused = value; }
|
void setPaused(bool value){ paused = value; }
|
||||||
bool hasDesync(){ return desync; }
|
bool hasDesync(){ return desync; }
|
||||||
void setDesync(bool value){ desync = value; }
|
void setDesync(bool value){ desync = value; }
|
||||||
void recordPingResult( uint64_t delay_ms );
|
void recordPingResult( const uint64_t delay_ms );
|
||||||
void resetPingData(void);
|
void resetPingData(void);
|
||||||
double getAvgPingDelay();
|
double getAvgPingDelay();
|
||||||
|
unsigned long long getLastPingDelay(){ return pingDelayLast; };
|
||||||
|
unsigned long long getMinPingDelay(){ return pingDelayMin; };
|
||||||
|
unsigned long long getMaxPingDelay(){ return pingDelayMax; };
|
||||||
void setDebugLog(QFile* file){ debugLog = file; };
|
void setDebugLog(QFile* file){ debugLog = file; };
|
||||||
|
|
||||||
QString userName;
|
QString userName;
|
||||||
QString password;
|
QString password;
|
||||||
int role = -1;
|
int role = -1;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
int desyncCount = 0;
|
unsigned int desyncCount = 0;
|
||||||
|
unsigned int desyncSinceReset = 0;
|
||||||
|
unsigned int totalDesyncCount = 0;
|
||||||
bool syncOk = false;
|
bool syncOk = false;
|
||||||
bool romMatch = false;
|
bool romMatch = false;
|
||||||
unsigned int currentFrame = 0;
|
unsigned int currentFrame = 0;
|
||||||
|
@ -336,6 +341,8 @@ class NetPlayClient : public QObject
|
||||||
|
|
||||||
uint64_t pingDelaySum = 0;
|
uint64_t pingDelaySum = 0;
|
||||||
uint64_t pingDelayLast = 0;
|
uint64_t pingDelayLast = 0;
|
||||||
|
uint64_t pingDelayMin = 1000;
|
||||||
|
uint64_t pingDelayMax = 0;
|
||||||
uint64_t pingNumSamples = 0;
|
uint64_t pingNumSamples = 0;
|
||||||
uint32_t romCrc32 = 0;
|
uint32_t romCrc32 = 0;
|
||||||
uint32_t numMsgBoxObjs = 0;
|
uint32_t numMsgBoxObjs = 0;
|
||||||
|
@ -436,6 +443,14 @@ class NetPlayClientTreeItem : public QTreeWidgetItem
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
StatusInfo = 0,
|
||||||
|
PingInfo,
|
||||||
|
DesyncInfo
|
||||||
|
};
|
||||||
|
|
||||||
|
int type = StatusInfo;
|
||||||
NetPlayClient* client = nullptr;
|
NetPlayClient* client = nullptr;
|
||||||
NetPlayServer* server = nullptr;
|
NetPlayServer* server = nullptr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue