From 2e0787bb63ca10789c0f19d00f89bd828264af56 Mon Sep 17 00:00:00 2001 From: KusakabeSi Date: Wed, 27 Oct 2021 01:53:01 +0000 Subject: [PATCH] Fix AdditionalCost bug --- path/path.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/path/path.go b/path/path.go index fbaf315..0bde95b 100644 --- a/path/path.go +++ b/path/path.go @@ -246,10 +246,10 @@ func (g *IG) Weight(u, v config.Vertex, withAC bool) (ret float64) { if time.Now().After(g.edges[u][v].time.Add(g.NodeReportTimeout)) { return Infinity } - if withAC { - ret = g.edges[u][v].ping + g.edges[u][v].additionalCost - } ret = g.edges[u][v].ping + if withAC { + ret += g.edges[u][v].additionalCost + } if ret >= Infinity { return Infinity } @@ -268,10 +268,10 @@ func (g *IG) OldWeight(u, v config.Vertex, withAC bool) (ret float64) { if _, ok := g.edges[u][v]; !ok { return Infinity } - if withAC { - ret = g.edges[u][v].ping_old + g.edges[u][v].additionalCost - } ret = g.edges[u][v].ping_old + if withAC { + ret += g.edges[u][v].additionalCost + } if ret >= Infinity { return Infinity }