summaryrefslogtreecommitdiffstats
path: root/src/gamestate/Game.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/gamestate/Game.cpp (renamed from Game.cpp)26
1 files changed, 20 insertions, 6 deletions
diff --git a/Game.cpp b/src/gamestate/Game.cpp
index db38977..15f83e6 100644
--- a/Game.cpp
+++ b/src/gamestate/Game.cpp
@@ -1,7 +1,7 @@
#include "Game.hpp"
-#include "PacketParser.hpp"
-#include "PacketBuilder.hpp"
-#include "json.hpp"
+#include "../packet/PacketParser.hpp"
+#include "../packet/PacketBuilder.hpp"
+#include <nlohmann/json.hpp>
Game::Game() {
m_display = new Display(1280, 720, "AltCraft", &m_world);
@@ -21,7 +21,7 @@ Game::Game() {
Game::~Game() {
std::cout << "Stopping game thread..." << std::endl;
- m_exit=true;
+ m_exit = true;
m_gameThread.join();
std::cout << "Stopping graphics..." << std::endl;
delete m_display;
@@ -31,6 +31,7 @@ Game::~Game() {
void Game::MainLoop() {
while (!m_exit) {
+
ParsePackets();
if (m_display->IsClosed())
m_exit = true;
@@ -48,6 +49,8 @@ void Game::ParsePackets() {
delete packetPtr;
PacketParser::Parse(packet);
nlohmann::json json;
+ //std::cout<<"Parsing packet: "<<std::hex<<packet.GetId()<<std::dec<<std::endl;
+ fflush(stdout);
switch (packet.GetId()) {
case 0x23:
@@ -114,9 +117,10 @@ void Game::ParsePackets() {
m_nc->AddPacketToQueue(PacketBuilder::CPlay0x03(0));
m_nc->AddPacketToQueue(PacketBuilder::CPlay0x00(packet.GetField(6).GetVarInt()));
std::cout << "Game is started! " << std::endl;
- std::cout << "PlayerPos is " << g_PlayerX << "," << g_PlayerY << "," << g_PlayerZ << "\tAngle: " << g_PlayerYaw
+ std::cout << "PlayerPos is " << g_PlayerX << ", " << g_PlayerY << ", " << g_PlayerZ << "\tAngle: "
+ << g_PlayerYaw
<< "," << g_PlayerPitch << std::endl;
- m_display->SetPlayerPos(g_PlayerX, g_PlayerY,g_PlayerZ);
+ m_display->SetPlayerPos(g_PlayerX, g_PlayerY, g_PlayerZ);
gameStartWaiter.notify_all();
break;
case 0x1A:
@@ -126,6 +130,16 @@ void Game::ParsePackets() {
break;
case 0x20:
m_world.ParseChunkData(packet);
+ {
+ std::vector<Vector>vec;
+ for (auto &it:m_world.m_sections) {
+ for (auto& it2:vec){
+ if (it2==it.first)
+ std::cout<<it.first<<std::endl;
+ }
+ vec.push_back(it.first);
+ }
+ }
break;
case 0x07:
std::cout << "Statistics:" << std::endl;