From 1b9d5538c298e177493fbf6b8a124fbda55539c9 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Tue, 1 Nov 2016 15:07:58 -0600 Subject: [PATCH] qbsp: make BuildSurfaces not rely on map iteration order --- qbsp/csg4.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/qbsp/csg4.cc b/qbsp/csg4.cc index 0877626b..cc5f1cb4 100644 --- a/qbsp/csg4.cc +++ b/qbsp/csg4.cc @@ -384,13 +384,18 @@ surface_t * BuildSurfaces(const std::map &planefaces) { surface_t *surfaces = NULL; - for (const auto &entry : planefaces) { + + for (int i = 0; i < map.numplanes(); i++) { + const auto entry = planefaces.find(i); + if (entry == planefaces.end() || entry->second == nullptr) // FIXME: entry->second == nullptr should never happen, turn into Q_assert + continue; + /* create a new surface to hold the faces on this plane */ surface_t *surf = (surface_t *)AllocMem(SURFACE, 1, true); - surf->planenum = entry.first; + surf->planenum = entry->first; surf->next = surfaces; surfaces = surf; - surf->faces = entry.second; + surf->faces = entry->second; for (const face_t *face = surf->faces; face; face = face->next) csgmergefaces++;