2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-22 01:45:19 +01:00

engine: fix some const qualifier lose and pointer-to-int casts

This commit is contained in:
Alibek Omarov 2021-07-20 16:02:59 +03:00
parent c3da9d8c8f
commit 0efc5e82ec
22 changed files with 43 additions and 40 deletions

View File

@ -2535,7 +2535,7 @@ CL_ServerCommand
send command to a server
====================
*/
void CL_ServerCommand( qboolean reliable, char *fmt, ... )
void CL_ServerCommand( qboolean reliable, const char *fmt, ... )
{
char string[MAX_SYSPATH];
va_list argptr;

View File

@ -990,13 +990,12 @@ void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height
{
int curLength = 0;
if( !con.curFont ) return;
if( height ) *height = con.curFont->charHeight;
if( !length ) return;
*length = 0;
if( !con.curFont ) return;
if( height ) *height = con.curFont->charHeight;
while( *pText )
{
byte c = *pText;

View File

@ -29,7 +29,7 @@ typedef struct
typedef struct keyname_s
{
char *name; // key name
const char *name; // key name
int keynum; // key number
const char *binding; // default bind
} keyname_t;

View File

@ -1773,7 +1773,7 @@ void S_Music_f( void )
else if( c == 2 )
{
string intro, main, track;
char *ext[] = { "mp3", "wav" };
const char *ext[] = { "mp3", "wav" };
int i;
Q_strncpy( track, Cmd_Argv( 1 ), sizeof( track ));

View File

@ -15,9 +15,9 @@ GNU General Public License for more details.
#include "common.h"
static char *date = __DATE__ ;
static char *mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static const char *date = __DATE__ ;
static const char *mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static const char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
// returns days since Apr 1 2015
int Q_buildnum( void )

View File

@ -25,7 +25,7 @@ typedef enum
T_COUNT
} cvartype_t;
char *cvartypes[] = { NULL, "BOOL" , "NUMBER", "LIST", "STRING" };
const char *cvartypes[] = { NULL, "BOOL", "NUMBER", "LIST", "STRING" };
typedef struct parserstate_s
{

View File

@ -463,7 +463,7 @@ typedef struct cmd_s
} cmd_t;
static int cmd_argc;
static char *cmd_args = NULL;
static const char *cmd_args = NULL;
static char *cmd_argv[MAX_CMD_TOKENS];
static char cmd_tokenized[MAX_CMD_BUFFER]; // will have 0 bytes inserted
static cmd_t *cmd_functions; // possible commands to execute
@ -560,7 +560,7 @@ are inserted in the apropriate place, The argv array
will point into this temporary buffer.
============
*/
void Cmd_TokenizeString( char *text )
void Cmd_TokenizeString( const char *text )
{
char cmd_token[MAX_CMD_BUFFER];
int i;
@ -577,7 +577,7 @@ void Cmd_TokenizeString( char *text )
while( 1 )
{
// skip whitespace up to a /n
while( *text && ((byte)*text) <= ' ' && *text != '\r' && *text != '\n' )
while( *text && *text <= ' ' && *text != '\r' && *text != '\n' )
text++;
if( *text == '\n' || *text == '\r' )
@ -885,7 +885,7 @@ Cmd_ExecuteString
A complete command line has been parsed, so try to execute it
============
*/
void Cmd_ExecuteString( char *text )
void Cmd_ExecuteString( const char *text )
{
cmd_t *cmd = NULL;
cmdalias_t *a = NULL;

View File

@ -498,8 +498,8 @@ int Cmd_ListMaps( search_t *t , char *lastmapname, size_t len );
qboolean Cmd_GetMapList( const char *s, char *completedname, int length );
qboolean Cmd_GetDemoList( const char *s, char *completedname, int length );
qboolean Cmd_GetMovieList( const char *s, char *completedname, int length );
void Cmd_TokenizeString( char *text );
void Cmd_ExecuteString( char *text );
void Cmd_TokenizeString( const char *text );
void Cmd_ExecuteString( const char *text );
void Cmd_ForwardToServer( void );
//
@ -869,14 +869,14 @@ void SV_CreateDecal( sizebuf_t *msg, const float *origin, int decalIndex, int en
void Log_Printf( const char *fmt, ... ) _format( 1 );
void SV_BroadcastCommand( const char *fmt, ... ) _format( 1 );
qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
void SV_BroadcastPrintf( struct sv_client_s *ignore, char *fmt, ... ) _format( 2 );
void SV_BroadcastPrintf( struct sv_client_s *ignore, const char *fmt, ... ) _format( 2 );
int R_CreateDecalList( struct decallist_s *pList );
void R_ClearAllDecals( void );
void CL_ClearStaticEntities( void );
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position );
struct cl_entity_s *CL_GetEntityByIndex( int index );
struct player_info_s *CL_GetPlayerInfo( int playerIndex );
void CL_ServerCommand( qboolean reliable, char *fmt, ... ) _format( 2 );
void CL_ServerCommand( qboolean reliable, const char *fmt, ... ) _format( 2 );
void CL_HudMessage( const char *pMessage );
const char *CL_MsgInfo( int cmd );
void SV_DrawDebugTriangles( void );

View File

@ -285,7 +285,7 @@ struct sigaction oldFilter;
#define STACK_BACKTRACE_STR "Stack backtrace:\n"
#define STACK_DUMP_STR_LEN 12
#define STACK_DUMP_STR "Stack dump:\n"
#define ALIGN( x, y ) (((int) (x) + ((y)-1)) & ~((y)-1))
#define ALIGN( x, y ) (((uintptr_t) (x) + ((y)-1)) & ~((y)-1))
static void Sys_Crash( int signal, siginfo_t *si, void *context)
{

View File

@ -18,8 +18,12 @@ GNU General Public License for more details.
#include "cvardef.h"
#ifdef XASH_64BIT
#define CVAR_SENTINEL 0xDEADBEEFDEADBEEF
#else
#define CVAR_SENTINEL 0xDEADBEEF
#define CVAR_CHECK_SENTINEL( cv ) ((uint)(cv)->next == CVAR_SENTINEL)
#endif
#define CVAR_CHECK_SENTINEL( cv ) ((uintptr_t)(cv)->next == CVAR_SENTINEL)
// NOTE: if this is changed, it must be changed in cvardef.h too
typedef struct convar_s
@ -46,7 +50,7 @@ typedef struct convar_s
#define FCVAR_LOCALONLY (1<<22) // can be set only from local buffers
#define CVAR_DEFINE( cv, cvname, cvstr, cvflags, cvdesc ) \
convar_t cv = { cvname, cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, cvdesc, NULL }
convar_t cv = { (char*)cvname, (char*)cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, (char*)cvdesc, NULL }
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) \
CVAR_DEFINE( cv, #cv, cvstr, cvflags, cvdesc )

View File

@ -74,7 +74,7 @@ typedef struct stringlist_s
typedef struct wadtype_s
{
char *ext;
const char *ext;
signed char type;
} wadtype_t;

View File

@ -517,7 +517,7 @@ Netchan_OutOfBandPrint
Sends a text message in an out-of-band datagram
================
*/
void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, char *format, ... )
void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, const char *format, ... )
{
char string[MAX_PRINT_MSG];
va_list argptr;

View File

@ -536,7 +536,7 @@ static int NET_StringToSockaddr( const char *s, struct sockaddr *sadr, qboolean
NET_AdrToString
====================
*/
char *NET_AdrToString( const netadr_t a )
const char *NET_AdrToString( const netadr_t a )
{
if( a.type == NA_LOOPBACK )
return "loopback";
@ -548,7 +548,7 @@ char *NET_AdrToString( const netadr_t a )
NET_BaseAdrToString
====================
*/
char *NET_BaseAdrToString( const netadr_t a )
const char *NET_BaseAdrToString( const netadr_t a )
{
if( a.type == NA_LOOPBACK )
return "loopback";

View File

@ -53,8 +53,8 @@ qboolean NET_IsActive( void );
qboolean NET_IsConfigured( void );
void NET_Config( qboolean net_enable );
qboolean NET_IsLocalAddress( netadr_t adr );
char *NET_AdrToString( const netadr_t a );
char *NET_BaseAdrToString( const netadr_t a );
const char *NET_AdrToString( const netadr_t a );
const char *NET_BaseAdrToString( const netadr_t a );
qboolean NET_IsReservedAdr( netadr_t a );
qboolean NET_CompareClassBAdr( netadr_t a, netadr_t b );
qboolean NET_StringToAdr( const char *string, netadr_t *adr );

View File

@ -297,7 +297,7 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename );
void Netchan_Transmit( netchan_t *chan, int lengthInBytes, byte *data );
void Netchan_TransmitBits( netchan_t *chan, int lengthInBits, byte *data );
void Netchan_OutOfBand( int net_socket, netadr_t adr, int length, byte *data );
void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, char *format, ... ) _format( 3 );
void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, const char *format, ... ) _format( 3 );
qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg );
void Netchan_UpdateProgress( netchan_t *chan );
qboolean Netchan_IncomingReady( netchan_t *chan );

View File

@ -118,7 +118,7 @@ Sys_GetCurrentUser
returns username for current profile
================
*/
char *Sys_GetCurrentUser( void )
const char *Sys_GetCurrentUser( void )
{
#if XASH_WIN32
static string s_userName;

View File

@ -48,7 +48,7 @@ writes into struct by offsets not names
void Sys_Sleep( int msec );
double Sys_DoubleTime( void );
char *Sys_GetClipboardData( void );
char *Sys_GetCurrentUser( void );
const char *Sys_GetCurrentUser( void );
int Sys_CheckParm( const char *parm );
void Sys_Warn( const char *format, ... ) _format( 1 );
void Sys_Error( const char *error, ... ) _format( 1 );

View File

@ -384,7 +384,7 @@ typedef enum _fieldtypes
typedef struct
{
FIELDTYPE fieldType;
char *fieldName;
const char *fieldName;
int fieldOffset;
short fieldSize;
short flags;

View File

@ -510,7 +510,7 @@ void SV_WaterMove( edict_t *ent );
// sv_send.c
//
void SV_SendClientMessages( void );
void SV_ClientPrintf( sv_client_t *cl, char *fmt, ... ) _format( 2 );
void SV_ClientPrintf( sv_client_t *cl, const char *fmt, ... ) _format( 2 );
void SV_BroadcastCommand( const char *fmt, ... ) _format( 1 );
//
@ -532,7 +532,7 @@ void SV_ClientThink( sv_client_t *cl, usercmd_t *cmd );
void SV_ExecuteClientMessage( sv_client_t *cl, sizebuf_t *msg );
void SV_ConnectionlessPacket( netadr_t from, sizebuf_t *msg );
edict_t *SV_FakeConnect( const char *netname );
void SV_ExecuteClientCommand( sv_client_t *cl, char *s );
void SV_ExecuteClientCommand( sv_client_t *cl, const char *s );
void SV_RunCmd( sv_client_t *cl, usercmd_t *ucmd, int random_seed );
void SV_BuildReconnect( sizebuf_t *msg );
qboolean SV_IsPlayerIndex( int idx );
@ -540,7 +540,7 @@ int SV_CalcPing( sv_client_t *cl );
void SV_InitClientMove( void );
void SV_UpdateServerInfo( void );
void SV_EndRedirect( void );
void SV_RejectConnection( netadr_t from, char *fmt, ... ) _format( 2 );
void SV_RejectConnection( netadr_t from, const char *fmt, ... ) _format( 2 );
//
// sv_cmds.c

View File

@ -137,7 +137,7 @@ SV_RejectConnection
Rejects connection request and sends back a message
================
*/
void SV_RejectConnection( netadr_t from, char *fmt, ... )
void SV_RejectConnection( netadr_t from, const char *fmt, ... )
{
char text[1024];
va_list argptr;
@ -2118,7 +2118,7 @@ ucmd_t ucmds[] =
SV_ExecuteUserCommand
==================
*/
void SV_ExecuteClientCommand( sv_client_t *cl, char *s )
void SV_ExecuteClientCommand( sv_client_t *cl, const char *s )
{
ucmd_t *u;

View File

@ -25,7 +25,7 @@ SV_ClientPrintf
Sends text across to be displayed if the level passes
=================
*/
void SV_ClientPrintf( sv_client_t *cl, char *fmt, ... )
void SV_ClientPrintf( sv_client_t *cl, const char *fmt, ... )
{
char string[MAX_SYSPATH];
va_list argptr;
@ -48,7 +48,7 @@ SV_BroadcastPrintf
Sends text to all active clients
=================
*/
void SV_BroadcastPrintf( sv_client_t *ignore, char *fmt, ... )
void SV_BroadcastPrintf( sv_client_t *ignore, const char *fmt, ... )
{
char string[MAX_SYSPATH];
va_list argptr;

View File

@ -810,7 +810,7 @@ static char *StoreHashTable( SAVERESTOREDATA *pSaveData )
{
for( i = 0; i < pSaveData->tokenCount; i++ )
{
char *pszToken = pSaveData->pTokens[i] ? pSaveData->pTokens[i] : "";
const char *pszToken = pSaveData->pTokens[i] ? pSaveData->pTokens[i] : "";
// just copy the token byte-by-byte
while( *pszToken )