Finish using game everywhere

This commit is contained in:
Jonathan 2021-09-06 18:09:13 -04:00
parent dd3bcebe39
commit 437459a4dd
10 changed files with 31 additions and 36 deletions

View File

@ -215,7 +215,7 @@ TextureName_Contents(const char *texname)
bool //mxd
ContentsOrSurfaceFlags_IsTranslucent(const mbsp_t *bsp, const int contents_or_surf_flags)
{
if (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism)
if (bsp->loadversion->game == GAME_QUAKE_II)
return (contents_or_surf_flags & Q2_SURF_TRANSLUCENT) && ((contents_or_surf_flags & Q2_SURF_TRANSLUCENT) != Q2_SURF_TRANSLUCENT); // Don't count KMQ2 fence flags combo as translucent
else
return contents_or_surf_flags == CONTENTS_WATER || contents_or_surf_flags == CONTENTS_LAVA || contents_or_surf_flags == CONTENTS_SLIME;
@ -230,7 +230,7 @@ Face_IsTranslucent(const mbsp_t *bsp, const bsp2_dface_t *face)
int //mxd. Returns CONTENTS_ value for Q1, Q2_SURF_ bitflags for Q2...
Face_ContentsOrSurfaceFlags(const mbsp_t *bsp, const bsp2_dface_t *face)
{
if (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism) {
if (bsp->loadversion->game == GAME_QUAKE_II) {
const gtexinfo_t *info = Face_Texinfo(bsp, face);
return info->flags.native;
} else {
@ -275,7 +275,7 @@ static bool Light_PointInSolid_r(const mbsp_t *bsp, const int nodenum, const vec
const mleaf_t *leaf = BSP_GetLeafFromNodeNum(bsp, nodenum);
//mxd
if (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism) {
if (bsp->loadversion->game == GAME_QUAKE_II) {
return leaf->contents & Q2_CONTENTS_SOLID;
}

View File

@ -69,18 +69,13 @@ enum class brushformat_t {
class mapbrush_t {
public:
int firstface;
int numfaces;
brushformat_t format;
int contents;
mapbrush_t() :
firstface(0),
numfaces(0),
format(brushformat_t::NORMAL),
contents(0) {}
int firstface = 0;
int numfaces = 0;
brushformat_t format = brushformat_t::NORMAL;
int contents = 0;
const mapface_t &face(int i) const;
} ;
};
struct lumpdata {
int count;

View File

@ -1579,7 +1579,7 @@ static void MakeSurfaceLights(const mbsp_t *bsp)
for (int i = 0; i < bsp->numleafs; i++) {
const mleaf_t *leaf = bsp->dleafs + i;
const qboolean underwater = ((bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism) ? leaf->contents & Q2_CONTENTS_LIQUID : leaf->contents != CONTENTS_EMPTY); //mxd
const qboolean underwater = ((bsp->loadversion->game == GAME_QUAKE_II) ? (leaf->contents & Q2_CONTENTS_LIQUID) : leaf->contents != CONTENTS_EMPTY); //mxd
for (int k = 0; k < leaf->nummarksurfaces; k++) {
const int facenum = bsp->dleaffaces[leaf->firstmarksurface + k];

View File

@ -44,7 +44,7 @@ void // WHO TOUCHED MY PALET?
LoadPalette(bspdata_t *bspdata)
{
// Load Quake 2 palette
if (bspdata->loadversion == &bspver_q2 || bspdata->loadversion == &bspver_qbism) {
if (bspdata->loadversion->game == GAME_QUAKE_II) {
uint8_t *palette;
char path[1024];
char colormap[] = "pics/colormap.pcx";
@ -66,7 +66,7 @@ LoadPalette(bspdata_t *bspdata)
for (int i = 0; i < 768; i++)
thepalette[i] = palette[i];
} else if (bspdata->loadversion == &bspver_h2) {
} else if (bspdata->loadversion->game == GAME_HEXEN_II) {
// Copy Hexen 2 palette
for (int i = 0; i < 768; i++)
thepalette[i] = hexen2palette[i];
@ -721,7 +721,7 @@ void // Expects correct palette and game/mod paths to be set
LoadOrConvertTextures(mbsp_t *bsp)
{
// Load or convert textures...
if (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism)
if (bsp->loadversion->game == GAME_QUAKE_II)
LoadTextures(bsp);
else if (bsp->texdatasize > 0)
ConvertTextures(bsp);

View File

@ -537,9 +537,9 @@ LoadExtendedTexinfoFlags(const char *sourcefilename, const mbsp_t *bsp)
static const char* //mxd
GetBaseDirName(bspdata_t *bspdata)
{
if (bspdata->loadversion == &bspver_q2 || bspdata->loadversion == &bspver_qbism)
if (bspdata->loadversion->game == GAME_QUAKE_II)
return "BASEQ2";
if (bspdata->loadversion == &bspver_h2)
if (bspdata->loadversion->game == GAME_HEXEN_II)
return "DATA1";
return "ID1";
}
@ -1194,7 +1194,7 @@ light_main(int argc, const char **argv)
ConvertBSPFormat(&bspdata, &bspver_generic);
//mxd. Use 1.0 rangescale as a default to better match with qrad3/arghrad
if ((loadversion == &bspver_q2 || loadversion == &bspver_qbism) && !cfg.rangescale.isChanged())
if ((loadversion->game == GAME_QUAKE_II) && !cfg.rangescale.isChanged())
{
const auto rs = new lockable_vec_t(cfg.rangescale.primaryName(), 1.0f, 0.0f, 100.0f);
cfg.rangescale = *rs; // Gross hacks to avoid displaying this in OptionsSummary...

View File

@ -3081,7 +3081,7 @@ WriteLightmaps(const mbsp_t *bsp, bsp2_dface_t *face, facesup_t *facesup, const
continue;
// skip lightmaps where all samples have brightness below 1
if (bsp->loadversion != &bspver_q2 && bsp->loadversion != &bspver_qbism) { // HACK: don't do this on Q2. seems if all styles are 0xff, the face is drawn fullbright instead of black (Q1)
if (bsp->loadversion->game == GAME_QUAKE_II) { // HACK: don't do this on Q2. seems if all styles are 0xff, the face is drawn fullbright instead of black (Q1)
const float maxb = Lightmap_MaxBrightness(&lightmap, lightsurf);
if (maxb < 1)
continue;

View File

@ -716,7 +716,7 @@ TraceFaces (traceinfo_t *ti, int node, const vec3_t start, const vec3_t end)
// only solid and sky faces stop the trace.
bool issolid, issky; //mxd
if(bsp_static->loadversion == &bspver_q2 || bsp_static->loadversion == &bspver_qbism) {
if(bsp_static->loadversion->game == GAME_QUAKE_II) {
issolid = !(fi->content_or_surf_flags & Q2_SURF_TRANSLUCENT);
issky = (fi->content_or_surf_flags & Q2_SURF_SKY);
} else {

View File

@ -353,7 +353,7 @@ Embree_FilterFuncN(const struct RTCFilterFunctionNArguments* args)
//mxd
bool isFence, isGlass;
if(bsp_static->loadversion == &bspver_q2 || bsp_static->loadversion == &bspver_qbism) {
if(bsp_static->loadversion->game == GAME_QUAKE_II) {
const int surf_flags = Face_ContentsOrSurfaceFlags(bsp_static, face);
isFence = ((surf_flags & Q2_SURF_TRANSLUCENT) == Q2_SURF_TRANSLUCENT); // KMQuake 2-specific. Use texture alpha chanel when both flags are set.
isGlass = !isFence && (surf_flags & Q2_SURF_TRANSLUCENT);
@ -558,7 +558,7 @@ MakeFaces_r(const mbsp_t *bsp, const int nodenum, std::vector<plane_t> *planes,
const int leafnum = -nodenum - 1;
const mleaf_t *leaf = &bsp->dleafs[leafnum];
if ((bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism) ? leaf->contents & Q2_CONTENTS_SOLID : leaf->contents == CONTENTS_SOLID) {
if ((bsp->loadversion->game == GAME_QUAKE_II) ? (leaf->contents & Q2_CONTENTS_SOLID) : leaf->contents == CONTENTS_SOLID) {
std::vector<winding_t *> leaf_windings = Leaf_MakeFaces(bsp, leaf, *planes);
for (winding_t *w : leaf_windings) {
result->push_back(w);
@ -630,7 +630,7 @@ Embree_TraceInit(const mbsp_t *bsp)
const int contents_or_surf_flags = Face_ContentsOrSurfaceFlags(bsp, face); //mxd
const gtexinfo_t *texinfo = Face_Texinfo(bsp, face);
const bool is_q2 = bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism;
const bool is_q2 = bsp->loadversion->game == GAME_QUAKE_II;
//mxd. Skip NODRAW faces, but not SKY ones (Q2's sky01.wal has both flags set)
if(is_q2 && (contents_or_surf_flags & Q2_SURF_NODRAW) && !(contents_or_surf_flags & Q2_SURF_SKY))

View File

@ -622,9 +622,9 @@ EnsureTexturesLoaded()
static const char* //mxd
GetBaseDirName(const bspversion_t *bspver)
{
if (bspver == &bspver_q2 || bspver == &bspver_qbism)
if (bspver->game == GAME_QUAKE_II)
return "BASEQ2";
if (bspver == &bspver_h2)
if (bspver->game == GAME_HEXEN_II)
return "DATA1";
return "ID1";
}

View File

@ -571,7 +571,7 @@ LeafFlow(int leafnum, mleaf_t *dleaf, const mbsp_t *bsp)
/*
* flow through all portals, collecting visible bits
*/
outbuffer = (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism ? uncompressed_q2 : uncompressed) + leafnum * leafbytes;
outbuffer = (bsp->loadversion->game == GAME_QUAKE_II ? uncompressed_q2 : uncompressed) + leafnum * leafbytes;
leaf = &leafs[leafnum];
for (i = 0; i < leaf->numportals; i++) {
p = leaf->portals[i];
@ -653,7 +653,7 @@ ClusterFlow(int clusternum, leafbits_t *buffer, const mbsp_t *bsp)
*/
numvis = 0;
if (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism) {
if (bsp->loadversion->game == GAME_QUAKE_II) {
outbuffer = uncompressed_q2 + clusternum * leafbytes;
for (i = 0; i < portalleafs; i++) {
if (TestLeafBit(buffer, i)) {
@ -688,7 +688,7 @@ ClusterFlow(int clusternum, leafbits_t *buffer, const mbsp_t *bsp)
}
/* Allocate for worst case where RLE might grow the data (unlikely) */
if (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism) {
if (bsp->loadversion->game == GAME_QUAKE_II) {
compressed = static_cast<uint8_t *>(malloc(portalleafs * 2 / 8));
len = CompressRow(outbuffer, (portalleafs + 7) >> 3, compressed);
} else {
@ -1061,7 +1061,7 @@ LoadPortals(char *name, mbsp_t *bsp)
if (count != 2)
Error("%s: unable to parse %s HEADER\n", __func__, PORTALFILE);
if (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism) {
if (bsp->loadversion->game == GAME_QUAKE_II) {
portalleafs_real = bsp->numleafs;
logprint("%6d leafs\n", portalleafs_real);
logprint("%6d clusters\n", portalleafs);
@ -1101,7 +1101,7 @@ LoadPortals(char *name, mbsp_t *bsp)
leafs = static_cast<leaf_t *>(malloc(portalleafs * sizeof(leaf_t)));
memset(leafs, 0, portalleafs * sizeof(leaf_t));
if (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism) {
if (bsp->loadversion->game == GAME_QUAKE_II) {
originalvismapsize = portalleafs * ((portalleafs + 7) / 8);
} else {
originalvismapsize = portalleafs_real * ((portalleafs_real + 7) / 8);
@ -1180,7 +1180,7 @@ LoadPortals(char *name, mbsp_t *bsp)
}
/* Load the cluster expansion map if needed */
if (bsp->loadversion == &bspver_q2 || bsp->loadversion == &bspver_qbism) {
if (bsp->loadversion->game == GAME_QUAKE_II) {
clustermap = static_cast<int *>(malloc(portalleafs_real * sizeof(int)));
for (int32_t i = 0; i < bsp->numleafs; i++) {
@ -1333,7 +1333,7 @@ main(int argc, char **argv)
StripExtension(statetmpfile);
DefaultExtension(statetmpfile, ".vi0");
if (bsp->loadversion != &bspver_q2 && bsp->loadversion != &bspver_qbism) {
if (bsp->loadversion->game != GAME_QUAKE_II) {
uncompressed = static_cast<uint8_t *>(calloc(portalleafs, leafbytes_real));
} else {
uncompressed_q2 = static_cast<uint8_t *>(calloc(portalleafs, leafbytes));
@ -1351,7 +1351,7 @@ main(int argc, char **argv)
bsp->visdatasize, originalvismapsize);
// no ambient sounds for Q2
if (bsp->loadversion != &bspver_q2 && bsp->loadversion != &bspver_qbism) {
if (bsp->loadversion->game != GAME_QUAKE_II) {
CalcAmbientSounds(bsp);
}