mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-23 13:24:13 +00:00
common: cleanup port.h
This commit is contained in:
parent
fb8791529e
commit
4f89288ccf
@ -20,8 +20,6 @@ GNU General Public License for more details.
|
||||
#include "build.h"
|
||||
|
||||
#if !XASH_WIN32
|
||||
|
||||
|
||||
#if XASH_APPLE
|
||||
#include <sys/syslimits.h>
|
||||
#define OS_LIB_EXT "dylib"
|
||||
@ -30,67 +28,38 @@ GNU General Public License for more details.
|
||||
#define OS_LIB_EXT "so"
|
||||
#define OPEN_COMMAND "xdg-open"
|
||||
#endif
|
||||
|
||||
#define OS_LIB_PREFIX "lib"
|
||||
|
||||
#if XASH_ANDROID
|
||||
//#if defined(LOAD_HARDFP)
|
||||
// #define POSTFIX "_hardfp"
|
||||
//#else
|
||||
#define POSTFIX
|
||||
//#endif
|
||||
#else
|
||||
#endif
|
||||
|
||||
#define VGUI_SUPPORT_DLL "libvgui_support." OS_LIB_EXT
|
||||
|
||||
// Windows-specific
|
||||
#define __cdecl
|
||||
#define __stdcall
|
||||
|
||||
#define _inline static inline
|
||||
#define FORCEINLINE inline __attribute__((always_inline))
|
||||
|
||||
#if XASH_POSIX
|
||||
#define PATH_SPLITTER "/"
|
||||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
#define O_BINARY 0 // O_BINARY is Windows extension
|
||||
#define O_TEXT 0 // O_TEXT is Windows extension
|
||||
// Windows functions to posix equivalent
|
||||
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
|
||||
#define LoadLibrary( x ) dlopen( x, RTLD_NOW )
|
||||
#define GetProcAddress( x, y ) dlsym( x, y )
|
||||
#define FreeLibrary( x ) dlclose( x )
|
||||
#define tell( a ) lseek(a, 0, SEEK_CUR)
|
||||
#define HAVE_DUP
|
||||
#endif
|
||||
#if XASH_POSIX
|
||||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#if XASH_DOS4GW
|
||||
#define PATH_SPLITTER "\\"
|
||||
#define LoadLibrary( x ) (0)
|
||||
#define GetProcAddress( x, y ) (0)
|
||||
#define FreeLibrary( x ) (0)
|
||||
#endif
|
||||
//#define MAKEWORD( a, b ) ((short int)(((unsigned char)(a))|(((short int)((unsigned char)(b)))<<8)))
|
||||
#define max( a, b ) (((a) > (b)) ? (a) : (b))
|
||||
#define min( a, b ) (((a) < (b)) ? (a) : (b))
|
||||
#define PATH_SPLITTER "/"
|
||||
#define HAVE_DUP
|
||||
|
||||
/// TODO: check if we may clean this defines, it should not appear in non-platform code!
|
||||
typedef unsigned char BYTE;
|
||||
typedef short int WORD;
|
||||
typedef unsigned int DWORD;
|
||||
typedef int LONG;
|
||||
typedef unsigned int ULONG;
|
||||
typedef int WPARAM;
|
||||
typedef unsigned int LPARAM;
|
||||
#define O_BINARY 0
|
||||
#define O_TEXT 0
|
||||
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
|
||||
#define LoadLibrary( x ) dlopen( x, RTLD_NOW )
|
||||
#define GetProcAddress( x, y ) dlsym( x, y )
|
||||
#define FreeLibrary( x ) dlclose( x )
|
||||
#elif XASH_DOS4GW
|
||||
#define PATH_SPLITTER "\\"
|
||||
#define LoadLibrary( x ) (0)
|
||||
#define GetProcAddress( x, y ) (0)
|
||||
#define FreeLibrary( x ) (0)
|
||||
#endif
|
||||
|
||||
typedef void* HANDLE;
|
||||
typedef void* HMODULE;
|
||||
typedef void* HINSTANCE;
|
||||
|
||||
typedef char* LPSTR;
|
||||
|
||||
typedef struct tagPOINT
|
||||
{
|
||||
int x, y;
|
||||
@ -108,19 +77,6 @@ GNU General Public License for more details.
|
||||
#define read _read
|
||||
#define alloca _alloca
|
||||
|
||||
// shut-up compiler warnings
|
||||
#pragma warning(disable : 4244) // MIPS
|
||||
#pragma warning(disable : 4018) // signed/unsigned mismatch
|
||||
#pragma warning(disable : 4305) // truncation from const double to float
|
||||
#pragma warning(disable : 4115) // named type definition in parentheses
|
||||
#pragma warning(disable : 4100) // unreferenced formal parameter
|
||||
#pragma warning(disable : 4127) // conditional expression is constant
|
||||
#pragma warning(disable : 4057) // differs in indirection to slightly different base types
|
||||
#pragma warning(disable : 4201) // nonstandard extension used
|
||||
#pragma warning(disable : 4706) // assignment within conditional expression
|
||||
#pragma warning(disable : 4054) // type cast' : from function pointer
|
||||
#pragma warning(disable : 4310) // cast truncates constant value
|
||||
|
||||
#define HSPRITE WINAPI_HSPRITE
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <winsock2.h>
|
||||
@ -130,12 +86,7 @@ GNU General Public License for more details.
|
||||
#define OS_LIB_PREFIX ""
|
||||
#define OS_LIB_EXT "dll"
|
||||
#define VGUI_SUPPORT_DLL "../vgui_support." OS_LIB_EXT
|
||||
#ifdef XASH_64BIT
|
||||
// windows NameForFunction not implemented yet
|
||||
#define XASH_ALLOW_SAVERESTORE_OFFSETS
|
||||
#endif
|
||||
#define HAVE_DUP
|
||||
|
||||
#endif //WIN32
|
||||
|
||||
#ifndef XASH_LOW_MEMORY
|
||||
|
@ -243,7 +243,7 @@ void CL_SignonReply( void )
|
||||
|
||||
float CL_LerpInterval( void )
|
||||
{
|
||||
return max( cl_interp->value, 1.f / cl_updaterate->value );
|
||||
return Q_max( cl_interp->value, 1.f / cl_updaterate->value );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -296,7 +296,7 @@ static float CL_LerpPoint( void )
|
||||
if( cl_interp->value > 0.001f )
|
||||
{
|
||||
// manual lerp value (goldsrc mode)
|
||||
float td = max( 0.f, cl.time - cl.mtime[0] );
|
||||
float td = Q_max( 0.f, cl.time - cl.mtime[0] );
|
||||
frac = td / CL_LerpInterval();
|
||||
}
|
||||
else if( server_frametime > 0.001f )
|
||||
@ -528,7 +528,7 @@ qboolean CL_ProcessShowTexturesCmds( usercmd_t *cmd )
|
||||
if( released & ( IN_RIGHT|IN_MOVERIGHT ))
|
||||
Cvar_SetValue( "r_showtextures", gl_showtextures->value + 1 );
|
||||
if( released & ( IN_LEFT|IN_MOVELEFT ))
|
||||
Cvar_SetValue( "r_showtextures", max( 1, gl_showtextures->value - 1 ));
|
||||
Cvar_SetValue( "r_showtextures", Q_max( 1, gl_showtextures->value - 1 ));
|
||||
oldbuttons = cmd->buttons;
|
||||
|
||||
return true;
|
||||
|
@ -1819,7 +1819,7 @@ void CL_ParseScreenShake( sizebuf_t *msg )
|
||||
clgame.shake.amplitude = (float)(word)MSG_ReadShort( msg ) * (1.0f / (float)(1<<12));
|
||||
clgame.shake.duration = (float)(word)MSG_ReadShort( msg ) * (1.0f / (float)(1<<12));
|
||||
clgame.shake.frequency = (float)(word)MSG_ReadShort( msg ) * (1.0f / (float)(1<<8));
|
||||
clgame.shake.time = cl.time + max( clgame.shake.duration, 0.01f );
|
||||
clgame.shake.time = cl.time + Q_max( clgame.shake.duration, 0.01f );
|
||||
clgame.shake.next_shake = 0.0f; // apply immediately
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ static void R_EnvShot( const float *vieworg, const char *name, qboolean skyshot,
|
||||
else cls.scrshot_action = scrshot_envshot;
|
||||
|
||||
// catch negative values
|
||||
cls.envshot_viewsize = max( 0, shotsize );
|
||||
cls.envshot_viewsize = Q_max( 0, shotsize );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -361,8 +361,8 @@ void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
|
||||
sound_t handle;
|
||||
|
||||
if( isshellcasing )
|
||||
fvol *= min ( 1.0f, ((float)zvel) / 350.0f );
|
||||
else fvol *= min ( 1.0f, ((float)zvel) / 450.0f );
|
||||
fvol *= Q_min( 1.0f, ((float)zvel) / 350.0f );
|
||||
else fvol *= Q_min( 1.0f, ((float)zvel) / 450.0f );
|
||||
|
||||
if( !COM_RandomLong( 0, 3 ) && !isshellcasing )
|
||||
pitch = COM_RandomLong( 95, 105 );
|
||||
|
@ -2172,7 +2172,7 @@ void Con_DrawSolidConsole( int lines )
|
||||
Con_DrawInput( lines );
|
||||
|
||||
y = lines - ( con.curFont->charHeight * 1.2f );
|
||||
SCR_DrawFPS( max( y, 4 )); // to avoid to hide fps counter
|
||||
SCR_DrawFPS( Q_max( y, 4 )); // to avoid to hide fps counter
|
||||
|
||||
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ void DLY_CheckNewDelayVal( void )
|
||||
}
|
||||
else
|
||||
{
|
||||
delay = min( delay, MAX_MONO_DELAY );
|
||||
delay = Q_min( delay, MAX_MONO_DELAY );
|
||||
dly->delaysamples = (int)(delay * idsp_dma_speed) << sxhires;
|
||||
|
||||
// init dly
|
||||
|
@ -809,7 +809,7 @@ void S_MixBufferUpsample2x( int count, portable_samplepair_t *pbuffer, portable_
|
||||
// zero out all paintbuffers
|
||||
void MIX_ClearAllPaintBuffers( int SampleCount, qboolean clearFilters )
|
||||
{
|
||||
int count = min( SampleCount, PAINTBUFFER_SIZE );
|
||||
int count = Q_min( SampleCount, PAINTBUFFER_SIZE );
|
||||
int i;
|
||||
|
||||
// zero out all paintbuffer data (ignore sampleCount)
|
||||
|
@ -3649,8 +3649,8 @@ search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||
slash = Q_strrchr( pattern, '/' );
|
||||
backslash = Q_strrchr( pattern, '\\' );
|
||||
colon = Q_strrchr( pattern, ':' );
|
||||
separator = max( slash, backslash );
|
||||
separator = max( separator, colon );
|
||||
separator = Q_max( slash, backslash );
|
||||
separator = Q_max( separator, colon );
|
||||
basepathlength = separator ? (separator + 1 - pattern) : 0;
|
||||
basepath = Mem_Calloc( fs_mempool, basepathlength + 1 );
|
||||
if( basepathlength ) memcpy( basepath, pattern, basepathlength );
|
||||
|
@ -456,8 +456,8 @@ void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int
|
||||
g = palSrc[i*pal_size+1];
|
||||
b = palSrc[i*pal_size+2];
|
||||
|
||||
maxcol = max( max( r, g ), b ) / 255.0f;
|
||||
mincol = min( min( r, g ), b ) / 255.0f;
|
||||
maxcol = Q_max( Q_max( r, g ), b ) / 255.0f;
|
||||
mincol = Q_min( Q_min( r, g ), b ) / 255.0f;
|
||||
|
||||
if( maxcol == 0 ) continue;
|
||||
|
||||
|
@ -291,12 +291,12 @@ static char *COM_GetItaniumName( const char * const in_name )
|
||||
len = len * 10 + ( *f - '0' );
|
||||
|
||||
// sane value
|
||||
len = min( remaining, len );
|
||||
len = Q_min( remaining, len );
|
||||
|
||||
if( len == 0 )
|
||||
goto invalid_format;
|
||||
|
||||
Q_strncpy( symbols[i], f, min( len + 1, sizeof( out_name )));
|
||||
Q_strncpy( symbols[i], f, Q_min( len + 1, sizeof( out_name )));
|
||||
f += len;
|
||||
remaining -= len;
|
||||
|
||||
@ -361,7 +361,7 @@ char **COM_ConvertToLocalPlatform( EFunctionMangleType to, const char *from, siz
|
||||
|
||||
if( at ) len = (uint)( at - prev );
|
||||
else len = (uint)Q_strlen( prev );
|
||||
Q_strncpy( symbols[i], prev, min( len + 1, sizeof( symbols[i] )));
|
||||
Q_strncpy( symbols[i], prev, Q_min( len + 1, sizeof( symbols[i] )));
|
||||
prev = at + 1;
|
||||
|
||||
if( !at )
|
||||
|
@ -107,7 +107,7 @@ void Sys_Sleep( int msec )
|
||||
if( !msec )
|
||||
return;
|
||||
|
||||
msec = min( msec, 1000 );
|
||||
msec = Q_min( msec, 1000 );
|
||||
Platform_Sleep( msec );
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ void *ANDROID_LoadLibrary( const char *dllname )
|
||||
if( !libdir[i] )
|
||||
continue;
|
||||
|
||||
Q_snprintf( path, MAX_SYSPATH, "%s/lib%s"POSTFIX"."OS_LIB_EXT, libdir[i], dllname );
|
||||
Q_snprintf( path, MAX_SYSPATH, "%s/lib%s."OS_LIB_EXT, libdir[i], dllname );
|
||||
pHandle = dlopen( path, RTLD_LAZY );
|
||||
if( pHandle )
|
||||
return pHandle;
|
||||
|
@ -15,8 +15,7 @@ GNU General Public License for more details.
|
||||
#define _GNU_SOURCE
|
||||
#include "platform/platform.h"
|
||||
#if XASH_LIB == LIB_POSIX
|
||||
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include "common.h"
|
||||
#include "library.h"
|
||||
#include "filesystem.h"
|
||||
|
@ -349,7 +349,7 @@ void Wcon_CreateConsole( void )
|
||||
// create the scrollbuffer
|
||||
GetClientRect( s_wcd.hWnd, &rect );
|
||||
|
||||
s_wcd.hwndBuffer = CreateWindowEx( WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE, "edit", NULL, CONSTYLE, 0, 0, rect.right - rect.left, min(365, rect.bottom), s_wcd.hWnd, (HMENU)EDIT_ID, host.hInst, NULL );
|
||||
s_wcd.hwndBuffer = CreateWindowEx( WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE, "edit", NULL, CONSTYLE, 0, 0, rect.right - rect.left, Q_min(365, rect.bottom), s_wcd.hWnd, (HMENU)EDIT_ID, host.hInst, NULL );
|
||||
SendMessage( s_wcd.hwndBuffer, WM_SETFONT, (WPARAM)s_wcd.hfBufferFont, 0 );
|
||||
|
||||
if( host.type == HOST_DEDICATED )
|
||||
|
@ -101,7 +101,7 @@ qboolean SV_CheckID( const char *id )
|
||||
for( filter = cidfilter; filter; filter = filter->next )
|
||||
{
|
||||
int len1 = Q_strlen( id ), len2 = Q_strlen( filter->id );
|
||||
int len = min( len1, len2 );
|
||||
int len = Q_min( len1, len2 );
|
||||
|
||||
while( filter->endTime && host.realtime > filter->endTime )
|
||||
{
|
||||
|
@ -21,6 +21,7 @@ GNU General Public License for more details.
|
||||
#include <time.h>
|
||||
#include "stdio.h"
|
||||
#include "crtlib.h"
|
||||
#include "xash3d_mathlib.h"
|
||||
|
||||
void Q_strnupr( const char *in, char *out, size_t size_out )
|
||||
{
|
||||
@ -651,7 +652,7 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
|
||||
else Q_sprintf( suffix, " bytes" );
|
||||
|
||||
// clamp to >= 0
|
||||
digitsafterdecimal = max( digitsafterdecimal, 0 );
|
||||
digitsafterdecimal = Q_max( digitsafterdecimal, 0 );
|
||||
|
||||
// if it's basically integral, don't do any decimals
|
||||
if( fabs( value - (int)value ) < 0.00001f )
|
||||
|
@ -22,6 +22,7 @@ GNU General Public License for more details.
|
||||
#endif
|
||||
|
||||
#include "build.h"
|
||||
#include "com_model.h"
|
||||
|
||||
#ifdef XASH_MSVC
|
||||
#pragma warning(disable : 4201) // nonstandard extension used
|
||||
@ -104,7 +105,7 @@ GNU General Public License for more details.
|
||||
#define VectorScale(in, scale, out) ((out)[0] = (in)[0] * (scale),(out)[1] = (in)[1] * (scale),(out)[2] = (in)[2] * (scale))
|
||||
#define VectorCompare(v1,v2) ((v1)[0]==(v2)[0] && (v1)[1]==(v2)[1] && (v1)[2]==(v2)[2])
|
||||
#define VectorDivide( in, d, out ) VectorScale( in, (1.0f / (d)), out )
|
||||
#define VectorMax(a) ( max((a)[0], max((a)[1], (a)[2])) )
|
||||
#define VectorMax(a) ( Q_max((a)[0], Q_max((a)[1], (a)[2])) )
|
||||
#define VectorAvg(a) ( ((a)[0] + (a)[1] + (a)[2]) / 3 )
|
||||
#define VectorLength(a) ( sqrt( DotProduct( a, a )))
|
||||
#define VectorLength2(a) (DotProduct( a, a ))
|
||||
|
@ -300,7 +300,7 @@ GL_TexGen
|
||||
*/
|
||||
void GL_TexGen( GLenum coord, GLenum mode )
|
||||
{
|
||||
int tmu = min( glConfig.max_texture_coords, glState.activeTMU );
|
||||
int tmu = Q_min( glConfig.max_texture_coords, glState.activeTMU );
|
||||
int bit, gen;
|
||||
|
||||
switch( coord )
|
||||
@ -350,7 +350,7 @@ GL_SetTexCoordArrayMode
|
||||
*/
|
||||
void GL_SetTexCoordArrayMode( GLenum mode )
|
||||
{
|
||||
int tmu = min( glConfig.max_texture_coords, glState.activeTMU );
|
||||
int tmu = Q_min( glConfig.max_texture_coords, glState.activeTMU );
|
||||
int bit, cmode = glState.texCoordArrayMode[tmu];
|
||||
|
||||
if( mode == GL_TEXTURE_COORD_ARRAY )
|
||||
@ -656,7 +656,7 @@ rebuild_page:
|
||||
if( i == MAX_TEXTURES && gl_showtextures->value != 1 )
|
||||
{
|
||||
// bad case, rewind to one and try again
|
||||
gEngfuncs.Cvar_SetValue( "r_showtextures", max( 1, gl_showtextures->value - 1 ));
|
||||
gEngfuncs.Cvar_SetValue( "r_showtextures", Q_max( 1, gl_showtextures->value - 1 ));
|
||||
if( ++numTries < 2 ) goto rebuild_page; // to prevent infinite loop
|
||||
}
|
||||
|
||||
|
@ -476,8 +476,8 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
|
||||
|
||||
// Now figure out the part of the projection that intersects pDecal's
|
||||
// clip box [0,0,1,1].
|
||||
Vector2Set( vUnionMin, max( vDecalMin[0], 0 ), max( vDecalMin[1], 0 ));
|
||||
Vector2Set( vUnionMax, min( vDecalMax[0], 1 ), min( vDecalMax[1], 1 ));
|
||||
Vector2Set( vUnionMin, Q_max( vDecalMin[0], 0 ), Q_max( vDecalMin[1], 0 ));
|
||||
Vector2Set( vUnionMax, Q_min( vDecalMax[0], 1 ), Q_min( vDecalMax[1], 1 ));
|
||||
|
||||
if( vUnionMin[0] < 1 && vUnionMin[1] < 1 && vUnionMax[0] > 0 && vUnionMax[1] > 0 )
|
||||
{
|
||||
|
@ -1620,7 +1620,7 @@ int GL_LoadTextureArray( const char **names, int flags )
|
||||
|
||||
mipsize = srcsize = dstsize = 0;
|
||||
|
||||
for( j = 0; j < max( 1, pic->numMips ); j++ )
|
||||
for( j = 0; j < Q_max( 1, pic->numMips ); j++ )
|
||||
{
|
||||
int width = Q_max( 1, ( pic->width >> j ));
|
||||
int height = Q_max( 1, ( pic->height >> j ));
|
||||
|
@ -379,7 +379,7 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
|
||||
RI.farClip = R_GetFarClip();
|
||||
|
||||
zNear = 4.0f;
|
||||
zFar = max( 256.0f, RI.farClip );
|
||||
zFar = Q_max( 256.0f, RI.farClip );
|
||||
|
||||
yMax = zNear * tan( RI.fov_y * M_PI_F / 360.0f );
|
||||
yMin = -yMax;
|
||||
|
@ -2934,8 +2934,8 @@ static qboolean R_CheckLightMap( msurface_t *fa )
|
||||
}
|
||||
else
|
||||
{
|
||||
smax = min( smax, 132 );
|
||||
tmax = min( tmax, 132 );
|
||||
smax = Q_min( smax, 132 );
|
||||
tmax = Q_min( tmax, 132 );
|
||||
//Host_MapDesignError( "R_RenderBrushPoly: bad surface extents: %d %d", fa->extents[0], fa->extents[1] );
|
||||
memset( temp, 255, sizeof( temp ) );
|
||||
}
|
||||
|
@ -480,8 +480,8 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
|
||||
|
||||
// Now figure out the part of the projection that intersects pDecal's
|
||||
// clip box [0,0,1,1].
|
||||
Vector2Set( vUnionMin, max( vDecalMin[0], 0 ), max( vDecalMin[1], 0 ));
|
||||
Vector2Set( vUnionMax, min( vDecalMax[0], 1 ), min( vDecalMax[1], 1 ));
|
||||
Vector2Set( vUnionMin, Q_max( vDecalMin[0], 0 ), Q_max( vDecalMin[1], 0 ));
|
||||
Vector2Set( vUnionMax, Q_min( vDecalMax[0], 1 ), Q_min( vDecalMax[1], 1 ));
|
||||
|
||||
if( vUnionMin[0] < 1 && vUnionMin[1] < 1 && vUnionMax[0] > 0 && vUnionMax[1] > 0 )
|
||||
{
|
||||
|
@ -496,7 +496,7 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
|
||||
RI.farClip = R_GetFarClip();
|
||||
|
||||
zNear = 4.0f;
|
||||
zFar = max( 256.0f, RI.farClip );
|
||||
zFar = Q_max( 256.0f, RI.farClip );
|
||||
|
||||
yMax = zNear * tan( RI.fov_y * M_PI_F / 360.0f );
|
||||
yMin = -yMax;
|
||||
|
Loading…
x
Reference in New Issue
Block a user