mirror of
https://github.com/glest/glest-source.git
synced 2025-09-02 20:42:34 +02:00
server_interface:lag:allow a greater grace period before dropping player
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
// connection_slot.cpp:
|
||||
// connected clients (not the host or user setting up the game)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
// Copyright (C) 2018 The ZetaGlest team <https://github.com/ZetaGlest>
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
// ZetaGlest is a fork of MegaGlest <https://megaglest.org>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "connection_slot.h"
|
||||
|
||||
@@ -371,6 +380,7 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex
|
||||
this->platform = "";
|
||||
this->currentFrameCount = 0;
|
||||
this->currentLagCount = 0;
|
||||
this->graceLagCtr = 0;
|
||||
this->gotLagCountWarning = false;
|
||||
this->lastReceiveCommandListTime = 0;
|
||||
this->receivedNetworkGameStatus = false;
|
||||
@@ -1451,7 +1461,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
||||
}
|
||||
|
||||
void ConnectionSlot::validateConnection() {
|
||||
if(this->isConnected() == true &&
|
||||
if(this->isConnected() == true &&
|
||||
gotIntro == false && connectedTime > 0 &&
|
||||
difftime((long int)time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) {
|
||||
|
||||
|
@@ -1,13 +1,22 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
// connection_slot.h:
|
||||
// connected clients (not the host or user setting up the game)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
// Copyright (C) 2018 The ZetaGlest team <https://github.com/ZetaGlest>
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
// ZetaGlest is a fork of MegaGlest <https://megaglest.org>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef _GLEST_GAME_CONNECTIONSLOT_H_
|
||||
#define _GLEST_GAME_CONNECTIONSLOT_H_
|
||||
@@ -145,6 +154,7 @@ private:
|
||||
ConnectionSlotThread* slotThreadWorker;
|
||||
int currentFrameCount;
|
||||
int currentLagCount;
|
||||
int graceLagCtr;
|
||||
time_t lastReceiveCommandListTime;
|
||||
bool gotLagCountWarning;
|
||||
string versionString;
|
||||
@@ -187,6 +197,9 @@ public:
|
||||
bool getSkipLagCheck() const { return skipLagCheck; }
|
||||
bool getJoinGameInProgress() const { return joinGameInProgress; }
|
||||
|
||||
int getGraceLagCtr() { return graceLagCtr++; }
|
||||
void resetGraceLagCtr() { graceLagCtr = 0; }
|
||||
|
||||
bool getSentSavedGameInfo() const { return sentSavedGameInfo; }
|
||||
void setSentSavedGameInfo(bool value) { sentSavedGameInfo = value; }
|
||||
|
||||
|
@@ -58,6 +58,7 @@ double maxClientLagTimeAllowedEver = 25;
|
||||
double warnFrameCountLagPercent = 0.50;
|
||||
double LAG_CHECK_GRACE_PERIOD = 15;
|
||||
double LAG_CHECK_INTERVAL_PERIOD = 4;
|
||||
int GRACE_LAG_CTR_LIMIT = 5;
|
||||
|
||||
const int MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE_MILLISECONDS = 15000;
|
||||
const int MAX_CLIENT_PAUSE_FOR_LAG_COUNT = 3;
|
||||
@@ -802,12 +803,16 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
|
||||
}
|
||||
}
|
||||
|
||||
if(gameSettings.getNetworkPauseGameForLaggedClients() == false ||
|
||||
if((gameSettings.getNetworkPauseGameForLaggedClients() == false ||
|
||||
(maxFrameCountLagAllowedEver > 0 && clientLagCount > maxFrameCountLagAllowedEver) ||
|
||||
(maxClientLagTimeAllowedEver > 0 && clientLagTime > maxClientLagTimeAllowedEver)) {
|
||||
(maxClientLagTimeAllowedEver > 0 && clientLagTime > maxClientLagTimeAllowedEver) &&
|
||||
connectionSlot->getGraceLagCtr() > GRACE_LAG_CTR_LIMIT)) {
|
||||
|
||||
//printf("Closing connection slot lagged out!\n");
|
||||
connectionSlot->close();
|
||||
// not needed now, but will be needed when in-game joins and rejoins
|
||||
// are used
|
||||
connectionSlot->resetGraceLagCtr();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1115,8 +1120,10 @@ void ServerInterface::checkForAutoPauseForLaggingClient(int index,ConnectionSlot
|
||||
connectionSlot->incrementAutoPauseGameCountForLag();
|
||||
|
||||
this->clientsAutoPausedDueToLag = true;
|
||||
if (this->clientLagCallbackInterface->clientLagHandler(index, true) == false) {
|
||||
if ((this->clientLagCallbackInterface->clientLagHandler(index, true) == false) &&
|
||||
connectionSlot->getGraceLagCtr() > GRACE_LAG_CTR_LIMIT) {
|
||||
connectionSlot->close();
|
||||
connectionSlot->resetGraceLagCtr();
|
||||
}
|
||||
else {
|
||||
if (this->clientsAutoPausedDueToLagTimer.isStarted()== true) {
|
||||
|
Reference in New Issue
Block a user