- bold change to see what this does for network play (CAUTION THIS is for testing only and may be reverted)

This commit is contained in:
Mark Vejvoda 2012-07-21 00:23:27 +00:00
parent 0b9ad4c457
commit 159a273aa1
3 changed files with 31 additions and 3 deletions

View File

@ -497,8 +497,11 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
bool gotTextMsg = true;
bool gotCellMarkerMsg = true;
for(;this->hasDataToRead() == true &&
(gotTextMsg == true || gotCellMarkerMsg == true);) {
bool waitForLaggingClient = false;
for(;waitForLaggingClient == true ||
(this->hasDataToRead() == true &&
(gotTextMsg == true || gotCellMarkerMsg == true));) {
waitForLaggingClient = false;
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] polling for networkMessageType...\n",__FILE__,__FUNCTION__,__LINE__);
NetworkMessageType networkMessageType= getNextMessageType();
@ -1128,6 +1131,28 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
}
}
}
//!!!
double LAG_CHECK_GRACE_PERIOD = 15;
double maxFrameCountLagAllowed = 7;
double maxClientLagTimeAllowed = 7;
if(this->serverInterface->getGameStartTime() > 0 &&
difftime(time(NULL),this->serverInterface->getGameStartTime()) >= LAG_CHECK_GRACE_PERIOD) {
if(this->isConnected() == true) {
double clientLag = this->serverInterface->getCurrentFrameCount() - this->getCurrentFrameCount();
double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0);
double clientLagTime = difftime(time(NULL),this->getLastReceiveCommandListTime());
// New lag check
if((maxFrameCountLagAllowed > 0 && clientLagCount > maxFrameCountLagAllowed) ||
(maxClientLagTimeAllowed > 0 && clientLagTime > maxClientLagTimeAllowed)) {
waitForLaggingClient = true;
printf("*TESTING*: Waiting for lagging client playerIndex = %d clientLagCount = %f [%f]\n",playerIndex,clientLagCount,clientLagTime);
}
}
}
}
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());

View File

@ -657,7 +657,8 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
try {
alreadyInLagCheck = true;
if(difftime(time(NULL),gameStartTime) >= LAG_CHECK_GRACE_PERIOD) {
if(gameStartTime > 0 &&
difftime(time(NULL),gameStartTime) >= LAG_CHECK_GRACE_PERIOD) {
if(connectionSlot != NULL && connectionSlot->isConnected() == true) {
double clientLag = this->getCurrentFrameCount() - connectionSlot->getCurrentFrameCount();
double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0);

View File

@ -104,6 +104,8 @@ public:
// return &serverSocket;
//}
time_t getGameStartTime() const { return gameStartTime; }
virtual void close();
virtual void update();
virtual void updateLobby() { };