public void FsTrim() { int mapEntriesLength = Header.MapEntryCount * MapEntryLength; long dataEnd = MapEntries.Max(x => x.PhysicalOffsetEnd); MapEntryStorage.Slice(mapEntriesLength).Fill(SaveDataFileSystem.TrimFillValue); BaseStorage.Slice(dataEnd).Fill(SaveDataFileSystem.TrimFillValue); }
private void SetMapEntries() { Nation n = SelectedDisplayEntry != null ? SelectedDisplayEntry.Nation : null; ObservableCollection <MapDisplayEntry> entries = new ObservableCollection <MapDisplayEntry>(); if (ReferencedGame != null) { if (MapEntries == null) { foreach (Nation nat in ReferencedGame.Nations.Values.ToList()) { entries.Add(new MapDisplayEntry(nat, nat.WarSide.HasValue ? ReferencedGame.Sides[nat.WarSide.Value] : null, this)); } MapEntries = entries; if (n != null) { SelectedDisplayEntry = entries.FirstOrDefault(e => e.Nation == n); } else { SelectedDisplayEntry = entries.FirstOrDefault(); } } else { List <Nation> currentNationList = ReferencedGame.Nations.Values.ToList(); ObservableCollection <MapDisplayEntry> currentEntries = new ObservableCollection <MapDisplayEntry>(MapEntries); foreach (MapDisplayEntry entry in currentEntries) { if (currentNationList.FirstOrDefault(nat => nat == entry.Nation) == null) { MapEntries.Remove(entry); } } foreach (Nation nat in currentNationList) { if (MapEntries.FirstOrDefault(e => e.Nation == nat) == null) { MapEntries.Add(new MapDisplayEntry(nat, nat.WarSide.HasValue ? ReferencedGame.Sides[nat.WarSide.Value] : null, this)); } } foreach (Nation nat in currentNationList) { MapDisplayEntry entry = MapEntries.First(e => e.Nation == nat); entry.Update(nat, nat.WarSide.HasValue ? ReferencedGame.Sides[nat.WarSide.Value] : null); } } } OnPropertyChanged("SelectedNationIsAtWar"); }
private MapEntry GetMapEntry(long offset) { // todo: is O(n) search a possible performance issue? MapEntry entry = MapEntries.FirstOrDefault(x => offset >= x.VirtualOffset && offset < x.VirtualOffsetEnd); if (entry == null) { throw new ArgumentOutOfRangeException(nameof(offset)); } return(entry); }
private void SetNationEntries() { ObservableCollection <Nation> entries = new ObservableCollection <Nation>(); if (ReferencedGame != null) { if (Nations == null) { foreach (Nation nat in ReferencedGame.Nations.Values.ToList()) { entries.Add(nat); } Nations = entries; } else { List <Nation> currentNationList = ReferencedGame.Nations.Values.ToList(); ObservableCollection <Nation> currentEntries = new ObservableCollection <Nation>(Nations); foreach (Nation entry in currentEntries) { if (currentNationList.FirstOrDefault(nat => nat == entry) == null) { Nations.Remove(entry); } } foreach (Nation nat in currentNationList) { if (Nations.FirstOrDefault(e => e == nat) == null) { Nations.Add(nat); } } } if (SelectedDisplayEntry == null) { SelectedDisplayEntry = MapEntries.First(); } } }
public static MapEntry GetMapEntry(string id) { return(MapEntries.Find(entry => entry.Id == id)); }