示例#1
0
        private void WriteTableInfo(HashWriter hashWriter)
        {
            var tableInfo = _cf.RootStorage.AddStorage("TableInfo");

            // order for the hashing is important here.
            var knownTags = new[] {
                "TableName", "AuthorName", "TableVersion", "ReleaseDate", "AuthorEmail",
                "AuthorWebSite", "TableBlurb", "TableDescription", "TableRules", "Screenshot"
            };

            // 1. write known tags
            foreach (var tag in knownTags)
            {
                WriteInfoTag(tableInfo, tag, hashWriter);
            }

            // 2. write custom tag names
            _tableContainer.CustomInfoTags?.WriteData(_gameStorage, hashWriter);

            // 3. write custom tags
            foreach (var tag in _tableContainer.CustomInfoTags?.TagNames ?? Array.Empty <string>())
            {
                WriteInfoTag(tableInfo, tag, hashWriter);
            }
        }
示例#2
0
        private void WriteGameItems(HashWriter hashWriter)
        {
            // again, the order is important, because we're hashing at the same time.

            // 1. game data
            _tableContainer.Table.Data.WriteData(_gameStorage, hashWriter);

            // 2. game items
            foreach (var gameItem in _tableContainer.ItemDatas.OrderBy(gi => gi.StorageIndex))
            {
                gameItem.WriteData(_gameStorage);
            }
                        #if !WRITE_VP106 && !WRITE_VP107
            foreach (var gameItem in _tableContainer.VpeItemDatas.OrderBy(gi => gi.StorageIndex))
            {
                gameItem.WriteData(_gameStorage);
            }
                        #endif

            // 3. Collections
            var collections = _tableContainer.Collections;
            foreach (var collection in collections.OrderBy(c => c.StorageIndex))
            {
                collection.WriteData(_gameStorage, hashWriter);
            }
        }
示例#3
0
        public void WriteTable(string fileName)
        {
            using (var hashWriter = new HashWriter()) {
                _cf          = new CompoundFile();
                _gameStorage = _cf.RootStorage.AddStorage("GameStg");

                // 1. version
                WriteStream(_gameStorage, "Version", BitConverter.GetBytes(VpFileFormatVersion), hashWriter);

                // 2. table info
                WriteTableInfo(hashWriter);

                // 3. game items
                WriteGameItems(hashWriter);

                // 4. the rest, which isn't hashed.
                WriteTextures();
                WriteSounds();

                // finally write hash
                WriteStream(_gameStorage, "MAC", hashWriter.Hash());

                _cf.Save(fileName);
                _cf.Close();
            }
        }
示例#4
0
        private void WriteGameItems(HashWriter hashWriter)
        {
            // again, the order is important, because we're hashing at the same time.

            // 1. game data
            _table.Data.WriteData(_gameStorage, hashWriter);

            // 2. game items
            foreach (var writeable in _table.ItemDatas.OrderBy(gi => gi.StorageIndex))
            {
                writeable.WriteData(_gameStorage);
            }

            // 3. Collections
            var collections = _table.Collections.Values;

            foreach (var collection in collections.Select(c => c.Data).OrderBy(c => c.StorageIndex))
            {
                collection.WriteData(_gameStorage, hashWriter);
            }

            // 4. Mapping Configs
            var mappingConfigs = _table.MappingConfigs.Values;

            foreach (var mappingConfig in mappingConfigs.Select(mc => mc.Data).OrderBy(mc => mc.StorageIndex))
            {
                mappingConfig.WriteData(_gameStorage, hashWriter);
            }
        }
        private void WriteGameItems(HashWriter hashWriter)
        {
            // again, the order is important, because we're hashing at the same time.

            // 1. game data
            _table.Data.WriteData(_gameStorage, hashWriter);

            // 2. game items
            foreach (var writeable in _table.ItemDatas.OrderBy(gi => gi.StorageIndex))
            {
                                #if !WRITE_VP106
                // clean material and texture references
                CleanInvalidReferences <MaterialReferenceAttribute, Material>(writeable, v => _table.GetMaterial(v));
                CleanInvalidReferences <TextureReferenceAttribute, Texture>(writeable, v => _table.GetTexture(v));
                                #endif

                writeable.WriteData(_gameStorage);
            }

            // 3. Collections
            var collections = _table.Collections.Values;
            foreach (var collection in collections.Select(c => c.Data).OrderBy(c => c.StorageIndex))
            {
                collection.WriteData(_gameStorage, hashWriter);
            }

            // 5. Mappings
                        #if !WRITE_VP106 && !WRITE_VP107
            _table.Mappings.Data.WriteData(_gameStorage);
                        #endif
        }
示例#6
0
 private void WriteInfoTag(CFStorage tableInfo, string tag, HashWriter hashWriter)
 {
     if (!_tableContainer.TableInfo.ContainsKey(tag))
     {
         return;
     }
     WriteStream(tableInfo, tag, BiffUtil.GetWideString(_tableContainer.TableInfo[tag]), hashWriter);
 }
示例#7
0
        private void WriteGameItems(HashWriter hashWriter)
        {
            // again, the order is important, because we're hashing at the same time.

            // 1. game data
            _table.Data.WriteData(_gameStorage, hashWriter);

            // 2. game items
            foreach (var writeable in _table.GameItems.OrderBy(gi => gi.StorageIndex))
            {
                writeable.WriteData(_gameStorage);
            }

            // 3. Collections
            var collections = _table.Collections.Values.ToArray();
            int i           = 0;

            foreach (var collection in collections.Select(c => c.Data).OrderBy(c => c.StorageIndex))
            {
                collection.StorageIndex = i++;
                collection.WriteData(_gameStorage, hashWriter);
            }
        }
示例#8
0
 private static void WriteStream(CFStorage storage, string streamName, byte[] data, HashWriter hashWriter = null)
 {
     storage.AddStream(streamName).SetData(data);
     hashWriter?.Write(data);
 }
 public override void Write(BinaryWriter writer, HashWriter hashWriter)
 {
     WriteRecord(writer, Attributes, hashWriter);
     WriteEnd(writer, hashWriter);
 }