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

Method update

source/game/StarSystemWorldServer.cpp:211–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211void SystemWorldServer::update(float dt) {
212 for (auto p : m_ships)
213 p.second->serverUpdate(this, dt);
214
215 for (auto p : m_objects) {
216 p.second->serverUpdate(this, dt);
217
218 // don't destroy objects that still have players at them
219 if (p.second->shouldDestroy() && shipsAtLocation(p.first).size() == 0)
220 removeObject(p.first);
221 }
222
223 spawnObjects();
224
225 queueUpdatePackets();
226
227 // remove objects and ships after queueing update packets to ensure they're not updated after being removed
228 for (auto objectUuid : take(m_objectDestroyQueue)) {
229 for (auto p : m_clientNetVersions) {
230 p.second.objects.remove(objectUuid);
231 m_outgoingPackets[p.first].append(make_shared<SystemObjectDestroyPacket>(objectUuid));
232 }
233 m_objects.remove(objectUuid);
234 m_triggerStorage = true;
235 }
236 for (auto shipUuid : take(m_shipDestroyQueue)) {
237 for (auto p : m_clientNetVersions) {
238 p.second.ships.remove(shipUuid);
239 m_outgoingPackets[p.first].append(make_shared<SystemShipDestroyPacket>(shipUuid));
240 }
241 m_ships.remove(shipUuid);
242 m_triggerStorage = true;
243 }
244}
245
246List<SystemObjectPtr> SystemWorldServer::objects() const {
247 return m_objects.values();

Callers

nothing calls this directly

Calls 6

takeFunction · 0.85
serverUpdateMethod · 0.80
shouldDestroyMethod · 0.45
sizeMethod · 0.45
removeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected