From a399ed31d7f42a3e22d93f91e0c779ac1ab8886f Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Thu, 22 Dec 2022 09:54:31 +0100 Subject: [PATCH] relconst: fix a printing bug causing some constants to show as 0 Constants (no base) that fit on a single byte would print as 0 due to flawed logic. --- lib/ai/RelConst.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ai/RelConst.cpp b/lib/ai/RelConst.cpp index a72cb5e..b92c1e8 100644 --- a/lib/ai/RelConst.cpp +++ b/lib/ai/RelConst.cpp @@ -300,12 +300,17 @@ std::string RelConst::str() const noexcept if(ival >= -256 && ival < 256) { uint32_t v = 0; - if(str.size() && ival > 0) - str += "+", v = ival; - if(str.size() && ival < 0) - str += "-", v = -ival; + if(ival >= 0) { + if(str.size()) + str += "+"; + v = ival; + } + else { + str += "-"; + v = -ival; + } - return str + format("%d", v); + return str + format("%d (0x%08x)", v, uval); } else { return str + format("0x%08x", uval);