From ec06793a1980bacb74109e8daa0eebd8fb3d40cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 14 Apr 2022 04:31:46 +0200 Subject: [PATCH] Code cleanup --- src/map/IMG/nodfile.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/map/IMG/nodfile.cpp b/src/map/IMG/nodfile.cpp index bed50bde..bf8f794a 100644 --- a/src/map/IMG/nodfile.cpp +++ b/src/map/IMG/nodfile.cpp @@ -6,8 +6,8 @@ using namespace IMG; #define ARRAY_SIZE(array) \ (sizeof(array) / sizeof(array[0])) -#define DELTA(val, s1, s2) \ - (((int)((val) << (s1)) >> (s1)) << (s2)) +#define DELTA(val, llBits, maxBits) \ + (((int)((val) << (32 - (llBits))) >> (32 - (llBits))) << (32 - (maxBits))) static const struct { @@ -207,10 +207,9 @@ bool NODFile::nodeInfo(Handle &hdl, AdjacencyInfo &adj) const if (!(bs.read(lonBits, lon) && bs.read(latBits, lat))) return false; - quint8 shift = 0x20 - maxBits; QPoint pos( - adj.blockInfo.hdr.nodeLonBase + DELTA(lon, 0x20 - lonBits, shift), - adj.blockInfo.hdr.nodeLatBase + DELTA(lat, 0x20 - latBits, shift)); + adj.blockInfo.hdr.nodeLonBase + DELTA(lon, lonBits, maxBits), + adj.blockInfo.hdr.nodeLatBase + DELTA(lat, latBits, maxBits)); adj.nodeInfo.bytes = ((lonBits + latBits) >> 3) + 1; if ((maxBits < 0x1c) && (adj.nodeInfo.flags & 8)) {