diff options
author | jackpoz <giacomopoz@gmail.com> | 2015-11-25 21:49:27 +0100 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2015-11-25 21:49:27 +0100 |
commit | 981b871d2f2a30c5624c5ffc439e13b7995b1bc9 (patch) | |
tree | 6a158f905bed993bc793b028c3f0127c1729438d /src | |
parent | e9bd78635141bbf04224b8d593a7382306b93133 (diff) |
Tools/MMapGenerator: Fix an edge case of infinite loop
Fix a (pseudo) infinite loop happening when generating mmaps for single tile maps (like 249) but with vmaps not present in the correct folder. This would trigger a 18446744065119600000 (uint32 max ^ 2) iterations loop.
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/mmaps_generator/MapBuilder.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp index ff2f72f3534..0c41be65cf7 100644 --- a/src/tools/mmaps_generator/MapBuilder.cpp +++ b/src/tools/mmaps_generator/MapBuilder.cpp @@ -215,10 +215,12 @@ namespace MMAP /**************************************************************************/ void MapBuilder::getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY) const { - maxX = std::numeric_limits<uint32>::max(); - maxY = std::numeric_limits<uint32>::max(); - minX = 0; - minY = 0; + // min and max are initialized to invalid values so the caller iterating the [min, max] range + // will never enter the loop unless valid min/max values are found + maxX = 0; + maxY = 0; + minX = std::numeric_limits<uint32>::max(); + minY = std::numeric_limits<uint32>::max(); float bmin[3] = { 0, 0, 0 }; float bmax[3] = { 0, 0, 0 }; |