Browse Source

engine: fix long<->int conversion UBs

pull/2/head
Alibek Omarov 6 years ago
parent
commit
ab7a67464b
  1. 2
      common/xash3d_types.h
  2. 12
      engine/client/avi/avi.h
  3. 12
      engine/client/avi/avi_stub.c
  4. 10
      engine/client/avi/avi_win.c
  5. 2
      engine/client/cl_mobile.c
  6. 2
      engine/client/cl_video.c
  7. 2
      engine/client/input.h
  8. 8
      engine/client/ref_common.c
  9. 4
      engine/menu_int.h
  10. 2
      engine/physint.h
  11. 6
      engine/ref_api.h
  12. 2
      mainui

2
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_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 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 GAMMA ( 2.2 ) // Valve Software gamma
#define INVGAMMA ( 1.0 / 2.2 ) // back to 1.0 #define INVGAMMA ( 1.0 / 2.2 ) // back to 1.0
#define TEXGAMMA ( 0.9 ) // compensate dim textures #define TEXGAMMA ( 0.9 ) // compensate dim textures

12
engine/client/avi/avi.h

@ -19,15 +19,15 @@ GNU General Public License for more details.
// avikit.c // avikit.c
// //
typedef struct movie_state_s movie_state_t; typedef struct movie_state_s movie_state_t;
long AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ); int AVI_GetVideoFrameNumber( movie_state_t *Avi, float time );
byte *AVI_GetVideoFrame( movie_state_t *Avi, long frame ); byte *AVI_GetVideoFrame( movie_state_t *Avi, int frame );
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 );
qboolean AVI_GetAudioInfo( movie_state_t *Avi, wavdata_t *snd_info ); 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 ); 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 ); movie_state_t *AVI_LoadVideo( const char *filename, qboolean load_audio );
long AVI_TimeToSoundPosition( movie_state_t *Avi, long time ); int AVI_TimeToSoundPosition( movie_state_t *Avi, int time );
long AVI_GetVideoFrameCount( movie_state_t *Avi ); int AVI_GetVideoFrameCount( movie_state_t *Avi );
void AVI_CloseVideo( movie_state_t *Avi ); void AVI_CloseVideo( movie_state_t *Avi );
qboolean AVI_IsActive( movie_state_t *Avi ); qboolean AVI_IsActive( movie_state_t *Avi );
void AVI_FreeVideo( movie_state_t *Avi ); void AVI_FreeVideo( movie_state_t *Avi );

12
engine/client/avi/avi_stub.c

@ -16,17 +16,17 @@ GNU General Public License for more details.
#ifndef _WIN32 #ifndef _WIN32
#include "common.h" #include "common.h"
long AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ) int AVI_GetVideoFrameNumber( movie_state_t *Avi, float time )
{ {
return 0; return 0;
} }
byte *AVI_GetVideoFrame( movie_state_t *Avi, long frame ) byte *AVI_GetVideoFrame( movie_state_t *Avi, int frame )
{ {
return NULL; 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; return false;
} }
@ -36,7 +36,7 @@ qboolean AVI_GetAudioInfo( movie_state_t *Avi, wavdata_t *snd_info )
return false; 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; return 0;
} }
@ -51,12 +51,12 @@ movie_state_t *AVI_LoadVideo( const char *filename, qboolean load_audio )
return NULL; return NULL;
} }
long AVI_TimeToSoundPosition( movie_state_t *Avi, long time ) int AVI_TimeToSoundPosition( movie_state_t *Avi, int time )
{ {
return 0; return 0;
} }
long AVI_GetVideoFrameCount( movie_state_t *Avi ) int AVI_GetVideoFrameCount( movie_state_t *Avi )
{ {
return 0; return 0;
} }

10
engine/client/avi/avi_win.c

@ -251,7 +251,7 @@ qboolean AVI_ACMConvertAudio( movie_state_t *Avi )
return true; 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 ) if( !Avi->active )
return false; return false;
@ -269,7 +269,7 @@ qboolean AVI_GetVideoInfo( movie_state_t *Avi, long *xres, long *yres, float *du
} }
// returns a unique frame identifier // 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 ) if( !Avi->active )
return 0; return 0;
@ -277,7 +277,7 @@ long AVI_GetVideoFrameNumber( movie_state_t *Avi, float time )
return (time * Avi->video_fps); return (time * Avi->video_fps);
} }
long AVI_GetVideoFrameCount( movie_state_t *Avi ) int AVI_GetVideoFrameCount( movie_state_t *Avi )
{ {
if( !Avi->active ) if( !Avi->active )
return 0; return 0;
@ -285,7 +285,7 @@ long AVI_GetVideoFrameCount( movie_state_t *Avi )
return Avi->video_frames; 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 ) if( !Avi->active || !Avi->audio_stream )
return 0; 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) // 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; long result = 0;
int i; int i;

2
engine/client/cl_mobile.c

@ -95,7 +95,7 @@ static void *pfnGetNativeObject( const char *obj )
return Platform_GetNativeObject( obj ); return Platform_GetNativeObject( obj );
} }
void IN_TouchHideButtons( const char *str, qboolean hide ) void IN_TouchHideButtons( const char *str, unsigned char hide )
{ {
} }

2
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 video_duration;
static float cin_time; static float cin_time;
static int cin_frame; static int cin_frame;

2
engine/client/input.h

@ -57,7 +57,7 @@ void IN_TouchDraw( void );
void IN_TouchEditClear( void ); void IN_TouchEditClear( void );
void IN_TouchSetClientOnly( qboolean state ); void IN_TouchSetClientOnly( qboolean state );
void IN_TouchRemoveButton( const char *name ); 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_TouchSetCommand( const char *name, const char *command );
//void IN_TouchSetTexture( const char *name, const char *texture ); //void IN_TouchSetTexture( const char *name, const char *texture );
//void IN_TouchSetColor( const char *name, byte *color ); //void IN_TouchSetColor( const char *name, byte *color );

8
engine/client/ref_common.c

@ -118,7 +118,7 @@ static void pfnGetPredictedOrigin( vec3_t v )
VectorCopy( cl.simorg, 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]; return &clgame.palette[color];
} }
@ -201,13 +201,13 @@ static ref_api_t gEngfuncs =
{ {
pfnEngineGetParm, pfnEngineGetParm,
Cvar_Get, (void*)Cvar_Get,
Cvar_FindVarExt, (void*)Cvar_FindVarExt,
Cvar_VariableValue, Cvar_VariableValue,
Cvar_VariableString, Cvar_VariableString,
Cvar_SetValue, Cvar_SetValue,
Cvar_Set, Cvar_Set,
Cvar_RegisterVariable, (void*)Cvar_RegisterVariable,
Cvar_FullSet, Cvar_FullSet,
Cmd_AddRefCommand, Cmd_AddRefCommand,

4
engine/menu_int.h

@ -52,7 +52,7 @@ struct ref_viewpass_s;
typedef struct ui_enginefuncs_s typedef struct ui_enginefuncs_s
{ {
// image handlers // 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 ); void (*pfnPIC_Free)( const char *szPicName );
int (*pfnPIC_Width)( HIMAGE hPic ); int (*pfnPIC_Width)( HIMAGE hPic );
int (*pfnPIC_Height)( 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 ); int (*pfnCompareFileTime)( const char *filename1, const char *filename2, int *iCompare );
const char *(*pfnGetModeString)( int vid_mode ); 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 ); int (*COM_RemoveFile)( const char *filepath );
} ui_enginefuncs_t; } ui_enginefuncs_t;

2
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 ); int (*pfnSaveLump)( const char *filename, const int lump, void *lumpdata, int lumpsize );
// FS tools // 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 byte *(*pfnLoadImagePixels)( const char *filename, int *width, int *height );
const char* (*pfnGetModelName)( int modelindex ); const char* (*pfnGetModelName)( int modelindex );

6
engine/ref_api.h

@ -292,7 +292,7 @@ typedef struct ref_api_s
struct cl_entity_s *(*GetViewModel)( void ); struct cl_entity_s *(*GetViewModel)( void );
struct cl_entity_s *(*GetEntityByIndex)( int idx ); struct cl_entity_s *(*GetEntityByIndex)( int idx );
struct cl_entity_s *(*R_BeamGetEntity)( int index ); 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 ); qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
// brushes // brushes
@ -341,7 +341,7 @@ typedef struct ref_api_s
struct screenfade_s *(*GetScreenFade)( void ); struct screenfade_s *(*GetScreenFade)( void );
struct client_textmessage_s *(*pfnTextMessageGet)( const char *pName ); struct client_textmessage_s *(*pfnTextMessageGet)( const char *pName );
void (*GetPredictedOrigin)( vec3_t v ); 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 (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
void (*SetLocalLightLevel)( int level ); // cl.local.light_level void (*SetLocalLightLevel)( int level ); // cl.local.light_level
int (*Sys_CheckParm)( const char *flag ); int (*Sys_CheckParm)( const char *flag );
@ -377,7 +377,7 @@ typedef struct ref_api_s
// video init // video init
// try to create window // try to create window
// will call GL_SetupAttributes in case of REF_GL // 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 ); void (*R_Free_Video)( void );
// GL // GL

2
mainui

@ -1 +1 @@
Subproject commit ebc9d90fb16b713f484ddee9c6755fe6281c7fe0 Subproject commit ec653a40ba1e1d43cdd99c285fafbc205e2c7c58
Loading…
Cancel
Save