From d05b8fc3dba5d174077bd9d3824f8dcd40c5d3de Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 2 Jun 2022 18:59:51 -0400 Subject: [PATCH] don't output texinfo for SKIP faces - rendered faces won't reference them anyways (unless includeskip is on) --- bspinfo/main.cc | 22 ++++++++++++++++++++++ qbsp/writebsp.cc | 2 ++ 2 files changed, 24 insertions(+) diff --git a/bspinfo/main.cc b/bspinfo/main.cc index 8d0d69f3..90fc03e5 100644 --- a/bspinfo/main.cc +++ b/bspinfo/main.cc @@ -64,6 +64,26 @@ static void PrintBSPTextureUsage(const mbsp_t &bsp) } } +static void FindInfiniteChains(const mbsp_t &bsp) +{ + for (auto &ti : bsp.texinfo) + { + if (ti.nexttexinfo == -1) + continue; + + int loop = 0; + + for (int i = ti.nexttexinfo; i != -1; i = bsp.texinfo[i].nexttexinfo, loop++) + { + if (loop > bsp.texinfo.size()) + { + printf("INFINITE LOOP!"); + exit(1); + } + } + } +} + // TODO settings::common_settings options; @@ -95,6 +115,8 @@ int main(int argc, char **argv) PrintBSPTextureUsage(std::get(bsp.bsp)); + FindInfiniteChains(std::get(bsp.bsp)); + printf("---------------------\n"); fs::clear(); diff --git a/qbsp/writebsp.cc b/qbsp/writebsp.cc index 69514824..05eac3d4 100644 --- a/qbsp/writebsp.cc +++ b/qbsp/writebsp.cc @@ -85,6 +85,8 @@ size_t ExportMapTexinfo(size_t texinfonum) if (src.outputnum.has_value()) return src.outputnum.value(); + else if (!options.includeskip.value() && src.flags.is_skip) + return -1; // this will be the index of the exported texinfo in the BSP lump const size_t i = map.bsp.texinfo.size();