qbsp: support -convert quake2 to write classic q2/q3 format with three 0 flags
This commit is contained in:
parent
32b001b4d9
commit
f3caed2f8b
19
qbsp/map.cc
19
qbsp/map.cc
|
|
@ -1622,7 +1622,7 @@ static void fprintDoubleAndSpc(FILE *f, double v)
|
|||
}
|
||||
|
||||
static void
|
||||
ConvertMapFace(FILE *f, const mapface_t &mapface, const texcoord_style_t format)
|
||||
ConvertMapFace(FILE *f, const mapface_t &mapface, const texcoord_style_t format, const mapformat_t mapformat)
|
||||
{
|
||||
EnsureTexturesLoaded();
|
||||
const texture_t *texture = WADList_GetTexture(mapface.texname.c_str());
|
||||
|
|
@ -1648,6 +1648,11 @@ ConvertMapFace(FILE *f, const mapface_t &mapface, const texcoord_style_t format)
|
|||
fprintDoubleAndSpc(f, quakeed.rotate);
|
||||
fprintDoubleAndSpc(f, quakeed.scale[0]);
|
||||
fprintDoubleAndSpc(f, quakeed.scale[1]);
|
||||
|
||||
if (mapformat == mapformat_t::q2) {
|
||||
fprintf(f, "0 0 0");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case texcoord_style_t::TX_VALVE_220: {
|
||||
|
|
@ -1682,6 +1687,8 @@ ConvertMapFace(FILE *f, const mapface_t &mapface, const texcoord_style_t format)
|
|||
fprintDoubleAndSpc(f, bp.texMat[1][0]);
|
||||
fprintDoubleAndSpc(f, bp.texMat[1][1]);
|
||||
fprintDoubleAndSpc(f, bp.texMat[1][2]);
|
||||
|
||||
// N.B.: always print the Q2/Q3 flags
|
||||
fprintf(f, ") ) %s 0 0 0", mapface.texname.c_str());
|
||||
break;
|
||||
}
|
||||
|
|
@ -1693,7 +1700,7 @@ ConvertMapFace(FILE *f, const mapface_t &mapface, const texcoord_style_t format)
|
|||
}
|
||||
|
||||
static void
|
||||
ConvertMapBrush(FILE *f, const mapbrush_t &mapbrush, const texcoord_style_t format)
|
||||
ConvertMapBrush(FILE *f, const mapbrush_t &mapbrush, const texcoord_style_t format, const mapformat_t mapformat)
|
||||
{
|
||||
fprintf(f, "{\n");
|
||||
if (format == texcoord_style_t::TX_BRUSHPRIM) {
|
||||
|
|
@ -1701,7 +1708,7 @@ ConvertMapBrush(FILE *f, const mapbrush_t &mapbrush, const texcoord_style_t form
|
|||
fprintf(f, "{\n");
|
||||
}
|
||||
for (int i=0; i<mapbrush.numfaces; i++) {
|
||||
ConvertMapFace(f, mapbrush.face(i), format);
|
||||
ConvertMapFace(f, mapbrush.face(i), format, mapformat);
|
||||
}
|
||||
if (format == texcoord_style_t::TX_BRUSHPRIM) {
|
||||
fprintf(f, "}\n");
|
||||
|
|
@ -1710,14 +1717,14 @@ ConvertMapBrush(FILE *f, const mapbrush_t &mapbrush, const texcoord_style_t form
|
|||
}
|
||||
|
||||
static void
|
||||
ConvertEntity(FILE *f, const mapentity_t *entity, const texcoord_style_t format)
|
||||
ConvertEntity(FILE *f, const mapentity_t *entity, const texcoord_style_t format, const mapformat_t mapformat)
|
||||
{
|
||||
fprintf(f, "{\n");
|
||||
for (const epair_t *epair = entity->epairs; epair; epair = epair->next) {
|
||||
fprintf(f, "\"%s\" \"%s\"\n", epair->key, epair->value);
|
||||
}
|
||||
for (int i=0; i<entity->nummapbrushes; i++) {
|
||||
ConvertMapBrush(f, entity->mapbrush(i), format);
|
||||
ConvertMapBrush(f, entity->mapbrush(i), format, mapformat);
|
||||
}
|
||||
fprintf(f, "}\n");
|
||||
}
|
||||
|
|
@ -1753,7 +1760,7 @@ void ConvertMapFile(void)
|
|||
Error("Couldn't open file\n");
|
||||
|
||||
for (const mapentity_t &entity : map.entities) {
|
||||
ConvertEntity(f, &entity, options.convertMapTexFormat);
|
||||
ConvertEntity(f, &entity, options.convertMapTexFormat, options.convertMapFormat);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
|
|
|||
|
|
@ -819,10 +819,16 @@ ParseOptions(char *szOptions)
|
|||
Error("Invalid argument to option %s", szTok);
|
||||
|
||||
if (!Q_strcasecmp(szTok2, "quake")) {
|
||||
options.convertMapFormat = mapformat_t::q1;
|
||||
options.convertMapTexFormat = texcoord_style_t::TX_QUAKED;
|
||||
} else if (!Q_strcasecmp(szTok2, "quake2")) {
|
||||
options.convertMapFormat = mapformat_t::q2;
|
||||
options.convertMapTexFormat = texcoord_style_t::TX_QUAKED;
|
||||
} else if (!Q_strcasecmp(szTok2, "valve")) {
|
||||
options.convertMapFormat = mapformat_t::q1;
|
||||
options.convertMapTexFormat = texcoord_style_t::TX_VALVE_220;
|
||||
} else if (!Q_strcasecmp(szTok2, "bp")) {
|
||||
options.convertMapFormat = mapformat_t::q2;
|
||||
options.convertMapTexFormat = texcoord_style_t::TX_BRUSHPRIM;
|
||||
} else {
|
||||
Error("Invalid argument to option %s", szTok);
|
||||
|
|
|
|||
|
|
@ -484,6 +484,10 @@ typedef enum {
|
|||
TX_BRUSHPRIM = 4
|
||||
} texcoord_style_t;
|
||||
|
||||
typedef enum {
|
||||
q1, q2
|
||||
} mapformat_t;
|
||||
|
||||
typedef struct options_s {
|
||||
bool fNofill;
|
||||
bool fNoclip;
|
||||
|
|
@ -491,6 +495,7 @@ typedef struct options_s {
|
|||
bool fOnlyents;
|
||||
bool fConvertMapFormat;
|
||||
texcoord_style_t convertMapTexFormat;
|
||||
mapformat_t convertMapFormat;
|
||||
bool fVerbose;
|
||||
bool fAllverbose;
|
||||
bool fSplitspecial;
|
||||
|
|
|
|||
Loading…
Reference in New Issue