- attempt to stop clients from lagging too much and output to console

This commit is contained in:
Mark Vejvoda 2012-07-21 00:55:57 +00:00
parent 159a273aa1
commit acb648904c
1 changed files with 13 additions and 4 deletions

View File

@ -498,6 +498,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
bool gotTextMsg = true;
bool gotCellMarkerMsg = true;
bool waitForLaggingClient = false;
bool waitedForLaggingClient = false;
for(;waitForLaggingClient == true ||
(this->hasDataToRead() == true &&
(gotTextMsg == true || gotCellMarkerMsg == true));) {
@ -1134,8 +1136,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
//!!!
double LAG_CHECK_GRACE_PERIOD = 15;
double maxFrameCountLagAllowed = 7;
double maxClientLagTimeAllowed = 7;
double maxFrameCountLagAllowed = 10;
double maxClientLagTimeAllowed = 8;
if(this->serverInterface->getGameStartTime() > 0 &&
difftime(time(NULL),this->serverInterface->getGameStartTime()) >= LAG_CHECK_GRACE_PERIOD) {
@ -1147,14 +1149,21 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
// 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);
waitForLaggingClient = true;
if(waitedForLaggingClient == false) {
waitedForLaggingClient = true;
printf("*TESTING*: START Waiting for lagging client playerIndex = %d clientLagCount = %f [%f]\n",playerIndex,clientLagCount,clientLagTime);
}
}
}
}
}
if(waitedForLaggingClient == true) {
printf("*TESTING*: FINISHED Waiting for lagging client playerIndex = %d\n",playerIndex);
}
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
validateConnection();