newnet: Don't bother sending synch messages unless actually out of synch.
If it ain't broke, don't use up bandwidth trying to fix it.master
parent
d2994ad998
commit
c28316c5c7
|
@ -435,3 +435,8 @@ void setPlayerGameTime(unsigned player, uint32_t time)
|
|||
gameQueueTime[player] = time;
|
||||
}
|
||||
}
|
||||
|
||||
bool isInSync(void)
|
||||
{
|
||||
return !crcError;
|
||||
}
|
||||
|
|
|
@ -180,6 +180,8 @@ void recvPlayerGameTime(NETQUEUE_ queue); ///< Processes a GAME_
|
|||
bool checkPlayerGameTime(unsigned player); ///< Checks that we are not waiting for a GAME_GAME_TIME message from this player. (player can be NET_ALL_PLAYERS.)
|
||||
void setPlayerGameTime(unsigned player, uint32_t time); ///< Sets the player's time.
|
||||
|
||||
bool isInSync(void); ///< Returns true unless there was a CRC mismatch between the last GAME_GAME_TIME messages.
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif //__cplusplus
|
||||
|
|
|
@ -220,7 +220,11 @@ static BOOL sendDroidCheck(void)
|
|||
|
||||
lastSent = gameTime;
|
||||
|
||||
|
||||
if (!isInSync()) // Don't really send anything, unless out of synch.
|
||||
{
|
||||
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_CHECK_DROID);
|
||||
}
|
||||
|
||||
// Allocate space for the list of droids to send
|
||||
ppD = alloca(sizeof(DROID *) * toSend);
|
||||
|
@ -245,6 +249,8 @@ static BOOL sendDroidCheck(void)
|
|||
*(PACKAGED_CHECK *)pD->gameCheckDroid = packageCheck(pD);
|
||||
}
|
||||
|
||||
if (!isInSync()) // Don't really send anything, unless out of synch.
|
||||
{
|
||||
// Send the number of droids to expect
|
||||
NETuint8_t(&count);
|
||||
NETuint32_t(&gameTime); // Send game time.
|
||||
|
@ -254,10 +260,16 @@ static BOOL sendDroidCheck(void)
|
|||
{
|
||||
NETPACKAGED_CHECK((PACKAGED_CHECK *)ppD[i]->gameCheckDroid);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isInSync()) // Don't really send anything, unless out of synch.
|
||||
{
|
||||
return NETend();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define MIN_DELAY_BETWEEN_DROID_SYNCHS 5000 // Must be longer than maximum possible latency.
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// Send a Single Droid Check message
|
||||
|
@ -511,6 +523,8 @@ static BOOL sendStructureCheck(void)
|
|||
structureCheckLastType[player] = pS->pStructureType->type;
|
||||
|
||||
if (myResponsibility(player))
|
||||
{
|
||||
if (!isInSync()) // Don't really send anything, unless out of synch.
|
||||
{
|
||||
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_CHECK_STRUCT);
|
||||
NETuint8_t(&player);
|
||||
|
@ -526,6 +540,7 @@ static BOOL sendStructureCheck(void)
|
|||
NETend();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -679,6 +694,8 @@ static BOOL sendPowerCheck()
|
|||
{
|
||||
powerCheckLastPower[player] = getPower(player);
|
||||
if (myResponsibility(player))
|
||||
{
|
||||
if (!isInSync()) // Don't really send anything, unless out of synch.
|
||||
{
|
||||
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_CHECK_POWER);
|
||||
NETuint8_t(&player);
|
||||
|
@ -687,6 +704,7 @@ static BOOL sendPowerCheck()
|
|||
NETend();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue