Merge r9584/9585

"Add sync counters to more accurately keep track of what is being synced and what isn't.

This information is saved in netplay.log in the config dir."


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9590 4a71c877-e1ca-e34f-864e-861f7616d084
master
Buginator 2010-01-31 04:45:20 +00:00 committed by Git SVN Gateway
parent 3a5f7d556b
commit 46ea38f8d5
4 changed files with 70 additions and 2 deletions

View File

@ -146,6 +146,7 @@ BOOL NETstartLogging(void)
BOOL NETstopLogging(void)
{
static const char dash_line[] = "-----------------------------------------------------------\n";
char buf[256];
int i;
@ -161,6 +162,22 @@ BOOL NETstopLogging(void)
packetcount[0][i], packetsize[0][i], packetcount[1][i], packetsize[1][i]);
PHYSFS_write(pFileHandle, buf, strlen(buf), 1);
}
snprintf(buf, sizeof(buf), "\n-Sync statistics -\n");
PHYSFS_write(pFileHandle, buf, strlen(buf), 1);
PHYSFS_write(pFileHandle, dash_line, strlen(dash_line), 1);
snprintf(buf, sizeof(buf), "sent/unsent DroidCheck %llu / %llu\n", sync_counter.sentDroidCheck, sync_counter.unsentDroidCheck);
PHYSFS_write(pFileHandle, buf, strlen(buf), 1);
snprintf(buf, sizeof(buf), "sent/unsent StructureCheck %llu / %llu\n", sync_counter.sentStructureCheck, sync_counter.unsentStructureCheck);
PHYSFS_write(pFileHandle, buf, strlen(buf), 1);
snprintf(buf, sizeof(buf), "sent/unsent PowerCheck %llu / %llu\n", sync_counter.sentPowerCheck, sync_counter.unsentPowerCheck);
PHYSFS_write(pFileHandle, buf, strlen(buf), 1);
snprintf(buf, sizeof(buf), "sent/unsent ScoreCheck %llu / %llu\n", sync_counter.sentScoreCheck, sync_counter.unsentScoreCheck);
PHYSFS_write(pFileHandle, buf, strlen(buf), 1);
snprintf(buf, sizeof(buf), "sent/unsent Ping %llu / %llu\n", sync_counter.sentPing, sync_counter.unsentPing);
PHYSFS_write(pFileHandle, buf, strlen(buf), 1);
snprintf(buf, sizeof(buf), "sent/unsent isMPDirtyBit %llu / %llu\n", sync_counter.sentisMPDirtyBit, sync_counter.unsentisMPDirtyBit);
PHYSFS_write(pFileHandle, buf, strlen(buf), 1);
PHYSFS_write(pFileHandle, dash_line, strlen(dash_line), 1);
if (!PHYSFS_close(pFileHandle))
{

View File

@ -146,7 +146,7 @@ void NETresetGamePassword(void);
* Network globals, these are part of the new network API
*/
NETMSG NetMsg;
SYNC_COUNTER sync_counter; // keeps track on how well we are in sync
// ////////////////////////////////////////////////////////////////////////
// Types
@ -1946,6 +1946,7 @@ int NETinit(BOOL bFirstCall)
NetPlay.ShowedMOTD = false;
NetPlay.GamePassworded = false;
memset(&sync_counter, 0x0, sizeof(sync_counter)); //clear counters
return 0;
}

View File

@ -186,6 +186,21 @@ typedef struct
#define NET_ALL_PLAYERS 255
#define NET_HOST_ONLY 0
// the following structure is going to be used to track if we sync or not
typedef struct {
uint64_t sentDroidCheck;
uint64_t unsentDroidCheck;
uint64_t sentStructureCheck;
uint64_t unsentStructureCheck;
uint64_t sentPowerCheck;
uint64_t unsentPowerCheck;
uint64_t sentScoreCheck;
uint64_t unsentScoreCheck;
uint64_t sentPing;
uint64_t unsentPing;
uint64_t sentisMPDirtyBit;
uint64_t unsentisMPDirtyBit;
} SYNC_COUNTER;
typedef struct {
uint16_t size; // used size of body
@ -264,7 +279,7 @@ typedef struct {
extern NETPLAY NetPlay;
extern NETMSG NetMsg;
extern SYNC_COUNTER sync_counter;
// update flags
extern bool netPlayersUpdated;
extern int mapDownloadProgress;

View File

@ -134,22 +134,57 @@ BOOL sendCheck(void)
if(okToSend())
{
sendDroidCheck();
sync_counter.sentDroidCheck++;
}
else
{
sync_counter.unsentDroidCheck++;
}
if(okToSend())
{
sendStructureCheck();
sync_counter.sentStructureCheck++;
}
else
{
sync_counter.unsentStructureCheck++;
}
if(okToSend())
{
sendPowerCheck();
sync_counter.sentPowerCheck++;
}
else
{
sync_counter.unsentPowerCheck++;
}
if(okToSend())
{
sendScoreCheck();
sync_counter.sentScoreCheck++;
}
else
{
sync_counter.unsentScoreCheck++;
}
if(okToSend())
{
sendPing();
sync_counter.sentPing++;
}
else
{
sync_counter.unsentPing++;
}
if (isMPDirtyBit)
{
sync_counter.sentisMPDirtyBit++;
}
else
{
sync_counter.unsentisMPDirtyBit++;
}
// FIXME: reset flag--For now, we always do this since we have no way of knowing which routine(s) we had to set this flag
isMPDirtyBit = false;