forked from teamnwah/openmw-tes3coop
[Server] Reimplement 4ebfcc4a21
for 0.6
This commit is contained in:
parent
bf906b3f0a
commit
a3a341fee6
4 changed files with 20 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
void Player::setHandshake()
|
||||
{
|
||||
handshakeState = true;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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…
Reference in a new issue