From 34893ff6311d6a9543e943ac66c939372a7624de Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 9 Apr 2018 15:25:50 +0300 Subject: [PATCH] [Server] Split up handshake handling into multiple functions for debug Unfortunately, the handshake attempt limit implemented in 4ebfcc4a21051702425c9f0ad9a710814e7cca90 for 0.7 and then ported over to 0.6 in a3a341fee64843985be9c7a10c105ab65d2ac416 does not appear to work properly, which is why gathering more information on it is important. --- apps/openmw-mp/Networking.cpp | 6 +++++- apps/openmw-mp/Player.cpp | 9 +++++++-- apps/openmw-mp/Player.hpp | 5 +++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 9c7eb949f..663256dd7 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -116,8 +116,12 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!player->isHandshaked()) { + player->incrementHandshakeAttempts(); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d", player->getId()); - if (player->handshakeAttempts() > 5) + + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Attempts so far: %i", player->getHandshakeAttempts()); + + if (player->getHandshakeAttempts() > 5) kickPlayer(player->guid); return; } diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index 18e51a89a..6e66f8151 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -100,9 +100,14 @@ void Player::setHandshake() handshakeCounter = numeric_limits::max(); } -int Player::handshakeAttempts() +void Player::incrementHandshakeAttempts() { - return handshakeCounter++; + handshakeCounter++; +} + +int Player::getHandshakeAttempts() +{ + return handshakeCounter; } diff --git a/apps/openmw-mp/Player.hpp b/apps/openmw-mp/Player.hpp index aa52d7574..a956a4a52 100644 --- a/apps/openmw-mp/Player.hpp +++ b/apps/openmw-mp/Player.hpp @@ -58,7 +58,8 @@ public: void setId(unsigned short id); bool isHandshaked(); - int handshakeAttempts(); + int getHandshakeAttempts(); + void incrementHandshakeAttempts(); void setHandshake(); void setLoadState(int state); @@ -73,8 +74,8 @@ public: private: CellController::TContainer cells; - int handshakeCounter; int loadState; + int handshakeCounter; };