diff --git a/src/map/IMG/rgnfile.cpp b/src/map/IMG/rgnfile.cpp index ecb12355..deacae64 100644 --- a/src/map/IMG/rgnfile.cpp +++ b/src/map/IMG/rgnfile.cpp @@ -538,54 +538,53 @@ bool RGNFile::links(Handle &hdl, const SubDiv *subdiv, quint32 shift, return true; } -QMap RGNFile::segments(Handle &hdl, - SubDiv *subdiv) const +bool RGNFile::segments(Handle &hdl, SubDiv *subdiv, SubDiv::Segment seg[5]) const { - QMap ret; - if (subdiv->offset() == subdiv->end() || !(subdiv->objects() & 0x1F)) - return ret; + return true; quint32 offset = _offset + subdiv->offset(); + if (!seek(hdl, offset)) + return false; int no = 0; - for (quint8 mask = 0x1; mask <= 0x10; mask <<= 1) - if (subdiv->objects() & mask) + for (int i = 0; i < 5; i++) + if (subdiv->objects() & (1<objects() & mask) { + for (int i = 0; i < 5; i++) { + if (subdiv->objects() & (1<(); + return false; start = offset + po; - ret.insert(lt, SubDiv::Segment(ls, start)); + seg[lt] = SubDiv::Segment(ls, start); } - lt = (SegmentType)mask; + lt = i; ls = start; } } - ret.insert(lt, SubDiv::Segment(ls, subdiv->end() - ? _offset + subdiv->end() : _offset + _size)); + seg[lt] = SubDiv::Segment(ls, + subdiv->end() ? _offset + subdiv->end() : _offset + _size); - return ret; + return true; } bool RGNFile::subdivInit(Handle &hdl, SubDiv *subdiv) const { - QMap seg(segments(hdl, subdiv)); + SubDiv::Segment seg[5]; SubDiv::Segment extPoints, extLines, extPolygons; + if (!segments(hdl, subdiv, seg)) + return false; + if (subdiv->extPointsOffset() != subdiv->extPointsEnd()) { quint32 start = _pointsOffset + subdiv->extPointsOffset(); quint32 end = subdiv->extPointsEnd() @@ -608,9 +607,8 @@ bool RGNFile::subdivInit(Handle &hdl, SubDiv *subdiv) const extLines = SubDiv::Segment(start, end); } - subdiv->init(seg.value(Point), seg.value(IndexedPoint), seg.value(Line), - seg.value(Polygon), seg.value(RoadReference), extPoints, extLines, - extPolygons); + subdiv->init(seg[Point], seg[IndexedPoint], seg[Line], seg[Polygon], + seg[RoadReference], extPoints, extLines, extPolygons); return true; } diff --git a/src/map/IMG/rgnfile.h b/src/map/IMG/rgnfile.h index 8a6e8d9c..28e8fa16 100644 --- a/src/map/IMG/rgnfile.h +++ b/src/map/IMG/rgnfile.h @@ -15,11 +15,11 @@ class RGNFile : public SubFile { public: enum SegmentType { - Point = 0x1, - IndexedPoint = 0x2, - Line = 0x4, - Polygon = 0x8, - RoadReference = 0x10 + Point, + IndexedPoint, + Line, + Polygon, + RoadReference }; RGNFile(const IMGData *img) @@ -61,8 +61,7 @@ public: quint32 dictSize() const {return _dictSize;} private: - QMap segments(Handle &hdl, SubDiv *subdiv) - const; + bool segments(Handle &hdl, SubDiv *subdiv, SubDiv::Segment seg[5]) const; bool readClassFields(Handle &hdl, SegmentType segmentType, MapData::Poly *poly = 0, const LBLFile *lbl = 0) const; bool skipLclFields(Handle &hdl, const quint32 flags[3]) const;