do not duplicate "breaks." If we successfully break it one way, do not repeat it.

This commit is contained in:
Tim Young 2017-08-29 15:08:31 -05:00
parent 465de0f6b0
commit 36654e837f

View File

@ -66,6 +66,7 @@ namespace EduNetworkBuilder
private List<string> PacketColors = new List<string>();
private List<Image> PacketImages = new List<Image>();
private List<PingTestStatus> PingTestStats = new List<PingTestStatus>();
private List<string> BrokenItems = new List<string>();
/// <summary>
/// WhatFrom: If we are launched from a homework, we remember it here.
@ -1936,6 +1937,9 @@ namespace EduNetworkBuilder
int BreakNetComponent(NetworkComponent What, HowToBreak How, string Data)
{
int didit = 0;
if (What == null) return 0;
string WhatBreak = What.hostname + "-" + How.ToString() + "-" + Data;
if (BrokenItems.Contains(WhatBreak)) return 0; //it was already done
NetworkDevice tDevice = null;
NetworkLink tLink = null;
if (What is NetworkDevice) tDevice = (NetworkDevice)What;
@ -1998,6 +2002,8 @@ namespace EduNetworkBuilder
didit = 2;
break;
}
if(didit > 0)
BrokenItems.Add(WhatBreak);
if (didit > 0) Console.WriteLine("Broke it:" + What.hostname + " : " + How + " : " + Data);
if (didit == 0) Console.WriteLine("Did not break it:" + What.hostname + " : " + How + " : " + Data);
return didit;