本文整理汇总了C#中IWriter.WriteUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# IWriter.WriteUInt32方法的具体用法?C# IWriter.WriteUInt32怎么用?C# IWriter.WriteUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWriter
的用法示例。
在下文中一共展示了IWriter.WriteUInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteLocaleChanges
private static void WriteLocaleChanges(Patch patch, IWriter writer)
{
if (patch.LanguageChanges.Count == 0)
return;
long startPos = writer.Position;
writer.WriteInt32(AssemblyPatchBlockID.Locl);
writer.WriteUInt32(0); // Size filled in later
writer.WriteByte(0); // Version 0
// Write change data for each language
writer.WriteByte((byte)patch.LanguageChanges.Count);
foreach (LanguageChange language in patch.LanguageChanges)
{
writer.WriteByte(language.LanguageIndex);
// Write the change data for each string in the language
writer.WriteInt32(language.LocaleChanges.Count);
foreach (LocaleChange change in language.LocaleChanges)
{
writer.WriteUInt16((ushort)change.Index);
writer.WriteUTF8(change.NewValue);
}
}
// Fill in the block size
long endPos = writer.Position;
writer.SeekTo(startPos + 4);
writer.WriteUInt32((uint)(endPos - startPos));
writer.SeekTo(endPos);
}
示例2: WritePatch
public static void WritePatch(Patch patch, IWriter writer)
{
writer.WriteInt32(AssemblyPatchMagic);
writer.WriteUInt32(0); // File size filled in later
writer.WriteByte(0); // No compression
WriteBlocks(patch, writer);
// Fill in the file size
long fileSize = writer.Position;
writer.SeekTo(4);
writer.WriteUInt32((uint)fileSize - 8);
writer.SeekTo(fileSize);
}
示例3: WriteBlockHeader
private static long WriteBlockHeader(IWriter writer, int magic)
{
var startPos = writer.Position;
writer.WriteInt32(magic);
writer.WriteUInt32(0); // Size filled in later
return startPos;
}
示例4: EndBlock
private static void EndBlock(IWriter writer, long headerPos)
{
var endPos = writer.Position;
writer.SeekTo(headerPos + 4);
writer.WriteUInt32((uint)(endPos - headerPos));
writer.SeekTo(endPos);
}
示例5: WriteDataBlocks
private static void WriteDataBlocks(TagContainer tags, ContainerWriter container, IWriter writer)
{
foreach (DataBlock dataBlock in tags.DataBlocks)
{
container.StartBlock("data", 2);
// Main data
writer.WriteUInt32(dataBlock.OriginalAddress);
writer.WriteInt32(dataBlock.EntryCount);
WriteByteArray(dataBlock.Data, writer);
// Address fixups
writer.WriteInt32(dataBlock.AddressFixups.Count);
foreach (DataBlockAddressFixup blockRef in dataBlock.AddressFixups)
{
writer.WriteUInt32(blockRef.OriginalAddress);
writer.WriteInt32(blockRef.WriteOffset);
}
// Tagref fixups
writer.WriteInt32(dataBlock.TagFixups.Count);
foreach (DataBlockTagFixup tagRef in dataBlock.TagFixups)
{
writer.WriteUInt32(tagRef.OriginalIndex.Value);
writer.WriteInt32(tagRef.WriteOffset);
}
// Resource reference fixups
writer.WriteInt32(dataBlock.ResourceFixups.Count);
foreach (DataBlockResourceFixup resourceRef in dataBlock.ResourceFixups)
{
writer.WriteUInt32(resourceRef.OriginalIndex.Value);
writer.WriteInt32(resourceRef.WriteOffset);
}
// StringID fixups
writer.WriteInt32(dataBlock.StringIDFixups.Count);
foreach (DataBlockStringIDFixup sid in dataBlock.StringIDFixups)
{
writer.WriteAscii(sid.OriginalString);
writer.WriteInt32(sid.WriteOffset);
}
container.EndBlock();
}
}
示例6: WriteSegmentChanges
private static void WriteSegmentChanges(Patch patch, ContainerWriter container, IWriter writer)
{
if (patch.SegmentChanges.Count == 0)
return;
container.StartBlock("segm", 0); // Version 0
writer.WriteByte((byte) patch.SegmentChanges.Count);
foreach (SegmentChange segment in patch.SegmentChanges)
{
writer.WriteUInt32(segment.OldOffset);
writer.WriteInt32(segment.OldSize);
writer.WriteUInt32(segment.NewOffset);
writer.WriteInt32(segment.NewSize);
writer.WriteByte(Convert.ToByte(segment.ResizeAtEnd));
WriteDataChanges(segment.DataChanges, writer);
}
container.EndBlock();
}
示例7: WriteDataChanges
private static void WriteDataChanges(IList<DataChange> changes, IWriter writer)
{
List<DataChange> fourByteChanges = changes.Where(c => c.Data.Length == 4).ToList();
List<DataChange> otherChanges = changes.Where(c => c.Data.Length != 4).ToList();
// Write 4-byte changes
writer.WriteUInt32((uint) fourByteChanges.Count);
foreach (DataChange change in fourByteChanges)
{
writer.WriteUInt32(change.Offset);
writer.WriteBlock(change.Data);
}
// Write other changes
writer.WriteUInt32((uint) otherChanges.Count);
foreach (DataChange change in otherChanges)
{
writer.WriteUInt32(change.Offset);
writer.WriteInt32(change.Data.Length);
writer.WriteBlock(change.Data);
}
}
示例8: WriteBlfInfo
private static void WriteBlfInfo(Patch patch, IWriter writer)
{
if (patch.CustomBlfContent == null)
return;
var startPos = WriteBlockHeader(writer, AssemblyPatchBlockID.Blfc);
writer.WriteByte(0); // Version 0
writer.WriteByte((byte)patch.CustomBlfContent.TargetGame);
// Write mapinfo filename
if (patch.CustomBlfContent.MapInfoFileName != null)
writer.WriteAscii(patch.CustomBlfContent.MapInfoFileName);
else
writer.WriteByte(0);
// Write mapinfo data
if (patch.CustomBlfContent.MapInfo != null)
{
writer.WriteUInt32((uint)patch.CustomBlfContent.MapInfo.Length);
writer.WriteBlock(patch.CustomBlfContent.MapInfo);
}
else
{
writer.WriteUInt32(0);
}
// Write BLF containers
writer.WriteInt16((short)patch.CustomBlfContent.BlfContainerEntries.Count);
foreach (var blfContainerEntry in patch.CustomBlfContent.BlfContainerEntries)
{
writer.WriteAscii(blfContainerEntry.FileName);
writer.WriteUInt32((uint)blfContainerEntry.BlfContainer.Length);
writer.WriteBlock(blfContainerEntry.BlfContainer);
}
EndBlock(writer, startPos);
}
示例9: WriteBlfInfo
private static void WriteBlfInfo(Patch patch, ContainerWriter container, IWriter writer)
{
if (patch.CustomBlfContent == null)
return;
container.StartBlock("blfc", 0); // Version 0
writer.WriteByte((byte) patch.CustomBlfContent.TargetGame);
// Write mapinfo filename
if (patch.CustomBlfContent.MapInfoFileName != null)
writer.WriteAscii(patch.CustomBlfContent.MapInfoFileName);
else
writer.WriteByte(0);
// Write mapinfo data
if (patch.CustomBlfContent.MapInfo != null)
{
writer.WriteUInt32((uint) patch.CustomBlfContent.MapInfo.Length);
writer.WriteBlock(patch.CustomBlfContent.MapInfo);
}
else
{
writer.WriteUInt32(0);
}
// Write BLF containers
writer.WriteInt16((short) patch.CustomBlfContent.BlfContainerEntries.Count);
foreach (BlfContainerEntry blfContainerEntry in patch.CustomBlfContent.BlfContainerEntries)
{
writer.WriteAscii(blfContainerEntry.FileName);
writer.WriteUInt32((uint) blfContainerEntry.BlfContainer.Length);
writer.WriteBlock(blfContainerEntry.BlfContainer);
}
container.EndBlock();
}
示例10: WriteMetaChanges
private static void WriteMetaChanges(Patch patch, IWriter writer)
{
if (patch.MetaChanges.Count == 0)
return;
long startPos = writer.Position;
writer.WriteInt32(AssemblyPatchBlockID.Meta);
writer.WriteUInt32(0); // Size filled in later
writer.WriteByte(0); // Version 0
// Filter meta changes by size (as a file size optimization)
List<MetaChange> fourByteChanges = new List<MetaChange>();
List<MetaChange> otherChanges = new List<MetaChange>();
foreach (MetaChange change in patch.MetaChanges)
{
if (change.Data.Length == 4)
fourByteChanges.Add(change);
else
otherChanges.Add(change);
}
// Write 4-byte changes
writer.WriteUInt32((uint)fourByteChanges.Count);
foreach (MetaChange change in fourByteChanges)
{
writer.WriteUInt32(change.Address);
writer.WriteBlock(change.Data);
}
// Write other changes
writer.WriteUInt32((uint)otherChanges.Count);
foreach (MetaChange change in otherChanges)
{
writer.WriteUInt32(change.Address);
writer.WriteUInt32((uint)change.Data.Length);
writer.WriteBlock(change.Data);
}
// Fill in the block size
long endPos = writer.Position;
writer.SeekTo(startPos + 4);
writer.WriteUInt32((uint)(endPos - startPos));
writer.SeekTo(endPos);
}
示例11: WritePatchInfo
private static void WritePatchInfo(Patch patch, ContainerWriter container, IWriter writer)
{
container.StartBlock("titl", 2); // Version 2
// Write target map info
writer.WriteInt32(patch.MapID);
if (patch.MapInternalName != null)
writer.WriteAscii(patch.MapInternalName);
else
writer.WriteByte(0);
// Write patch info
writer.WriteUTF16(patch.Name);
writer.WriteUTF16(patch.Description);
writer.WriteUTF16(patch.Author);
// Write screenshot
if (patch.Screenshot != null)
{
writer.WriteInt32(patch.Screenshot.Length);
writer.WriteBlock(patch.Screenshot);
}
else
{
writer.WriteInt32(0);
}
// Write meta info
writer.WriteUInt32(patch.MetaPokeBase);
writer.WriteSByte((sbyte) patch.MetaChangesIndex);
// Write output name
if (patch.OutputName != null)
writer.WriteAscii(patch.OutputName);
else
writer.WriteByte(0);
container.EndBlock();
}
示例12: WriteResourcePages
private static void WriteResourcePages(TagContainer tags, ContainerWriter container, IWriter writer)
{
foreach (ResourcePage page in tags.ResourcePages)
{
container.StartBlock("rspg", 1);
writer.WriteInt32(page.Index);
writer.WriteUInt16(page.Salt);
writer.WriteByte(page.Flags);
writer.WriteAscii(page.FilePath ?? "");
writer.WriteInt32(page.Offset);
writer.WriteInt32(page.UncompressedSize);
writer.WriteByte((byte) page.CompressionMethod);
writer.WriteInt32(page.CompressedSize);
writer.WriteUInt32(page.Checksum);
WriteByteArray(page.Hash1, writer);
WriteByteArray(page.Hash2, writer);
WriteByteArray(page.Hash3, writer);
writer.WriteInt32(page.Unknown1);
writer.WriteInt32(page.Unknown2);
writer.WriteInt32(page.Unknown3);
container.EndBlock();
}
}
示例13: WriteDataBlocks
private static void WriteDataBlocks(TagContainer tags, ContainerWriter container, IWriter writer)
{
foreach (DataBlock dataBlock in tags.DataBlocks)
{
container.StartBlock("data", 6);
// Main data
writer.WriteUInt32(dataBlock.OriginalAddress);
writer.WriteInt32(dataBlock.EntryCount);
writer.WriteInt32(dataBlock.Alignment);
WriteByteArray(dataBlock.Data, writer);
// Address fixups
writer.WriteInt32(dataBlock.AddressFixups.Count);
foreach (DataBlockAddressFixup blockRef in dataBlock.AddressFixups)
{
writer.WriteUInt32(blockRef.OriginalAddress);
writer.WriteInt32(blockRef.WriteOffset);
}
// Tagref fixups
writer.WriteInt32(dataBlock.TagFixups.Count);
foreach (DataBlockTagFixup tagRef in dataBlock.TagFixups)
{
writer.WriteUInt32(tagRef.OriginalIndex.Value);
writer.WriteInt32(tagRef.WriteOffset);
}
// Resource reference fixups
writer.WriteInt32(dataBlock.ResourceFixups.Count);
foreach (DataBlockResourceFixup resourceRef in dataBlock.ResourceFixups)
{
writer.WriteUInt32(resourceRef.OriginalIndex.Value);
writer.WriteInt32(resourceRef.WriteOffset);
}
// StringID fixups
writer.WriteInt32(dataBlock.StringIDFixups.Count);
foreach (DataBlockStringIDFixup sid in dataBlock.StringIDFixups)
{
writer.WriteAscii(sid.OriginalString);
writer.WriteInt32(sid.WriteOffset);
}
// Shader fixups
writer.WriteInt32(dataBlock.ShaderFixups.Count);
foreach (DataBlockShaderFixup shaderRef in dataBlock.ShaderFixups)
{
writer.WriteInt32(shaderRef.WriteOffset);
if (shaderRef.Data != null)
{
writer.WriteInt32(shaderRef.Data.Length);
writer.WriteBlock(shaderRef.Data);
}
else
{
writer.WriteInt32(0);
}
}
// Unicode string list fixups
writer.WriteInt32(dataBlock.UnicListFixups.Count);
foreach (DataBlockUnicListFixup unicList in dataBlock.UnicListFixups)
{
writer.WriteInt32(unicList.LanguageIndex);
writer.WriteInt32(unicList.WriteOffset);
writer.WriteInt32(unicList.Strings.Length);
foreach (UnicListFixupString str in unicList.Strings)
{
writer.WriteAscii(str.StringID);
writer.WriteUTF8(str.String);
}
}
container.EndBlock();
}
}
示例14: WriteTags
private static void WriteTags(TagContainer tags, ContainerWriter container, IWriter writer)
{
foreach (ExtractedTag tag in tags.Tags)
{
container.StartBlock("tag!", 0);
writer.WriteUInt32(tag.OriginalIndex.Value);
writer.WriteUInt32(tag.OriginalAddress);
writer.WriteInt32(tag.Class);
writer.WriteAscii(tag.Name);
container.EndBlock();
}
}
示例15: WriteResources
private static void WriteResources(TagContainer tags, ContainerWriter container, IWriter writer)
{
foreach (ExtractedResourceInfo resource in tags.Resources)
{
container.StartBlock("rsrc", 1);
writer.WriteUInt32(resource.OriginalIndex.Value);
writer.WriteUInt32(resource.Flags);
if (resource.Type != null)
writer.WriteAscii(resource.Type);
else
writer.WriteByte(0);
WriteByteArray(resource.Info, writer);
writer.WriteUInt32(resource.OriginalParentTagIndex.Value);
if (resource.Location != null)
{
writer.WriteByte(1);
writer.WriteInt32(resource.Location.OriginalPrimaryPageIndex);
writer.WriteInt32(resource.Location.PrimaryOffset);
writer.WriteInt32(resource.Location.PrimaryUnknown);
writer.WriteInt32(resource.Location.OriginalSecondaryPageIndex);
writer.WriteInt32(resource.Location.SecondaryOffset);
writer.WriteInt32(resource.Location.SecondaryUnknown);
}
else
{
writer.WriteByte(0);
}
writer.WriteInt32(resource.Unknown1);
writer.WriteInt32(resource.Unknown2);
writer.WriteInt32(resource.Unknown3);
writer.WriteInt32(resource.ResourceFixups.Count);
foreach (ResourceFixup fixup in resource.ResourceFixups)
{
writer.WriteInt32(fixup.Offset);
writer.WriteUInt32(fixup.Address);
}
writer.WriteInt32(resource.DefinitionFixups.Count);
foreach (ResourceDefinitionFixup fixup in resource.DefinitionFixups)
{
writer.WriteInt32(fixup.Offset);
writer.WriteInt32(fixup.Type);
}
container.EndBlock();
}
}