From ab7a67464b6f6ea92a46a879e9220bfa3bc8d5e5 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 2 May 2019 19:05:09 +0300 Subject: [PATCH] engine: fix long<->int conversion UBs --- common/xash3d_types.h | 2 +- engine/client/avi/avi.h | 12 ++++++------ engine/client/avi/avi_stub.c | 12 ++++++------ engine/client/avi/avi_win.c | 10 +++++----- engine/client/cl_mobile.c | 2 +- engine/client/cl_video.c | 2 +- engine/client/input.h | 2 +- engine/client/ref_common.c | 8 ++++---- engine/menu_int.h | 4 ++-- engine/physint.h | 2 +- engine/ref_api.h | 6 +++--- mainui | 2 +- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/common/xash3d_types.h b/common/xash3d_types.h index 3f55ca55..ebd94bf9 100644 --- a/common/xash3d_types.h +++ b/common/xash3d_types.h @@ -48,7 +48,7 @@ typedef integer64 longtime_t; #define MAX_MODS 512 // environment games that engine can keep visible #define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions -#define BIT( n ) ( 1 << ( n )) +#define BIT( n ) ( 1U << ( n )) #define GAMMA ( 2.2 ) // Valve Software gamma #define INVGAMMA ( 1.0 / 2.2 ) // back to 1.0 #define TEXGAMMA ( 0.9 ) // compensate dim textures diff --git a/engine/client/avi/avi.h b/engine/client/avi/avi.h index 6cf49dff..6435a161 100644 --- a/engine/client/avi/avi.h +++ b/engine/client/avi/avi.h @@ -19,15 +19,15 @@ GNU General Public License for more details. // avikit.c // typedef struct movie_state_s movie_state_t; -long AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ); -byte *AVI_GetVideoFrame( movie_state_t *Avi, long frame ); -qboolean AVI_GetVideoInfo( movie_state_t *Avi, long *xres, long *yres, float *duration ); +int AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ); +byte *AVI_GetVideoFrame( movie_state_t *Avi, int frame ); +qboolean AVI_GetVideoInfo( movie_state_t *Avi, int *xres, int *yres, float *duration ); qboolean AVI_GetAudioInfo( movie_state_t *Avi, wavdata_t *snd_info ); -long AVI_GetAudioChunk( movie_state_t *Avi, char *audiodata, long offset, long length ); +int AVI_GetAudioChunk( movie_state_t *Avi, char *audiodata, int offset, int length ); void AVI_OpenVideo( movie_state_t *Avi, const char *filename, qboolean load_audio, int quiet ); movie_state_t *AVI_LoadVideo( const char *filename, qboolean load_audio ); -long AVI_TimeToSoundPosition( movie_state_t *Avi, long time ); -long AVI_GetVideoFrameCount( movie_state_t *Avi ); +int AVI_TimeToSoundPosition( movie_state_t *Avi, int time ); +int AVI_GetVideoFrameCount( movie_state_t *Avi ); void AVI_CloseVideo( movie_state_t *Avi ); qboolean AVI_IsActive( movie_state_t *Avi ); void AVI_FreeVideo( movie_state_t *Avi ); diff --git a/engine/client/avi/avi_stub.c b/engine/client/avi/avi_stub.c index 0ea1db8c..6a5202a8 100644 --- a/engine/client/avi/avi_stub.c +++ b/engine/client/avi/avi_stub.c @@ -16,17 +16,17 @@ GNU General Public License for more details. #ifndef _WIN32 #include "common.h" -long AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ) +int AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ) { return 0; } -byte *AVI_GetVideoFrame( movie_state_t *Avi, long frame ) +byte *AVI_GetVideoFrame( movie_state_t *Avi, int frame ) { return NULL; } -qboolean AVI_GetVideoInfo( movie_state_t *Avi, long *xres, long *yres, float *duration ) +qboolean AVI_GetVideoInfo( movie_state_t *Avi, int *xres, int *yres, float *duration ) { return false; } @@ -36,7 +36,7 @@ qboolean AVI_GetAudioInfo( movie_state_t *Avi, wavdata_t *snd_info ) return false; } -long AVI_GetAudioChunk( movie_state_t *Avi, char *audiodata, long offset, long length ) +int AVI_GetAudioChunk( movie_state_t *Avi, char *audiodata, int offset, int length ) { return 0; } @@ -51,12 +51,12 @@ movie_state_t *AVI_LoadVideo( const char *filename, qboolean load_audio ) return NULL; } -long AVI_TimeToSoundPosition( movie_state_t *Avi, long time ) +int AVI_TimeToSoundPosition( movie_state_t *Avi, int time ) { return 0; } -long AVI_GetVideoFrameCount( movie_state_t *Avi ) +int AVI_GetVideoFrameCount( movie_state_t *Avi ) { return 0; } diff --git a/engine/client/avi/avi_win.c b/engine/client/avi/avi_win.c index 19651c14..abedebab 100644 --- a/engine/client/avi/avi_win.c +++ b/engine/client/avi/avi_win.c @@ -251,7 +251,7 @@ qboolean AVI_ACMConvertAudio( movie_state_t *Avi ) return true; } -qboolean AVI_GetVideoInfo( movie_state_t *Avi, long *xres, long *yres, float *duration ) +qboolean AVI_GetVideoInfo( movie_state_t *Avi, int *xres, int *yres, float *duration ) { if( !Avi->active ) return false; @@ -269,7 +269,7 @@ qboolean AVI_GetVideoInfo( movie_state_t *Avi, long *xres, long *yres, float *du } // returns a unique frame identifier -long AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ) +int AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ) { if( !Avi->active ) return 0; @@ -277,7 +277,7 @@ long AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ) return (time * Avi->video_fps); } -long AVI_GetVideoFrameCount( movie_state_t *Avi ) +int AVI_GetVideoFrameCount( movie_state_t *Avi ) { if( !Avi->active ) return 0; @@ -285,7 +285,7 @@ long AVI_GetVideoFrameCount( movie_state_t *Avi ) return Avi->video_frames; } -long AVI_TimeToSoundPosition( movie_state_t *Avi, long time ) +int AVI_TimeToSoundPosition( movie_state_t *Avi, int time ) { if( !Avi->active || !Avi->audio_stream ) return 0; @@ -382,7 +382,7 @@ qboolean AVI_SeekPosition( movie_state_t *Avi, dword offset ) } // get a chunk of audio from the stream (in bytes) -long AVI_GetAudioChunk( movie_state_t *Avi, char *audiodata, long offset, long length ) +int AVI_GetAudioChunk( movie_state_t *Avi, char *audiodata, int offset, int length ) { long result = 0; int i; diff --git a/engine/client/cl_mobile.c b/engine/client/cl_mobile.c index d3480c97..6e43cb59 100644 --- a/engine/client/cl_mobile.c +++ b/engine/client/cl_mobile.c @@ -95,7 +95,7 @@ static void *pfnGetNativeObject( const char *obj ) return Platform_GetNativeObject( obj ); } -void IN_TouchHideButtons( const char *str, qboolean hide ) +void IN_TouchHideButtons( const char *str, unsigned char hide ) { } diff --git a/engine/client/cl_video.c b/engine/client/cl_video.c index 87bc933a..3928abf7 100644 --- a/engine/client/cl_video.c +++ b/engine/client/cl_video.c @@ -24,7 +24,7 @@ AVI PLAYING ================================================================= */ -static long xres, yres; +static int xres, yres; static float video_duration; static float cin_time; static int cin_frame; diff --git a/engine/client/input.h b/engine/client/input.h index dbfd0a8a..148b1f3f 100644 --- a/engine/client/input.h +++ b/engine/client/input.h @@ -57,7 +57,7 @@ void IN_TouchDraw( void ); void IN_TouchEditClear( void ); void IN_TouchSetClientOnly( qboolean state ); void IN_TouchRemoveButton( const char *name ); -void IN_TouchHideButtons( const char *name, qboolean hide ); +void IN_TouchHideButtons( const char *name, unsigned char hide ); //void IN_TouchSetCommand( const char *name, const char *command ); //void IN_TouchSetTexture( const char *name, const char *texture ); //void IN_TouchSetColor( const char *name, byte *color ); diff --git a/engine/client/ref_common.c b/engine/client/ref_common.c index 683e23f1..8782a1dd 100644 --- a/engine/client/ref_common.c +++ b/engine/client/ref_common.c @@ -118,7 +118,7 @@ static void pfnGetPredictedOrigin( vec3_t v ) VectorCopy( cl.simorg, v ); } -static color24 *pfnCL_GetPaletteColor(int color) // clgame.palette[color] +static color24 *pfnCL_GetPaletteColor( int color ) // clgame.palette[color] { return &clgame.palette[color]; } @@ -201,13 +201,13 @@ static ref_api_t gEngfuncs = { pfnEngineGetParm, - Cvar_Get, - Cvar_FindVarExt, + (void*)Cvar_Get, + (void*)Cvar_FindVarExt, Cvar_VariableValue, Cvar_VariableString, Cvar_SetValue, Cvar_Set, - Cvar_RegisterVariable, + (void*)Cvar_RegisterVariable, Cvar_FullSet, Cmd_AddRefCommand, diff --git a/engine/menu_int.h b/engine/menu_int.h index ab59bc48..3dfd0f91 100644 --- a/engine/menu_int.h +++ b/engine/menu_int.h @@ -52,7 +52,7 @@ struct ref_viewpass_s; typedef struct ui_enginefuncs_s { // image handlers - HIMAGE (*pfnPIC_Load)( const char *szPicName, const byte *ucRawImage, long ulRawImageSize, long flags ); + HIMAGE (*pfnPIC_Load)( const char *szPicName, const byte *ucRawImage, int ulRawImageSize, int flags ); void (*pfnPIC_Free)( const char *szPicName ); int (*pfnPIC_Width)( HIMAGE hPic ); int (*pfnPIC_Height)( HIMAGE hPic ); @@ -168,7 +168,7 @@ typedef struct ui_enginefuncs_s int (*pfnCompareFileTime)( const char *filename1, const char *filename2, int *iCompare ); const char *(*pfnGetModeString)( int vid_mode ); - int (*COM_SaveFile)( const char *filename, const void *data, long len ); + int (*COM_SaveFile)( const char *filename, const void *data, int len ); int (*COM_RemoveFile)( const char *filepath ); } ui_enginefuncs_t; diff --git a/engine/physint.h b/engine/physint.h index dcc15fd1..e1e15c42 100644 --- a/engine/physint.h +++ b/engine/physint.h @@ -102,7 +102,7 @@ typedef struct server_physics_api_s int (*pfnSaveLump)( const char *filename, const int lump, void *lumpdata, int lumpsize ); // FS tools - int (*pfnSaveFile)( const char *filename, const void *data, long len ); + int (*pfnSaveFile)( const char *filename, const void *data, int len ); const byte *(*pfnLoadImagePixels)( const char *filename, int *width, int *height ); const char* (*pfnGetModelName)( int modelindex ); diff --git a/engine/ref_api.h b/engine/ref_api.h index b3cfc00a..5c5d4696 100644 --- a/engine/ref_api.h +++ b/engine/ref_api.h @@ -292,7 +292,7 @@ typedef struct ref_api_s struct cl_entity_s *(*GetViewModel)( void ); struct cl_entity_s *(*GetEntityByIndex)( int idx ); struct cl_entity_s *(*R_BeamGetEntity)( int index ); - struct cl_entity_s *(*CL_GetWaterEntity)( vec3_t p ); + struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p ); qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType ); // brushes @@ -341,7 +341,7 @@ typedef struct ref_api_s struct screenfade_s *(*GetScreenFade)( void ); struct client_textmessage_s *(*pfnTextMessageGet)( const char *pName ); void (*GetPredictedOrigin)( vec3_t v ); - byte *(*CL_GetPaletteColor)(int color); // clgame.palette[color] + color24 *(*CL_GetPaletteColor)(int color); // clgame.palette[color] void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL void (*SetLocalLightLevel)( int level ); // cl.local.light_level int (*Sys_CheckParm)( const char *flag ); @@ -377,7 +377,7 @@ typedef struct ref_api_s // video init // try to create window // will call GL_SetupAttributes in case of REF_GL - int (*R_Init_Video)( int type ); + qboolean (*R_Init_Video)( int type ); void (*R_Free_Video)( void ); // GL diff --git a/mainui b/mainui index ebc9d90f..ec653a40 160000 --- a/mainui +++ b/mainui @@ -1 +1 @@ -Subproject commit ebc9d90fb16b713f484ddee9c6755fe6281c7fe0 +Subproject commit ec653a40ba1e1d43cdd99c285fafbc205e2c7c58