#include #include "server/GameServer.h" #include "server/commands/CommandManager.h" #include "server/commands/CommandTypes.h" #include "server/world/WorldGenerator.h" GameServer::GameServer(Server& server) : state(server), reader(0, "> ") { worlds.add(new World(blocks)); WorldGenerator wg(blocks, *(worlds[0])); } void GameServer::tick() { tps.update(); handleCommands(); } void GameServer::handleCommands() { if(!reader.canRead()) { return; } const char* s = reader.readLine(); if(s == nullptr) { return; } RawCommand rawCommand(s); commandManager.execute(state, rawCommand); } void GameServer::onConnect(Server::Client& client) { (void)client; std::cout << "connected\n"; } void GameServer::onDisconnect(Server::Client& client) { (void)client; std::cout << "disconnected\n"; } void GameServer::onPacket(Server::Client& client, InPacket& in) { (void)client; StringBuffer<256> s; int8 c; while(in.readS8(c)) { s.append(c); } std::cout << "Packet: " << s << "\n"; } bool GameServer::isRunning() const { return state.running; }