engine: fix various compiler warnings

This commit is contained in:
Alibek Omarov
2019-07-13 23:25:03 +03:00
parent a0cbac4fc7
commit 4beba75159
30 changed files with 130 additions and 134 deletions
+13 -14
View File
@@ -60,10 +60,7 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
{
search_t *t;
file_t *f;
string message;
string compiler;
string generator;
string matchbuf;
string message, compiler, generator, matchbuf;
byte buf[MAX_SYSPATH]; // 1 kb
int i, nummaps;
@@ -83,6 +80,8 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
char *ents = NULL, *pfile;
qboolean validmap = false;
int version = 0;
char *szBuf;
string version_description;
if( Q_stricmp( ext, "bsp" )) continue;
Q_strncpy( message, "^1error^7", sizeof( message ));
@@ -114,7 +113,7 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename ));
COM_StripExtension( entfilename );
COM_DefaultExtension( entfilename, ".ent" );
ents = FS_LoadFile( entfilename, NULL, true );
ents = (char *)FS_LoadFile( entfilename, NULL, true );
if( !ents && lumplen >= 10 )
{
@@ -162,24 +161,24 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
switch( ver )
{
case Q1BSP_VERSION:
Q_strncpy( buf, "Quake", sizeof( buf ));
Q_strncpy( version_description, "Quake", sizeof( version_description ));
break;
case QBSP2_VERSION:
Q_strncpy( buf, "Darkplaces BSP2", sizeof( buf ));
Q_strncpy( version_description, "Darkplaces BSP2", sizeof( version_description ));
break;
case HLBSP_VERSION:
switch( version )
{
case 1: Q_strncpy( buf, "XashXT old format", sizeof( buf )); break;
case 2: Q_strncpy( buf, "Paranoia 2: Savior", sizeof( buf )); break;
case 4: Q_strncpy( buf, "Half-Life extended", sizeof( buf )); break;
default: Q_strncpy( buf, "Half-Life", sizeof( buf )); break;
case 1: Q_strncpy( version_description, "XashXT old format", sizeof( version_description )); break;
case 2: Q_strncpy( version_description, "Paranoia 2: Savior", sizeof( version_description )); break;
case 4: Q_strncpy( version_description, "Half-Life extended", sizeof( version_description )); break;
default: Q_strncpy( version_description, "Half-Life", sizeof( version_description )); break;
}
break;
default: Q_strncpy( buf, "??", sizeof( buf )); break;
default: Q_strncpy( version_description, "??", sizeof( version_description )); break;
}
Con_Printf( "%16s (%s) ^3%s^7 ^2%s %s^7\n", matchbuf, buf, message, compiler, generator );
Con_Printf( "%16s (%s) ^3%s^7 ^2%s %s^7\n", matchbuf, version_description, message, compiler, generator );
nummaps++;
}
@@ -896,7 +895,7 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename ));
COM_StripExtension( entfilename );
COM_DefaultExtension( entfilename, ".ent" );
ents = FS_LoadFile( entfilename, NULL, true );
ents = (char *)FS_LoadFile( entfilename, NULL, true );
if( !ents && lumplen >= 10 )
{
+4 -4
View File
@@ -1699,7 +1699,7 @@ static qboolean FS_ParseLiblistGam( const char *filename, const char *gamedir, g
char *afile;
if( !GameInfo ) return false;
afile = FS_LoadFile( filename, NULL, false );
afile = (char *)FS_LoadFile( filename, NULL, false );
if( !afile ) return false;
FS_InitGameInfo( GameInfo, gamedir );
@@ -1742,7 +1742,7 @@ static qboolean FS_ReadGameInfo( const char *filepath, const char *gamedir, game
{
char *afile;
afile = FS_LoadFile( filepath, NULL, false );
afile = (char *)FS_LoadFile( filepath, NULL, false );
if( !afile ) return false;
FS_InitGameInfo( GameInfo, gamedir );
@@ -1813,7 +1813,7 @@ static qboolean FS_ParseGameInfo( const char *gamedir, gameinfo_t *GameInfo )
}
else if( roGameInfoTime > rwGameInfoTime )
{
char *afile_ro = FS_LoadDirectFile( filepath_ro, NULL );
char *afile_ro = (char *)FS_LoadDirectFile( filepath_ro, NULL );
if( afile_ro )
{
@@ -2909,7 +2909,7 @@ qboolean CRC32_File( dword *crcvalue, const char *filename )
qboolean MD5_HashFile( byte digest[16], const char *pszFileName, uint seed[4] )
{
file_t *file;
char buffer[1024];
byte buffer[1024];
MD5Context_t MD5_Hash;
int bytes;
+2 -1
View File
@@ -256,7 +256,8 @@ Host_Exec_f
void Host_Exec_f( void )
{
string cfgpath;
char *f, *txt;
byte *f;
char *txt;
fs_offset_t len;
if( Cmd_Argc() != 2 )
+7 -5
View File
@@ -86,8 +86,7 @@ void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *pData, f
{
int filelocation;
string pakname;
char md5[16];
char *temp;
byte md5[16];
file_t *fout;
MD5Context_t ctx;
@@ -115,6 +114,8 @@ void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *pData, f
if( pData == NULL )
{
byte *temp;
// there are better ways
filelocation = FS_Tell( fin );
temp = Z_Malloc( pResource->nDownloadSize );
@@ -196,8 +197,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
hpak_info_t srcpak, dstpak;
file_t *file_src;
file_t *file_dst;
char md5[16];
byte *temp;
byte md5[16];
MD5Context_t ctx;
if( pData == NULL && pFile == NULL )
@@ -215,6 +215,8 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
if( pData == NULL )
{
byte *temp;
// there are better ways
position = FS_Tell( pFile );
temp = Z_Malloc( pResource->nDownloadSize );
@@ -369,7 +371,7 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet )
MD5Context_t MD5_Hash;
string pakname;
resource_t *pRes;
char md5[16];
byte md5[16];
if( quiet ) HPAK_FlushHostQueue();
+5 -2
View File
@@ -174,10 +174,11 @@ Load master server list from xashcomm.lst
*/
static void NET_LoadMasters( void )
{
byte *afile, *pfile;
byte *afile;
char *pfile;
char token[MAX_TOKEN];
pfile = afile = FS_LoadFile( "xashcomm.lst", NULL, true );
afile = FS_LoadFile( "xashcomm.lst", NULL, true );
if( !afile ) // file doesn't exist yet
{
@@ -185,6 +186,8 @@ static void NET_LoadMasters( void )
return;
}
pfile = (char*)afile;
// format: master <addr>\n
while( ( pfile = COM_ParseFile( pfile, token ) ) )
{
+3 -3
View File
@@ -351,7 +351,7 @@ Returns true if the bandwidth choke isn't active
qboolean Netchan_CanPacket( netchan_t *chan, qboolean choke )
{
// never choke loopback packets.
if( !choke || !net_chokeloopback->value && NET_IsLocalAddress( chan->remote_address ))
if( !choke || ( !net_chokeloopback->value && NET_IsLocalAddress( chan->remote_address ) ))
{
chan->cleartime = host.realtime;
return true;
@@ -528,7 +528,7 @@ void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, char *format, ... )
Q_vsnprintf( string, sizeof( string ) - 1, format, argptr );
va_end( argptr );
Netchan_OutOfBand( net_socket, adr, Q_strlen( string ), string );
Netchan_OutOfBand( net_socket, adr, Q_strlen( string ), (byte *)string );
}
/*
@@ -1640,7 +1640,7 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
if( chan->pfnBlockSize )
maxsize = chan->pfnBlockSize( chan->client, FRAGSIZE_UNRELIABLE );
if( MSG_GetNumBytesWritten( &send ) + length >> 3 <= maxsize )
if( (( MSG_GetNumBytesWritten( &send ) + length ) >> 3) <= maxsize )
MSG_WriteBits( &send, data, length );
else Con_Printf( S_WARN "Netchan_Transmit: unreliable message overflow: %d\n", MSG_GetNumBytesWritten( &send ) );
}
+15 -13
View File
@@ -515,6 +515,7 @@ void Delta_ParseTableField( sizebuf_t *msg )
float mul = 1.0f, post_mul = 1.0f;
int flags, bits;
const char *pName;
qboolean ignore = false;
delta_info_t *dt;
tableIndex = MSG_ReadUBitLong( msg, 4 );
@@ -523,18 +524,15 @@ void Delta_ParseTableField( sizebuf_t *msg )
Host_Error( "Delta_ParseTableField: not initialized" );
nameIndex = MSG_ReadUBitLong( msg, 8 ); // read field name index
if( !( nameIndex >= 0 && nameIndex < dt->maxFields ) )
if( ( nameIndex >= 0 && nameIndex < dt->maxFields ) )
{
Con_Reportf( "Delta_ParseTableField: wrong nameIndex %d for table %s, ignoring\n", nameIndex, dt->pName );
MSG_ReadUBitLong( msg, 10 );
MSG_ReadUBitLong( msg, 5 ) + 1;
if( MSG_ReadOneBit( msg ))
MSG_ReadFloat( msg );
if( MSG_ReadOneBit( msg ))
MSG_ReadFloat( msg );
return;
pName = dt->pInfo[nameIndex].name;
}
else
{
ignore = true;
Con_Reportf( "Delta_ParseTableField: wrong nameIndex %d for table %s, ignoring\n", nameIndex, dt->pName );
}
pName = dt->pInfo[nameIndex].name;
flags = MSG_ReadUBitLong( msg, 10 );
bits = MSG_ReadUBitLong( msg, 5 ) + 1;
@@ -546,6 +544,9 @@ void Delta_ParseTableField( sizebuf_t *msg )
if( MSG_ReadOneBit( msg ))
post_mul = MSG_ReadFloat( msg );
if( ignore )
return;
// delta encoders it's already initialized on this machine (local game)
if( delta_init )
Delta_Shutdown();
@@ -750,14 +751,15 @@ void Delta_ParseTable( char **delta_script, delta_info_t *dt, const char *encode
void Delta_InitFields( void )
{
char *afile, *pfile;
byte *afile;
char *pfile;
string encodeDll, encodeFunc, token;
delta_info_t *dt;
afile = FS_LoadFile( DELTA_PATH, NULL, false );
if( !afile ) Sys_Error( "DELTA_Load: couldn't load file %s\n", DELTA_PATH );
pfile = afile;
pfile = (char *)afile;
while(( pfile = COM_ParseFile( pfile, token )) != NULL )
{
@@ -1083,7 +1085,7 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
{
// strings are handled difference
if( FBitSet( pField->flags, DT_STRING ))
countBits += Q_strlen(((byte *)to + pField->offset )) * 8;
countBits += Q_strlen((char *)((byte *)to + pField->offset )) * 8;
else countBits += pField->bits;
}
}
+1
View File
@@ -18,6 +18,7 @@ GNU General Public License for more details.
#include "pm_local.h"
#include "ref_common.h"
#undef FRAC_EPSILON
#define FRAC_EPSILON (1.0f / 32.0f)
typedef struct
+2 -2
View File
@@ -1505,7 +1505,7 @@ Sequence_ParseBuffer
==============
*/
void Sequence_ParseBuffer( byte *buffer, int bufferSize )
static void Sequence_ParseBuffer( char *buffer, int bufferSize )
{
char symbol;
@@ -1566,7 +1566,7 @@ void Sequence_ParseFile( const char *fileName, qboolean isGlobal )
Con_Reportf( "reading sequence file: %s\n", fileName );
Sequence_ParseBuffer( buffer, bufSize );
Sequence_ParseBuffer( (char *)buffer, bufSize );
Mem_Free( buffer );
}
+5 -5
View File
@@ -39,7 +39,7 @@ void *create_decoder( int *error )
return mpg;
}
int feed_mpeg_header( void *mpg, const char *data, long bufsize, long streamsize, wavinfo_t *sc )
int feed_mpeg_header( void *mpg, const byte *data, long bufsize, long streamsize, wavinfo_t *sc )
{
mpg123_handle_t *mh = (mpg123_handle_t *)mpg;
int ret, no;
@@ -67,7 +67,7 @@ int feed_mpeg_header( void *mpg, const char *data, long bufsize, long streamsize
return 1;
}
int feed_mpeg_stream( void *mpg, const char *data, long bufsize, char *outbuf, size_t *outsize )
int feed_mpeg_stream( void *mpg, const byte *data, long bufsize, byte *outbuf, size_t *outsize )
{
switch( mpg123_decode( mpg, data, bufsize, outbuf, OUTBUF_SIZE, outsize ))
{
@@ -87,7 +87,7 @@ int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavin
if( !mh || !sc ) return 0;
ret = mpg123_replace_reader_handle( mh, f_read, f_seek, NULL );
ret = mpg123_replace_reader_handle( mh, (void *)f_read, (void *)f_seek, NULL );
if( ret != MPG123_OK )
return 0;
@@ -106,7 +106,7 @@ int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavin
return 1;
}
int read_mpeg_stream( void *mpg, char *outbuf, size_t *outsize )
int read_mpeg_stream( void *mpg, byte *outbuf, size_t *outsize )
{
switch( mpg123_read( mpg, outbuf, OUTBUF_SIZE, outsize ))
{
@@ -131,4 +131,4 @@ void close_decoder( void *mpg )
{
mpg123_delete( mpg );
mpg123_exit();
}
}
+3 -3
View File
@@ -39,10 +39,10 @@ typedef long (*pfread)( void *handle, void *buf, size_t count );
typedef long (*pfseek)( void *handle, long offset, int whence );
extern void *create_decoder( int *error );
extern int feed_mpeg_header( void *mpg, const char *data, long bufsize, long streamsize, wavinfo_t *sc );
extern int feed_mpeg_header( void *mpg, const byte *data, long bufsize, long streamsize, wavinfo_t *sc );
extern int feed_mpeg_stream( void *mpg, const char *data, long bufsize, char *outbuf, size_t *outsize );
extern int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavinfo_t *sc );
extern int read_mpeg_stream( void *mpg, char *outbuf, size_t *outsize );
extern int read_mpeg_stream(void *mpg, byte *outbuf, size_t *outsize );
extern int get_stream_pos( void *mpg );
extern int set_stream_pos( void *mpg, int curpos );
extern void close_decoder( void *mpg );
@@ -52,4 +52,4 @@ const char *get_error( void *mpeg );
}
#endif
#endif//LIBMPG_H
#endif//LIBMPG_H
+2 -31
View File
@@ -14,36 +14,7 @@ GNU General Public License for more details.
*/
#include "soundlib.h"
/*
=======================================================================
MPG123 DEFINITION
=======================================================================
*/
#define MP3_ERR -1
#define MP3_OK 0
#define MP3_NEED_MORE 1
typedef struct
{
int rate; // num samples per second (e.g. 11025 - 11 khz)
int channels; // num channels (1 - mono, 2 - stereo)
int playtime; // stream size in milliseconds
} wavinfo_t;
// custom stdio
typedef int (*pfread)( void *handle, void *buf, size_t count );
typedef int (*pfseek)( void *handle, int offset, int whence );
extern void *create_decoder( int *error );
extern int feed_mpeg_header( void *mpg, const char *data, int bufsize, int streamsize, wavinfo_t *sc );
extern int feed_mpeg_stream( void *mpg, const char *data, int bufsize, char *outbuf, size_t *outsize );
extern int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavinfo_t *sc );
extern int read_mpeg_stream( void *mpg, char *outbuf, size_t *outsize );
extern int get_stream_pos( void *mpg );
extern int set_stream_pos( void *mpg, int curpos );
extern void close_decoder( void *mpg );
const char *get_error( void *mpeg );
#include "libmpg.h"
/*
=================================================================
@@ -57,7 +28,7 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, fs_offset_t filesi
void *mpeg;
size_t pos = 0;
size_t bytesWrite = 0;
char out[OUTBUF_SIZE];
byte out[OUTBUF_SIZE];
size_t outsize, padsize;
int ret;
wavinfo_t sc;
+4 -4
View File
@@ -85,7 +85,7 @@ static void FindNextChunk( const char *name )
iff_dataPtr -= 8;
iff_lastChunk = iff_dataPtr + 8 + ((iff_chunkLen + 1) & ~1);
if( !Q_strncmp( iff_dataPtr, name, 4 ))
if( !Q_strncmp( (const char *)iff_dataPtr, name, 4 ))
return;
}
}
@@ -153,7 +153,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
// find "RIFF" chunk
FindChunk( "RIFF" );
if( !( iff_dataPtr && !Q_strncmp( iff_dataPtr + 8, "WAVE", 4 )))
if( !( iff_dataPtr && !Q_strncmp( (const char *)iff_dataPtr + 8, "WAVE", 4 )))
{
Con_DPrintf( S_ERROR "Sound_LoadWAV: %s missing 'RIFF/WAVE' chunks\n", name );
return false;
@@ -216,7 +216,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
if( iff_dataPtr )
{
if( !Q_strncmp( iff_dataPtr + 28, "mark", 4 ))
if( !Q_strncmp( (const char *)iff_dataPtr + 28, "mark", 4 ))
{
// this is not a proper parse, but it works with CoolEdit...
iff_dataPtr += 24;
@@ -287,7 +287,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
if( sound.width == 1 )
{
int i, j;
char *pData = sound.wav;
signed char *pData = (signed char *)sound.wav;
for( i = 0; i < sound.samples; i++ )
{