MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / update

Method update

source/game/StarWorldServerThread.cpp:253–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253void WorldServerThread::update(WorldServerFidelity fidelity) {
254 RecursiveMutexLocker locker(m_mutex);
255 auto unerroredClientIds = m_worldServer->clientIds();
256 for (auto clientId : unerroredClientIds) {
257 RecursiveMutexLocker queueLocker(m_queueMutex);
258 auto incomingPackets = take(m_incomingPacketQueue[clientId]);
259 queueLocker.unlock();
260 try {
261 m_worldServer->handleIncomingPackets(clientId, std::move(incomingPackets));
262 } catch (std::exception const& e) {
263 Logger::error("WorldServerThread exception caught handling incoming packets for client {}: {}",
264 clientId, outputException(e, true));
265 RecursiveMutexLocker queueLocker(m_queueMutex);
266 m_outgoingPacketQueue[clientId].appendAll(m_worldServer->removeClient(clientId));
267 unerroredClientIds.remove(clientId);
268 }
269 }
270
271 float dt = ServerGlobalTimestep * GlobalTimescale;
272 m_worldServer->setFidelity(fidelity);
273 if (dt > 0.0f && (!m_pause || *m_pause == false))
274 m_worldServer->update(dt);
275
276 List<Message> messages;
277 {
278 RecursiveMutexLocker locker(m_messageMutex);
279 messages = std::move(m_messages);
280 }
281 for (auto& message : messages) {
282 if (auto resp = m_worldServer->receiveMessage(ServerConnectionId, message.message, message.args))
283 message.promise.fulfill(*resp);
284 else
285 message.promise.fail("Message not handled by world");
286 }
287
288 for (auto& clientId : unerroredClientIds) {
289 auto outgoingPackets = m_worldServer->getOutgoingPackets(clientId);
290 RecursiveMutexLocker queueLocker(m_queueMutex);
291 m_outgoingPacketQueue[clientId].appendAll(std::move(outgoingPackets));
292 }
293
294 m_shouldExpire = m_worldServer->shouldExpire();
295
296 if (m_updateAction)
297 m_updateAction(this, m_worldServer.get());
298}
299
300void WorldServerThread::sync() {
301 RecursiveMutexLocker locker(m_mutex);

Callers

nothing calls this directly

Calls 15

takeFunction · 0.85
errorFunction · 0.85
appendAllMethod · 0.80
setFidelityMethod · 0.80
outputExceptionFunction · 0.50
clientIdsMethod · 0.45
unlockMethod · 0.45
handleIncomingPacketsMethod · 0.45
removeClientMethod · 0.45
removeMethod · 0.45
receiveMessageMethod · 0.45
fulfillMethod · 0.45

Tested by

no test coverage detected