diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 81938cbff..658a0b1f1 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -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 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]) diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index d79e61b06..374de78da 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -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; } diff --git a/apps/openmw-mp/Player.hpp b/apps/openmw-mp/Player.hpp index 6942268e1..7fbc5275b 100644 --- a/apps/openmw-mp/Player.hpp +++ b/apps/openmw-mp/Player.hpp @@ -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 diff --git a/apps/openmw/mwmp/Main.cpp b/apps/openmw/mwmp/Main.cpp index 68a7fbdb2..ebbbb475f 100644 --- a/apps/openmw/mwmp/Main.cpp +++ b/apps/openmw/mwmp/Main.cpp @@ -91,11 +91,11 @@ void Main::Configure(const boost::program_options::variables_map &variables) Main::addr = variables["connect"].as(); } -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;