[Server] Reimplement 4ebfcc4a21 for 0.6

pull/396/head
David Cernat 7 years ago
parent bf906b3f0a
commit a3a341fee6

@ -117,7 +117,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;
}

@ -8,6 +8,8 @@
TPlayers Players::players;
TSlots Players::slots;
using namespace std;
void Players::deletePlayer(RakNet::RakNetGUID guid)
{
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)
{
handshakeState = false;
handshakeCounter = 0;
loadState = NOTLOADED;
}
@ -88,16 +90,22 @@ void Player::setId(unsigned short id)
this->id = id;
}
bool Player::isHandshaked()
{
return handshakeCounter == numeric_limits<int>::max();
}
void Player::setHandshake()
{
handshakeState = true;
handshakeCounter = numeric_limits<int>::max();
}
bool Player::isHandshaked()
int Player::handshakeAttempts()
{
return handshakeState;
return handshakeCounter++;
}
void Player::setLoadState(int state)
{
loadState = state;

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

@ -19,7 +19,7 @@ namespace mwmp
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);
}
};

Loading…
Cancel
Save