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; @@ -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

12
engine/client/avi/avi.h

@ -19,15 +19,15 @@ GNU General Public License for more details. @@ -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 );

12
engine/client/avi/avi_stub.c

@ -16,17 +16,17 @@ GNU General Public License for more details. @@ -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 ) @@ -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 ) @@ -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;
}

10
engine/client/avi/avi_win.c

@ -251,7 +251,7 @@ qboolean AVI_ACMConvertAudio( movie_state_t *Avi ) @@ -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 @@ -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 ) @@ -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 ) @@ -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 ) @@ -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;

2
engine/client/cl_mobile.c

@ -95,7 +95,7 @@ static void *pfnGetNativeObject( const char *obj ) @@ -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 )
{
}

2
engine/client/cl_video.c

@ -24,7 +24,7 @@ AVI PLAYING @@ -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;

2
engine/client/input.h

@ -57,7 +57,7 @@ void IN_TouchDraw( void ); @@ -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 );

8
engine/client/ref_common.c

@ -118,7 +118,7 @@ static void pfnGetPredictedOrigin( vec3_t v ) @@ -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 = @@ -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,

4
engine/menu_int.h

@ -52,7 +52,7 @@ struct ref_viewpass_s; @@ -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 @@ -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;

2
engine/physint.h

@ -102,7 +102,7 @@ typedef struct server_physics_api_s @@ -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 );

6
engine/ref_api.h

@ -292,7 +292,7 @@ typedef struct ref_api_s @@ -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 @@ -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 @@ -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

2
mainui

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