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

Method update

source/game/StarSystemWorldServerThread.cpp:83–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void SystemWorldServerThread::update() {
84 WriteLocker queueLocker(m_queueMutex);
85 WriteLocker locker(m_mutex);
86
87 for (auto p : take(m_incomingPacketQueue))
88 m_systemWorld->handleIncomingPacket(p.first, p.second);
89
90 for (auto p : take(m_clientShipActions))
91 p.second(m_systemWorld->clientShip(p.first).get());
92
93 if (!m_pause || *m_pause == false)
94 m_systemWorld->update(SystemWorldTimestep * GlobalTimescale);
95 m_triggerStorage = m_systemWorld->triggeredStorage();
96
97 // important to set destinations before getting locations
98 // setting a destination nullifies the current location
99 for (auto p : take(m_clientShipDestinations))
100 m_systemWorld->setClientDestination(p.first, p.second);
101
102 m_activeInstanceWorlds = m_systemWorld->activeInstanceWorlds();
103
104 for (auto clientId : m_clients) {
105 m_outgoingPacketQueue[clientId].appendAll(m_systemWorld->pullOutgoingPackets(clientId));
106 auto shipSystemLocation = m_systemWorld->clientShipLocation(clientId);
107 auto& shipLocation = m_clientShipLocations[clientId];
108 if (shipLocation.first != shipSystemLocation) {
109 shipLocation.first = shipSystemLocation;
110 shipLocation.second = m_systemWorld->clientSkyParameters(clientId);
111 }
112 if (auto warpAction = m_systemWorld->clientWarpAction(clientId))
113 m_clientWarpActions.set(clientId, *warpAction);
114 else if (m_clientWarpActions.contains(clientId))
115 m_clientWarpActions.remove(clientId);
116 }
117 queueLocker.unlock();
118
119 if (m_updateAction)
120 m_updateAction(this);
121}
122
123void SystemWorldServerThread::setClientDestination(ConnectionId clientId, SystemLocation const& destination) {
124 WriteLocker locker(m_queueMutex);

Callers

nothing calls this directly

Calls 15

takeFunction · 0.85
clientShipMethod · 0.80
triggeredStorageMethod · 0.80
appendAllMethod · 0.80
handleIncomingPacketMethod · 0.45
getMethod · 0.45
setClientDestinationMethod · 0.45
activeInstanceWorldsMethod · 0.45
pullOutgoingPacketsMethod · 0.45
clientShipLocationMethod · 0.45
clientSkyParametersMethod · 0.45
clientWarpActionMethod · 0.45

Tested by

no test coverage detected