[Client] Preparing chunk request.

This commit is contained in:
Quentin Bazin 2019-01-14 10:53:43 +01:00
parent 307a1bdb23
commit c14e5ecd4d
4 changed files with 13 additions and 12 deletions

2
TODO
View File

@ -1,5 +1,7 @@
TODO
• TODO: Use Faithful 32x for buttons, backgrounds and font (or use Minecraftia for the latter)
# Issues
• TODO: `Workbench` and `Furnace` are not scaled correctly with lower GUI scale settings

View File

@ -32,7 +32,7 @@ class Client {
void connect(sf::IpAddress serverAddress, u16 serverPort);
void disconnect();
void sendReady();
void send(sf::Packet &packet) { m_tcpSocket->send(packet); }
void sendKeyState();
void update(bool &hasGameStarted);

View File

@ -57,12 +57,6 @@ void Client::disconnect() {
m_tcpSocket->send(packet);
}
void Client::sendReady() {
sf::Packet packet;
packet << Network::Command::ClientReady << m_id;
m_tcpSocket->send(packet);
}
void Client::sendKeyState() {
if (!m_keyUpdateTimer.isStarted())
m_keyUpdateTimer.start();
@ -108,13 +102,12 @@ void Client::update(bool &hasGameStarted) {
disconnect();
break;
}
else {
for (auto &it : m_commands)
if (command == it.first)
it.second(packet);
}
}
}
void Client::setCommandCallback(Network::Command command, const CommandCallback &callback) {
m_commands[command] = callback;

View File

@ -47,6 +47,12 @@ GameState::GameState(Client &client) : m_client(client) {
m_client.setCommandCallback(Network::Command::ChunkData, [this](sf::Packet &packet) {
m_world.receiveChunkData(packet);
});
m_client.setCommandCallback(Network::Command::GameStart, [](sf::Packet &) {
sf::Packet packet;
// TODO
m_client.send(packet);
});
}
void GameState::testLuaAPI() {