From 1453aa27be873a4eaa13125a270a516095d899d7 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sat, 24 Feb 2018 13:56:26 -0600 Subject: [PATCH] Trees drop packets very fast --- EduNetworkBuilder/Network.cs | 20 ++++++++++++++++++++ EduNetworkBuilder/NetworkLink.cs | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index 457c509..dfd8dc1 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -1659,6 +1659,26 @@ namespace EduNetworkBuilder return null; } + public bool DeviceInTree(LinkType myLink, Point location) + { + NetworkDevice ND = null; + if (myLink != LinkType.wireless) return false; //we do not care + foreach (NetworkComponent NC in NetComponents) + { + if (NB.GetComponentType(NC) == GeneralComponentType.device) + { + ND = (NetworkDevice)NC; + if (ND.GetNetType() == NetworkComponentType.tree) + { + if (ND.GetMyRectangle().Contains(location)) + return true; + } + } + } + return false; + + } + public bool DeviceIsOverDamaging(LinkType myLink, Point location) { NetworkDevice ND; diff --git a/EduNetworkBuilder/NetworkLink.cs b/EduNetworkBuilder/NetworkLink.cs index c3408e4..131fda8 100644 --- a/EduNetworkBuilder/NetworkLink.cs +++ b/EduNetworkBuilder/NetworkLink.cs @@ -384,6 +384,10 @@ namespace EduNetworkBuilder } if(theLinkType == LinkType.wireless) { + if(myNet.DeviceInTree(theLinkType, newLocation)) + { + tPacket.health -= 60; + } NetworkDevice sDev = myNet.GetDeviceFromID(SrcNic); NetworkDevice dDev = myNet.GetDeviceFromID(DstNic); double distance = myNet.distance(sDev, dDev) * (tPacket.myLinkPercent * 0.01);