X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/40b4277000058eaab29f7d74a31a327ce2d1b700..162ec6e7763efa260523f5cf03f635159803947d:/process.cpp?ds=inline diff --git a/process.cpp b/process.cpp index 97f2a69..b5531b0 100644 --- a/process.cpp +++ b/process.cpp @@ -421,7 +421,11 @@ void process::data_send(neighbor& nb) else excess_load = real_load; - double balance = nb.get_debt() - nb.get_credit(); + double balance; + if (nb.get_credit() > 0.0) + balance = nb.get_debt() - nb.get_credit(); + else + balance = nb.get_debt(); load_to_send = std::min(excess_load, std::max(0.0, balance));