Ejemplo n.º 1
0
 /// <summary>
 /// Reads the contents of a section block from an XML document.
 /// </summary>
 /// <param name="node">XML node which represents an instance of this data block.</param>
 /// <param name="index">Index within a sequence (starts at 0).</param>
 public void ReadXml(XmlNode thisNode, int index)
 {
     try
     {
         SRXmlNodeReader reader = new SRXmlNodeReader(thisNode);
         sectionID = reader.ReadUInt32("id");
         gpuSize = reader.ReadUInt32("gpu_size");
         XmlNode cpuDataNode = reader.GetNodeOptional("cpu_data");
         if (cpuDataNode == null)
             cpuData = null;
         else if (SRRawDataBlock.HasRawXmlData(cpuDataNode))
             cpuData = new SRRawDataBlock(cpuDataNode);
         else
             cpuData = new SRZoneObjectSectionCpuData(cpuDataNode);
     }
     catch (Exception e)
     {
         // Add context information for the error message
         if (index >= 0)
             e.Data[BlockName] = index + 1;
         throw;
     }
 }
Ejemplo n.º 2
0
 // READERS / WRITERS
 /// <summary>
 /// Reads a section block from a .czn_pc file binary stream.
 /// </summary>
 /// <param name="binaryReader">Binary reader to read the block from.  Must point to the beginning of the block.</param>
 /// <param name="index">Index within a sequence (starts at 0).</param>
 public void Read(SRBinaryReader binaryReader, int index)
 {
     try
     {
         binaryReader.Align(Alignment);
         SRTrace.WriteLine("");
         SRTrace.WriteLine("SECTION #{0}:  [file offset 0x{1:X8}]", index + 1, binaryReader.BaseStream.Position);
         sectionID = binaryReader.ReadUInt32();
         SRTrace.WriteLine("  Section ID:   0x{0:X8}", sectionID);
         if (SectionType() < 0x2233 || SectionType() >= 0x2300)
             throw new SRZoneFileException("Invalid section ID.  Not a valid zone file.");
         if (HasDescription())
             SRTrace.WriteLine("  Description:  " + Description());
         var cpuSize = binaryReader.ReadUInt32();
         SRTrace.WriteLine("  CPU Size:     {0} bytes", cpuSize);
         gpuSize = 0;
         if (HasGPUData())
         {
             gpuSize = binaryReader.ReadUInt32();
             SRTrace.WriteLine("  GPU Size:     {0} bytes", gpuSize);
         }
         if (cpuSize == 0)
             cpuData = null;
         else if (OptionParseObjects && SectionType() == 0x2234)
             cpuData = new SRZoneObjectSectionCpuData(binaryReader, (int)cpuSize);
         else
             cpuData = new SRRawDataBlock(binaryReader, (int)cpuSize);
     }
     catch (Exception e)
     {
         // Add context information for the error message
         if (index >= 0)
             e.Data[BlockName] = index + 1;
         throw;
     }
 }