Esempio n. 1
0
        public void AddSpace(uint offset, uint amount)
        {
            // move the data
            byte[] block = m_File.ReadBlock(offset, (uint)(m_File.m_Data.Length - offset));
            m_File.WriteBlock(offset + amount, block);

            // write zeroes in the newly created space
            for (int i = 0; i < amount; i++)
            {
                m_File.Write8((uint)(offset + i), 0);
            }

            // update the pointers
            for (int i = 0; i < m_PointerList.Count; i++)
            {
                PointerReference ptrref = m_PointerList[i];
                if (ptrref.m_ReferenceAddr >= offset)
                {
                    ptrref.m_ReferenceAddr += amount;
                }
                if (ptrref.m_PointerAddr >= offset)
                {
                    ptrref.m_PointerAddr += amount;
                    m_File.Write32(ptrref.m_ReferenceAddr, ptrref.m_PointerAddr);
                }
                m_PointerList[i] = ptrref;
            }

            foreach (NitroTexture tex in m_Textures.Values)
            {
                if (tex.m_EntryOffset >= offset)
                {
                    tex.m_EntryOffset += amount;
                }
                if (tex.m_PalEntryOffset >= offset)
                {
                    tex.m_PalEntryOffset += amount;
                }
                if (tex.m_PalOffset >= offset)
                {
                    tex.m_PalOffset += amount;
                }
            }
        }
Esempio n. 2
0
        public void RemoveSpace(uint offset, uint amount)
        {
            // move the data
            byte[] block = m_File.ReadBlock(offset + amount, (uint)(m_File.m_Data.Length - offset - amount));
            m_File.WriteBlock(offset, block);
            Array.Resize(ref m_File.m_Data, (int)(m_File.m_Data.Length - amount));

            // update the pointers
            for (int i = 0; i < m_PointerList.Count; i++)
            {
                PointerReference ptrref = m_PointerList[i];
                if (ptrref.m_ReferenceAddr >= (offset + amount))
                {
                    ptrref.m_ReferenceAddr -= amount;
                }
                if (ptrref.m_PointerAddr >= (offset + amount))
                {
                    ptrref.m_PointerAddr -= amount;
                    m_File.Write32(ptrref.m_ReferenceAddr, ptrref.m_PointerAddr);
                }
                m_PointerList[i] = ptrref;
            }

            foreach (NitroTexture tex in m_Textures.Values)
            {
                if (tex.m_EntryOffset >= (offset + amount))
                {
                    tex.m_EntryOffset -= amount;
                }
                if (tex.m_PalEntryOffset >= (offset + amount))
                {
                    tex.m_PalEntryOffset -= amount;
                }
                if (tex.m_PalOffset >= (offset + amount))
                {
                    tex.m_PalOffset -= amount;
                }
            }
        }