Compare commits

...

13 Commits

Author SHA1 Message Date
Andrey Akhmichin
dabed4f9eb utils: mdldec: add separate directories creation for sequences and textures. 2023-12-05 11:18:47 +03:00
Andrey Akhmichin
f9b6389248 utils: mdldec: create full destination path into "Kratisto's mdldec" maner. 2023-12-05 11:18:47 +03:00
Alibek Omarov
9ec1e259b4 engine: platform: sdl: unused variable cleanup 2023-12-05 10:48:47 +03:00
Alibek Omarov
0c2d480d89 engine: client: unused variables cleanup 2023-12-05 10:47:55 +03:00
Alibek Omarov
350d8ccb7b engine: common: cvar: unused variables cleanup 2023-12-05 10:46:26 +03:00
Alibek Omarov
0c512d0431 engine: server: unused variables cleanup 2023-12-05 10:46:03 +03:00
Alibek Omarov
3bf55c9ea4 filesystem: zip: hide CRC checks under common macro 2023-12-04 03:01:11 +03:00
Alibek Omarov
9994c57796 filesystem: fix updating gameinfo.txt from rodir 2023-12-04 03:00:51 +03:00
Alibek Omarov
3f724b6b17 filesystem: remove some really unused variables 2023-12-04 03:00:29 +03:00
Alibek Omarov
255773b4de ref: gl: remove useless calls to glGetString if we're running under GL4ES 2023-12-04 02:53:51 +03:00
Alibek Omarov
5b73a788da ref: gl: disable unused variable warning for GL functions defintions 2023-12-04 02:53:27 +03:00
Alibek Omarov
748b06a00e wscript: warn about unused variables 2023-12-04 02:53:07 +03:00
Alibek Omarov
273bccdc9a engine: nswitch: fix compiling by removing stdc++ from SDL2 dependencies as we link it later (#1519) 2023-12-02 20:25:51 +03:00
22 changed files with 142 additions and 73 deletions

View File

@@ -202,7 +202,6 @@ SCR_PlayCinematic
*/
qboolean SCR_PlayCinematic( const char *arg )
{
string path;
const char *fullpath;
fullpath = FS_GetDiskPath( arg, false );

View File

@@ -1136,8 +1136,6 @@ As Cvar_Set, but also flags it as glconfig
*/
void Cvar_SetGL_f( void )
{
convar_t *var;
if( Cmd_Argc() != 3 )
{
Con_Printf( S_USAGE "setgl <variable> <value>\n" );

View File

@@ -1087,7 +1087,6 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
delta_info_t *dt = NULL;
delta_t *pField;
int i, countBits;
int numChanges = 0;
countBits = MAX_ENTITY_BITS + 2;
@@ -1121,7 +1120,7 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
if( !Delta_CompareField( pField, from, to, timebase ))
{
// strings are handled difference
// strings are handled differently
if( FBitSet( pField->flags, DT_STRING ))
countBits += Q_strlen((char *)((byte *)to + pField->offset )) * 8;
else countBits += pField->bits;

View File

@@ -654,9 +654,9 @@ static void VID_SetWindowIcon( SDL_Window *hWnd )
{
rgbdata_t *icon = NULL;
char iconpath[MAX_STRING];
#if XASH_WIN32 // ICO support only for Win32
const char *localIcoPath;
#if XASH_WIN32 // ICO support only for Win32
if(( localIcoPath = FS_GetDiskPath( GI->iconpath, true )))
{
HICON ico = (HICON)LoadImage( NULL, localIcoPath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE|LR_DEFAULTSIZE );

View File

@@ -36,7 +36,7 @@ static void SV_SourceQuery_Details( netadr_t from )
{
sizebuf_t buf;
char answer[2048];
int i, bot_count, client_count;
int bot_count, client_count;
int is_private = 0;
SV_GetPlayerCount( &client_count, &bot_count );

View File

@@ -1475,7 +1475,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
float ds, dt, s, t;
int sample_size;
msurface_t *surf;
mtexinfo_t *tex;
mextrasurf_t *info;
color24 *lm;
vec3_t mid;
@@ -1510,7 +1509,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
{
int smax, tmax;
tex = surf->texinfo;
info = surf->info;
if( FBitSet( surf->flags, SURF_DRAWTILED ))

View File

@@ -49,14 +49,14 @@ def configure(conf):
# re-enable undefined reference errors
conf.env.CXXFLAGS += ['-Wl,--no-undefined']
conf.env.CFLAGS += ['-Wl,--no-undefined']
# allow the SDL2 sanity check to complete properly by linking in libstdc++ and lm normally
conf.env.LDFLAGS += ['-lstdc++', '-lm']
# allow the SDL2 sanity check to complete properly by linking in lm normally
conf.env.LDFLAGS += ['-lm']
conf.load('sdl2')
if not conf.env.HAVE_SDL2:
conf.fatal('SDL2 not availiable! Install switch-sdl2!')
conf.define('XASH_SDL', 2)
# then remove them to avoid them getting linked to shared objects
conf.env.LDFLAGS.remove('-lstdc++')
conf.env.LIB_SDL2.remove('stdc++') # remove libstdc++ linking from SDL2, we link it later
conf.env.LDFLAGS.remove('-lm')
elif conf.env.DEST_OS == 'psvita':
# allow the SDL2 sanity check to complete properly by linking in some deps missing from the pkg-config file
@@ -189,7 +189,7 @@ def build(bld):
# HACK: link in the entirety of libstdc++ so that dynamic libs could use all of it without manual exporting
# we can't do this right away because std::filesystem will complain about not having pathconf(),
# which we have defined in sys_nswitch.c
bld.env.LDFLAGS += ['-Wl,--whole-archive', '-lstdc++', '-Wl,--no-whole-archive', '-lm']
bld.env.LDFLAGS += ['-v', '-Wl,--whole-archive', '-lstdc++', '-Wl,--no-whole-archive', '-lm']
if bld.env.DEST_OS == 'psvita':
libs += [ 'VRTLD' ]
@@ -225,13 +225,9 @@ def build(bld):
# Switch and PSVita have custom parameters
if bld.env.DEST_OS in ['nswitch', 'psvita']:
program = 'cxxprogram'
if bld.env.DEST_OS == 'nswitch':
program = 'cprogram' # avoid linking with g++, we link standard library explicitly
bld(source = source,
target = 'xash',
features = ['c', program],
features = 'c cxxprogram',
includes = includes,
use = libs,
install_path = None,

View File

@@ -449,7 +449,6 @@ static void FS_Search_DIR( searchpath_t *search, stringlist_t *list, const char
static int FS_FileTime_DIR( searchpath_t *search, const char *filename )
{
int time;
char path[MAX_SYSPATH];
Q_snprintf( path, sizeof( path ), "%s%s", search->filename, filename );

View File

@@ -1078,29 +1078,39 @@ static qboolean FS_ParseGameInfo( const char *gamedir, gameinfo_t *GameInfo )
roGameInfoTime = FS_SysFileTime( gameinfo_ro );
rwGameInfoTime = FS_SysFileTime( gameinfo_path );
// if rodir's liblist.gam newer than rwdir's gameinfo.txt, then convert it
if( roLibListTime > rwGameInfoTime )
{
haveUpdate = FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_ro );
}
// if rodir's gameinfo.txt newer than rwdir's gameinfo.txt, just copy the file
else if( roGameInfoTime > rwGameInfoTime )
{
fs_offset_t len;
char *afile_ro = (char *)FS_LoadDirectFile( gameinfo_ro, &len );
file_t *ro, *rw;
fs_offset_t ro_size;
if( afile_ro )
{
Con_DPrintf( "Copy rodir %s to rwdir %s\n", gameinfo_ro, gameinfo_path );
haveUpdate = true;
FS_WriteFile( gameinfo_path, afile_ro, len );
Mem_Free( afile_ro );
}
// read & write as binary to copy the exact file
ro = FS_SysOpen( gameinfo_ro, "rb" );
rw = FS_SysOpen( gameinfo_path, "wb" );
FS_Seek( ro, 0, SEEK_END );
ro_size = FS_Tell( ro );
FS_Seek( ro, 0, SEEK_SET );
FS_FileCopy( rw, ro, ro_size );
FS_Close( rw );
FS_Close( ro );
haveUpdate = true;
}
FS_AllowDirectPaths( false );
}
// do not update gameinfo.txt, if it was just copied from rodir's
// if user change liblist.gam update the gameinfo.txt
if( FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false ))
if( !haveUpdate && FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false ))
FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_path );
// force to create gameinfo for specified game if missing

View File

@@ -334,7 +334,7 @@ searchpath_t *FS_AddPak_Fullpath( const char *pakfile, int flags )
{
searchpath_t *search;
pack_t *pak;
int i, errorcode = PAK_LOAD_COULDNT_OPEN;
int errorcode = PAK_LOAD_COULDNT_OPEN;
pak = FS_LoadPackPAK( pakfile, &errorcode );

View File

@@ -129,6 +129,8 @@ struct zip_s
zipfile_t *files;
};
// #define ENABLE_CRC_CHECK // known to be buggy because of possible libpublic crc32 bug, disabled
#ifdef XASH_REDUCE_FD
static void FS_EnsureOpenZip( zip_t *zip )
{
@@ -423,12 +425,13 @@ FS_LoadZIPFile
static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_ind, fs_offset_t *sizeptr )
{
zipfile_t *file;
int index;
byte *compressed_buffer = NULL, *decompressed_buffer = NULL;
int zlib_result = 0;
dword test_crc, final_crc;
z_stream decompress_stream;
size_t c;
#ifdef ENABLE_CRC_CHECK
dword test_crc, final_crc;
#endif // ENABLE_CRC_CHECK
if( sizeptr ) *sizeptr = 0;
@@ -460,7 +463,7 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
return NULL;
}
#if 0
#ifdef ENABLE_CRC_CHECK
CRC32_Init( &test_crc );
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
@@ -472,7 +475,8 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
Mem_Free( decompressed_buffer );
return NULL;
}
#endif
#endif // ENABLE_CRC_CHECK
if( sizeptr ) *sizeptr = file->size;
FS_EnsureOpenZip( NULL );
@@ -516,7 +520,7 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
if( zlib_result == Z_OK || zlib_result == Z_STREAM_END )
{
Mem_Free( compressed_buffer ); // finaly free compressed buffer
#if 0
#if ENABLE_CRC_CHECK
CRC32_Init( &test_crc );
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
@@ -668,7 +672,7 @@ searchpath_t *FS_AddZip_Fullpath( const char *zipfile, int flags )
{
searchpath_t *search;
zip_t *zip;
int i, errorcode = ZIP_LOAD_COULDNT_OPEN;
int errorcode = ZIP_LOAD_COULDNT_OPEN;
zip = FS_LoadZip( zipfile, &errorcode );

View File

@@ -892,6 +892,11 @@ typedef float GLmatrix[16];
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#if defined( XASH_GL_STATIC ) && !defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
#define GL_FUNCTION( name ) name
#elif defined( XASH_GL_STATIC ) && defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
@@ -1861,4 +1866,8 @@ APIENTRY_LINKAGE void GL_FUNCTION( glTexImage2DMultisample )(GLenum target, GLsi
#define pglSwapInterval glSwapInterval
#endif
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#endif//GL_EXPORT_H

View File

@@ -913,13 +913,7 @@ void GL_InitExtensionsBigGL( void )
// gl4es may be used system-wide
if( Q_stristr( glConfig.renderer_string, "gl4es" ))
{
const char *vendor = (const char *)pglGetString( GL_VENDOR | 0x10000 );
const char *renderer = (const char *)pglGetString( GL_RENDERER | 0x10000 );
const char *version = (const char *)pglGetString( GL_VERSION | 0x10000 );
const char *extensions = (const char *)pglGetString( GL_EXTENSIONS | 0x10000 );
glConfig.wrapper = GLES_WRAPPER_GL4ES;
}
// multitexture
glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1;

View File

@@ -351,11 +351,8 @@ static qboolean LoadMDL( const char *modelname )
if( destdir[0] != '\0' )
{
if( !MakeDirectory( destdir ))
{
fprintf( stderr, "ERROR: Couldn't create directory %s\n", destdir );
if( !MakeFullPath( destdir ))
return false;
}
}
else
COM_ExtractFilePath( modelname, destdir );

View File

@@ -22,6 +22,8 @@ GNU General Public License for more details.
#include "version.h"
#include "mdldec.h"
#include "utils.h"
#include "smd.h"
#include "texture.h"
#include "qc.h"
static char **activity_names;
@@ -62,7 +64,7 @@ qboolean LoadActivityList( const char *appname )
if( !fp )
{
fputs( "ERROR: Can't open file " ACTIVITIES_FILE ".\n", stderr );
fputs( "ERROR: Couldn't open file " ACTIVITIES_FILE ".\n", stderr );
return false;
}
}
@@ -474,11 +476,11 @@ static void WriteSequenceInfo( FILE *fp )
if( seqdesc->numblends > 1 )
{
for( j = 0; j < seqdesc->numblends; j++ )
fprintf( fp, "\t\"%s_blend%02i\"\n", seqdesc->label, j + 1 );
fprintf( fp, "\t\"" DEFAULT_SEQUENCEPATH "%s_blend%02i\"\n", seqdesc->label, j + 1 );
}
else
{
fprintf( fp, "\t\"%s\"\n", seqdesc->label );
fprintf( fp, "\t\"" DEFAULT_SEQUENCEPATH "%s\"\n", seqdesc->label );
}
if( seqdesc->activity )
@@ -565,7 +567,7 @@ void WriteQCScript( void )
if( len == -1 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.qc\n", modelfile );
fprintf( stderr, "ERROR: Destination path is too long. Couldn't write %s.qc\n", modelfile );
return;
}
@@ -573,7 +575,7 @@ void WriteQCScript( void )
if( !fp )
{
fprintf( stderr, "ERROR: Can't write %s\n", filename );
fprintf( stderr, "ERROR: Couldn't write %s\n", filename );
return;
}
@@ -594,7 +596,7 @@ void WriteQCScript( void )
fprintf( fp, "$modelname \"%s.mdl\"\n", modelfile );
fputs( "$cd \".\"\n", fp );
fputs( "$cdtexture \".\"\n", fp );
fputs( "$cdtexture \"./" DEFAULT_TEXTUREPATH "\"\n", fp );
fputs( "$cliptotextures\n", fp );
fputs( "$scale 1.0\n", fp );
fputs( "\n", fp );

View File

@@ -23,6 +23,7 @@ GNU General Public License for more details.
#include "studio.h"
#include "mdldec.h"
#include "smd.h"
#include "utils.h"
static matrix3x4 *bonetransform;
static matrix3x4 *worldtransform;
@@ -520,7 +521,7 @@ static void WriteReferences( void )
if( len == -1 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.smd\n", model->name );
fprintf( stderr, "ERROR: Destination path is too long. Couldn't write %s.smd\n", model->name );
goto _fail;
}
@@ -528,7 +529,7 @@ static void WriteReferences( void )
if( !fp )
{
fprintf( stderr, "ERROR: Can't write %s\n", filename );
fprintf( stderr, "ERROR: Couldn't write %s\n", filename );
goto _fail;
}
@@ -559,31 +560,41 @@ WriteSequences
static void WriteSequences( void )
{
int i, j;
int len;
int len, namelen, emptyplace;
FILE *fp;
char filename[MAX_SYSPATH];
char path[MAX_SYSPATH];
mstudioseqdesc_t *seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex );
len = Q_snprintf( path, MAX_SYSPATH, "%s" DEFAULT_SEQUENCEPATH, destdir );
if( len == -1 || !MakeDirectory( path ))
{
fputs( "ERROR: Destination path is too long or write permission denied. Couldn't create directory for sequences\n", stderr );
return;
}
emptyplace = MAX_SYSPATH - len;
for( i = 0; i < model_hdr->numseq; ++i, ++seqdesc )
{
for( j = 0; j < seqdesc->numblends; j++ )
{
if( seqdesc->numblends == 1 )
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s.smd", destdir, seqdesc->label );
namelen = Q_snprintf( &path[len], emptyplace, "%s.smd", seqdesc->label );
else
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s_blend%02i.smd", destdir, seqdesc->label, j + 1 );
namelen = Q_snprintf( &path[len], emptyplace, "%s_blend%02i.smd", seqdesc->label, j + 1 );
if( len == -1 )
if( namelen == -1 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.smd\n", seqdesc->label );
fprintf( stderr, "ERROR: Destination path is too long. Couldn't write %s.smd\n", seqdesc->label );
return;
}
fp = fopen( filename, "w" );
fp = fopen( path, "w" );
if( !fp )
{
fprintf( stderr, "ERROR: Can't write %s\n", filename );
fprintf( stderr, "ERROR: Couldn't write %s\n", path );
return;
}
@@ -594,7 +605,7 @@ static void WriteSequences( void )
fclose( fp );
printf( "Sequence: %s\n", filename );
printf( "Sequence: %s\n", path );
}
}
}

View File

@@ -16,6 +16,8 @@ GNU General Public License for more details.
#ifndef SMD_H
#define SMD_H
#define DEFAULT_SEQUENCEPATH "anims/"
void WriteSMD( void );
#endif // SMD_H

View File

@@ -23,6 +23,7 @@ GNU General Public License for more details.
#include "img_tga.h"
#include "mdldec.h"
#include "texture.h"
#include "utils.h"
/*
============
@@ -130,27 +131,37 @@ WriteTextures
*/
void WriteTextures( void )
{
int i, len;
int i, len, namelen, emptyplace;
FILE *fp;
mstudiotexture_t *texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex );
char filename[MAX_SYSPATH];
char path[MAX_SYSPATH];
len = Q_snprintf( path, MAX_SYSPATH, "%s" DEFAULT_TEXTUREPATH, destdir );
if( len == -1 || !MakeDirectory( path ))
{
fputs( "ERROR: Destination path is too long or write permission denied. Couldn't create directory for textures\n", stderr );
return;
}
emptyplace = MAX_SYSPATH - len;
for( i = 0; i < texture_hdr->numtextures; ++i, ++texture )
{
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s", destdir, texture->name );
namelen = Q_strncpy( &path[len], texture->name, emptyplace );
if( len == -1 )
if( emptyplace - namelen < 0 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s\n", texture->name );
continue;
fprintf( stderr, "ERROR: Destination path is too long. Couldn't write %s\n", texture->name );
return;
}
fp = fopen( filename, "wb" );
fp = fopen( path, "wb" );
if( !fp )
{
fprintf( stderr, "ERROR: Can't write texture file %s\n", filename );
continue;
fprintf( stderr, "ERROR: Couldn't write texture file %s\n", path );
return;
}
if( !Q_stricmp( COM_FileExtension( texture->name ), "tga" ))
@@ -160,7 +171,7 @@ void WriteTextures( void )
fclose( fp );
printf( "Texture: %s\n", filename );
printf( "Texture: %s\n", path );
}
}

View File

@@ -16,6 +16,8 @@ GNU General Public License for more details.
#ifndef TEXTURE_H
#define TEXTURE_H
#define DEFAULT_TEXTUREPATH "textures/"
void WriteTextures( void );
#endif // TEXTURE_H

View File

@@ -54,6 +54,40 @@ qboolean MakeDirectory( const char *path )
return true;
}
/*
============
MakeFullPath
============
*/
qboolean MakeFullPath( const char *path )
{
char *p = (char *)path, tmp;
for( ; *p; )
{
p = Q_strpbrk( p, "/\\" );
if( p )
{
tmp = *p;
*p = '\0';
}
if( !MakeDirectory( path ))
{
fprintf( stderr, "ERROR: Couldn't create directory %s\n", path );
return false;
}
if( !p )
break;
*p++ = tmp;
}
return true;
}
/*
============
ExtractFileName

View File

@@ -17,6 +17,7 @@ GNU General Public License for more details.
#define UTILS_H
qboolean MakeDirectory( const char *path );
qboolean MakeFullPath( const char *path );
void ExtractFileName( char *name, size_t size );
off_t GetSizeOfFile( FILE *fp );
byte *LoadFile( const char *filename, off_t *size );

View File

@@ -324,6 +324,9 @@ def configure(conf):
# disabled, flood
# '-Wdouble-promotion',
'-Wunused-variable',
'-Wunused-but-set-variable',
]
opt_cflags = [