#include #include "gaming-core/network/ENet.h" #include "gaming-core/network/Server.h" #include "gaming-core/utils/Clock.h" #include "server/GameServer.h" int main() { ENet enet; if(enet.init()) { std::cout << "cannot initialize enet\n"; return 0; } Server server(11196, 50); if(server.hasError()) { return 0; } GameServer gameServer(server); Clock clock; constexpr Clock::Nanos NANOS_PER_TICK = 50000000; Clock::Nanos lag = 0; while(gameServer.isRunning()) { lag += clock.update(); while(lag >= NANOS_PER_TICK) { lag -= NANOS_PER_TICK; server.consumeEvents(gameServer); gameServer.tick(); } Clock::Nanos waitNanos = NANOS_PER_TICK - lag; if(waitNanos > 300000) { clock.wait(waitNanos); } } return 0; }