1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-31 09:05:14 +01:00

Code cleanup

This commit is contained in:
Martin Tůma 2020-07-02 00:17:41 +02:00
parent 14f4dead76
commit 29a821f8b2
2 changed files with 21 additions and 28 deletions

View File

@ -1,4 +1,3 @@
#include <cstring>
#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;

View File

@ -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<SegmentType, SubDiv::Segment> 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;