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

Method isAuthoritative

source/game/StarDamageManager.cpp:217–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217bool DamageManager::isAuthoritative(EntityPtr const& causingEntity, EntityPtr const& targetEntity) {
218 // Damage manager is authoritative if either one of the entities is
219 // masterOnly, OR the manager is server-side and both entities are
220 // server-side master entities, OR the damage manager is server-side and both
221 // entities are different clients, OR if the manager is client-side and the
222 // source is client-side master and the target is server-side master, OR if
223 // the manager is client-side and the target is client-side master.
224 //
225 // This means that PvE and EvP are both decided on the player doing the
226 // hitting or getting hit, and PvP is decided on the server, except for
227 // master-only entities whose interactions are always decided on the machine
228 // they are residing on.
229
230 auto causingClient = connectionForEntity(causingEntity->entityId());
231 auto targetClient = connectionForEntity(targetEntity->entityId());
232
233 if (causingEntity->masterOnly() || targetEntity->masterOnly())
234 return true;
235 else if (causingClient == ServerConnectionId && targetClient == ServerConnectionId)
236 return m_connectionId == ServerConnectionId;
237 else if (causingClient != ServerConnectionId && targetClient != ServerConnectionId && causingClient != targetClient)
238 return m_connectionId == ServerConnectionId;
239 else if (targetClient == ServerConnectionId)
240 return causingClient == m_connectionId;
241 else
242 return targetClient == m_connectionId;
243}
244
245void DamageManager::addHitRequest(RemoteHitRequest const& remoteHitRequest) {
246 if (remoteHitRequest.destinationConnection() == m_connectionId)

Callers

nothing calls this directly

Calls 3

connectionForEntityFunction · 0.85
entityIdMethod · 0.80
masterOnlyMethod · 0.45

Tested by

no test coverage detected