diff --git a/common/bspfile_generic.cc b/common/bspfile_generic.cc index 0081c19f..4891bbba 100644 --- a/common/bspfile_generic.cc +++ b/common/bspfile_generic.cc @@ -121,6 +121,7 @@ void miptex_t::stream_read(std::istream &stream, size_t len) name = dtex.name.data(); width = dtex.width; height = dtex.height; + offsets = dtex.offsets; } void miptex_t::stream_write(std::ostream &stream) const diff --git a/docs/qbsp.rst b/docs/qbsp.rst index dceeaac6..a4625566 100644 --- a/docs/qbsp.rst +++ b/docs/qbsp.rst @@ -329,6 +329,14 @@ Options avoids inclusion of third-party copyrighted images inside your maps, but is not backwards compatible but will work in FTEQW and QSS. + Note that the textures still need to be available to qbsp. + + Technical details: ``LUMP_TEXTURES`` is still written, but each texture + within is the ``dmiptex_t`` header only (with no texture data following), + with ``offsets`` all set to 0. + + This only has effect in Q1 family games. + .. option:: -notjunc Alias for :option:`-tjunc none` diff --git a/include/common/bspfile_generic.hh b/include/common/bspfile_generic.hh index c0707afb..6560d1de 100644 --- a/include/common/bspfile_generic.hh +++ b/include/common/bspfile_generic.hh @@ -106,6 +106,10 @@ struct miptex_t * set at read time if the offset is -1 */ bool null_texture = false; + /** + * exposed for testing -notex + */ + std::array offsets; size_t stream_size() const; diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index d2109512..b286e9bd 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -1571,7 +1571,7 @@ static void LoadTextureData() header.width = miptex.width; header.height = miptex.height; - header.offsets = {-1, -1, -1, -1}; + header.offsets = {0, 0, 0, 0}; omemstream stream(miptex.data.data(), miptex.data.size()); stream <= header; diff --git a/tests/test_qbsp.cc b/tests/test_qbsp.cc index b4f7d2da..94f5336a 100644 --- a/tests/test_qbsp.cc +++ b/tests/test_qbsp.cc @@ -1904,6 +1904,40 @@ TEST_CASE("q1_missing_texture") CHECK("" == bsp.dtex.textures[1].name); CHECK(bsp.dtex.textures[1].null_texture); + + CHECK(6 == bsp.dfaces.size()); +} + +TEST_CASE("q1 notex") +{ + const auto [bsp, bspx, prt] = LoadTestmap("q1_cube.map", {"-notex"}); + + REQUIRE(2 == bsp.dtex.textures.size()); + + { + // FIXME: we shouldn't really be writing skip + // (our test data includes an actual "skip" texture, + // so that gets included in the bsp.) + auto &t0 = bsp.dtex.textures[0]; + CHECK("skip" == t0.name); + CHECK(!t0.null_texture); + CHECK(64 == t0.width); + CHECK(64 == t0.height); + CHECK(t0.data.size() == sizeof(dmiptex_t)); + for (int i = 0; i < 4; ++i) + CHECK(t0.offsets[i] == 0); + } + + { + auto &t1 = bsp.dtex.textures[1]; + CHECK("orangestuff8" == t1.name); + CHECK(!t1.null_texture); + CHECK(64 == t1.width); + CHECK(64 == t1.height); + CHECK(t1.data.size() == sizeof(dmiptex_t)); + for (int i = 0; i < 4; ++i) + CHECK(t1.offsets[i] == 0); + } } TEST_CASE("hl_basic")