From 1ab6cc1e6595a4948e13c6346d29bd77ec850d4b Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 27 Aug 2022 14:39:27 -0600 Subject: [PATCH] qbsp: fix iterator debug assertion in ChopBrushes "cannot decrement begin list iterator" --- qbsp/brushbsp.cc | 6 +++--- tests/test_qbsp.cc | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/qbsp/brushbsp.cc b/qbsp/brushbsp.cc index b0e9b9fe..fbd04198 100644 --- a/qbsp/brushbsp.cc +++ b/qbsp/brushbsp.cc @@ -1475,9 +1475,9 @@ newlist: if (c1 < c2) { stats.c_from_split += sub.size(); - auto before = std::prev(list.erase(b1_it)); // remove the current brush, go back one - list.splice(std::next(before), sub); // splice new list in place of where the brush was - b1_it = std::next(before); // restart list with the new brushes + auto before = list.erase(b1_it); // remove the current brush, go back one + list.splice(before, sub); // splice new list in place of where the brush was + b1_it = before; // restart list with the new brushes goto newlist; } else { stats.c_from_split += sub2.size(); diff --git a/tests/test_qbsp.cc b/tests/test_qbsp.cc index 53b58648..566e4908 100644 --- a/tests/test_qbsp.cc +++ b/tests/test_qbsp.cc @@ -1545,6 +1545,15 @@ TEST_CASE("quake maps", "[testmaps_q1][.releaseonly]") } } +TEST_CASE("chop", "[testmaps_q1]") +{ + const auto [bsp, bspx, prt] = LoadTestmapQ1("quake_map_source/DM1-test.map", {"-chop", "-debugchop"}); + + CHECK(GAME_QUAKE == bsp.loadversion->game->id); + CHECK(prt); + CheckFilled(bsp); +} + TEST_CASE("base1leak", "[testmaps_q2]") { const auto [bsp, bspx, prt] = LoadTestmapQ2("base1leak.map");