tests: add ExportWad test

This commit is contained in:
Eric Wasylishen 2023-05-27 17:05:41 -06:00
parent 2703761edb
commit c649e3a0c8
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,49 @@
// Game: Quake
// Format: Valve
// entity 0
{
"mapversion" "220"
"classname" "worldspawn"
"wad" "deprecated/fence.wad;deprecated/free_wad.wad"
// brush 0
{
( -64 -64 -16 ) ( -64 -63 -16 ) ( -64 -64 -15 ) bolt14 [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1
( -64 -64 -16 ) ( -64 -64 -15 ) ( -63 -64 -16 ) bolt14 [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( -64 -64 -16 ) ( -63 -64 -16 ) ( -64 -63 -16 ) bolt14 [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 64 64 16 ) ( 64 65 16 ) ( 65 64 16 ) bolt14 [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 64 64 16 ) ( 65 64 16 ) ( 64 64 17 ) bolt14 [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 64 64 16 ) ( 64 64 17 ) ( 64 65 16 ) bolt14 [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1
}
// brush 1
{
( -64 -192 -16 ) ( -64 -191 -16 ) ( -64 -192 -15 ) *swater4 [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1
( -64 -192 -16 ) ( -64 -192 -15 ) ( -63 -192 -16 ) *swater4 [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( -64 -192 -16 ) ( -63 -192 -16 ) ( -64 -191 -16 ) *swater4 [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 64 -64 16 ) ( 64 -63 16 ) ( 65 -64 16 ) *swater4 [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 64 -64 16 ) ( 65 -64 16 ) ( 64 -64 17 ) *swater4 [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 64 -64 16 ) ( 64 -64 17 ) ( 64 -63 16 ) *swater4 [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1
}
// brush 2
{
( -64 -64 144 ) ( -64 -63 144 ) ( -64 -64 145 ) sky3 [ 0 -1 0 0 ] [ 0 0 -1 32 ] 0 1 1
( -64 -64 144 ) ( -64 -64 145 ) ( -63 -64 144 ) sky3 [ 1 0 0 0 ] [ 0 0 -1 32 ] 0 1 1
( -64 -64 144 ) ( -63 -64 144 ) ( -64 -63 144 ) sky3 [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 64 64 176 ) ( 64 65 176 ) ( 65 64 176 ) sky3 [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 64 64 176 ) ( 65 64 176 ) ( 64 64 177 ) sky3 [ -1 0 0 0 ] [ 0 0 -1 32 ] 0 1 1
( 64 64 176 ) ( 64 64 177 ) ( 64 65 176 ) sky3 [ 0 1 0 0 ] [ 0 0 -1 32 ] 0 1 1
}
// brush 3
{
( -144 -64 0 ) ( -144 -63 0 ) ( -144 -64 1 ) brownlight [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1
( -144 0 0 ) ( -144 0 1 ) ( -143 0 0 ) brownlight [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( -144 -64 -208 ) ( -143 -64 -208 ) ( -144 -63 -208 ) brownlight [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( -64 64 16 ) ( -64 65 16 ) ( -63 64 16 ) brownlight [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( -64 64 16 ) ( -63 64 16 ) ( -64 64 17 ) brownlight [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( -64 64 16 ) ( -64 64 17 ) ( -64 65 16 ) brownlight [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1
}
}
// entity 1
{
"classname" "info_player_start"
"origin" "-32 -16 40"
}

View File

@ -4,6 +4,7 @@
#include <common/decompile.hh>
#include <common/bsputils.hh>
#include <qbsp/map.hh>
#include <bsputil/bsputil.hh>
#include "testmaps.hh"
#include "test_qbsp.hh"
@ -46,4 +47,28 @@ TEST_SUITE("bsputil")
CHECK(face2_texinfo->vecs == face_texinfo->vecs);
}
}
TEST_CASE("extract-textures")
{
const auto [bsp, bspx, prt] = LoadTestmapQ1("q1_extract_textures.map");
// extract .bsp textures to test.wad
std::ofstream wadfile("test.wad", std::ios::binary);
ExportWad(wadfile, &bsp);
// reload .wad
fs::clear();
img::clear();
auto ar = fs::addArchive("test.wad");
REQUIRE(ar);
for (std::string texname : {"*swater4", "bolt14", "sky3", "brownlight"}) {
INFO(texname);
fs::data data = ar->load(texname);
REQUIRE(data);
auto loaded_tex = img::load_mip(texname, data, false, bspver_q1.game);
CHECK(loaded_tex);
}
}
}