| 1656 | } |
| 1657 | |
| 1658 | NetworkObjectRole NetworkReplicator::GetObjectRole(const ScriptingObject* obj) |
| 1659 | { |
| 1660 | NetworkObjectRole role = NetworkObjectRole::None; |
| 1661 | if (obj && NetworkManager::IsConnected()) |
| 1662 | { |
| 1663 | ScopeLock lock(ObjectsLock); |
| 1664 | const auto it = Objects.Find(obj->GetID()); |
| 1665 | if (it != Objects.End()) |
| 1666 | role = it->Item.Role; |
| 1667 | else |
| 1668 | { |
| 1669 | for (const SpawnItem& item : SpawnQueue) |
| 1670 | { |
| 1671 | if (item.Object == obj) |
| 1672 | { |
| 1673 | if (item.HasOwnership) |
| 1674 | role = item.Role; |
| 1675 | #if USE_NETWORK_REPLICATOR_LOG |
| 1676 | return role; |
| 1677 | #else |
| 1678 | break; |
| 1679 | #endif |
| 1680 | } |
| 1681 | } |
| 1682 | #if USE_NETWORK_REPLICATOR_LOG |
| 1683 | NETWORK_REPLICATOR_LOG(Error, "[NetworkReplicator] Failed to get ownership of unregistered network object {} ({})", obj->GetID(), obj->GetType().ToString()); |
| 1684 | #endif |
| 1685 | } |
| 1686 | } |
| 1687 | return role; |
| 1688 | } |
| 1689 | |
| 1690 | void NetworkReplicator::SetObjectOwnership(ScriptingObject* obj, uint32 ownerClientId, NetworkObjectRole localRole, bool hierarchical) |
| 1691 | { |
no test coverage detected