123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include "server/Game.h"
- #include "server/GameServer.h"
- #include "server/commands/Commands.h"
- #include "server/snuviscript/Snuvi.h"
- #include "utils/Logger.h"
- void loop() {
- Clock clock;
- constexpr Clock::Nanos NANOS_PER_TICK = 50000000;
- Clock::Nanos lag = 0;
- while(Game::isRunning()) {
- lag += clock.update();
- while(lag >= NANOS_PER_TICK) {
- lag -= NANOS_PER_TICK;
- GameServer::tick();
- Game::tick();
- }
- Clock::Nanos waitNanos = NANOS_PER_TICK - lag;
- if(waitNanos > 300000) {
- clock.wait(waitNanos);
- }
- }
- }
- void init(Server* server) {
- Snuvi::init();
- Commands::init();
- GameServer::init(server);
- Game::testWorld();
- }
- int main() {
- Server server;
- Error error = server.start(11196, 50);
- if(error.has()) {
- LOG_ERROR(error.message);
- return 0;
- }
- init(&server);
- loop();
- return 0;
- }
|