diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index f1e0e43..63ed66d 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -179,6 +179,57 @@ namespace EduNetworkBuilder } } + public bool Equals(Network CompareTo) + { + if (PuzzleName != CompareTo.PuzzleName) return false; + if (myHeight != CompareTo.myHeight) return false; + if (myWidth != CompareTo.myWidth) return false; + if (Level != CompareTo.Level) return false; + if (SortOrder != CompareTo.SortOrder) return false; + if (OptionShowLabels != CompareTo.OptionShowLabels) return false; + if (ShowLabelsHere != CompareTo.ShowLabelsHere) return false; + if (VLANsEnabled != CompareTo.VLANsEnabled) return false; + if (VLANPacketColors != CompareTo.VLANPacketColors) return false; + if (_LoadedFromResource != CompareTo._LoadedFromResource) return false; + if (!NetMessage.Equals(CompareTo.NetMessage)) return false; + if (!NetTitle.Equals(CompareTo.NetTitle)) return false; + if (!NetURL.Equals(CompareTo.NetURL)) return false; + if (itemsize != CompareTo.itemsize) return false; + if (UniqueIdentifier != CompareTo.UniqueIdentifier) return false; + if (IsRandomNetwork != CompareTo.IsRandomNetwork) return false; + if (NetworkFilename != CompareTo.NetworkFilename) return false; + if (AlreadyDisplayedMessage != CompareTo.AlreadyDisplayedMessage) return false; + if (HintsToDisplay != CompareTo.HintsToDisplay) return false; + if (StartingHelpLevel != CompareTo.StartingHelpLevel) return false; + if (PuzzleIsSolved != CompareTo.PuzzleIsSolved) return false; + + if (NetTests.Count != CompareTo.NetTests.Count) return false; + for (int i = 0; i < NetTests.Count; i++) + if (!NetTests[i].Equals(CompareTo.NetTests[i])) return false; + + if (BrokenItems.Count != CompareTo.BrokenItems.Count) return false; + for (int i = 0; i < BrokenItems.Count; i++) + if (BrokenItems[i] != CompareTo.BrokenItems[i]) return false; + + if (NetComponents.Count != CompareTo.NetComponents.Count) return false; + for (int i = 0; i < NetComponents.Count; i++) + if (!NetComponents[i].Equals(CompareTo.NetComponents[i])) return false; + + if (Shapes.Count != CompareTo.Shapes.Count) return false; + for (int i = 0; i < Shapes.Count; i++) + if (!Shapes[i].Equals(CompareTo.Shapes[i])) return false; + + if (PingTestStats.Count != CompareTo.PingTestStats.Count) return false; + if (SuggestedReadings.Count != CompareTo.SuggestedReadings.Count) return false; + if (myMessages.Count != CompareTo.myMessages.Count) return false; + + if (VlanNames.Count != CompareTo.VlanNames.Count) return false; + for (int i = 0; i < VlanNames.Count; i++) + if (!VlanNames[i].Equals(CompareTo.VlanNames[i])) return false; + + return true; + } + public void ClearComponents() { NetComponents.Clear(); diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index 873ead7..16c18fa 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -243,7 +243,8 @@ namespace EduNetworkBuilder public void StoreNetworkState(Network toStore) { - //We should verify something has changed before storing it. Oh well... + if (storedNetworkStates.Count > 0 && toStore.Equals(storedNetworkStates[0])) + return; //The states are identical. Do not store this state. storedNetworkStates.Insert(0,Network.DeepClone(toStore)); int maxCount = 30; if(storedNetworkStates.Count > maxCount)