diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 704584ac3..6abbd9951 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -114,7 +114,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!player->isHandshaked()) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d", player->getId()); - //KickPlayer(player->guid); + if(player->handshakeAttempts() > 5) + kickPlayer(player->guid); return; } @@ -126,6 +127,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!result) { + LOG_MESSAGE(Log::LOG_TRACE, "Player \"%s\" Disconnected by ON_PLAYER_CONNECT event", player->getName().c_str()); playerPacketController->GetPacket(ID_USER_DISCONNECTED)->setPlayer(player.get()); playerPacketController->GetPacket(ID_USER_DISCONNECTED)->Send(false); Players::deletePlayerByGUID(packet->guid); diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index 1e91b80e3..c61132122 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -94,7 +94,7 @@ Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid), NetActor(), changedM basePlayer = this; netCreature = this; printf("Player::Player()\n"); - handshakeState = false; + handshakeCounter = 0; loadState = NOTLOADED; resetUpdateFlags(); cell.blank(); @@ -226,12 +226,17 @@ void Player::setId(unsigned short id) bool Player::isHandshaked() { - return handshakeState; + return handshakeCounter == numeric_limits::max(); } void Player::setHandshake() { - handshakeState = true; + handshakeCounter = numeric_limits::max(); +} + +int Player::handshakeAttempts() +{ + return handshakeCounter++; } int Player::getLoadState() diff --git a/apps/openmw-mp/Player.hpp b/apps/openmw-mp/Player.hpp index ae249455b..909e8f16b 100644 --- a/apps/openmw-mp/Player.hpp +++ b/apps/openmw-mp/Player.hpp @@ -57,10 +57,11 @@ public: void setId(unsigned short id); bool isHandshaked(); + int handshakeAttempts(); void setHandshake(); - int getLoadState(); void setLoadState(int state); + int getLoadState(); virtual ~Player(); @@ -180,7 +181,7 @@ public: private: CellController::TContainer cells; - bool handshakeState; + int handshakeCounter; int loadState; bool /*statsChanged, attributesChanged, skillsChanged, baseInfoChanged, positionChanged,*/ changedMap; CharClass cClass;