From 70c32d288fa2134c63c70964611da646fcdfe4e9 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Thu, 30 Jul 2020 04:36:24 +0500 Subject: Minor protocol support improvement --- src/GameState.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/GameState.cpp') diff --git a/src/GameState.cpp b/src/GameState.cpp index fdb453f..03b13ae 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -268,6 +268,16 @@ void GameState::UpdatePacket(std::shared_ptr ptr) { LOG(INFO) << "Gamemode is " << gameStatus.gamemode << ", Difficulty is " << (int)gameStatus.difficulty << ", Level Type is " << gameStatus.levelType; PUSH_EVENT("PlayerConnected", 0); + + auto packetSettings = std::make_shared("en_us", 0x14, 0, true, 0x7F, 1); + PUSH_EVENT("SendPacket", std::static_pointer_cast(packetSettings)); + + std::string brandStr("\x08""AltCraft"); + std::vector brandData; + std::copy(brandStr.begin(), brandStr.end(), std::back_inserter(brandData)); + auto packetPluginBrand = std::make_shared("MC|Brand", brandData); + PUSH_EVENT("SendPacket", std::static_pointer_cast(packetPluginBrand)); + break; } -- cgit v1.2.3 From 99267ff981c080e2c0b96c38af54a9b8c0623e66 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Thu, 30 Jul 2020 05:07:56 +0500 Subject: Corrected Game Start conditions --- src/GameState.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/GameState.cpp') 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(0); + PUSH_EVENT("SendPacket", std::static_pointer_cast(packetPerformRespawn)); + } + } + if (!gameStatus.isGameStarted) return; @@ -269,6 +285,8 @@ void GameState::UpdatePacket(std::shared_ptr ptr) { << ", Level Type is " << gameStatus.levelType; PUSH_EVENT("PlayerConnected", 0); + receivedJoinGame = true; + auto packetSettings = std::make_shared("en_us", 0x14, 0, true, 0x7F, 1); PUSH_EVENT("SendPacket", std::static_pointer_cast(packetSettings)); @@ -364,18 +382,11 @@ void GameState::UpdatePacket(std::shared_ptr 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(packet->TeleportId); - auto packetPerformRespawn = std::make_shared(0); - PUSH_EVENT("SendPacket", std::static_pointer_cast(packetResponse)); - PUSH_EVENT("SendPacket", std::static_pointer_cast(packetPerformRespawn)); + break; } -- cgit v1.2.3