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

Method addClientShip

source/game/StarSystemWorldServer.cpp:90–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90void SystemWorldServer::addClientShip(ConnectionId clientId, Uuid const& uuid, float shipSpeed, SystemLocation location) {
91 if (auto objectUuid = location.maybe<Uuid>()) {
92 if (getObject(*objectUuid) == nullptr)
93 location.reset();
94 }
95 if (!location)
96 location = randomArrivalPosition();
97
98 SystemClientShipPtr ship = make_shared<SystemClientShip>(this, uuid, shipSpeed, location);
99 m_clientShips.set(clientId, ship->uuid());
100 m_ships.set(ship->uuid(), ship);
101 m_clientNetVersions.set(clientId, {{}, {} });
102 m_outgoingPackets.set(clientId, {});
103
104 List<ByteArray> objectStores = m_objects.values().transformed([](SystemObjectPtr const& o) { return o->netStore(); });
105 List<ByteArray> shipStores = m_ships.values().filtered([uuid](SystemClientShipPtr const& s) {
106 return s->uuid() != uuid;
107 }).transformed([](SystemClientShipPtr const& s) {
108 return s->netStore();
109 });
110 pair<Uuid, SystemLocation> clientShip = {ship->uuid(), ship->systemLocation()};
111 m_outgoingPackets[clientId].append(make_shared<SystemWorldStartPacket>(m_location, objectStores, shipStores, clientShip));
112
113 for (ConnectionId otherClient : m_clientShips.keys()) {
114 if (otherClient != clientId)
115 m_outgoingPackets[otherClient].append(make_shared<SystemShipCreatePacket>(ship->netStore()));
116 }
117}
118
119void SystemWorldServer::removeClientShip(ConnectionId clientId) {
120 m_shipDestroyQueue.append(m_clientShips.get(clientId));

Callers 1

addClientMethod · 0.80

Calls 10

systemLocationMethod · 0.80
resetMethod · 0.45
setMethod · 0.45
uuidMethod · 0.45
transformedMethod · 0.45
valuesMethod · 0.45
netStoreMethod · 0.45
filteredMethod · 0.45
appendMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected