void OnEntityHashDataReceved(EntityHashData hashData) { Entity entity; if (!_gameVM.Game.GlobalManager.FindEntityByGuid(hashData.EntityID, out entity)) { //not sure this should even happen... but just incase SendEntityDataRequest(hashData.EntityID); } else { if (entity.Manager.ManagerSubpulses.StarSysDateTime != hashData.AtDatetime) { Messages.Add("Unmatched Date, can't compare hashes"); } else { if (entity.GetHashCode() != hashData.EntityHash) { foreach (var datablob in entity.DataBlobs) { if (!hashData.DatablobHashes.ContainsKey(datablob.GetType().ToString())) { entity.RemoveDataBlob(EntityManager.DataBlobTypes[datablob.GetType()]); } if (datablob.GetHashCode() != hashData.DatablobHashes[datablob.GetType().ToString()]) { //SendDatablobRequest(hashData.EntityID, datablob.GetType()); Messages.Add("Datablob hashes don't match: " + datablob.GetType()); } } } } } }
void HandleEntityHashData(NetIncomingMessage message) { Guid entityID = new Guid(message.ReadBytes(16)); DateTime atDate = new DateTime(message.ReadInt64()); int entityHash = message.ReadInt32(); int count = message.ReadInt32(); Dictionary <string, int> hashDict = new Dictionary <string, int>(); for (int i = 0; i < count - 1; i++) { string key = message.ReadString(); int hash = message.ReadInt32(); hashDict.Add(key, hash); } EntityHashData hashData = new EntityHashData { EntityID = entityID, AtDatetime = atDate, EntityHash = entityHash, DatablobHashes = hashDict }; OnEntityHashDataReceved(hashData); }