|
@@ -1,7 +1,11 @@
|
|
|
#include "client/Game.h"
|
|
|
+#include "client/packets/WorldPackets.h"
|
|
|
#include "common/network/Packets.h"
|
|
|
+#include "utils/Logger.h"
|
|
|
#include "utils/Utils.h"
|
|
|
|
|
|
+BlockRegistry Game::blockRegistry;
|
|
|
+
|
|
|
Game::Game(TextInput*& textInput, const Controller& controller,
|
|
|
const Clock& fps, const Clock& tps, RenderSettings& settings,
|
|
|
const Size& size, Client& client)
|
|
@@ -10,7 +14,7 @@ Game::Game(TextInput*& textInput, const Controller& controller,
|
|
|
renderState(&Game::renderConnectState),
|
|
|
baseGUI(size, textInput, controller), startGUI(baseGUI),
|
|
|
world(blockRegistry), worldRenderer(world) {
|
|
|
- pos = Vector3(16.0f, 30.0f, -10.0f);
|
|
|
+ pos = Vector3(0.0f, 30.0f, 0.0f);
|
|
|
rotation = Quaternion(Vector3(1.0f, 0.0f, 0.0f), 30) * rotation;
|
|
|
rotation = Quaternion(Vector3(0.0f, 1.0f, 0.0f), 30) * rotation;
|
|
|
}
|
|
@@ -93,31 +97,14 @@ void Game::onPacket(InPacket& in) {
|
|
|
return;
|
|
|
}
|
|
|
switch(id) {
|
|
|
- case ServerPacket::CHAT:
|
|
|
+ case S_CHAT:
|
|
|
{
|
|
|
StringBuffer<256> s;
|
|
|
in.readString(s);
|
|
|
- std::cout << s << '\n';
|
|
|
- break;
|
|
|
- }
|
|
|
- case ServerPacket::WORLD:
|
|
|
- {
|
|
|
- std::cout << "World data:\n";
|
|
|
- for(int x = 0; x < world.getSize(); x++) {
|
|
|
- for(int y = 0; y < world.getHeight(); y++) {
|
|
|
- for(int z = 0; z < world.getSize(); z++) {
|
|
|
- BlockId id;
|
|
|
- if(in.readU16(id)) {
|
|
|
- std::cout << "WELL\n";
|
|
|
- return;
|
|
|
- }
|
|
|
- world.setBlock(x, y, z, blockRegistry.getBlock(id));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- world.dirty = true;
|
|
|
+ puts(s);
|
|
|
break;
|
|
|
}
|
|
|
+ case S_WORLD_SEGMENT: WorldPackets::receiveChunk(world, in); break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -126,9 +113,9 @@ void Game::tickConnectState() {
|
|
|
StartGUI::Address a;
|
|
|
if(startGUI.getAddress(a)) {
|
|
|
if(client.connect(a, 11196, 3000)) {
|
|
|
- std::cout << client.getError() << '\n';
|
|
|
+ LOG_INFO(client.getError());
|
|
|
} else {
|
|
|
- std::cout << "connected\n";
|
|
|
+ LOG_INFO("connected");
|
|
|
tickState = &Game::tickConnectedState;
|
|
|
renderState = &Game::renderConnectedState;
|
|
|
}
|