[GameState|ServerApplication] Test for block sending: OK.

This commit is contained in:
Quentin Bazin 2019-01-12 13:58:27 +01:00
parent 5070a35b62
commit 104c47d898
2 changed files with 15 additions and 15 deletions

View File

@ -47,20 +47,19 @@ GameState::GameState() : m_chunk(0, 0, 2, gk::ResourceHandler::getInstance().get
initShaders();
m_client.setCommandCallback(Network::Command::ChunkData, [](sf::Packet &packet) {
std::string str;
packet >> str;
std::cout << str << std::endl;
});
for (u16 x = 0 ; x < CHUNK_WIDTH ; ++x) {
for (u16 y = 0 ; y < CHUNK_HEIGHT ; ++y) {
for (u16 z = 0 ; z < CHUNK_DEPTH ; ++z) {
m_chunk.setBlock(x, y, z, (rand() % 2) * 2);
m_chunk.lightmap().addSunlight(x, y, z, 15);
m_client.setCommandCallback(Network::Command::ChunkData, [this](sf::Packet &packet) {
for (u16 z = 0 ; z < CHUNK_DEPTH ; ++z) {
for (u16 y = 0 ; y < CHUNK_HEIGHT ; ++y) {
for (u16 x = 0 ; x < CHUNK_WIDTH ; ++x) {
u16 block;
packet >> block;
m_chunk.setBlock(x, y, z, block);
m_chunk.lightmap().addSunlight(x, y, z, 15);
}
}
}
}
});
}
void GameState::testLuaAPI() {

View File

@ -11,6 +11,7 @@
*
* =====================================================================================
*/
#include "Config.hpp"
#include "Network.hpp"
#include "ServerApplication.hpp"
@ -22,11 +23,11 @@ void ServerApplication::init() {
gk::CoreApplication::init();
m_server.setConnectionCallback([](Client &client) {
DEBUG("lol");
sf::Packet packet;
packet << Network::Command::ChunkData;
packet << std::string{"hello"};
for (u64 i = 0 ; i < CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH ; ++i)
packet << u16(rand() % 2);
client.tcpSocket->send(packet);
});