summaryrefslogtreecommitdiffstats
path: root/src/gamestate
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-18 16:03:05 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-18 16:03:05 +0200
commit4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79 (patch)
tree548911d4e341fd5717acff3b5bc752c7b5650bf4 /src/gamestate
parent2017-05-13 (diff)
downloadAltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.gz
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.bz2
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.lz
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.xz
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.zst
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.zip
Diffstat (limited to '')
-rw-r--r--src/gamestate/Game.cpp (renamed from Game.cpp)26
-rw-r--r--src/gamestate/Game.hpp (renamed from code/Game.hpp)10
-rw-r--r--src/gamestate/GameState.cpp1
-rw-r--r--src/gamestate/GameState.hpp8
4 files changed, 34 insertions, 11 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;
diff --git a/code/Game.hpp b/src/gamestate/Game.hpp
index b9096a5..adf9059 100644
--- a/code/Game.hpp
+++ b/src/gamestate/Game.hpp
@@ -1,9 +1,9 @@
#pragma once
-#include "PositionI.hpp"
-#include "NetworkClient.hpp"
-#include "World.hpp"
-#include "graphics/Display.hpp"
+#include "../utility/Vector.hpp"
+#include "../network/NetworkClient.hpp"
+#include "../world/World.hpp"
+#include "../graphics/Display.hpp"
class Game {
public:
@@ -41,7 +41,7 @@ private:
byte g_MaxPlayers;
std::string g_LevelType;
bool g_ReducedDebugInfo;
- PositionI g_SpawnPosition;
+ Vector g_SpawnPosition;
bool g_PlayerInvulnerable;
bool g_PlayerFlying;
bool g_PlayerAllowFlying;
diff --git a/src/gamestate/GameState.cpp b/src/gamestate/GameState.cpp
new file mode 100644
index 0000000..7bcc2d5
--- /dev/null
+++ b/src/gamestate/GameState.cpp
@@ -0,0 +1 @@
+#include "GameState.hpp"
diff --git a/src/gamestate/GameState.hpp b/src/gamestate/GameState.hpp
new file mode 100644
index 0000000..e9c433d
--- /dev/null
+++ b/src/gamestate/GameState.hpp
@@ -0,0 +1,8 @@
+#pragma once
+
+#include "../world/World.hpp"
+
+class GameState {
+public:
+ World world;
+};