qbsp: handle target bsp version
This commit is contained in:
parent
3cbf54749e
commit
54d9e08033
|
|
@ -21,17 +21,18 @@
|
||||||
#include <common/mathlib.hh>
|
#include <common/mathlib.hh>
|
||||||
#include <common/bspfile.hh>
|
#include <common/bspfile.hh>
|
||||||
|
|
||||||
const bspversion_t bspver_generic { NO_VERSION, NO_VERSION, "mbsp", "generic BSP" };
|
/* hexen2, quake2 */
|
||||||
const bspversion_t bspver_q1 { BSPVERSION, NO_VERSION, "bsp29", "Quake BSP" };
|
const bspversion_t bspver_generic { NO_VERSION, NO_VERSION, "mbsp", "generic BSP", false, false };
|
||||||
const bspversion_t bspver_bsp2 { BSP2VERSION, NO_VERSION, "bsp2", "Quake BSP2" };
|
const bspversion_t bspver_q1 { BSPVERSION, NO_VERSION, "bsp29", "Quake BSP", false, false };
|
||||||
const bspversion_t bspver_bsp2rmq { BSP2RMQVERSION, NO_VERSION, "bsp2rmq", "Quake BSP2-RMQ" };
|
const bspversion_t bspver_bsp2 { BSP2VERSION, NO_VERSION, "bsp2", "Quake BSP2", false, false };
|
||||||
/* Hexen II doesn't use a separate version, but we can still use a separate tag/name for it */
|
const bspversion_t bspver_bsp2rmq { BSP2RMQVERSION, NO_VERSION, "bsp2rmq", "Quake BSP2-RMQ", false, false };
|
||||||
const bspversion_t bspver_h2 { BSPVERSION, NO_VERSION, "hexen2", "Hexen II BSP" };
|
/* Hexen II doesn't use a separate version, but we can still use a separate tag/name for it */
|
||||||
const bspversion_t bspver_h2bsp2 { BSP2VERSION, NO_VERSION, "hexen2bsp2", "Hexen II BSP2" };
|
const bspversion_t bspver_h2 { BSPVERSION, NO_VERSION, "hexen2", "Hexen II BSP", true, false };
|
||||||
const bspversion_t bspver_h2bsp2rmq { BSP2RMQVERSION, NO_VERSION, "hexen2bsp2rmq", "Hexen II BSP2-RMQ" };
|
const bspversion_t bspver_h2bsp2 { BSP2VERSION, NO_VERSION, "hexen2bsp2", "Hexen II BSP2", true, false };
|
||||||
const bspversion_t bspver_hl { BSPHLVERSION, NO_VERSION, "hl", "Half-Life BSP" };
|
const bspversion_t bspver_h2bsp2rmq { BSP2RMQVERSION, NO_VERSION, "hexen2bsp2rmq", "Hexen II BSP2-RMQ", true, false };
|
||||||
const bspversion_t bspver_q2 { Q2_BSPIDENT, Q2_BSPVERSION, "q2bsp", "Quake II BSP" };
|
const bspversion_t bspver_hl { BSPHLVERSION, NO_VERSION, "hl", "Half-Life BSP", false, false };
|
||||||
const bspversion_t bspver_qbism { Q2_QBISMIDENT, Q2_BSPVERSION, "qbism", "Quake II Qbism BSP" };
|
const bspversion_t bspver_q2 { Q2_BSPIDENT, Q2_BSPVERSION, "q2bsp", "Quake II BSP", false, true };
|
||||||
|
const bspversion_t bspver_qbism { Q2_QBISMIDENT, Q2_BSPVERSION, "qbism", "Quake II Qbism BSP", false, true };
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
BSPVersionString(const bspversion_t *version)
|
BSPVersionString(const bspversion_t *version)
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ struct bspversion_t
|
||||||
const char *short_name;
|
const char *short_name;
|
||||||
/* full display name for printing */
|
/* full display name for printing */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
bool hexen2;
|
||||||
|
bool quake2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NO_VERSION -1
|
#define NO_VERSION -1
|
||||||
|
|
|
||||||
|
|
@ -286,8 +286,7 @@ public:
|
||||||
bool fixRotateObjTexture;
|
bool fixRotateObjTexture;
|
||||||
bool fbspx_brushes;
|
bool fbspx_brushes;
|
||||||
bool fNoTextures;
|
bool fNoTextures;
|
||||||
int hexen2;/*2 if the worldspawn mission pack flag was set*/
|
const bspversion_t *target_version = nullptr;
|
||||||
int BSPVersion;
|
|
||||||
int dxSubdivide;
|
int dxSubdivide;
|
||||||
int dxLeakDist;
|
int dxLeakDist;
|
||||||
int maxNodeSize;
|
int maxNodeSize;
|
||||||
|
|
@ -342,8 +341,6 @@ public:
|
||||||
fixRotateObjTexture(true),
|
fixRotateObjTexture(true),
|
||||||
fbspx_brushes(false),
|
fbspx_brushes(false),
|
||||||
fNoTextures(false),
|
fNoTextures(false),
|
||||||
hexen2(0),
|
|
||||||
BSPVersion(BSPVERSION), // Default to the original Quake BSP Version...
|
|
||||||
dxSubdivide(240),
|
dxSubdivide(240),
|
||||||
dxLeakDist(2),
|
dxLeakDist(2),
|
||||||
maxNodeSize(1024),
|
maxNodeSize(1024),
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ CreateBrushFaces(const mapentity_t *src, hullbrush_t *hullbrush,
|
||||||
(rotate_offset[0] != 0.0 || rotate_offset[1] != 0.0 || rotate_offset[2] != 0.0)
|
(rotate_offset[0] != 0.0 || rotate_offset[1] != 0.0 || rotate_offset[2] != 0.0)
|
||||||
&& rottype == rotation_t::hipnotic
|
&& rottype == rotation_t::hipnotic
|
||||||
&& (hullnum >= 0) // hullnum < 0 corresponds to -wrbrushes clipping hulls
|
&& (hullnum >= 0) // hullnum < 0 corresponds to -wrbrushes clipping hulls
|
||||||
&& !options.hexen2; // never do this in Hexen 2
|
&& !options.target_version->hexen2; // never do this in Hexen 2
|
||||||
|
|
||||||
if (shouldExpand) {
|
if (shouldExpand) {
|
||||||
vec_t delta;
|
vec_t delta;
|
||||||
|
|
@ -909,7 +909,7 @@ brush_t *LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, int conte
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.BSPVersion == BSPHLVERSION)
|
if (options.target_version == &bspver_hl)
|
||||||
{
|
{
|
||||||
if (hullnum == 1) {
|
if (hullnum == 1) {
|
||||||
vec3_t size[2] = { {-16, -16, -36}, {16, 16, 36} };
|
vec3_t size[2] = { {-16, -16, -36}, {16, 16, 36} };
|
||||||
|
|
@ -930,7 +930,7 @@ brush_t *LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, int conte
|
||||||
facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum);
|
facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (options.hexen2)
|
else if (options.target_version->hexen2)
|
||||||
{
|
{
|
||||||
if (hullnum == 1) {
|
if (hullnum == 1) {
|
||||||
vec3_t size[2] = { {-16, -16, -32}, {16, 16, 24} };
|
vec3_t size[2] = { {-16, -16, -32}, {16, 16, 24} };
|
||||||
|
|
|
||||||
35
qbsp/qbsp.cc
35
qbsp/qbsp.cc
|
|
@ -576,9 +576,9 @@ CreateHulls(void)
|
||||||
CreateSingleHull(1);
|
CreateSingleHull(1);
|
||||||
CreateSingleHull(2);
|
CreateSingleHull(2);
|
||||||
|
|
||||||
if (options.BSPVersion == BSPHLVERSION)
|
if (options.target_version == &bspver_hl)
|
||||||
CreateSingleHull(3);
|
CreateSingleHull(3);
|
||||||
else if (options.hexen2)
|
else if (options.target_version->hexen2)
|
||||||
{ /*note: h2mp doesn't use hull 2 automatically, however gamecode can explicitly set ent.hull=3 to access it*/
|
{ /*note: h2mp doesn't use hull 2 automatically, however gamecode can explicitly set ent.hull=3 to access it*/
|
||||||
CreateSingleHull(3);
|
CreateSingleHull(3);
|
||||||
CreateSingleHull(4);
|
CreateSingleHull(4);
|
||||||
|
|
@ -781,6 +781,9 @@ ParseOptions(char *szOptions)
|
||||||
char *szEnd;
|
char *szEnd;
|
||||||
int NameCount = 0;
|
int NameCount = 0;
|
||||||
|
|
||||||
|
// temporary flags
|
||||||
|
bool hexen2 = false;
|
||||||
|
|
||||||
szEnd = szOptions + strlen(szOptions);
|
szEnd = szOptions + strlen(szOptions);
|
||||||
szTok = GetTok(szOptions, szEnd);
|
szTok = GetTok(szOptions, szEnd);
|
||||||
while (szTok) {
|
while (szTok) {
|
||||||
|
|
@ -832,7 +835,11 @@ ParseOptions(char *szOptions)
|
||||||
else if (!Q_strcasecmp(szTok, "nopercent"))
|
else if (!Q_strcasecmp(szTok, "nopercent"))
|
||||||
options.fNopercent = true;
|
options.fNopercent = true;
|
||||||
else if (!Q_strcasecmp(szTok, "hexen2"))
|
else if (!Q_strcasecmp(szTok, "hexen2"))
|
||||||
options.hexen2 = true;
|
hexen2 = true; // can be combined with -bsp2 or -2psb
|
||||||
|
else if (!Q_strcasecmp(szTok, "q2bsp"))
|
||||||
|
options.target_version = &bspver_q2;
|
||||||
|
else if (!Q_strcasecmp(szTok, "qbism"))
|
||||||
|
options.target_version = &bspver_qbism;
|
||||||
else if (!Q_strcasecmp(szTok, "wrbrushes") || !Q_strcasecmp(szTok, "bspx"))
|
else if (!Q_strcasecmp(szTok, "wrbrushes") || !Q_strcasecmp(szTok, "bspx"))
|
||||||
options.fbspx_brushes = true;
|
options.fbspx_brushes = true;
|
||||||
else if (!Q_strcasecmp(szTok, "wrbrushesonly") || !Q_strcasecmp(szTok, "bspxonly")) {
|
else if (!Q_strcasecmp(szTok, "wrbrushesonly") || !Q_strcasecmp(szTok, "bspxonly")) {
|
||||||
|
|
@ -840,11 +847,11 @@ ParseOptions(char *szOptions)
|
||||||
options.fNoclip = true;
|
options.fNoclip = true;
|
||||||
}
|
}
|
||||||
else if (!Q_strcasecmp(szTok, "hlbsp")) {
|
else if (!Q_strcasecmp(szTok, "hlbsp")) {
|
||||||
options.BSPVersion = BSPHLVERSION;
|
options.target_version = &bspver_hl;
|
||||||
} else if (!Q_strcasecmp(szTok, "bsp2")) {
|
} else if (!Q_strcasecmp(szTok, "bsp2")) {
|
||||||
options.BSPVersion = BSP2VERSION;
|
options.target_version = &bspver_bsp2;
|
||||||
} else if (!Q_strcasecmp(szTok, "2psb")) {
|
} else if (!Q_strcasecmp(szTok, "2psb")) {
|
||||||
options.BSPVersion = BSP2RMQVERSION;
|
options.target_version = &bspver_bsp2rmq;
|
||||||
} else if (!Q_strcasecmp(szTok, "leakdist")) {
|
} else if (!Q_strcasecmp(szTok, "leakdist")) {
|
||||||
szTok2 = GetTok(szTok + strlen(szTok) + 1, szEnd);
|
szTok2 = GetTok(szTok + strlen(szTok) + 1, szEnd);
|
||||||
if (!szTok2)
|
if (!szTok2)
|
||||||
|
|
@ -951,6 +958,22 @@ ParseOptions(char *szOptions)
|
||||||
}
|
}
|
||||||
szTok = GetTok(szTok + strlen(szTok) + 1, szEnd);
|
szTok = GetTok(szTok + strlen(szTok) + 1, szEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// combine format flags
|
||||||
|
if (hexen2) {
|
||||||
|
if (options.target_version == &bspver_bsp2) {
|
||||||
|
options.target_version = &bspver_h2bsp2;
|
||||||
|
} else if (options.target_version == &bspver_bsp2rmq) {
|
||||||
|
options.target_version = &bspver_h2bsp2rmq;
|
||||||
|
} else {
|
||||||
|
options.target_version = &bspver_h2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// default to bspver_q1
|
||||||
|
if (options.target_version == nullptr) {
|
||||||
|
options.target_version = &bspver_q1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ WAD_LoadInfo(wad_t *wad, bool external)
|
||||||
int w = LittleLong(miptex.width);
|
int w = LittleLong(miptex.width);
|
||||||
int h = LittleLong(miptex.height);
|
int h = LittleLong(miptex.height);
|
||||||
wad->lumps[i].size = sizeof(miptex) + (w>>0)*(h>>0) + (w>>1)*(h>>1) + (w>>2)*(h>>2) + (w>>3)*(h>>3);
|
wad->lumps[i].size = sizeof(miptex) + (w>>0)*(h>>0) + (w>>1)*(h>>1) + (w>>2)*(h>>2) + (w>>3)*(h>>3);
|
||||||
if (options.BSPVersion == BSPHLVERSION)
|
if (options.target_version == &bspver_hl)
|
||||||
wad->lumps[i].size += 2+3*256; //palette size+palette data
|
wad->lumps[i].size += 2+3*256; //palette size+palette data
|
||||||
wad->lumps[i].size = (wad->lumps[i].size+3) & ~3; //keep things aligned if we can.
|
wad->lumps[i].size = (wad->lumps[i].size+3) & ~3; //keep things aligned if we can.
|
||||||
|
|
||||||
|
|
@ -296,7 +296,7 @@ WAD_LoadLump(const wad_t *wad, const char *name, uint8_t *dest)
|
||||||
memcpy(dest+out->offsets[2], data.data()+(in->offsets[2]), (in->width>>2)*(in->height>>2));
|
memcpy(dest+out->offsets[2], data.data()+(in->offsets[2]), (in->width>>2)*(in->height>>2));
|
||||||
memcpy(dest+out->offsets[3], data.data()+(in->offsets[3]), (in->width>>3)*(in->height>>3));
|
memcpy(dest+out->offsets[3], data.data()+(in->offsets[3]), (in->width>>3)*(in->height>>3));
|
||||||
|
|
||||||
if (options.BSPVersion == BSPHLVERSION)
|
if (options.target_version == &bspver_hl)
|
||||||
{ //palette size. 256 in little endian.
|
{ //palette size. 256 in little endian.
|
||||||
dest[palofs+0] = ((256>>0)&0xff);
|
dest[palofs+0] = ((256>>0)&0xff);
|
||||||
dest[palofs+1] = ((256>>8)&0xff);
|
dest[palofs+1] = ((256>>8)&0xff);
|
||||||
|
|
@ -329,7 +329,7 @@ WADList_AddAnimationFrames(const wad_t *wadlist)
|
||||||
oldcount = map.nummiptex();
|
oldcount = map.nummiptex();
|
||||||
|
|
||||||
for (i = 0; i < oldcount; i++) {
|
for (i = 0; i < oldcount; i++) {
|
||||||
if (map.miptex.at(i)[0] != '+' && (options.BSPVersion!=BSPHLVERSION||map.miptex.at(i)[0] != '-'))
|
if (map.miptex.at(i)[0] != '+' && (options.target_version != &bspver_hl || map.miptex.at(i)[0] != '-'))
|
||||||
continue;
|
continue;
|
||||||
std::string name = map.miptex.at(i);
|
std::string name = map.miptex.at(i);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -442,7 +442,7 @@ WriteBSPFile()
|
||||||
|
|
||||||
//GenLump("LMSHIFT", BSPX_LMSHIFT, 1);
|
//GenLump("LMSHIFT", BSPX_LMSHIFT, 1);
|
||||||
|
|
||||||
ConvertBSPFormat(&bspdata, &bspver_q1); // assume q1 for now
|
ConvertBSPFormat(&bspdata, options.target_version);
|
||||||
|
|
||||||
StripExtension(options.szBSPName);
|
StripExtension(options.szBSPName);
|
||||||
strcat(options.szBSPName, ".bsp");
|
strcat(options.szBSPName, ".bsp");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue