From 09a6d8655ea7f3a8277cf11a4b747fbbdd1974ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 23 Aug 2021 22:27:36 +0200 Subject: [PATCH] Code cleanup --- src/map/IMG/netfile.cpp | 6 +++--- src/map/IMG/nodfile.cpp | 16 +++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/map/IMG/netfile.cpp b/src/map/IMG/netfile.cpp index 46caa027..d65d9e56 100644 --- a/src/map/IMG/netfile.cpp +++ b/src/map/IMG/netfile.cpp @@ -433,9 +433,9 @@ bool NETFile::link(const SubDiv *subdiv, quint32 shift, Handle &hdl, quint16 mask = 0; quint32 size; - bool firstIsShape = (linkInfo.flags >> 0x12) & 1; - bool singleTopology = (linkInfo.flags >> 0x11) & 1; - bool hasLevels = (linkInfo.flags >> 0x13) & 1; + bool firstIsShape = (linkInfo.flags >> 10) & 1; + bool singleTopology = (linkInfo.flags >> 9) & 1; + bool hasLevels = (linkInfo.flags >> 11) & 1; if (!singleTopology || hasLevels) { if (!bs.readVUInt32(size)) diff --git a/src/map/IMG/nodfile.cpp b/src/map/IMG/nodfile.cpp index e37490f7..88dcb078 100644 --- a/src/map/IMG/nodfile.cpp +++ b/src/map/IMG/nodfile.cpp @@ -156,14 +156,12 @@ bool NODFile::linkInfo(Handle &hdl, const BlockInfo &blockInfo, quint32 linkId, if (!seek(hdl, infoOffset)) return false; - quint32 unused, flags; + quint32 padding; BitStream1 bs(*this, hdl, _blockOffset + _blockSize - infoOffset); - if (!(bs.read(skip, unused) && bs.read(0xc, flags))) + if (!(bs.read(skip, padding) && bs.read(0xc, linkInfo.flags))) return false; - linkInfo.flags = ((flags << 8) & 0xf0000) | (flags & 0xff); - - if (!(flags << 8 & 0x10000)) { + if (!(linkInfo.flags & 0x100)) { if (!bs.read(s1, linkInfo.linkOffset)) return false; } else { @@ -221,10 +219,9 @@ bool NODFile::nodeInfo(Handle &hdl, const BlockInfo &blockInfo, pos.setX(pos.x() | extraLon << 4); pos.setY(pos.y() | extraLat << 4); nodeInfo.bytes++; } - // TODO?: extra bits + // TODO?: check and adjust (shift) coordinates nodeInfo.pos = pos; - nodeInfo.flags &= 0xf8; return true; } @@ -311,8 +308,9 @@ bool NODFile::absAdjInfo(Handle &hdl, AdjacencyInfo &adj) const if (firstLoop) { skip >>= (flags >> 5) & 1; flags |= 0x20; + firstLoop = false; } - firstLoop = false; + quint32 f4 = flags & 0x10; quint32 f4sn = (f4 >> 4) ^ 1; quint32 m1 = (flags >> 5) & f4sn; @@ -416,8 +414,8 @@ bool NODFile::relAdjInfo(Handle &hdl, AdjacencyInfo &adj) const if (firstLoop) { skip >>= (flags >> 5) & 1; flags = ((flags >> 1) & 0x20) | (flags & 0xffffffdf); + firstLoop = false; } - firstLoop = false; flagsBits >>= (flags >> 3) & 1; quint32 m = (((flags & 0x70) == 0x30) << 1) | ((flags >> 6) & 1); if (!m) {