LSLib.Granny.GR2.GR2Reader.ReadSectionRelocations C# (CSharp) Method

ReadSectionRelocations() private method

private ReadSectionRelocations ( Section section ) : void
section Section
return void
        private void ReadSectionRelocations(Section section)
        {
#if DEBUG_GR2_SERIALIZATION
            System.Console.WriteLine(String.Format(" ===== Relocations for section at {0:X8} ===== ", section.Header.offsetInFile));
#endif

            InputStream.Seek(section.Header.relocationsOffset, SeekOrigin.Begin);
            for (int i = 0; i < section.Header.numRelocations; i++)
            {
                UInt32 offsetInSection = InputReader.ReadUInt32();
                Debug.Assert(offsetInSection <= section.Header.uncompressedSize);
                var reference = ReadSectionReference();

                Stream.Position = section.Header.offsetInFile + offsetInSection;
                var fixupAddress = Sections[(int)reference.Section].Header.offsetInFile + reference.Offset;
                Stream.Write(BitConverter.GetBytes(fixupAddress), 0, 4);

#if DEBUG_GR2_SERIALIZATION
                System.Console.WriteLine(String.Format("    LOCAL  {0:X8} --> {1}:{2:X8}", offsetInSection, (SectionType)reference.Section, reference.Offset));
                System.Console.WriteLine(String.Format("    GLOBAL {0:X8} --> {1:X8}", 
                    offsetInSection + section.Header.offsetInFile, 
                    reference.Offset + Sections[(int)reference.Section].Header.offsetInFile));
#endif
            }
        }