qbsp: fix area assignment on leaking q2 maps

reverts c9243d4fea
This commit is contained in:
Eric Wasylishen 2022-12-21 21:18:06 -07:00
parent 54ada5be6d
commit 1fb53cbe4d
3 changed files with 47 additions and 1 deletions

View File

@ -710,7 +710,7 @@ bool FillOutside(tree_t &tree, hull_index_t hullnum, bspbrush_t::container &brus
}
// clear occupied state, so areas can be flooded in Q2
ClearOccupied_r(node);
//ClearOccupied_r(node);
return false;
}

22
testmaps/q2_leaked.map Normal file
View File

@ -0,0 +1,22 @@
// Game: Quake 2
// Format: Quake2 (Valve)
// entity 0
{
"mapversion" "220"
"classname" "worldspawn"
"_tb_textures" "textures/e1u1"
// brush 0
{
( 40 388 96 ) ( 40 389 96 ) ( 40 388 97 ) e1u1/florr1_8 [ 0 1 0 -16 ] [ 0 0 -1 0 ] 0 1 1
( 120 68 80 ) ( 119 68 80 ) ( 120 68 81 ) e1u1/florr1_8 [ -1 0 0 16 ] [ 0 0 -1 0 ] 180 1 1
( 120 68 80 ) ( 120 69 80 ) ( 119 68 80 ) e1u1/florr1_8 [ 1 0 0 -16 ] [ 0 -1 0 16 ] 180 1 1
( 40 388 96 ) ( 39 388 96 ) ( 40 389 96 ) e1u1/florr1_8 [ -1 0 0 16 ] [ 0 -1 0 16 ] 180 1 1
( 40 676 96 ) ( 40 676 97 ) ( 39 676 96 ) e1u1/florr1_8 [ 1 0 0 -16 ] [ 0 0 -1 0 ] 180 1 1
( 488 68 80 ) ( 488 68 81 ) ( 488 69 80 ) e1u1/florr1_8 [ 0 -1 0 16 ] [ 0 0 -1 0 ] 0 1 1
}
}
// entity 1
{
"classname" "info_player_start"
"origin" "112 436 120"
}

View File

@ -75,6 +75,7 @@ TEST_CASE("detail" * doctest::test_suite("testmaps_q2")) {
auto *detail_leaf = BSP_FindLeafAtPoint(&bsp, &bsp.dmodels[0], inside_button);
CHECK(Q2_CONTENTS_SOLID == detail_leaf->contents);
CHECK(-1 == detail_leaf->cluster);
CHECK(0 == detail_leaf->area); // solid leafs get the invalid area 0
// check for button (detail) brush
CHECK(1 == Leaf_Brushes(&bsp, detail_leaf).size());
@ -562,3 +563,26 @@ TEST_CASE("q2_mirrorinside" * doctest::test_suite("testmaps_q2"))
std::vector<std::string>({"e1u1/alphamask", "e1u1/alphamask"}));
}
}
/**
* Ensure that leaked maps still get areas assigned properly
* (empty leafs should get area 1, solid leafs area 0)
*/
TEST_CASE("q2_leaked" * doctest::test_suite("testmaps_q2"))
{
const auto [bsp, bspx, prt] = LoadTestmapQ2("q2_leaked.map");
CHECK(!prt);
CHECK(GAME_QUAKE_II == bsp.loadversion->game->id);
CHECK(bsp.dareaportals.size() == 1);
CHECK(bsp.dareas.size() == 2);
CHECK(bsp.dleafs.size() == 8);
for (auto &leaf : bsp.dleafs) {
if (leaf.contents == Q2_CONTENTS_SOLID) {
CHECK(0 == leaf.area);
} else {
CHECK(1 == leaf.area);
}
}
}