diff options
Diffstat (limited to 'source/game/StarWorldServer.cpp')
-rw-r--r-- | source/game/StarWorldServer.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/game/StarWorldServer.cpp b/source/game/StarWorldServer.cpp index 3c5fbfe..83e5cea 100644 --- a/source/game/StarWorldServer.cpp +++ b/source/game/StarWorldServer.cpp @@ -41,6 +41,7 @@ WorldServer::WorldServer(WorldTemplatePtr const& worldTemplate, IODevicePtr stor m_tileProtectionEnabled = true; m_universeSettings = make_shared<UniverseSettings>(); m_worldId = worldTemplate->worldName(); + m_expiryTimer = GameTimer(0.0f); init(true); writeMetadata(); @@ -514,6 +515,10 @@ List<PacketPtr> WorldServer::getOutgoingPackets(ConnectionId clientId) { return move(clientInfo->outgoingPackets); } +Maybe<Json> WorldServer::receiveMessage(ConnectionId fromConnection, String const& message, JsonArray const& args) { + return "what a wonderful world"; +} + WorldServerFidelity WorldServer::fidelity() const { return m_fidelity; } @@ -523,6 +528,19 @@ void WorldServer::setFidelity(WorldServerFidelity fidelity) { m_fidelityConfig = m_serverConfig.get("fidelitySettings").get(WorldServerFidelityNames.getRight(m_fidelity)); } +bool WorldServer::shouldExpire() { + if (!m_clientInfo.empty()) { + m_expiryTimer.reset(); + return false; + } + + return m_expiryTimer.ready(); +} + +void WorldServer::setExpiryTime(float expiryTime) { + m_expiryTimer = GameTimer(expiryTime); +} + void WorldServer::update(float dt) { ++m_currentStep; for (auto const& pair : m_clientInfo) @@ -627,6 +645,8 @@ void WorldServer::update(float dt) { for (auto& pair : m_clientInfo) pair.second->pendingForward = false; + m_expiryTimer.tick(dt); + LogMap::set(strf("server_{}_entities", m_worldId), strf("{} in {} sectors", m_entityMap->size(), m_tileArray->loadedSectorCount())); LogMap::set(strf("server_{}_time", m_worldId), strf("age = {:4.2f}, day = {:4.2f}/{:4.2f}s", epochTime(), timeOfDay(), dayLength())); LogMap::set(strf("server_{}_active_liquid", m_worldId), m_liquidEngine->activeCells()); |