private static ResourceInfo Register(UnitSync unitsync, ResourceInfo resource) { Trace.TraceInformation("UnitSyncer: registering {0}", resource.Name); ResourceInfo info = null; try { info = unitsync.GetResourceFromFileName(resource.ArchivePath); if (info != null) { var serializedData = MetaDataCache.SerializeAndCompressMetaData(info); var map = info as Map; var creator = new TorrentCreator(); creator.Path = resource.ArchivePath; var ms = new MemoryStream(); creator.Create(ms); byte[] minimap = null; byte[] metalMap = null; byte[] heightMap = null; if (map != null) { minimap = map.Minimap.ToBytes(ImageSize); metalMap = map.Metalmap.ToBytes(ImageSize); heightMap = map.Heightmap.ToBytes(ImageSize); } var hash = Hash.HashBytes(File.ReadAllBytes(resource.ArchivePath)); var length = new FileInfo(resource.ArchivePath).Length; Trace.TraceInformation("UnitSyncer: uploading {0} to server", info.Name); ReturnValue e; try { var service = GlobalConst.GetContentService(); e = service.RegisterResource(PlasmaServiceVersion, null, hash.ToString(), (int)length, info.ResourceType, resource.ArchiveName, info.Name, serializedData, info.Dependencies, minimap, metalMap, heightMap, ms.ToArray()); } catch (Exception ex) { Trace.TraceError("UnitSyncer: Error uploading data to server: {0}", ex); return(null); } if (e != ReturnValue.Ok) { Trace.TraceWarning("UnitSyncer: Resource registering failed: {0}", e); } } } catch (Exception ex) { Trace.TraceError("Error registering resource {0} : {1}", resource.ArchivePath, ex); return(null); } return(info); }