Compare commits

..

21 Commits

Author SHA1 Message Date
Alibek Omarov
def7bfc5d8 engine: ref_api: change RefGetParm return type to intptr_t, bump RefAPI version 2026-04-25 14:20:24 +05:00
Alibek Omarov
6a752a924c engine: client: fix server list response parsing on BE 2026-04-25 04:48:45 +05:00
Alibek Omarov
864c15cf83 ref: gl: do not limit texture units by broken report of shaders extension 2026-04-25 04:39:25 +05:00
Alibek Omarov
20d26d467d 3rdparty: mainui: update 2026-04-25 04:04:43 +05:00
Alibek Omarov
9898948424 ref: gl: add -glnoerr flag that enables no error context, for possible performance gains 2026-04-25 03:56:45 +05:00
Alibek Omarov
2320734ec0 engine: fix palette and builtin textures on BE 2026-04-25 03:56:45 +05:00
Alibek Omarov
dcc5756649 engine: handle swapping sequence files in LoadCacheFile for games with external StudioModelRenderer 2026-04-25 03:56:45 +05:00
Alibek Omarov
6256d99345 engine: soundlib: pass XASH_BIG_ENDIAN to ov_read in vorbis loader 2026-04-25 00:30:03 +05:00
Alibek Omarov
38bea0312c engine: platform: sdl: request AUDIO_S16SYS to make sound output in native endian 2026-04-25 00:23:35 +05:00
Alibek Omarov
35bb66d33a engine: mod_studio: implement loading sequence files on BE 2026-04-24 23:31:33 +05:00
Alibek Omarov
05d5a012d4 engine: client: Fix font loading on BE 2026-04-24 22:31:45 +05:00
Alibek Omarov
6ca7271006 engine: mod_studio: more studio model swapping 2026-04-24 22:09:46 +05:00
Alibek Omarov
e43ccee77f engine: soundlib: swap WAV data 2026-04-24 22:08:17 +05:00
Alibek Omarov
eb0241dac6 engine: platform: posix: remove Sys_Crash and Sys_CrashDetailsLibbacktrace from the output by matching function name only once 2026-04-24 20:48:00 +05:00
Alibek Omarov
526ebab062 engine: platform: posix: remove extra newline from libbacktrace output 2026-04-24 20:40:22 +05:00
Alibek Omarov
1dd3447cef engine: make Sys_LogFileNo return -1 when log file isn't opened 2026-04-24 20:35:13 +05:00
Alibek Omarov
a8ff36aa57 engine: imagelib: add IL_HOST_ENDIAN flag to mark on-disk data that's already in host endianness 2026-04-24 20:17:44 +05:00
Alibek Omarov
866c02802c wscript: define libbacktrace as libbacktrace_custom, fix DL_ITERATE_PHDR not defined due to failing fallback check
* Changed to libbacktrace_custom to not collide with libbacktrace built as part of compiler's runtime
2026-04-24 20:11:09 +05:00
Alibek Omarov
e3bfe5bb81 engine: platform: posix: better libbacktrace error output 2026-04-24 20:10:08 +05:00
Alibek Omarov
560f5e1f6d engine: soundlib: fixes for BE 2026-04-24 08:26:11 +05:00
Alibek Omarov
849ff0f7b5 engine: imagelib: fixes for BE 2026-04-24 08:26:11 +05:00
20 changed files with 150 additions and 336 deletions

View File

@@ -1,19 +0,0 @@
## Lightmapped water
Xash3D FWGS supports lightmapped water, as an extension. It adds three new cvars and new worldspawn key values.
### For level designers:
If you're a level designer and intend to make your level to have lightmapped water, you can put these keyvalues to worldspawn entity description (always first entity in entities list):
| Key | Value | Description |
| ---------------------- | ------- | ----------- |
| `_litwater` | integer | Set to any non-zero value to enable lightmapped water. Overrides `gl_litwater_force` cvar value. |
| `_litwater_minlight` | integer | Minimal lightmap value water surface will receive. Helps to avoid too dark areas when water isn't properly lit. If not set, defaults to zero. |
| `_litwater_scale` | float | Scales up lightmap value for water surfaces. If not set, defaults to 1.0. |
### For players:
Some of the maps already have computed lightmap for water surfaces and sometimes water has been properly lit but the support hasn't been declared by the level designer.
As a player, you can enable it in `Video options` menu or through console with `gl_litwater_force` cvar. There are also `gl_litwater_minlight` and `gl_litwater_scale` cvars that function similar to keys above. The default values has been set to `192` and `1.25` respectively to slightly avoid issues with maps that wasn't intended to have lightmapped water.

View File

@@ -403,11 +403,11 @@ static qboolean VOX_ParseWordParams( char *psz, voxword_t *pvoxword, voxword_t *
command = *psz++;
if( !isdigit((byte)*psz ))
if( !isdigit( *psz ))
break;
memset( sznum, 0, sizeof( sznum ));
for( i = 0; i < sizeof( sznum ) - 1 && isdigit((byte)*psz ); i++, psz++ )
for( i = 0; i < sizeof( sznum ) - 1 && isdigit( *psz ); i++, psz++ )
sznum[i] = *psz;
i = Q_atoi( sznum );

View File

@@ -833,7 +833,7 @@ static uint32_t Host_CheckBugcomp( void )
if( !Sys_CheckParm( "-bugcomp" ))
return 0;
if( Sys_GetParmFromCmdLine( "-bugcomp", args ) && isalpha((byte)args[0] ))
if( Sys_GetParmFromCmdLine( "-bugcomp", args ) && isalpha( args[0] ))
{
Q_splitstr( args, '+', &flags, Host_CheckBugcomp_splitstr_handler );
}

View File

@@ -514,7 +514,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
// three checks here: check if we can load luma, check the texture name and, finally,
// validate that palette isn't NULL
if( Image_CheckFlag( IL_ALLOW_WAD3_LUMA )
&& ( mip.name[0] == '~' || ( mip.name[0] == '+' && isdigit((byte)mip.name[1] ) && mip.name[2] == '~' ))
&& ( mip.name[0] == '~' || ( mip.name[0] == '+' && isdigit( mip.name[1] ) && mip.name[2] == '~' ))
&& pal != NULL )
{
SetBits( image.flags, IMAGE_HAS_LUMA );

View File

@@ -327,7 +327,7 @@ static char *COM_GetItaniumName( const char * const in_name )
{
// parse symbol length marker
len = 0;
for( ; isdigit((byte)*f ) && remaining > 0; f++, remaining-- )
for( ; isdigit( *f ) && remaining > 0; f++, remaining-- )
len = len * 10 + ( *f - '0' );
// sane value
@@ -344,7 +344,7 @@ static char *COM_GetItaniumName( const char * const in_name )
if( *f == 'E' )
break;
if( !isdigit((byte)*f ) || remaining <= 0 )
if( !isdigit( *f ) || remaining <= 0 )
goto invalid_format;
}

View File

@@ -166,32 +166,32 @@ typedef enum
LOADLUMP_BSPX, // ... from BSPX data
} loadlump_source_t;
#define LUMP_SAVESTATS BIT( 0 )
#define LUMP_BSHIFT_SWAP BIT( 1 )
#define LUMP_SILENT BIT( 2 )
#define LUMP_BSP30EXT BIT( 3 ) // extra marker for Mod_LoadLump
#define LUMP_BSPX BIT( 4 )
#define LUMP_SAVESTATS BIT( 0 )
#define LUMP_TESTONLY BIT( 1 )
#define LUMP_SILENT BIT( 2 )
#define LUMP_BSP30EXT BIT( 3 ) // extra marker for Mod_LoadLump
#define LUMP_BSPX BIT( 4 )
typedef struct
{
const int lumpnumber;
int lumpnumber;
// BSPX
const char lumpname[24];
const int flags;
int flags;
const size_t mincount;
const size_t maxcount;
const int entrysize;
const int entrysize32; // extended size (0 if not available)
const char *loadname;
const size_t dataofs; // offsetof into dbspmodel_t for data pointer
const size_t countofs; // offsetof into dbspmodel_t for count/size
const void **dataptr;
size_t *count;
#if XASH_BIG_ENDIAN // do not waste memory on little endian
const swap_struct_def_t *swap;
const size_t swaplen;
size_t swaplen;
const swap_struct_def_t *swap32;
const size_t swaplen32;
size_t swaplen32;
#endif
} mlumpinfo_t;
@@ -344,10 +344,11 @@ le_struct_begin( mip_swap )
le_struct_end();
world_static_t world;
static dbspmodel_t srcmodel;
static loadstat_t loadstat;
static model_t *worldmodel;
static byte g_visdata[(MAX_MAP_LEAFS+7)/8]; // intermediate buffer
static const mlumpinfo_t srclumps[HEADER_LUMPS] =
static mlumpinfo_t srclumps[HEADER_LUMPS] =
{
{
.lumpnumber = LUMP_ENTITIES,
@@ -355,8 +356,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.maxcount = MAX_MAP_ENTSTRING,
.entrysize = sizeof( byte ),
.loadname = "entities",
.dataofs = offsetof( dbspmodel_t, entdata ),
.countofs = offsetof( dbspmodel_t, entdatasize ),
.dataptr = (const void **)&srcmodel.entdata,
.count = &srcmodel.entdatasize,
},
{
.lumpnumber = LUMP_PLANES,
@@ -364,8 +365,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.maxcount = MAX_MAP_PLANES,
.entrysize = sizeof( dplane_t ),
.loadname = "planes",
.dataofs = offsetof( dbspmodel_t, planes ),
.countofs = offsetof( dbspmodel_t, numplanes ),
.dataptr = (const void **)&srcmodel.planes,
.count = &srcmodel.numplanes,
LUMP_SWAP( dplane_swap )
},
{
@@ -374,16 +375,16 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.maxcount = MAX_MAP_MIPTEX,
.entrysize = sizeof( byte ),
.loadname = "textures",
.dataofs = offsetof( dbspmodel_t, textures ),
.countofs = offsetof( dbspmodel_t, texdatasize ),
.dataptr = (const void **)&srcmodel.textures,
.count = &srcmodel.texdatasize,
},
{
.lumpnumber = LUMP_VERTEXES,
.maxcount = MAX_MAP_VERTS,
.entrysize = sizeof( dvertex_t ),
.loadname = "vertexes",
.dataofs = offsetof( dbspmodel_t, vertexes ),
.countofs = offsetof( dbspmodel_t, numvertexes ),
.dataptr = (const void **)&srcmodel.vertexes,
.count = &srcmodel.numvertexes,
LUMP_SWAP( dvertex_swap )
},
{
@@ -391,8 +392,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.maxcount = MAX_MAP_VISIBILITY,
.entrysize = sizeof( byte ),
.loadname = "visibility",
.dataofs = offsetof( dbspmodel_t, visdata ),
.countofs = offsetof( dbspmodel_t, visdatasize ),
.dataptr = (const void **)&srcmodel.visdata,
.count = &srcmodel.visdatasize,
},
{
.lumpnumber = LUMP_NODES,
@@ -402,8 +403,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize32 = sizeof( dnode32_t ),
.loadname = "nodes",
.flags = CHECK_OVERFLOW,
.dataofs = offsetof( dbspmodel_t, nodes ),
.countofs = offsetof( dbspmodel_t, numnodes ),
.dataptr = (const void **)&srcmodel.nodes,
.count = &srcmodel.numnodes,
LUMP_SWAP32( dnode_swap, dnode32_swap )
},
{
@@ -413,8 +414,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize = sizeof( dtexinfo_t ),
.loadname = "texinfo",
.flags = CHECK_OVERFLOW,
.dataofs = offsetof( dbspmodel_t, texinfo ),
.countofs = offsetof( dbspmodel_t, numtexinfo ),
.dataptr = (const void **)&srcmodel.texinfo,
.count = &srcmodel.numtexinfo,
LUMP_SWAP( dtexinfo_swap )
},
{
@@ -425,8 +426,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize32 = sizeof( dface32_t ),
.loadname = "faces",
.flags = CHECK_OVERFLOW,
.dataofs = offsetof( dbspmodel_t, surfaces ),
.countofs = offsetof( dbspmodel_t, numsurfaces ),
.dataptr = (const void **)&srcmodel.surfaces,
.count = &srcmodel.numsurfaces,
LUMP_SWAP32( dface_swap, dface32_swap )
},
{
@@ -436,8 +437,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize = sizeof( byte ),
.loadname = "lightmaps",
.flags = 0,
.dataofs = offsetof( dbspmodel_t, lightdata ),
.countofs = offsetof( dbspmodel_t, lightdatasize ),
.dataptr = (const void **)&srcmodel.lightdata,
.count = &srcmodel.lightdatasize,
},
{
.lumpnumber = LUMP_CLIPNODES,
@@ -447,8 +448,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize32 = sizeof( dclipnode32_t ),
.loadname = "clipnodes",
.flags = 0,
.dataofs = offsetof( dbspmodel_t, clipnodes ),
.countofs = offsetof( dbspmodel_t, numclipnodes ),
.dataptr = (const void **)&srcmodel.clipnodes,
.count = &srcmodel.numclipnodes,
LUMP_SWAP32( dclipnode_swap, dclipnode32_swap )
},
{
@@ -459,8 +460,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize32 = sizeof( dleaf32_t ),
.loadname = "leafs",
.flags = CHECK_OVERFLOW,
.dataofs = offsetof( dbspmodel_t, leafs ),
.countofs = offsetof( dbspmodel_t, numleafs ),
.dataptr = (const void **)&srcmodel.leafs,
.count = &srcmodel.numleafs,
LUMP_SWAP32( dleaf_swap, dleaf32_swap )
},
{
@@ -471,8 +472,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize32 = sizeof( dmarkface32_t ),
.loadname = "markfaces",
.flags = 0,
.dataofs = offsetof( dbspmodel_t, markfaces ),
.countofs = offsetof( dbspmodel_t, nummarkfaces ),
.dataptr = (const void **)&srcmodel.markfaces,
.count = &srcmodel.nummarkfaces,
},
{
.lumpnumber = LUMP_EDGES,
@@ -482,8 +483,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize32 = sizeof( dedge32_t ),
.loadname = "edges",
.flags = 0,
.dataofs = offsetof( dbspmodel_t, edges ),
.countofs = offsetof( dbspmodel_t, numedges ),
.dataptr = (const void **)&srcmodel.edges,
.count = &srcmodel.numedges,
LUMP_SWAP32( dedge_swap, dedge32_swap )
},
{
@@ -493,8 +494,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize = sizeof( dsurfedge_t ),
.loadname = "surfedges",
.flags = 0,
.dataofs = offsetof( dbspmodel_t, surfedges ),
.countofs = offsetof( dbspmodel_t, numsurfedges ),
.dataptr = (const void **)&srcmodel.surfedges,
.count = &srcmodel.numsurfedges,
},
{
.lumpnumber = LUMP_MODELS,
@@ -503,8 +504,8 @@ static const mlumpinfo_t srclumps[HEADER_LUMPS] =
.entrysize = sizeof( dmodel_t ),
.loadname = "models",
.flags = CHECK_OVERFLOW,
.dataofs = offsetof( dbspmodel_t, submodels ),
.countofs = offsetof( dbspmodel_t, numsubmodels ),
.dataptr = (const void **)&srcmodel.submodels,
.count = &srcmodel.numsubmodels,
LUMP_SWAP( dmodel_swap )
},
};
@@ -517,8 +518,8 @@ static const mlumpinfo_t extlumps[EXTRA_LUMPS] =
.maxcount = MAX_MAP_LIGHTING,
.entrysize = sizeof( byte ),
.loadname = "deluxmaps",
.dataofs = offsetof( dbspmodel_t, deluxdata ),
.countofs = offsetof( dbspmodel_t, deluxdatasize ),
.dataptr = (const void **)&srcmodel.deluxdata,
.count = &srcmodel.deluxdatasize,
},
{
.lumpnumber = LUMP_FACEINFO,
@@ -527,8 +528,8 @@ static const mlumpinfo_t extlumps[EXTRA_LUMPS] =
.entrysize = sizeof( dfaceinfo_t ),
.loadname = "faceinfos",
.flags = CHECK_OVERFLOW,
.dataofs = offsetof( dbspmodel_t, faceinfo ),
.countofs = offsetof( dbspmodel_t, numfaceinfo ),
.dataptr = (const void **)&srcmodel.faceinfo,
.count = &srcmodel.numfaceinfo,
LUMP_SWAP( dfaceinfo_swap )
},
{
@@ -537,8 +538,8 @@ static const mlumpinfo_t extlumps[EXTRA_LUMPS] =
.maxcount = MAX_MAP_LIGHTING / 3,
.entrysize = sizeof( byte ),
.loadname = "shadowmap",
.dataofs = offsetof( dbspmodel_t, shadowdata ),
.countofs = offsetof( dbspmodel_t, shadowdatasize ),
.dataptr = (const void **)&srcmodel.shadowdata,
.count = &srcmodel.shadowdatasize,
},
};
@@ -549,16 +550,16 @@ static const mlumpinfo_t bspxlumps[] =
.maxcount = MAX_MAP_LIGHTING,
.entrysize = sizeof( byte ),
.loadname = "rgblighting",
.dataofs = offsetof( dbspmodel_t, rgblightdata ),
.countofs = offsetof( dbspmodel_t, rgblightdatasize ),
.dataptr = (const void **)&srcmodel.rgblightdata,
.count = &srcmodel.rgblightdatasize,
},
{
.lumpname = "LIGHTINGDIR",
.maxcount = MAX_MAP_LIGHTING,
.entrysize = sizeof( byte ),
.loadname = "lightingdir",
.dataofs = offsetof( dbspmodel_t, deluxdata ),
.countofs = offsetof( dbspmodel_t, deluxdatasize ),
.dataptr = (const void **)&srcmodel.deluxdata,
.count = &srcmodel.deluxdatasize,
},
};
@@ -757,7 +758,7 @@ Mod_LoadLump
generic loader
=================
*/
static void Mod_LoadLump( const void *in, const mlumpinfo_t *info, mlumpstat_t *stat, int flags, loadlump_source_t source, const void *bspx_data, dbspmodel_t *bmod )
static void Mod_LoadLump( const void *in, const mlumpinfo_t *info, mlumpstat_t *stat, int flags, loadlump_source_t source, const void *bspx_data )
{
int version = ((const dheader_t *)in)->version, i;
size_t numelems, real_entrysize;
@@ -768,16 +769,7 @@ static void Mod_LoadLump( const void *in, const mlumpinfo_t *info, mlumpstat_t *
case LOADLUMP_STANDARD:
{
const dheader_t *header = in;
int lumpnumber = info->lumpnumber;
if( FBitSet( flags, LUMP_BSHIFT_SWAP ))
{
if( lumpnumber == LUMP_ENTITIES )
lumpnumber = LUMP_PLANES;
else if( lumpnumber == LUMP_PLANES )
lumpnumber = LUMP_ENTITIES;
}
l = header->lumps[lumpnumber];
l = header->lumps[info->lumpnumber];
break;
}
case LOADLUMP_BSP30EXT:
@@ -844,7 +836,7 @@ static void Mod_LoadLump( const void *in, const mlumpinfo_t *info, mlumpstat_t *
}
// bmodels not required the visibility
if( info->lumpnumber == LUMP_VISIBILITY && !world.loading && bmod )
if( !FBitSet( flags, LUMP_TESTONLY ) && !world.loading && info->lumpnumber == LUMP_VISIBILITY )
SetBits( flags, LUMP_SILENT ); // shut up warning
// fill the stats for world
@@ -922,31 +914,36 @@ static void Mod_LoadLump( const void *in, const mlumpinfo_t *info, mlumpstat_t *
}
}
// if no bmod is passed, we are only testing if BSP lumps are not corrupted
if( !bmod )
return;
byte *data = (byte *)in + l.fileofs;
if( FBitSet( flags, LUMP_TESTONLY ))
return; // don't fill the intermediate struct
// all checks are passed, store pointers
*(byte **)((byte *)bmod + info->dataofs) = data;
*(size_t *)((byte *)bmod + info->countofs) = numelems;
if( info->dataptr )
*info->dataptr = (void *)((byte *)in + l.fileofs);
if( info->count )
*info->count = numelems;
// finally, process the data
#if XASH_BIG_ENDIAN
const swap_struct_def_t *swap = real_entrysize == info->entrysize32 ? info->swap32 : info->swap;
size_t swaplen = real_entrysize == info->entrysize32 ? info->swaplen32 : info->swaplen;
if( swap )
if( info->dataptr && *info->dataptr )
{
for( size_t j = 0; j < numelems; j++ )
swap_struct_( swap, swaplen, data + j * real_entrysize );
}
// some lumps don't need a swapdef, as all needed data in the lump info
else if( real_entrysize > 1 )
{
for( size_t j = 0; j < numelems; j++ )
swap_field_( data + j * real_entrysize, real_entrysize );
byte *data = (byte *)*info->dataptr;
if( swap )
{
for( size_t j = 0; j < numelems; j++ )
swap_struct_( swap, swaplen, data + j * real_entrysize );
}
// some lumps don't need a swapdef, as all needed data in the lump info
else if( real_entrysize > 1 )
{
for( size_t j = 0; j < numelems; j++ )
swap_field_( data + j * real_entrysize, real_entrysize );
}
}
#endif
}
@@ -2407,9 +2404,6 @@ static void Mod_LoadEntities( model_t *mod, const dbspmodel_t *bmod )
world.wadlist = NULL;
world.wadcount = 0;
world.litwater_minlight = -1;
world.litwater_scale = -1.0f;
// parse all the wads for loading textures in right ordering
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
{
@@ -2453,15 +2447,6 @@ static void Mod_LoadEntities( model_t *mod, const dbspmodel_t *bmod )
Mem_Free( world.generator );
world.generator = copystring( token );
}
else if( !Q_stricmp( keyname, "_litwater" ))
{
if( Q_atoi( token ) != 0 )
SetBits( world.flags, FWORLD_HAS_LITWATER );
}
else if( !Q_stricmp( keyname, "_litwater_minlight" ))
world.litwater_minlight = Q_atoi( token );
else if( !Q_stricmp( keyname, "_litwater_scale" ))
world.litwater_scale = Q_atof( token );
}
return; // all done
}
@@ -4243,12 +4228,14 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, byte *mod_base, size_t buffer
{
dheader_t *header = (dheader_t *)mod_base;
int *extident = (int *)(mod_base + sizeof( dheader_t ));
dbspmodel_t *bmod = &srcmodel;
char wadvalue[2048];
size_t len = 0;
int i, stat_index = 0, ret, flags = 0;
fs_offset_t bspx_header_offset;
// always reset the intermediate struct
memset( bmod, 0, sizeof( *bmod ));
memset( &loadstat, 0, sizeof( loadstat ));
Q_strncpy( loadstat.name, mod->name, sizeof( loadstat.name ));
@@ -4257,6 +4244,10 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, byte *mod_base, size_t buffer
// byte-swap BSP header and lump directory from little-endian
Mod_SwapBSPLumps( mod_base, bufferlen );
// restore default lump numbers
srclumps[0].lumpnumber = LUMP_ENTITIES;
srclumps[1].lumpnumber = LUMP_PLANES;
switch( header->version )
{
case HLBSP_VERSION:
@@ -4269,7 +4260,8 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, byte *mod_base, size_t buffer
Mod_LumpLooksLikeEntities( mod_base + header->lumps[LUMP_PLANES].fileofs, header->lumps[LUMP_PLANES].filelen ))
{
// blue-shift swapped lumps
SetBits( flags, LUMP_BSHIFT_SWAP );
srclumps[0].lumpnumber = LUMP_PLANES;
srclumps[1].lumpnumber = LUMP_ENTITIES;
}
break;
case Q1BSP_VERSION:
@@ -4283,7 +4275,6 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, byte *mod_base, size_t buffer
return false;
}
dbspmodel_t *bmod = Mem_Calloc( mod->mempool, sizeof( *bmod ));
bmod->version = header->version; // share up global
if( isworld )
{
@@ -4296,17 +4287,17 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, byte *mod_base, size_t buffer
// loading base lumps
for( i = 0; i < ARRAYSIZE( srclumps ); i++, stat_index++ )
Mod_LoadLump( mod_base, &srclumps[i], &worldstats[stat_index], flags, LOADLUMP_STANDARD, NULL, bmod );
Mod_LoadLump( mod_base, &srclumps[i], &worldstats[stat_index], flags, LOADLUMP_STANDARD, NULL );
// loading extralumps
for( i = 0; i < ARRAYSIZE( extlumps ); i++, stat_index++ )
Mod_LoadLump( mod_base, &extlumps[i], &worldstats[stat_index], flags, LOADLUMP_BSP30EXT, NULL, bmod );
Mod_LoadLump( mod_base, &extlumps[i], &worldstats[stat_index], flags, LOADLUMP_BSP30EXT, NULL );
// loading bspx lumps
if( bspx_header_offset >= 0 )
{
for( i = 0; i < ARRAYSIZE( bspxlumps ); i++, stat_index++ )
Mod_LoadLump( mod_base, &bspxlumps[i], &worldstats[stat_index], flags, LOADLUMP_BSPX, mod_base + bspx_header_offset, bmod );
Mod_LoadLump( mod_base, &bspxlumps[i], &worldstats[stat_index], flags, LOADLUMP_BSPX, mod_base + bspx_header_offset );
}
if( !bmod->isworld ) // a1ba: why world excluded here?
@@ -4314,7 +4305,6 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, byte *mod_base, size_t buffer
if( loadstat.numerrors )
{
Con_DPrintf( "%s: %i error(s), %i warning(s)\n", __func__, loadstat.numerrors, loadstat.numwarnings );
Mem_Free( bmod );
return false; // there were errors, we can't load this map
}
@@ -4379,7 +4369,6 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, byte *mod_base, size_t buffer
Con_Reportf( "Wad files required to run the map: \"%s\"\n", wadvalue );
}
Mem_Free( bmod );
return true;
}
@@ -4422,7 +4411,7 @@ qboolean Mod_TestBmodelLumps( file_t *f, const char *name, byte *mod_base, size_
{
dheader_t *header = (dheader_t *)mod_base;
int *extident = (int *)( mod_base + sizeof( dheader_t ));
int i, flags = 0, stat_index = 0;
int i, flags = LUMP_TESTONLY, stat_index = 0;
// always reset the intermediate struct
memset( &loadstat, 0, sizeof( loadstat_t ));
@@ -4438,6 +4427,10 @@ qboolean Mod_TestBmodelLumps( file_t *f, const char *name, byte *mod_base, size_
// byte-swap BSP header and lump directory from little-endian
Mod_SwapBSPLumps( mod_base, buffersize );
// restore default lump numbers
srclumps[0].lumpnumber = LUMP_ENTITIES;
srclumps[1].lumpnumber = LUMP_PLANES;
switch( header->version )
{
case HLBSP_VERSION:
@@ -4459,7 +4452,11 @@ qboolean Mod_TestBmodelLumps( file_t *f, const char *name, byte *mod_base, size_
return false;
if( ret )
SetBits( flags, LUMP_BSHIFT_SWAP );
{
// blue-shift swapped lumps
srclumps[0].lumpnumber = LUMP_PLANES;
srclumps[1].lumpnumber = LUMP_ENTITIES;
}
}
}
break;
@@ -4475,15 +4472,15 @@ qboolean Mod_TestBmodelLumps( file_t *f, const char *name, byte *mod_base, size_
}
// get entities lump to caller
*entities = header->lumps[FBitSet( flags, LUMP_BSHIFT_SWAP ) ? LUMP_PLANES : LUMP_ENTITIES];
*entities = header->lumps[srclumps[0].lumpnumber];
// loading base lumps
for( i = 0; i < ARRAYSIZE( srclumps ); i++, stat_index++ )
Mod_LoadLump( mod_base, &srclumps[i], &worldstats[stat_index], flags, LOADLUMP_STANDARD, NULL, NULL );
Mod_LoadLump( mod_base, &srclumps[i], &worldstats[stat_index], flags, LOADLUMP_STANDARD, NULL );
// loading extralumps
for( i = 0; i < ARRAYSIZE( extlumps ); i++, stat_index++ )
Mod_LoadLump( mod_base, &extlumps[i], &worldstats[stat_index], flags, LOADLUMP_BSP30EXT, NULL, NULL );
Mod_LoadLump( mod_base, &extlumps[i], &worldstats[stat_index], flags, LOADLUMP_BSP30EXT, NULL );
// FIXME: BSPX testing

View File

@@ -124,10 +124,6 @@ typedef struct world_static_s
wadentry_t *wadlist;
int wadcount;
// lightmapped water extra info
float litwater_scale;
int litwater_minlight;
} world_static_t;
#ifndef REF_DLL

View File

@@ -86,7 +86,7 @@ void Sys_InitLog( void )
if( Sys_CheckParm( "-log" ))
{
if( !Sys_GetParmFromCmdLine( "-log", s_ld.log_path ) || !isalnum((byte)s_ld.log_path[0] ))
if( !Sys_GetParmFromCmdLine( "-log", s_ld.log_path ) || !isalnum( s_ld.log_path[0] ))
Q_strncpy( s_ld.log_path, "engine.log", sizeof( s_ld.log_path ));
COM_DefaultExtension( s_ld.log_path, ".log", sizeof( s_ld.log_path ));

View File

@@ -105,7 +105,6 @@ GNU General Public License for more details.
#define FWORLD_CUSTOM_SKYBOX BIT( 1 )
#define FWORLD_WATERALPHA BIT( 2 )
#define FWORLD_HAS_DELUXEMAP BIT( 3 )
#define FWORLD_HAS_LITWATER BIT( 4 )
// special rendermode for screenfade modulate
// (probably will be expanded at some point)

View File

@@ -3219,11 +3219,9 @@ void SV_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
return;
}
// Must check `args` because A2S_GOLDSRC_INFO contains spaces.
// `pcmd` points only to the first word from the query string.
if( !Q_strcmp( args, A2S_GOLDSRC_INFO ) || pcmd[0] == A2S_GOLDSRC_PLAYERS || pcmd[0] == A2S_GOLDSRC_RULES )
if( !Q_strcmp( pcmd, A2S_GOLDSRC_INFO ) || pcmd[0] == A2S_GOLDSRC_PLAYERS || pcmd[0] == A2S_GOLDSRC_RULES )
{
SV_SourceQuery_HandleConnnectionlessPacket( args, from );
SV_SourceQuery_HandleConnnectionlessPacket( pcmd, from );
}
else if( !Q_strcmp( pcmd, A2A_NETINFO ))
{

View File

@@ -801,7 +801,7 @@ qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent )
{
char c = id[i];
if( !isdigit((byte)id[i] ) && !( c >= 'a' && c <= 'f' ))
if( !isdigit( id[i] ) && !( c >= 'a' && c <= 'f' ))
{
SV_RejectConnection( from, "invalid authentication certificate\n" );
return false;

View File

@@ -929,12 +929,12 @@ void COM_TrimSpace( char *dst, const char *src, size_t size )
return;
// remove spaces from the start
for( ; *src && isspace((byte)*src ); src++ );
for( ; *src && isspace( *src ); src++ );
int len = Q_strlen( src );
// remove spaces from the end
for( ; len > 0 && isspace((byte)src[len - 1] ); len-- );
for( ; len > 0 && isspace( src[len - 1] ); len-- );
if( len > 0 )
{

View File

@@ -170,15 +170,9 @@ static inline qboolean Q_istype( const char *str, int (*istype)( int c ))
{
if( likely( str && *str ))
{
// a1ba: explicitly cast char to unsigned char to not trigger UB
// in ctype functions
while( istype((byte)*str ))
str++;
if( !*str )
return true;
while( istype( *str )) str++;
if( !*str ) return true;
}
return false;
}

View File

@@ -720,7 +720,6 @@ extern convar_t gl_msaa;
extern convar_t gl_stencilbits;
extern convar_t gl_overbright;
extern convar_t gl_fog;
extern convar_t gl_litwater_force;
extern convar_t r_lighting_ambient;
extern convar_t r_studio_lambert;

View File

@@ -22,7 +22,6 @@ CVAR_DEFINE_AUTO( gl_msaa, "1", FCVAR_GLCONFIG, "enable or disable multisample a
CVAR_DEFINE_AUTO( gl_stencilbits, "8", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "pixelformat stencil bits (0 - auto)" );
CVAR_DEFINE_AUTO( gl_overbright, "1", FCVAR_GLCONFIG, "overbrights" );
CVAR_DEFINE_AUTO( gl_fog, "1", FCVAR_GLCONFIG, "allow for rendering fog using built-in OpenGL fog implementation" );
CVAR_DEFINE_AUTO( gl_litwater_force, "0", FCVAR_GLCONFIG, "force enable lightmapped water, even if support not declared in the map" );
CVAR_DEFINE_AUTO( r_lighting_ambient, "0.3", FCVAR_GLCONFIG, "map ambient lighting scale" );
CVAR_DEFINE_AUTO( r_detailtextures, "1", FCVAR_GLCONFIG, "enable detail textures support" );
CVAR_DEFINE_AUTO( r_novis, "0", 0, "ignore vis information (perfomance test)" );
@@ -988,7 +987,8 @@ static void GL_InitExtensionsBigGL( void )
if( !GL_CheckExtension( "glDrawRangeElements", drawrangeelementsfuncs, ARRAYSIZE( drawrangeelementsfuncs ), "gl_drawrangeelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ) )
{
if( GL_CheckExtension( "glDrawRangeElementsEXT", drawrangeelementsextfuncs, ARRAYSIZE( drawrangeelementsextfuncs ), "gl_drawrangeelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ))
if( GL_CheckExtension( "glDrawRangeElementsEXT", drawrangeelementsextfuncs, ARRAYSIZE( drawrangeelementsextfuncs ),
"gl_drawrangelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ))
{
#if !XASH_GL_STATIC
pglDrawRangeElements = pglDrawRangeElementsEXT;
@@ -1184,7 +1184,6 @@ static void GL_InitCommands( void )
gEngfuncs.Cvar_RegisterVariable( &gl_round_down );
gEngfuncs.Cvar_RegisterVariable( &gl_overbright );
gEngfuncs.Cvar_RegisterVariable( &gl_fog );
gEngfuncs.Cvar_RegisterVariable( &gl_litwater_force );
gEngfuncs.Cvar_RegisterVariable( &gl_polyoffset );
gEngfuncs.Cvar_RegisterVariable( &gl_polyoffset_bmodels );

View File

@@ -76,39 +76,6 @@ static inline qboolean R_SeparatePassActive( const separate_pass_t *sp )
return sp->last >= 0 ? true : false;
}
static qboolean Mod_HaveLightmappedWater( void )
{
// if this flag set, it's level designer's job to ensure water has been properly lit
if( FBitSet( tr.world->flags, FWORLD_HAS_LITWATER ))
return true;
// otherwise, check user preference, as some maps have lightmapped water
return gl_litwater_force.value ? true : false;
}
static int Mod_LightmappedWaterMinlight( void )
{
if( FBitSet( tr.world->flags, FWORLD_HAS_LITWATER ))
{
if( tr.world->litwater_minlight >= 0 )
return tr.world->litwater_minlight;
}
return 0;
}
static float Mod_LightmappedWaterScale( void )
{
if( FBitSet( tr.world->flags, FWORLD_HAS_LITWATER ))
{
if( tr.world->litwater_scale >= 0.0f )
return tr.world->litwater_scale;
}
return 1.0f;
}
byte *Mod_GetCurrentVis( void )
{
if( gEngfuncs.drawFuncs->Mod_GetCurrentVis && tr.fCustomRendering )
@@ -285,29 +252,12 @@ static void SubdividePolygon_r( model_t *loadmodel, msurface_t *warpface, int nu
{
VectorCopy( verts, poly->verts[i] );
R_TextureCoord( verts, warpface, &poly->verts[i][3] );
// lightmap texcoords for subdivided surfaces will be calculated later
}
}
static void GL_BuildLightmapWater( model_t *mod, msurface_t *fa )
{
float sample_size;
glpoly2_t *poly;
if( !mod || !fa->texinfo || !fa->texinfo->texture )
return; // bad polygon?
sample_size = gEngfuncs.Mod_SampleSizeForFace( fa );
for( poly = fa->polys; poly; poly = poly->next )
{
int i;
for( i = 0; i < poly->numverts; i++ )
// for speed reasons
if( !FBitSet( warpface->flags, SURF_DRAWTURB ))
{
vec3_t vec;
VectorCopy( poly->verts[i], vec );
R_LightmapCoord( vec, fa, sample_size, &poly->verts[i][5] );
// lightmap texture coordinates
R_LightmapCoord( verts, warpface, sample_size, &poly->verts[i][5] );
}
}
}
@@ -753,8 +703,6 @@ static void R_BuildLightMap( const msurface_t *surf, byte *dest, int stride, qbo
const mextrasurf_t *info = surf->info;
int lightscale;
const int litwater_minlight = Mod_LightmappedWaterMinlight();
const float litwater_scale = Mod_LightmappedWaterScale();
const int sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
const int smax = ( info->lightextents[0] / sample_size ) + 1;
const int tmax = ( info->lightextents[1] / sample_size ) + 1;
@@ -804,14 +752,6 @@ static void R_BuildLightMap( const msurface_t *surf, byte *dest, int stride, qbo
{
int t = bl[i] * lightscale >> 14;
// amp up water lightmap to avoid too dark water
// when the it wasn't properly lit by the level designer
if( FBitSet( surf->flags, SURF_DRAWTURB ))
{
float ft = t * litwater_scale;
t = Q_max( Q_rint( ft ), litwater_minlight );
}
if( t > 1023 )
t = 1023;
@@ -1037,58 +977,6 @@ static void EmitWaterPolys( msurface_t *warp, qboolean reverse, qboolean ripples
GL_SetupFogColorForSurfaces();
}
/*
================
EmitWaterLightPolys
Render water lightmaps
================
*/
static void EmitWaterLightPolys( msurface_t *warp, float soffset, float toffset, qboolean dynamic )
{
const qboolean useQuads = FBitSet( warp->flags, SURF_DRAWTURB_QUADS );
glpoly2_t *p;
float waveHeight = RI.currententity->curstate.scale;
// set the current waveheight
if( warp->polys->verts[0][2] >= RI.rvp.vieworigin[2] )
waveHeight = -waveHeight;
if( useQuads )
pglBegin( GL_QUADS );
for( p = warp->polys; p; p = p->next )
{
float *v = p->verts[0];
int i;
if( !useQuads )
pglBegin( GL_POLYGON );
for( i = 0; i < p->numverts; i++, v += VERTEXSIZE )
{
if( !dynamic ) pglTexCoord2f( v[5], v[6] );
else pglTexCoord2f( v[5] - soffset, v[6] - toffset );
if( waveHeight )
{
float nv = r_turbsin[(int)(gp_cl->time * 160.0f + v[1] + v[0]) & 255] + 8.0f;
nv = (r_turbsin[(int)(v[0] * 5.0f + gp_cl->time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + nv;
nv = nv * waveHeight + v[2];
pglVertex3f( v[0], v[1], nv );
}
else pglVertex3fv( v );
}
if( !useQuads )
pglEnd ();
}
if( useQuads )
pglEnd();
}
/*
================
DrawGLPolyChain
@@ -1096,16 +984,10 @@ DrawGLPolyChain
Render lightmaps
================
*/
static void DrawGLPolyChain( glpoly2_t *p, float soffset, float toffset, msurface_t *surf )
static void DrawGLPolyChain( glpoly2_t *p, float soffset, float toffset )
{
const qboolean dynamic = soffset != 0.0f || toffset != 0.0f;
if( FBitSet( surf->flags, SURF_DRAWTURB ))
{
EmitWaterLightPolys( surf, soffset, toffset, dynamic );
return;
}
for( ; p != NULL; p = p->chain )
{
float *v;
@@ -1138,8 +1020,6 @@ static qboolean R_HasLightmap( void )
switch( RI.currententity->curstate.rendermode )
{
case kRenderTransTexture:
return FBitSet( RI.currentmodel->flags, MODEL_LIQUID ) ? true : false;
case kRenderTransColor:
case kRenderTransAdd:
case kRenderGlow:
@@ -1169,29 +1049,21 @@ static void R_BlendLightmaps( void )
pglEnable( GL_BLEND );
else pglDisable( GL_BLEND );
pglDisable( GL_ALPHA_TEST );
// lightmapped solid surfaces
pglDepthMask( GL_FALSE );
pglDepthFunc( GL_EQUAL );
if( RI.currententity->curstate.rendermode == kRenderTransTexture )
pglDisable( GL_ALPHA_TEST );
if( gl_overbright.value )
{
pglBlendFunc( GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA );
pglBlendFunc( GL_DST_COLOR, GL_SRC_COLOR );
if(!( R_HasEnabledVBO() && !r_vbo_overbrightmode.value ))
pglColor4f( 128.0f / 192.0f, 128.0f / 192.0f, 128.0f / 192.0f, 1.0f );
}
else
{
// lightmapped solid surfaces
pglDepthMask( GL_FALSE );
pglDepthFunc( GL_EQUAL );
if( gl_overbright.value )
{
pglBlendFunc( GL_DST_COLOR, GL_SRC_COLOR );
if(!( R_HasEnabledVBO() && !r_vbo_overbrightmode.value ))
pglColor4f( 128.0f / 192.0f, 128.0f / 192.0f, 128.0f / 192.0f, 1.0f );
}
else
{
pglBlendFunc( GL_ZERO, GL_SRC_COLOR );
}
pglBlendFunc( GL_ZERO, GL_SRC_COLOR );
}
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
// render static lightmaps first
@@ -1203,7 +1075,7 @@ static void R_BlendLightmaps( void )
for( surf = gl_lms.lightmap_surfaces[i]; surf != NULL; surf = surf->info->lightmapchain )
{
DrawGLPolyChain( surf->polys, 0.0f, 0.0f, surf );
if( surf->polys ) DrawGLPolyChain( surf->polys, 0.0f, 0.0f );
}
}
}
@@ -1244,10 +1116,12 @@ static void R_BlendLightmaps( void )
// draw all surfaces that use this lightmap
for( drawsurf = newsurf; drawsurf != surf; drawsurf = drawsurf->info->lightmapchain )
{
DrawGLPolyChain( drawsurf->polys,
if( drawsurf->polys )
{
DrawGLPolyChain( drawsurf->polys,
( drawsurf->light_s - drawsurf->info->dlight_s ) * ( 1.0f / (float)BLOCK_SIZE ),
( drawsurf->light_t - drawsurf->info->dlight_t ) * ( 1.0f / (float)BLOCK_SIZE ),
drawsurf );
( drawsurf->light_t - drawsurf->info->dlight_t ) * ( 1.0f / (float)BLOCK_SIZE ));
}
}
newsurf = drawsurf;
@@ -1271,10 +1145,12 @@ static void R_BlendLightmaps( void )
for( surf = newsurf; surf != NULL; surf = surf->info->lightmapchain )
{
DrawGLPolyChain( surf->polys,
if( surf->polys )
{
DrawGLPolyChain( surf->polys,
( surf->light_s - surf->info->dlight_s ) * ( 1.0f / (float)BLOCK_SIZE ),
( surf->light_t - surf->info->dlight_t ) * ( 1.0f / (float)BLOCK_SIZE ),
surf );
( surf->light_t - surf->info->dlight_t ) * ( 1.0f / (float)BLOCK_SIZE ));
}
}
}
@@ -1542,13 +1418,8 @@ static void R_RenderBrushPoly( msurface_t *fa, int cull_type )
if( FBitSet( fa->flags, SURF_DRAWTURB ))
{
// warp texture
// warp texture, no lightmaps
EmitWaterPolys( fa, cull_type == CULL_BACKSIDE, R_UploadRipples( t ));
// add lightmaps if requested
if( Mod_HaveLightmappedWater( ))
R_RenderLightmapForSurface( fa );
return;
}
else GL_Bind( XASH_TEXTURE0, t->gl_texturenum );
@@ -1729,20 +1600,11 @@ void R_DrawWaterSurfaces( void )
continue;
for( ; s; s = s->texturechain )
{
EmitWaterPolys( s, false, R_UploadRipples( t ));
if( Mod_HaveLightmappedWater( ))
R_RenderLightmapForSurface( s );
}
t->texturechain = NULL;
}
// litwater: not sure if needed
GL_ResetFogColor();
R_BlendLightmaps();
R_ResetSeparatePass( &draw_wateralpha );
pglDisable( GL_BLEND );
@@ -1855,16 +1717,8 @@ static int R_SortBrushModelSurfaces( cl_entity_t *e, model_t *clmodel, vec3_t mi
if( cull_type == CULL_BACKSIDE )
{
if( FBitSet( psurf->flags, SURF_DRAWTURB ))
{
if( Mod_HaveLightmappedWater( ))
continue; // we don't want back faces when drawing lightmaps to avoid Z fighting
}
else
{
if( !( psurf->pdecals && e->curstate.rendermode == kRenderTransTexture ))
continue;
}
if( !FBitSet( psurf->flags, SURF_DRAWTURB ) && !( psurf->pdecals && e->curstate.rendermode == kRenderTransTexture ))
continue;
}
if( num_sorted < gpGlobals->max_surfaces )
@@ -4063,10 +3917,7 @@ void GL_BuildLightmaps( void )
GL_CreateSurfaceLightmap( m->surfaces + j, m );
if( m->surfaces[j].flags & SURF_DRAWTURB )
{
GL_BuildLightmapWater( m, m->surfaces + j );
continue;
}
nColinElim += GL_BuildPolygonFromSurface( m, m->surfaces + j );
}

View File

@@ -49,12 +49,12 @@ IsValidName
*/
static qboolean IsValidName( char *name )
{
if( !( isalpha((byte)*name ) || isdigit((byte)*name )))
if( !( isalpha( *name ) || isdigit( *name )))
return false;
while( *( ++name ))
{
if( isalpha((byte)*name ) || isdigit((byte)*name )
if( isalpha( *name ) || isdigit( *name )
|| *name == '.' || *name == '-' || *name == '_'
|| *name == ' ' || *name == '(' || *name == ')'
|| *name == '[' || *name == ']')