maps: initial flags surface flags convert

Convert map flags before load for load maps files from games with
different flags meaning.
This commit is contained in:
Denis Pauk 2024-03-30 19:12:01 +02:00
parent c343f87928
commit d1e23ae740
20 changed files with 276 additions and 37 deletions

View File

@ -256,6 +256,13 @@ Set `0` by default.
* **gametype**: replace menu to different mod type without change mod name in game variable.
* **maptype**: convert surface map flags from different game on load:
* 0: Quake2,
* 1: Heretic2,
* 2: Daikatana,
* 3: Kingpin,
* 4: Anachronox.
* **nextdemo**: Defines the next command to run after maps from the
`nextserver` list. By default this is set to the empty string.

View File

@ -26,6 +26,7 @@
*/
#include "../ref_shared.h"
#include "maps.h"
/*
=================
@ -416,6 +417,38 @@ 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
@ -426,7 +459,7 @@ extra for skybox in soft render
void
Mod_LoadTexinfo(const char *name, mtexinfo_t **texinfo, int *numtexinfo,
const byte *mod_base, const lump_t *l, findimage_t find_image,
struct image_s *notexture)
struct image_s *notexture, maptype_t maptype)
{
texinfo_t *in;
mtexinfo_t *out, *step;
@ -457,7 +490,8 @@ Mod_LoadTexinfo(const char *name, mtexinfo_t **texinfo, int *numtexinfo,
out->vecs[1][j] = LittleFloat(in->vecs[1][j]);
}
out->flags = LittleLong(in->flags);
/* Convert flags for game type */
out->flags = Mod_LoadSurfConvertFlags(LittleLong(in->flags), maptype);
next = LittleLong(in->nexttexinfo);
if (next > 0)

View File

@ -0,0 +1,180 @@
/*
* 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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* The maps file format
*
* =======================================================================
*/
/*
* Based on https://github.com/TrenchBroom/
*/
static const int heretic2_flags[32] = {
SURF_LIGHT, /* 0: Emit light from the surface, brightness is specified in the 'value' field */
SURF_SLICK, /* 1: The surface is slippery */
SURF_SKY, /* 2: The surface is sky, the texture will not be drawn,
* but the background sky box is used instead */
SURF_WARP, /* 3: The surface warps (like water textures do) */
SURF_TRANS33, /* 4: The surface is 33% transparent */
SURF_TRANS66, /* 5: The surface is 66% transparent */
SURF_FLOWING, /* 6: The texture wraps in a downward 'flowing' pattern
* (warp must also be set) */
SURF_NODRAW, /* 7: Used for non-fixed-size brush triggers and clip brushes */
0, /* 8: Make a primary bsp splitter */
0, /* 9: Completely ignore, allowing non-closed brushes */
0, /* 10: Tall wall. Purpose unknown */
0, /* 11: Alpha_tex. Purpose unknown */
0, /* 12: Animspeed. Purpose unknown */
0, /* 13: Undulate. Purpose unknown */
0, /* 14: Skyreflect. Purpose unknown */
0, /* 15: Unused */
0, /* 16: Unused */
0, /* 17: Unused */
0, /* 18: Unused */
0, /* 19: Unused */
0, /* 20: Unused */
0, /* 21: Unused */
0, /* 22: Unused */
0, /* 23: Unused */
0, /* 24: Metal. Sound when walked on */
0, /* 25: Stone. Sound when walked on */
0, /* 26: Unused */
0, /* 27: Unused */
0, /* 28: Unused */
0, /* 29: Unused */
0, /* 30: Unused */
0, /* 31: Unused */
};
static const int daikatana_flags[32] = {
SURF_LIGHT, /* 0: Emit light from the surface, brightness is
* specified in the 'value' field" */
SURF_LIGHT, /* 1: Fullbright */
SURF_SKY, /* 2: The surface is sky, the texture will not be drawn,
* but the background sky box is used instead */
SURF_WARP, /* 3: The surface warps (like water textures do) */
SURF_TRANS33, /* 4: The surface is 33% transparent */
SURF_TRANS66, /* 5: The surface is 66% transparent */
SURF_FLOWING, /* 6: The texture wraps in a downward 'flowing' pattern
* (warp must also be set) */
SURF_NODRAW, /* 7: Used for non-fixed-size brush triggers and clip brushes */
0, /* 8: Hint */
0, /* 9: Skip */
0, /* 10: Wood */
0, /* 11: Metal */
0, /* 12: Stone */
0, /* 13: Glass */
0, /* 14: Ice */
0, /* 15: Snow */
0, /* 16: Mirror */
0, /* 17: Holy Grond */
SURF_ALPHATEST, /* 18: Alphachan */
0, /* 19: Midtexture (Used together with Clear and Nodraw.) */
0, /* 20: Puddle */
0, /* 21: Water Surge */
0, /* 22: Big Water Surge */
0, /* 23: Bullet Light */
0, /* 24: Fog */
0, /* 25: Sand */
0, /* 26: Unused */
0, /* 27: Unused */
0, /* 28: Unused */
0, /* 29: Unused */
0, /* 30: Unused */
0, /* 31: Unused */
};
static const int kingpin_flags[32] = {
SURF_LIGHT, /* 0: Emit light from the surface, brightness is specified
* in the 'value' field */
SURF_SLICK, /* 1: The surface is slippery */
SURF_SKY, /* 2: The surface is sky, the texture will not be drawn,
* but the background sky box is used instead */
SURF_WARP, /* 3: The surface warps (like water textures do) */
SURF_TRANS33, /* 4: The surface is 33% transparent */
SURF_TRANS66, /* 5: The surface is 66% transparent */
SURF_FLOWING, /* 6: The texture wraps in a downward 'flowing' pattern
* (warp must also be set) */
SURF_NODRAW, /* 7: Used for non-fixed-size brush triggers and clip brushes */
0, /* 8: Make a primary bsp splitter */
0, /* 9: Skip, Completely ignore, allowing non-closed brushes */
0, /* 10: Specular */
0, /* 11: Diffuse */
SURF_ALPHATEST, /* 12: Alpha texture */
0, /* 13: Mirror */
0, /* 14: Wndw33 */
0, /* 15: Wndw66 */
0, /* 16: Unused */
0, /* 17: Unused */
0, /* 18: Unused */
0, /* 19: Water sound */
0, /* 20: Concrete sound */
0, /* 21: Fabric sound */
0, /* 22: Gravel sound */
0, /* 23: Metal sound */
0, /* 24: Metal light sound */
0, /* 25: Tin sound */
0, /* 26: Tile sound */
0, /* 27: Wood sound */
0, /* 28: Reflect fake */
0, /* 29: Reflect light */
0, /* 30: Unused */
0, /* 31: Unused */
};
/*
* Based on https://anachrodox.talonbrave.info/
*/
static const int anachronox_flags[32] = {
SURF_LIGHT, /* 0: Light */
SURF_SLICK, /* 1: Slick */
SURF_SKY, /* 2: Sky Flag */
SURF_WARP, /* 3: Warp */
SURF_TRANS33, /* 4: Trans33 */
SURF_TRANS66, /* 5: Trans66 */
0, /* 6: Unused */
SURF_NODRAW, /* 7: NoDraw */
0, /* 8: Hint */
0, /* 9: Skip */
0, /* 10: Unused */
0, /* 11: Unused */
0, /* 12: Unused */
0, /* 13: Unused */
0, /* 14: Unused */
0, /* 15: Unused */
0, /* 16: Alpha Banner */
SURF_ALPHATEST, /* 17: Alpha Test */
0, /* 18: No V-turbulence */
0, /* 19: Unused */
0, /* 20: Unused */
0, /* 21: Unused */
0, /* 22: Unused */
0, /* 23: Unused */
0, /* 24: Unused */
0, /* 25: Unused */
0, /* 26: Unused */
0, /* 27: Unused */
0, /* 28: Half Scroll */
0, /* 29: Quarter Scroll */
0, /* 30: Surface Fog */
0, /* 31: Surface Curve */
};

View File

@ -102,6 +102,7 @@ cvar_t *r_customwidth;
cvar_t *r_customheight;
cvar_t *r_retexturing;
cvar_t *r_maptype;
cvar_t *r_scale8bittextures;
cvar_t *r_nolerp_list;
@ -1239,6 +1240,7 @@ R_Register(void)
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
r_validation = ri.Cvar_Get("r_validation", "0", CVAR_ARCHIVE);
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
/* don't bilerp characters and crosshairs */
r_nolerp_list = ri.Cvar_Get("r_nolerp_list", DEFAULT_NOLERP_LIST, CVAR_ARCHIVE);

View File

@ -709,7 +709,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
r_notexture);
r_notexture, r_maptype->value);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);

View File

@ -175,6 +175,7 @@ extern cvar_t *r_customwidth;
extern cvar_t *r_customheight;
extern cvar_t *r_retexturing;
extern cvar_t *r_maptype;
extern cvar_t *r_scale8bittextures;
extern cvar_t *r_validation;

View File

@ -82,6 +82,7 @@ const hmm_mat4 gl3_identityMat4 = {{
cvar_t *gl_msaa_samples;
cvar_t *r_vsync;
cvar_t *r_retexturing;
cvar_t *r_maptype;
cvar_t *r_scale8bittextures;
cvar_t *vid_fullscreen;
cvar_t *r_mode;
@ -209,6 +210,7 @@ GL3_Register(void)
r_vsync = ri.Cvar_Get("r_vsync", "1", CVAR_ARCHIVE);
gl_msaa_samples = ri.Cvar_Get ( "r_msaa_samples", "0", CVAR_ARCHIVE );
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
gl3_debugcontext = ri.Cvar_Get("gl3_debugcontext", "0", 0);
r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
@ -323,9 +325,6 @@ GL3_Register(void)
//r_customheight = ri.Cvar_Get("r_customheight", "768", CVAR_ARCHIVE);
//gl_msaa_samples = ri.Cvar_Get ( "r_msaa_samples", "0", CVAR_ARCHIVE );
//r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
gl1_stereo = ri.Cvar_Get( "gl1_stereo", "0", CVAR_ARCHIVE );
gl1_stereo_separation = ri.Cvar_Get( "gl1_stereo_separation", "-0.4", CVAR_ARCHIVE );
gl1_stereo_anaglyph_colors = ri.Cvar_Get( "gl1_stereo_anaglyph_colors", "rc", CVAR_ARCHIVE );

View File

@ -710,7 +710,7 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL3_FindImage,
gl3_notexture);
gl3_notexture, r_maptype->value);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);

View File

@ -507,6 +507,7 @@ extern void GL3_UpdateUBOLights(void);
extern cvar_t *gl_msaa_samples;
extern cvar_t *r_vsync;
extern cvar_t *r_retexturing;
extern cvar_t *r_maptype;
extern cvar_t *r_scale8bittextures;
extern cvar_t *vid_fullscreen;
extern cvar_t *r_mode;

View File

@ -78,6 +78,7 @@ const hmm_mat4 gl4_identityMat4 = {{
cvar_t *gl_msaa_samples;
cvar_t *r_vsync;
cvar_t *r_retexturing;
cvar_t *r_maptype;
cvar_t *r_scale8bittextures;
cvar_t *vid_fullscreen;
cvar_t *r_mode;
@ -205,6 +206,7 @@ GL4_Register(void)
r_vsync = ri.Cvar_Get("r_vsync", "1", CVAR_ARCHIVE);
gl_msaa_samples = ri.Cvar_Get ( "r_msaa_samples", "0", CVAR_ARCHIVE );
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
gl4_debugcontext = ri.Cvar_Get("gl4_debugcontext", "0", 0);
r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
@ -319,9 +321,6 @@ GL4_Register(void)
//r_customheight = ri.Cvar_Get("r_customheight", "768", CVAR_ARCHIVE);
//gl_msaa_samples = ri.Cvar_Get ( "r_msaa_samples", "0", CVAR_ARCHIVE );
//r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
gl1_stereo = ri.Cvar_Get( "gl1_stereo", "0", CVAR_ARCHIVE );
gl1_stereo_separation = ri.Cvar_Get( "gl1_stereo_separation", "-0.4", CVAR_ARCHIVE );
gl1_stereo_anaglyph_colors = ri.Cvar_Get( "gl1_stereo_anaglyph_colors", "rc", CVAR_ARCHIVE );

View File

@ -710,7 +710,7 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL4_FindImage,
gl4_notexture);
gl4_notexture, r_maptype->value);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);

View File

@ -497,6 +497,7 @@ extern void GL4_UpdateUBOLights(void);
extern cvar_t *gl_msaa_samples;
extern cvar_t *r_vsync;
extern cvar_t *r_retexturing;
extern cvar_t *r_maptype;
extern cvar_t *r_scale8bittextures;
extern cvar_t *vid_fullscreen;
extern cvar_t *r_mode;

View File

@ -356,7 +356,7 @@ extern void Mod_CalcSurfaceExtents(const int *surfedges, mvertex_t *vertexes,
medge_t *edges, msurface_t *s);
extern void Mod_LoadTexinfo(const char *name, mtexinfo_t **texinfo, int *numtexinfo,
const byte *mod_base, const lump_t *l, findimage_t find_image,
struct image_s *notexture);
struct image_s *notexture, maptype_t maptype);
extern void Mod_LoadSurfedges(const char *name, int **surfedges, int *numsurfedges,
const byte *mod_base, const lump_t *l);
extern mleaf_t *Mod_PointInLeaf(const vec3_t p, mnode_t *node);

View File

@ -398,6 +398,7 @@ extern cvar_t *sw_waterwarp;
extern cvar_t *sw_gunzposition;
extern cvar_t *r_validation;
extern cvar_t *r_retexturing;
extern cvar_t *r_maptype;
extern cvar_t *r_scale8bittextures;
extern cvar_t *r_palettedtexture;

View File

@ -148,6 +148,7 @@ cvar_t *sw_custom_particles;
static cvar_t *sw_anisotropic;
cvar_t *sw_texture_filtering;
cvar_t *r_retexturing;
cvar_t *r_maptype;
cvar_t *r_scale8bittextures;
cvar_t *sw_gunzposition;
cvar_t *r_validation;
@ -382,6 +383,7 @@ R_RegisterVariables (void)
sw_texture_filtering = ri.Cvar_Get("sw_texture_filtering", "0", CVAR_ARCHIVE);
sw_anisotropic = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE);
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
sw_gunzposition = ri.Cvar_Get("sw_gunzposition", "8", CVAR_ARCHIVE);
r_validation = ri.Cvar_Get("r_validation", "0", CVAR_ARCHIVE);

View File

@ -550,7 +550,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
r_notexture_mip);
r_notexture_mip, r_maptype->value);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);

View File

@ -137,6 +137,7 @@ extern cvar_t *vk_molten_fastmath;
extern cvar_t *vk_molten_metalbuffers;
#endif
extern cvar_t *r_retexturing;
extern cvar_t *r_maptype;
extern cvar_t *r_scale8bittextures;
extern cvar_t *r_nolerp_list;
extern cvar_t *r_lerp_list;

View File

@ -132,6 +132,7 @@ cvar_t *vk_mip_nearfilter;
cvar_t *vk_sampleshading;
cvar_t *vk_device_idx;
cvar_t *r_retexturing;
cvar_t *r_maptype;
cvar_t *r_scale8bittextures;
static cvar_t *vk_underwater;
cvar_t *r_nolerp_list;
@ -1177,6 +1178,7 @@ R_Register(void)
vk_molten_metalbuffers = ri.Cvar_Get("vk_molten_metalbuffer", "0", CVAR_ARCHIVE);
#endif
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
vk_underwater = ri.Cvar_Get("vk_underwater", "1", CVAR_ARCHIVE);
/* don't bilerp characters and crosshairs */

View File

@ -684,7 +684,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)Vk_FindImage,
r_notexture);
r_notexture, r_maptype->value);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);

View File

@ -39,6 +39,15 @@
#define EXTRA_LUMP_BRUSHSIDES 6
#define EXTRA_LUMP_LEAFS 1
typedef enum
{
map_quake2 = 0,
map_heretic2 = 1,
map_daikatana = 2,
map_kingpin = 3,
map_anachronox = 4,
} maptype_t;
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,
const byte *mod_base, const lump_t *l);