summaryrefslogtreecommitdiffstats
path: root/src/GameState.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2020-07-31 07:05:46 +0200
committerGitHub <noreply@github.com>2020-07-31 07:05:46 +0200
commit28caa598e29b7eaa36d0877dd57947d29fe92e06 (patch)
tree14ce54f1349966ce3482d270c1b104bdac6cc86d /src/GameState.cpp
parentMerge pull request #42 from LaG1924/ftr/chat_component_parse (diff)
parentCorrected Game Start conditions (diff)
downloadAltCraft-28caa598e29b7eaa36d0877dd57947d29fe92e06.tar
AltCraft-28caa598e29b7eaa36d0877dd57947d29fe92e06.tar.gz
AltCraft-28caa598e29b7eaa36d0877dd57947d29fe92e06.tar.bz2
AltCraft-28caa598e29b7eaa36d0877dd57947d29fe92e06.tar.lz
AltCraft-28caa598e29b7eaa36d0877dd57947d29fe92e06.tar.xz
AltCraft-28caa598e29b7eaa36d0877dd57947d29fe92e06.tar.zst
AltCraft-28caa598e29b7eaa36d0877dd57947d29fe92e06.zip
Diffstat (limited to 'src/GameState.cpp')
-rw-r--r--src/GameState.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp
index fdb453f..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;
@@ -268,6 +284,18 @@ void GameState::UpdatePacket(std::shared_ptr<Packet> ptr) {
LOG(INFO) << "Gamemode is " << gameStatus.gamemode << ", Difficulty is " << (int)gameStatus.difficulty
<< ", 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));
+
+ std::string brandStr("\x08""AltCraft");
+ std::vector<unsigned char> brandData;
+ std::copy(brandStr.begin(), brandStr.end(), std::back_inserter(brandData));
+ auto packetPluginBrand = std::make_shared<PacketPluginMessageSB>("MC|Brand", brandData);
+ PUSH_EVENT("SendPacket", std::static_pointer_cast<Packet>(packetPluginBrand));
+
break;
}
@@ -354,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;
}