| 139 | } |
| 140 | |
| 141 | void NetworkMessage::WriteNetworkId(const Guid& id) |
| 142 | { |
| 143 | #if USE_NETWORK_KEYS |
| 144 | ScopeLock lock(Keys.Lock); |
| 145 | uint32 index = MAX_uint32; |
| 146 | bool hasIndex = Keys.LookupId.TryGet(id, index); |
| 147 | if (hasIndex) |
| 148 | hasIndex &= IsNetworkKeyValid(index); |
| 149 | WriteUInt32(index); |
| 150 | if (!hasIndex) |
| 151 | { |
| 152 | // No key cached locally so send the full data |
| 153 | WriteBytes((const uint8*)&id, sizeof(Guid)); |
| 154 | |
| 155 | // Add to the pending list (ignore on clients as server will automatically create a key once it gets full data) |
| 156 | if (NetworkManager::Mode != NetworkManagerMode::Client && |
| 157 | !Keys.PendingIds.ContainsKey(id)) |
| 158 | { |
| 159 | Keys.PendingIds.Add(id, NetworkKey(id)); |
| 160 | } |
| 161 | } |
| 162 | #else |
| 163 | WriteBytes((const uint8*)&id, sizeof(Guid)); |
| 164 | #endif |
| 165 | } |
| 166 | |
| 167 | void NetworkMessage::ReadNetworkId(Guid& id) |
| 168 | { |
no test coverage detected