Fix packet spam

pull/58/head
Koncord 8 years ago
parent 96e2d749c7
commit 24617589e4

@ -49,15 +49,6 @@ void Networking::Update(RakNet::Packet *packet)
Player *player = Players::GetPlayer(packet->guid);
if (player == 0)
{
controller->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
Players::NewPlayer(packet->guid);
player = Players::GetPlayer(packet->guid);
controller->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(packet->guid), false);
return;
}
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
{
@ -68,6 +59,15 @@ void Networking::Update(RakNet::Packet *packet)
controller->SetStream(&bsIn, 0);
if (player == 0)
{
controller->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
Players::NewPlayer(packet->guid);
player = Players::GetPlayer(packet->guid);
controller->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(packet->guid), false);
return;
}
BasePacket *myPacket = controller->GetPacket(packet->data[0]);
if (packet->data[0] == ID_HANDSHAKE)
@ -109,7 +109,7 @@ void Networking::Update(RakNet::Packet *packet)
if (packet->data[0] == ID_LOADED)
{
player->Loaded();
player->Loaded(Player::LOADED);
static constexpr unsigned int ident = Script::CallbackIdentity("OnPlayerConnect");
Script::CallBackReturn<ident> result = true;
@ -131,12 +131,13 @@ void Networking::Update(RakNet::Packet *packet)
myPacket->Send(player, true);
}
if(!player->isLoaded())
if (player->LoadedState() == Player::NOTLOADED)
return;
else if(player->BirthSign()->empty())
else if (player->LoadedState() == Player::LOADED)
{
(*player->BirthSign()) = "a";
player->Loaded(Player::POSTLOADED);
NewPlayer(packet->guid);
return;
}
switch (packet->data[0])

@ -92,12 +92,12 @@ bool Player::isHandshaked()
return handshake;
}
void Player::Loaded()
void Player::Loaded(int state)
{
loaded = true;
loaded = state;
}
bool Player::isLoaded()
int Player::LoadedState()
{
return loaded;
}

@ -40,6 +40,12 @@ class Player : public mwmp::BasePlayer
unsigned short id;
public:
enum
{
NOTLOADED=0,
LOADED,
POSTLOADED
};
Player(RakNet::RakNetGUID id);
unsigned short GetID();
@ -48,13 +54,13 @@ public:
bool isHandshaked();
void Handshake();
void Loaded();
bool isLoaded();
void Loaded(int state);
int LoadedState();
virtual ~Player();
private:
bool handshake;
bool loaded;
int loaded;
};
#endif //OPENMW_PLAYER_HPP

@ -91,11 +91,11 @@ void Main::Configure(const boost::program_options::variables_map &variables)
Main::addr = variables["connect"].as<string>();
}
Settings::CategorySettingValueMap saveUserSettings;
Settings::CategorySettingValueMap saveDefaultSettings;
Settings::CategorySettingVector saveChangedSettings;
static Settings::CategorySettingValueMap saveUserSettings;
static Settings::CategorySettingValueMap saveDefaultSettings;
static Settings::CategorySettingVector saveChangedSettings;
Settings::Manager InitMgr(Settings::Manager &mgr)
void InitMgr(Settings::Manager &mgr)
{
saveUserSettings = mgr.mUserSettings;
saveDefaultSettings = mgr.mDefaultSettings;

Loading…
Cancel
Save