- 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:
parent
0b9ad4c457
commit
159a273aa1
|
@ -497,8 +497,11 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
||||||
|
|
||||||
bool gotTextMsg = true;
|
bool gotTextMsg = true;
|
||||||
bool gotCellMarkerMsg = true;
|
bool gotCellMarkerMsg = true;
|
||||||
for(;this->hasDataToRead() == true &&
|
bool waitForLaggingClient = false;
|
||||||
(gotTextMsg == true || gotCellMarkerMsg == true);) {
|
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__);
|
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();
|
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());
|
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
|
||||||
|
|
|
@ -657,7 +657,8 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
|
||||||
try {
|
try {
|
||||||
alreadyInLagCheck = true;
|
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) {
|
if(connectionSlot != NULL && connectionSlot->isConnected() == true) {
|
||||||
double clientLag = this->getCurrentFrameCount() - connectionSlot->getCurrentFrameCount();
|
double clientLag = this->getCurrentFrameCount() - connectionSlot->getCurrentFrameCount();
|
||||||
double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0);
|
double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0);
|
||||||
|
|
|
@ -104,6 +104,8 @@ public:
|
||||||
// return &serverSocket;
|
// return &serverSocket;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
time_t getGameStartTime() const { return gameStartTime; }
|
||||||
|
|
||||||
virtual void close();
|
virtual void close();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
virtual void updateLobby() { };
|
virtual void updateLobby() { };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user