void PacketDataSyncResponse(byte[] arguments) { SDataSync DataSync = CSerialization.Deserialize <SDataSync>(arguments); foreach (SSyncCallback SyncCallback in SyncCallbacks) { if (SyncCallback.list == DataSync.list) { SyncCallback.callback(DataSync.type, DataSync.index, DataSync.data); break; } } }
static void SynchronizeStructArray <T>(ESyncList list, List <T> one, ref List <T> result, CClientSocket ClientSocket) { for (int i = 0; i < one.Count; i++) { bool check = true; if (i > (result.Count - 1)) { result.Add(one[i]); check = false; } bool sync = true; byte[] source = null; if (check) { if (CheckSerialization <T>(one[i], result[i], out source)) { sync = false; } } else { source = CSerialization.Serialize <T>(one[i]); } if (sync) { SDataSync DataSync = new SDataSync { index = i, type = EDataSyncType.Set, list = list, data = source }; ClientSocket.SendPacket <SDataSync>((byte)EControllerPackets.SyncData, DataSync); } } if (one.Count < result.Count) { int removed = 0; for (int i = one.Count; i < result.Count; i++) { int index_correction = i - removed; result.RemoveAt(index_correction); SDataSync DataSync = new SDataSync { index = index_correction, type = EDataSyncType.Remove, list = list, data = null }; removed++; ClientSocket.SendPacket <SDataSync>((byte)EControllerPackets.SyncData, DataSync); } } }