maps: Convert surface flags by gametype

This commit is contained in:
Denis Pauk 2024-04-04 23:51:44 +03:00
parent 18d0310e4b
commit 5770a9ff1b
5 changed files with 40 additions and 37 deletions

View File

@ -26,7 +26,6 @@
*/ */
#include "../ref_shared.h" #include "../ref_shared.h"
#include "maps.h"
/* /*
================= =================
@ -417,38 +416,6 @@ Mod_CalcSurfaceExtents(const int *surfedges, mvertex_t *vertexes, medge_t *edges
} }
} }
static int
Mod_LoadSurfConvertFlags(int flags, maptype_t maptype)
{
const int *convert;
int sflags = 0;
int i;
switch (maptype)
{
case map_heretic2: convert = heretic2_flags; break;
case map_daikatana: convert = daikatana_flags; break;
case map_kingpin: convert = kingpin_flags; break;
case map_anachronox: convert = anachronox_flags; break;
default: convert = NULL; break;
}
if (!convert)
{
return flags;
}
for (i = 0; i < 32; i++)
{
if (flags & (1 << i))
{
sflags |= convert[i];
}
}
return sflags;
}
/* /*
================= =================
Mod_LoadTexinfo Mod_LoadTexinfo

View File

@ -26,6 +26,7 @@
#include "header/common.h" #include "header/common.h"
#include "header/cmodel.h" #include "header/cmodel.h"
#include "header/flags.h"
/* /*
================= =================
@ -279,3 +280,38 @@ Mod_LoadValidateLumps(const char *name, const dheader_t *header)
return maptype; return maptype;
} }
/*
* Convert Other games flags to Quake 2 surface flags
*/
int
Mod_LoadSurfConvertFlags(int flags, maptype_t maptype)
{
const int *convert;
int sflags = 0;
int i;
switch (maptype)
{
case map_heretic2: convert = heretic2_flags; break;
case map_daikatana: convert = daikatana_flags; break;
case map_kingpin: convert = kingpin_flags; break;
case map_anachronox: convert = anachronox_flags; break;
default: convert = NULL; break;
}
if (!convert)
{
return flags;
}
for (i = 0; i < 32; i++)
{
if (flags & (1 << i))
{
sflags |= convert[i];
}
}
return sflags;
}

View File

@ -1342,7 +1342,7 @@ CMod_LoadSubmodels(const char *name, cmodel_t *map_cmodels, int *numcmodels,
static void static void
CMod_LoadSurfaces(const char *name, mapsurface_t **map_surfaces, int *numtexinfo, CMod_LoadSurfaces(const char *name, mapsurface_t **map_surfaces, int *numtexinfo,
const byte *cmod_base, const lump_t *l) const byte *cmod_base, const lump_t *l, maptype_t maptype)
{ {
texinfo_t *in; texinfo_t *in;
mapsurface_t *out; mapsurface_t *out;
@ -1369,7 +1369,7 @@ CMod_LoadSurfaces(const char *name, mapsurface_t **map_surfaces, int *numtexinfo
{ {
Q_strlcpy(out->c.name, in->texture, sizeof(out->c.name)); Q_strlcpy(out->c.name, in->texture, sizeof(out->c.name));
Q_strlcpy(out->rname, in->texture, sizeof(out->rname)); Q_strlcpy(out->rname, in->texture, sizeof(out->rname));
out->c.flags = LittleLong(in->flags); out->c.flags = Mod_LoadSurfConvertFlags(LittleLong(in->flags), maptype);
} }
} }
@ -2105,7 +2105,7 @@ CM_LoadCachedMap(const char *name, model_t *mod)
mod->extradata = Hunk_Begin(hunkSize); mod->extradata = Hunk_Begin(hunkSize);
CMod_LoadSurfaces(mod->name, &mod->map_surfaces, &mod->numtexinfo, CMod_LoadSurfaces(mod->name, &mod->map_surfaces, &mod->numtexinfo,
cmod_base, &header.lumps[LUMP_TEXINFO]); cmod_base, &header.lumps[LUMP_TEXINFO], maptype);
if (header.ident == IDBSPHEADER) if (header.ident == IDBSPHEADER)
{ {
if ((maptype == map_daikatana) && if ((maptype == map_daikatana) &&

View File

@ -48,6 +48,7 @@ typedef enum
map_anachronox = 4, map_anachronox = 4,
} maptype_t; } maptype_t;
extern int Mod_LoadSurfConvertFlags(int flags, maptype_t maptype);
extern int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra); extern int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra);
extern void Mod_LoadVisibility(const char *name, dvis_t **vis, int *numvisibility, extern void Mod_LoadVisibility(const char *name, dvis_t **vis, int *numvisibility,
const byte *mod_base, const lump_t *l); const byte *mod_base, const lump_t *l);

View File

@ -1,6 +1,5 @@
/* /*
* Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2005-2015 David HENRY
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by