From 7ed36c9bec5b8f548c1a9fc7eec4c449d8dcc572 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Tue, 7 Mar 2023 22:12:22 -0700 Subject: [PATCH] qbsp: reject Q2 maps with mixed visible contents --- qbsp/map.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qbsp/map.cc b/qbsp/map.cc index 8e42e24f..0bc2126f 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -1716,6 +1716,21 @@ static void ParseTextureDef(const mapentity_t &entity, parser_t &parser, mapface } } + // Mixing visible contents on the input brush is illegal + { + const int32_t visible_contents = extinfo.info->contents.native & Q2_ALL_VISIBLE_CONTENTS; + + // TODO: Move to bspfile.hh API + for (int32_t i = Q2_CONTENTS_SOLID; i <= Q2_LAST_VISIBLE_CONTENTS; i <<= 1) { + if (visible_contents & i) { + if (visible_contents != i) { + FError("{}: Mixed visible contents: {}", mapface.line, + extinfo.info->contents.to_string(qbsp_options.target_game)); + } + } + } + } + // If Q2 style phong is enabled on a mirrored face, `light` will erroneously try to blend normals between // the front and back faces leading to light artifacts. const bool wants_phong = !(extinfo.info->flags.native & Q2_SURF_LIGHT) && (extinfo.info->value != 0);