1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-30 13:41:25 +00:00

[Server] Reimplement 4ebfcc4a21 for 0.6

This commit is contained in:
David Cernat 2018-03-10 22:18:33 +02:00
parent bf906b3f0a
commit a3a341fee6
4 changed files with 20 additions and 10 deletions

View file

@ -117,7 +117,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (!player->isHandshaked()) if (!player->isHandshaked())
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d", player->getId()); 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; return;
} }

View file

@ -8,6 +8,8 @@
TPlayers Players::players; TPlayers Players::players;
TSlots Players::slots; TSlots Players::slots;
using namespace std;
void Players::deletePlayer(RakNet::RakNetGUID guid) void Players::deletePlayer(RakNet::RakNetGUID guid)
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Deleting player with guid %lu", guid.g); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Deleting player with guid %lu", guid.g);
@ -69,7 +71,7 @@ unsigned short Players::getLastPlayerId()
Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid) Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid)
{ {
handshakeState = false; handshakeCounter = 0;
loadState = NOTLOADED; loadState = NOTLOADED;
} }
@ -88,16 +90,22 @@ void Player::setId(unsigned short id)
this->id = id; this->id = id;
} }
void Player::setHandshake()
{
handshakeState = true;
}
bool Player::isHandshaked() bool Player::isHandshaked()
{ {
return handshakeState; return handshakeCounter == numeric_limits<int>::max();
} }
void Player::setHandshake()
{
handshakeCounter = numeric_limits<int>::max();
}
int Player::handshakeAttempts()
{
return handshakeCounter++;
}
void Player::setLoadState(int state) void Player::setLoadState(int state)
{ {
loadState = state; loadState = state;

View file

@ -58,6 +58,7 @@ public:
void setId(unsigned short id); void setId(unsigned short id);
bool isHandshaked(); bool isHandshaked();
int handshakeAttempts();
void setHandshake(); void setHandshake();
void setLoadState(int state); void setLoadState(int state);
@ -72,7 +73,7 @@ public:
private: private:
CellController::TContainer cells; CellController::TContainer cells;
bool handshakeState; int handshakeCounter;
int loadState; int loadState;
}; };

View file

@ -19,7 +19,7 @@ namespace mwmp
virtual void Do(PlayerPacket &packet, BasePlayer *player) virtual void Do(PlayerPacket &packet, BasePlayer *player)
{ {
packet.setPlayer(getLocalPlayer()); // player is 0 because myGuid will be setted after ProcessUserMyID packet.setPlayer(getLocalPlayer()); // player is 0 because myGuid will be set after ProcessUserMyID
packet.Send(serverAddr); packet.Send(serverAddr);
} }
}; };