From 29a821f8b219a599fa3fbeb3fa61d3351d56ce94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 2 Jul 2020 00:17:41 +0200 Subject: [PATCH] Code cleanup --- src/map/IMG/rgnfile.cpp | 31 +++++++++++++------------------ src/map/IMG/rgnfile.h | 18 ++++++++---------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/map/IMG/rgnfile.cpp b/src/map/IMG/rgnfile.cpp index abd831ed..03d12988 100644 --- a/src/map/IMG/rgnfile.cpp +++ b/src/map/IMG/rgnfile.cpp @@ -1,4 +1,3 @@ -#include #include "common/rectc.h" #include "common/garmin.h" #include "deltastream.h" @@ -97,13 +96,6 @@ bool RGNFile::skipGblFields(Handle &hdl, quint32 flags) const return seek(hdl, hdl.pos() + cnt); } -void RGNFile::clearFlags() -{ - memset(_polygonsFlags, 0, sizeof(_polygonsFlags)); - memset(_linesFlags, 0, sizeof(_linesFlags)); - memset(_pointsFlags, 0, sizeof(_pointsFlags)); -} - bool RGNFile::init(Handle &hdl) { quint16 hdrLen; @@ -115,17 +107,20 @@ bool RGNFile::init(Handle &hdl) if (hdrLen >= 0x68) { if (!(readUInt32(hdl, _polygonsOffset) && readUInt32(hdl, _polygonsSize) - && seek(hdl, _gmpOffset + 0x29) && readUInt32(hdl, _polygonGblFlags) - && readUInt32(hdl, _polygonsFlags[0]) && readUInt32(hdl, _polygonsFlags[1]) - && readUInt32(hdl, _polygonsFlags[2]) + && seek(hdl, _gmpOffset + 0x29) && readUInt32(hdl, _polygonsGblFlags) + && readUInt32(hdl, _polygonsLclFlags[0]) + && readUInt32(hdl, _polygonsLclFlags[1]) + && readUInt32(hdl, _polygonsLclFlags[2]) && readUInt32(hdl, _linesOffset) && readUInt32(hdl, _linesSize) && seek(hdl, _gmpOffset + 0x45) && readUInt32(hdl, _linesGblFlags) - && readUInt32(hdl, _linesFlags[0]) && readUInt32(hdl, _linesFlags[1]) - && readUInt32(hdl, _linesFlags[2]) + && readUInt32(hdl, _linesLclFlags[0]) + && readUInt32(hdl, _linesLclFlags[1]) + && readUInt32(hdl, _linesLclFlags[2]) && readUInt32(hdl, _pointsOffset) && readUInt32(hdl, _pointsSize) && seek(hdl, _gmpOffset + 0x61) && readUInt32(hdl, _pointsGblFlags) - && readUInt32(hdl, _pointsFlags[0]) && readUInt32(hdl, _pointsFlags[1]) - && readUInt32(hdl, _pointsFlags[2]))) + && readUInt32(hdl, _pointsLclFlags[0]) + && readUInt32(hdl, _pointsLclFlags[1]) + && readUInt32(hdl, _pointsLclFlags[2]))) return false; } @@ -317,10 +312,10 @@ bool RGNFile::extPolyObjects(Handle &hdl, const SubDiv *subdiv, quint32 shift, if (subtype & 0x80 && !skipClassFields(hdl)) return false; if (subtype & 0x40 && !skipLclFields(hdl, segmentType == Line - ? _linesFlags : _polygonsFlags)) + ? _linesLclFlags : _polygonsLclFlags)) return false; quint32 gblFlags = (segmentType == Line) - ? _linesGblFlags : _polygonGblFlags; + ? _linesGblFlags : _polygonsGblFlags; if (gblFlags && !skipGblFields(hdl, gblFlags)) return false; @@ -403,7 +398,7 @@ bool RGNFile::extPointObjects(Handle &hdl, const SubDiv *subdiv, LBLFile *lbl, return false; if (subtype & 0x80 && !skipClassFields(hdl)) return false; - if (subtype & 0x40 && !skipLclFields(hdl, _pointsFlags)) + if (subtype & 0x40 && !skipLclFields(hdl, _pointsLclFlags)) return false; if (_pointsGblFlags && !skipGblFields(hdl, _pointsGblFlags)) return false; diff --git a/src/map/IMG/rgnfile.h b/src/map/IMG/rgnfile.h index 9e900c1f..637480f9 100644 --- a/src/map/IMG/rgnfile.h +++ b/src/map/IMG/rgnfile.h @@ -24,15 +24,14 @@ public: RGNFile(IMG *img) : SubFile(img), _offset(0), _size(0), _polygonsOffset(0), _polygonsSize(0), _linesOffset(0), _linesSize(0), _pointsOffset(0), - _pointsSize(0), _init(false) {clearFlags();} + _pointsSize(0), _init(false) {} RGNFile(const QString &path) : SubFile(path), _offset(0), _size(0), _polygonsOffset(0), _polygonsSize(0), _linesOffset(0), _linesSize(0), _pointsOffset(0), - _pointsSize(0), _init(false) {clearFlags();} + _pointsSize(0), _init(false) {} RGNFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset), _offset(0), _size(0), _polygonsOffset(0), _polygonsSize(0), _linesOffset(0), - _linesSize(0), _pointsOffset(0), _pointsSize(0), _init(false) - {clearFlags();} + _linesSize(0), _pointsOffset(0), _pointsSize(0), _init(false) {} bool initialized() const {return _init;} bool init(Handle &hdl); @@ -55,7 +54,6 @@ public: private: QMap segments(Handle &hdl, SubDiv *subdiv) const; - void clearFlags(); bool skipClassFields(Handle &hdl) const; bool skipLclFields(Handle &hdl, const quint32 flags[3]) const; @@ -66,15 +64,15 @@ private: quint32 _polygonsOffset; quint32 _polygonsSize; - quint32 _polygonsFlags[3]; + quint32 _polygonsLclFlags[3]; + quint32 _polygonsGblFlags; quint32 _linesOffset; quint32 _linesSize; - quint32 _linesFlags[3]; + quint32 _linesLclFlags[3]; + quint32 _linesGblFlags; quint32 _pointsOffset; quint32 _pointsSize; - quint32 _pointsFlags[3]; - quint32 _polygonGblFlags; - quint32 _linesGblFlags; + quint32 _pointsLclFlags[3]; quint32 _pointsGblFlags; HuffmanTable _huffmanTable;