diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2020-07-30 02:07:56 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2020-07-30 02:07:56 +0200 |
commit | 99267ff981c080e2c0b96c38af54a9b8c0623e66 (patch) | |
tree | 14ce54f1349966ce3482d270c1b104bdac6cc86d /src | |
parent | Improved connection exceptions handling (diff) | |
download | AltCraft-99267ff981c080e2c0b96c38af54a9b8c0623e66.tar AltCraft-99267ff981c080e2c0b96c38af54a9b8c0623e66.tar.gz AltCraft-99267ff981c080e2c0b96c38af54a9b8c0623e66.tar.bz2 AltCraft-99267ff981c080e2c0b96c38af54a9b8c0623e66.tar.lz AltCraft-99267ff981c080e2c0b96c38af54a9b8c0623e66.tar.xz AltCraft-99267ff981c080e2c0b96c38af54a9b8c0623e66.tar.zst AltCraft-99267ff981c080e2c0b96c38af54a9b8c0623e66.zip |
Diffstat (limited to '')
-rw-r--r-- | src/GameState.cpp | 29 | ||||
-rw-r--r-- | src/GameState.hpp | 7 |
2 files changed, 27 insertions, 9 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp index 03b13ae..3d1714b 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -9,6 +9,22 @@ void GameState::Update(double deltaTime) { OPTICK_EVENT(); + + if (!gameStatus.isGameStarted) { + if (!receivedEnoughChunks) { + receivedEnoughChunks = world.GetSectionsList().size() >= 49; + } + + if (receivedJoinGame && receivedEnoughChunks && receivedFirstPlayerPosAndLook) { + gameStatus.isGameStarted = true; + LOG(INFO) << "Game is started"; + PUSH_EVENT("RemoveLoadingScreen", 0); + + auto packetPerformRespawn = std::make_shared<PacketClientStatus>(0); + PUSH_EVENT("SendPacket", std::static_pointer_cast<Packet>(packetPerformRespawn)); + } + } + if (!gameStatus.isGameStarted) return; @@ -269,6 +285,8 @@ void GameState::UpdatePacket(std::shared_ptr<Packet> ptr) { << ", Level Type is " << gameStatus.levelType; PUSH_EVENT("PlayerConnected", 0); + receivedJoinGame = true; + auto packetSettings = std::make_shared<PacketClientSettings>("en_us", 0x14, 0, true, 0x7F, 1); PUSH_EVENT("SendPacket", std::static_pointer_cast<Packet>(packetSettings)); @@ -364,18 +382,11 @@ void GameState::UpdatePacket(std::shared_ptr<Packet> ptr) { PUSH_EVENT("PlayerPosChanged", player->pos); LOG(INFO) << "PlayerPos is " << player->pos << "\t\tAngle: " << player->yaw << "," << player->pitch;; - if (!gameStatus.isGameStarted) { - LOG(INFO) << "Game is started"; - PUSH_EVENT("RemoveLoadingScreen", 0); - } - - gameStatus.isGameStarted = true; + receivedFirstPlayerPosAndLook = true; auto packetResponse = std::make_shared<PacketTeleportConfirm>(packet->TeleportId); - auto packetPerformRespawn = std::make_shared<PacketClientStatus>(0); - PUSH_EVENT("SendPacket", std::static_pointer_cast<Packet>(packetResponse)); - PUSH_EVENT("SendPacket", std::static_pointer_cast<Packet>(packetPerformRespawn)); + break; } diff --git a/src/GameState.hpp b/src/GameState.hpp index 5489ac6..0ca858f 100644 --- a/src/GameState.hpp +++ b/src/GameState.hpp @@ -68,6 +68,13 @@ class GameState { Window playerInventory; std::vector<Window> openedWindows; + + bool receivedJoinGame = false; + + bool receivedEnoughChunks = false; + + bool receivedFirstPlayerPosAndLook = false; + public: void Update(double deltaTime); |