// This removes a lump from the WAD file public void Remove(Lump lump) { // Remove from list lumps.Remove(lump); lump.Dispose(); numlumps--; // Write the new headers WriteHeaders(); }
// This removes a lump from the WAD file by index public void RemoveAt(int index) { // Remove from list Lump l = lumps[index]; lumps.RemoveAt(index); l.Dispose(); numlumps--; // Write the new headers WriteHeaders(); }
// This removes a lump from the WAD file public void Remove(Lump lump) { // [ZZ] don't allow any edit actions on readonly archive if (isreadonly) { return; } // Remove from list lumps.Remove(lump); lump.Dispose(); numlumps--; // Write the new headers WriteHeaders(); }
// This removes a lump from the WAD file by index public void RemoveAt(int index, bool writeheaders = true) { // [ZZ] don't allow any edit actions on readonly archive if (isreadonly) { return; } // Remove from list Lump l = lumps[index]; lumps.RemoveAt(index); l.Dispose(); numlumps--; // Write the new headers if (writeheaders) { WriteHeaders(); } }
//mxd. This rebuilds the WAD file, removing all "dead" entries // Tech info: WAD.Remove() doesn't remove lump data, so MapManager.TemporaryMapFile slowly gets bigger // with every map save/test, which leads to lumpsoffset overflowing when TemporaryMapFile size reaches // int.MaxValue bytes in size (that's ~2Gb). internal void Compress() { // No can't do... if (isreadonly) { return; } // Gather existing data int totaldatalength = 0; List <LumpCopyData> copydata = new List <LumpCopyData>(lumps.Count); for (int i = 0; i < lumps.Count; i++) { // Copy lump... LumpCopyData lcd = new LumpCopyData(); Lump l = lumps[i]; lcd.FixedName = l.FixedName; lcd.Index = i; lcd.Data = l.Stream.ReadAllBytes(); // Store data copydata.Add(lcd); // Track total length totaldatalength += l.Length; // Dispose lump l.Dispose(); } // Compression required? if (totaldatalength >= lumpsoffset + 12) { return; } // Set new file length file.SetLength(totaldatalength + lumps.Count * 16); // Reset lumpsoffset lumpsoffset = 12; // Reset lumps collection lumps = new List <Lump>(copydata.Count); numlumps = copydata.Count; // Recreate all lumps foreach (LumpCopyData lcd in copydata) { Lump l = new Lump(file, this, lcd.FixedName, lumpsoffset, lcd.Data.Length); l.Stream.Write(lcd.Data, 0, lcd.Data.Length); l.Stream.Seek(0, SeekOrigin.Begin); lumps.Insert(lcd.Index, l); lumpsoffset += lcd.Data.Length; } // Write new headers WriteHeaders(); }