Compare commits

...

44 Commits

Author SHA1 Message Date
Andrey Akhmichin
520fc33394 utils: mdldec: fix wrong conditions. 2023-12-28 20:36:39 +03:00
Alibek Omarov
f705a7cd26 common: xash3d_types: another attempt to properly check static asserts availability 2023-12-28 17:32:07 +03:00
Alibek Omarov
65bfff69d0 engine: wscript: always require librt on Linux since we need it for Platform_SetTimer implementation 2023-12-27 04:14:19 +03:00
Alibek Omarov
9d8ba03f5e common: xash3d_types: fix static_assert macro 2023-12-27 03:10:41 +03:00
Alibek Omarov
778b8ede58 engine: platform: linux: add forgotten _GNU_SOURCE at the top of the file to enable gettid extension 2023-12-27 03:10:20 +03:00
Alibek Omarov
f8a1a2ed71 engine: platform: linux: add missing math.h include 2023-12-26 18:56:30 +03:00
mittorn
b4a7c266b5 platform/linux: implement debug timers and cl_maxframetime to catch very long frames on debugger 2023-12-25 14:22:20 +03:00
mittorn
a488f79852 ref_gl: workaround freezes on adreno with vbo on dlighted decals 2023-12-25 14:21:21 +03:00
Alibek Omarov
b290046503 ref: gl: remove hidden parm -gl-allow-vbo-dontuse needed to activate VBO renderer 2023-12-19 17:55:10 +03:00
Dmitry Toroshchin
e8409cee8b ref_gl: vbo: do not do zero-length drawcalls (fix glError on vivante) 2023-12-19 17:55:10 +03:00
mittorn
1d4d355b38 ref_gl: vbo: fix binding garbade texture after changelevel, fix wpoly counter 2023-12-19 17:55:10 +03:00
mittorn
dfe12535a5 ref_gl: vbo: disable R_TextureRandomTiling implementation until will be fixed 2023-12-19 17:55:10 +03:00
mittorn
74946100f1 ref_gl: fix not restoring static lightmap after decals 2023-12-19 17:55:10 +03:00
mittorn
9a1717915c ref_gl: vbo: apply a1batross's patch for uint index switch 2023-12-19 17:55:10 +03:00
mittorn
3691eb6e48 ref_gl: vbo: fix incorrect lightmap index, optimize loading maps with very big lightmap count, fix clouds drawing after VBO 2023-12-19 17:55:10 +03:00
mittorn
3bb7471fd3 ref_gl: vbo: fix lightmap0 processing, remove ilightmap 2023-12-19 17:55:10 +03:00
mittorn
74e09ddb12 ref_gl: change state management in vbo renderer 2023-12-19 17:55:10 +03:00
mittorn
6b73d056b2 ref_gl: vbo dlights refactiring 2023-12-19 17:55:10 +03:00
mittorn
3e7847551a ref_gl: add ability to skip uploading unused data (disabled) 2023-12-19 17:55:10 +03:00
mittorn
91d92935fa ref_gl: try avoid gpu locking on dlights in vbo renderer 2023-12-19 17:55:10 +03:00
mittorn
eff033298a ref_gl: disable singlepass detail renderer, use correct fog color multipliers in VBO 2023-12-19 17:55:10 +03:00
mittorn
3a8f4961bc ref_gl: fix rarely broken texturechain on some big maps 2023-12-19 17:55:10 +03:00
mittorn
b81f94518a ref_gl: fix out-by-one when all lightstyles are used. Also fix broken in this case in vbo after previous fix 2023-12-19 17:55:10 +03:00
Alibek Omarov
96f7f5457d engine: print all supported and enabled features 2023-12-17 17:51:15 +03:00
Alibek Omarov
498ec6b4f1 engine: client: print enabled features after server connect if it's not a local game 2023-12-17 17:44:05 +03:00
Alibek Omarov
607e62a1ae engine: client: sanitize legacy protocol supported engine features flags
Do not enable what can't be enabled in current protocol.
2023-12-17 17:44:05 +03:00
Alibek Omarov
d41a80bc2c engine: add mask to sanitize possible engine features bits 2023-12-17 17:43:51 +03:00
Alibek Omarov
643bec4071 engine: client: set max FPS when recording with fps_max 0 2023-12-16 22:02:26 +03:00
Alibek Omarov
a7e84230c3 ref: gl: use world version to enable large lightmaps for BSP2 automatically 2023-12-15 07:38:25 +03:00
Alibek Omarov
c96cf7e22d engine: expose world version through RefAPI 2023-12-15 07:38:07 +03:00
Alibek Omarov
46c61660cf engine: expose world BSP version through world global structure 2023-12-15 07:37:40 +03:00
Alibek Omarov
f6fecce52b wscript: do not recurse into ref_soft when BSP2 is enabled 2023-12-15 07:29:38 +03:00
Alibek Omarov
54a5947a3c engine: remove MSGBOX macro 2023-12-15 06:40:04 +03:00
Andrey Akhmichin
521bc675a2 utils: mdldec: smd.c: simplify proper bone rotation code. 2023-12-14 14:55:40 +03:00
Andrey Akhmichin
845cee2578 utils: mdldec: smd.c: prevent division by zero. 2023-12-14 14:54:49 +03:00
Alibek Omarov
93ceb0e4ed engine: client: split the sprites indices only when loading new sprite. Scan the whole array when searching.
Fixes incorrect sprite loading in XDM
2023-12-14 03:12:47 +03:00
Alibek Omarov
13aab4e59c engine: server: fix off-by-one error in Voice_Set/GetClientListening 2023-12-13 14:56:55 +03:00
Alibek Omarov
36c2f9e9f2 engine: refactor rcon redirect, don't make it depend on global object 2023-12-13 14:56:27 +03:00
Alibek Omarov
514da0ffa9 engine: host: do not depend on Sys_Sleep accuracy, instead allocate a timewindow that decrases with each skipped frame 2023-12-11 07:12:44 +03:00
Alibek Omarov
37b8d5da79 mainui: update 2023-12-11 07:12:30 +03:00
Alibek Omarov
b5d602d953 wscript: enable -Werror=alloc-size and -Walloc-zero 2023-12-11 07:11:40 +03:00
Alibek Omarov
c926fee13c filesystem: report an error when opening file was unsuccessful, with the exception for non-existent files 2023-12-11 07:10:51 +03:00
Alibek Omarov
a675806c91 engine: imagelib: img_ktx2: don't allow to load images with no mip levels 2023-12-11 07:06:12 +03:00
Alibek Omarov
683c4874f8 common: add ALLOC_CHECK macro that enables attribute alloc_size on GCC that allows to prevent suspicious allocation sizes 2023-12-09 19:00:25 +03:00
39 changed files with 1082 additions and 642 deletions

View File

@@ -27,4 +27,16 @@ GNU General Public License for more details.
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine #define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine
#define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer #define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer
// adjust the mask when features will be added or removed
#define ENGINE_FEATURES_MASK \
( ENGINE_WRITE_LARGE_COORD \
| ENGINE_QUAKE_COMPATIBLE \
| ENGINE_LOAD_DELUXEDATA \
| ENGINE_PHYSICS_PUSHER_EXT \
| ENGINE_LARGE_LIGHTMAPS \
| ENGINE_COMPENSATE_QUAKE_BUG \
| ENGINE_IMPROVED_LINETRACE \
| ENGINE_COMPUTE_STUDIO_LERP \
| ENGINE_LINEAR_GAMMA_SPACE )
#endif//FEATURES_H #endif//FEATURES_H

View File

@@ -229,7 +229,7 @@ typedef struct render_api_s
void (*R_Reserved0)( void ); void (*R_Reserved0)( void );
// static allocations // static allocations
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ); void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
void (*pfnMemFree)( void *mem, const char *filename, const int fileline ); void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
// engine utils (not related with render API but placed here) // engine utils (not related with render API but placed here)

View File

@@ -88,18 +88,21 @@ typedef uint64_t longtime_t;
#define _format(x) __attribute__((format(printf, x, x+1))) #define _format(x) __attribute__((format(printf, x, x+1)))
#define NORETURN __attribute__((noreturn)) #define NORETURN __attribute__((noreturn))
#define NONNULL __attribute__((nonnull)) #define NONNULL __attribute__((nonnull))
#define ALLOC_CHECK(x) __attribute__((alloc_size(x)))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport ) #define EXPORT __declspec( dllexport )
#define GAME_EXPORT #define GAME_EXPORT
#define _format(x) #define _format(x)
#define NORETURN #define NORETURN
#define NONNULL #define NONNULL
#define ALLOC_CHECK(x)
#else #else
#define EXPORT #define EXPORT
#define GAME_EXPORT #define GAME_EXPORT
#define _format(x) #define _format(x)
#define NORETURN #define NORETURN
#define NONNULL #define NONNULL
#define ALLOC_CHECK(x)
#endif #endif
#if ( __GNUC__ >= 3 ) #if ( __GNUC__ >= 3 )
@@ -118,10 +121,15 @@ typedef uint64_t longtime_t;
#define likely(x) (x) #define likely(x) (x)
#endif #endif
#if defined( static_assert ) // C11 static_assert #if __STDC_VERSION >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword
#define STATIC_ASSERT static_assert #define STATIC_ASSERT_ static_assert
#define STATIC_ASSERT static_assert
#elif __STDC_VERSION >= 201112L // in C11 it's _Static_assert
#define STATIC_ASSERT_ _Static_assert
#define STATIC_ASSERT _Static_assert
#else #else
#define STATIC_ASSERT( x, y ) extern int _static_assert_##__LINE__[( x ) ? 1 : -1] #define STATIC_ASSERT_( id, x, y ) extern int id[( x ) ? 1 : -1]
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_( static_assert_##__LINE__, x, y )
#endif #endif
#ifdef XASH_BIG_ENDIAN #ifdef XASH_BIG_ENDIAN

View File

@@ -372,7 +372,7 @@ void CL_WriteDemoHeader( const char *name )
demo.header.id = IDEMOHEADER; demo.header.id = IDEMOHEADER;
demo.header.dem_protocol = DEMO_PROTOCOL; demo.header.dem_protocol = DEMO_PROTOCOL;
demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION; demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION;
demo.header.host_fps = bound( MIN_FPS, host_maxfps.value, MAX_FPS ); demo.header.host_fps = host_maxfps.value ? bound( MIN_FPS, host_maxfps.value, MAX_FPS ) : MAX_FPS;
Q_strncpy( demo.header.mapname, clgame.mapname, sizeof( demo.header.mapname )); Q_strncpy( demo.header.mapname, clgame.mapname, sizeof( demo.header.mapname ));
Q_strncpy( demo.header.comment, clgame.maptitle, sizeof( demo.header.comment )); Q_strncpy( demo.header.comment, clgame.maptitle, sizeof( demo.header.comment ));
Q_strncpy( demo.header.gamedir, FS_Gamedir(), sizeof( demo.header.gamedir )); Q_strncpy( demo.header.gamedir, FS_Gamedir(), sizeof( demo.header.gamedir ));

View File

@@ -1235,11 +1235,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
{ {
char name[MAX_QPATH]; char name[MAX_QPATH];
model_t *mod; model_t *mod;
int i; int i, start;
// use high indices for client sprites
// for GoldSrc bug-compatibility
const int start = type != SPR_HUDSPRITE ? MAX_CLIENT_SPRITES / 2 : 0;
if( !COM_CheckString( filename )) if( !COM_CheckString( filename ))
{ {
@@ -1250,7 +1246,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
Q_strncpy( name, filename, sizeof( name )); Q_strncpy( name, filename, sizeof( name ));
COM_FixSlashes( name ); COM_FixSlashes( name );
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ ) for( i = 0, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
{ {
if( !Q_stricmp( mod->name, name )) if( !Q_stricmp( mod->name, name ))
{ {
@@ -1267,8 +1263,15 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
} }
// find a free model slot spot // find a free model slot spot
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ ) // use low indices only for HUD sprites
if( !mod->name[0] ) break; // this is a valid spot // for GoldSrc bug compatibility
start = type == SPR_HUDSPRITE ? 0 : MAX_CLIENT_SPRITES / 2;
for( i = 0, mod = &clgame.sprites[start]; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
{
if( !mod->name[0] )
break; // this is a valid spot
}
if( i == MAX_CLIENT_SPRITES / 2 ) if( i == MAX_CLIENT_SPRITES / 2 )
{ {

View File

@@ -87,6 +87,7 @@ static CVAR_DEFINE_AUTO( model, "", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABL
static CVAR_DEFINE_AUTO( topcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player top color" ); static CVAR_DEFINE_AUTO( topcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player top color" );
static CVAR_DEFINE_AUTO( bottomcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player bottom color" ); static CVAR_DEFINE_AUTO( bottomcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player bottom color" );
CVAR_DEFINE_AUTO( rate, "3500", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player network rate" ); CVAR_DEFINE_AUTO( rate, "3500", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player network rate" );
static CVAR_DEFINE_AUTO( cl_maxframetime, "0", 0, "set deadline timer for client rendering to catch freezes" );
client_t cl; client_t cl;
client_static_t cls; client_static_t cls;
@@ -2917,6 +2918,7 @@ void CL_InitLocal( void )
Cvar_RegisterVariable( &cl_showevents ); Cvar_RegisterVariable( &cl_showevents );
Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" ); Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" );
Cvar_RegisterVariable( &ui_renderworld ); Cvar_RegisterVariable( &ui_renderworld );
Cvar_RegisterVariable( &cl_maxframetime );
// these two added to shut up CS 1.5 about 'unknown' commands // these two added to shut up CS 1.5 about 'unknown' commands
Cvar_Get( "lightgamma", "1", FCVAR_ARCHIVE, "ambient lighting level (legacy, unused)" ); Cvar_Get( "lightgamma", "1", FCVAR_ARCHIVE, "ambient lighting level (legacy, unused)" );
@@ -3057,6 +3059,8 @@ void Host_ClientFrame( void )
{ {
// if client is not active, do nothing // if client is not active, do nothing
if( !cls.initialized ) return; if( !cls.initialized ) return;
if( cls.key_dest == key_game && cls.state == ca_active && !Con_Visible() )
Platform_SetTimer( cl_maxframetime.value );
// if running the server remotely, send intentions now after // if running the server remotely, send intentions now after
// the incoming messages have been read // the incoming messages have been read

View File

@@ -904,6 +904,10 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
background = MSG_ReadOneBit( msg ); background = MSG_ReadOneBit( msg );
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder )); Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
host.features = (uint)MSG_ReadLong( msg ); host.features = (uint)MSG_ReadLong( msg );
host.features &= legacy ? ENGINE_LEGACY_FEATURES_MASK : ENGINE_FEATURES_MASK;
if( !Host_IsLocalGame( ))
Host_PrintEngineFeatures( host.features );
if( !legacy ) if( !legacy )
{ {

View File

@@ -207,6 +207,8 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return pfnNumberOfEntities(); return pfnNumberOfEntities();
case PARM_NUMMODELS: case PARM_NUMMODELS:
return cl.nummodels; return cl.nummodels;
case PARM_WORLD_VERSION:
return world.version;
} }
} }
return 0; return 0;

View File

@@ -549,5 +549,6 @@ void V_PostRender( void )
SCR_MakeScreenShot(); SCR_MakeScreenShot();
ref.dllFuncs.R_AllowFog( true ); ref.dllFuncs.R_AllowFog( true );
Platform_SetTimer( 0.0f );
ref.dllFuncs.R_EndFrame(); ref.dllFuncs.R_EndFrame();
} }

View File

@@ -422,8 +422,8 @@ void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
// zone.c // zone.c
// //
void Memory_Init( void ); void Memory_Init( void );
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ); void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ); void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline ); poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline );
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline ); void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline ); void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
@@ -552,7 +552,7 @@ qboolean Host_IsLocalGame( void );
qboolean Host_IsLocalClient( void ); qboolean Host_IsLocalClient( void );
void Host_ShutdownServer( void ); void Host_ShutdownServer( void );
void Host_Error( const char *error, ... ) _format( 1 ); void Host_Error( const char *error, ... ) _format( 1 );
void Host_PrintEngineFeatures( void ); void Host_PrintEngineFeatures( int features );
void Host_Frame( float time ); void Host_Frame( float time );
void Host_InitDecals( void ); void Host_InitDecals( void );
void Host_Credits( void ); void Host_Credits( void );
@@ -793,7 +793,7 @@ void VID_Init( void );
void UI_SetActiveMenu( qboolean fActive ); void UI_SetActiveMenu( qboolean fActive );
void UI_ShowConnectionWarning( void ); void UI_ShowConnectionWarning( void );
void Cmd_Null_f( void ); void Cmd_Null_f( void );
void Rcon_Print( const char *pMsg ); void Rcon_Print( host_redirect_t *rd, const char *pMsg );
qboolean COM_ParseVector( char **pfile, float *v, size_t size ); qboolean COM_ParseVector( char **pfile, float *v, size_t size );
void COM_NormalizeAngles( vec3_t angles ); void COM_NormalizeAngles( vec3_t angles );
int COM_FileSize( const char *filename ); int COM_FileSize( const char *filename );

View File

@@ -490,7 +490,7 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
#ifdef XASH_SDL #ifdef XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_FALSE ); SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#endif #endif
MSGBOX( message ); Platform_MessageBox( "Xash Error", message, false );
// log saved, now we can try to save configs and close log correctly, it may crash // log saved, now we can try to save configs and close log correctly, it may crash
if( host.type == HOST_NORMAL ) if( host.type == HOST_NORMAL )

View File

@@ -62,6 +62,7 @@ CVAR_DEFINE_AUTO( host_limitlocal, "0", 0, "apply cl_cmdrate and rate to loopbac
CVAR_DEFINE( host_maxfps, "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" ); CVAR_DEFINE( host_maxfps, "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" );
static CVAR_DEFINE_AUTO( host_framerate, "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" ); static CVAR_DEFINE_AUTO( host_framerate, "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" );
static CVAR_DEFINE( host_sleeptime, "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" ); static CVAR_DEFINE( host_sleeptime, "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" );
static CVAR_DEFINE_AUTO( host_sleeptime_debug, "0", 0, "print sleeps between frames" );
CVAR_DEFINE( con_gamemaps, "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" ); CVAR_DEFINE( con_gamemaps, "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" );
void Sys_PrintUsage( void ) void Sys_PrintUsage( void )
@@ -189,22 +190,27 @@ void Host_ShutdownServer( void )
Host_PrintEngineFeatures Host_PrintEngineFeatures
================ ================
*/ */
void Host_PrintEngineFeatures( void ) void Host_PrintEngineFeatures( int features )
{ {
if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD )) const char *features_str[] =
Con_Reportf( "^3EXT:^7 big world support enabled\n" ); {
"Big World Support",
"Quake Compatibility",
"Deluxemap Support",
"Improved MOVETYPE_PUSH",
"Large Lightmaps",
"Stupid Quake Bug Compensation",
"Improved Trace Line",
"Studio MOVETYPE_STEP Lerping",
"Linear Gamma Space"
};
int i;
if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA )) for( i = 0; i < ARRAYSIZE( features_str ); i++ )
Con_Reportf( "^3EXT:^7 deluxemap support enabled\n" ); {
if( FBitSet( features, BIT( i )))
if( FBitSet( host.features, ENGINE_PHYSICS_PUSHER_EXT )) Con_Reportf( "^3EXT:^7 %s is enabled\n", features_str[i] );
Con_Reportf( "^3EXT:^7 Improved MOVETYPE_PUSH is used\n" ); }
if( FBitSet( host.features, ENGINE_LARGE_LIGHTMAPS ))
Con_Reportf( "^3EXT:^7 Large lightmaps enabled\n" );
if( FBitSet( host.features, ENGINE_COMPENSATE_QUAKE_BUG ))
Con_Reportf( "^3EXT:^7 Compensate quake bug enabled\n" );
} }
/* /*
@@ -618,6 +624,84 @@ double Host_CalcFPS( void )
return fps; return fps;
} }
static qboolean Host_Autosleep( double dt, double scale )
{
double targetframetime, fps;
int sleep;
fps = Host_CalcFPS();
if( fps <= 0 )
return true;
// limit fps to withing tolerable range
fps = bound( MIN_FPS, fps, MAX_FPS );
if( Host_IsDedicated( ))
targetframetime = ( 1.0 / ( fps + 1.0 ));
else targetframetime = ( 1.0 / fps );
sleep = Host_CalcSleep();
if( sleep == 0 ) // no sleeps between frames, much simpler code
{
if( dt < targetframetime * scale )
return false;
}
else
{
static double timewindow; // allocate a time window for sleeps
static int counter; // for debug
static double realsleeptime;
const double sleeptime = sleep * 0.001;
if( dt < targetframetime * scale )
{
// if we have allocated time window, try to sleep
if( timewindow > realsleeptime )
{
// Sys_Sleep isn't guaranteed to sleep an exact amount of milliseconds
// so we measure the real sleep time and use it to decrease the window
double t1 = Sys_DoubleTime(), t2;
Sys_Sleep( sleep ); // in msec!
t2 = Sys_DoubleTime();
realsleeptime = t2 - t1;
timewindow -= realsleeptime;
if( host_sleeptime_debug.value )
{
counter++;
Con_NPrintf( counter, "%d: %.4f %.4f", counter, timewindow, realsleeptime );
}
}
return false;
}
// if we exhausted this time window, allocate a new one after new frame
if( timewindow <= realsleeptime )
{
double targetsleeptime = targetframetime - host.pureframetime * 2;
if( targetsleeptime > 0 )
timewindow = targetsleeptime;
else timewindow = 0;
realsleeptime = sleeptime; // reset in case CPU was too busy
if( host_sleeptime_debug.value )
{
counter = 0;
Con_NPrintf( 0, "tgt = %.4f, pft = %.4f, wnd = %.4f", targetframetime, host.pureframetime, timewindow );
}
}
}
return true;
}
/* /*
=================== ===================
Host_FilterTime Host_FilterTime
@@ -628,55 +712,15 @@ Returns false if the time is too short to run a frame
qboolean Host_FilterTime( float time ) qboolean Host_FilterTime( float time )
{ {
static double oldtime; static double oldtime;
double fps, scale = sys_timescale.value; double dt;
double scale = sys_timescale.value;
host.realtime += time * scale; host.realtime += time * scale;
fps = Host_CalcFPS(); dt = host.realtime - oldtime;
// clamp the fps in multiplayer games // clamp the fps in multiplayer games
if( fps != 0.0 ) if( !Host_Autosleep( dt, scale ))
{ return false;
static int sleeps;
double targetframetime;
int sleeptime = Host_CalcSleep();
// limit fps to withing tolerable range
fps = bound( MIN_FPS, fps, MAX_FPS );
if( Host_IsDedicated( ))
targetframetime = ( 1.0 / ( fps + 1.0 ));
else targetframetime = ( 1.0 / fps );
if(( host.realtime - oldtime ) < targetframetime * scale )
{
if( sleeptime > 0 && sleeps > 0 )
{
Sys_Sleep( sleeptime );
sleeps--;
}
return false;
}
if( sleeptime > 0 && sleeps <= 0 )
{
if( host.status == HOST_FRAME )
{
// give few sleeps this frame with small margin
double targetsleeptime = targetframetime - host.pureframetime * 2;
// don't sleep if we can't keep up with the framerate
if( targetsleeptime > 0 )
sleeps = targetsleeptime / ( sleeptime * 0.001 );
else sleeps = 0;
}
else
{
// always sleep at least once in minimized/nofocus state
sleeps = 1;
}
}
}
host.frametime = host.realtime - oldtime; host.frametime = host.realtime - oldtime;
host.realframetime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME ); host.realframetime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
@@ -756,7 +800,7 @@ void GAME_EXPORT Host_Error( const char *error, ... )
Key_SetKeyDest( key_console ); Key_SetKeyDest( key_console );
Con_Printf( "Host_Error: %s", hosterror1 ); Con_Printf( "Host_Error: %s", hosterror1 );
} }
else MSGBOX2( hosterror1 ); else Platform_MessageBox( "Host Error", hosterror1, true );
} }
// host is shutting down. don't invoke infinite loop // host is shutting down. don't invoke infinite loop
@@ -1181,6 +1225,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
Cvar_RegisterVariable( &host_maxfps ); Cvar_RegisterVariable( &host_maxfps );
Cvar_RegisterVariable( &host_framerate ); Cvar_RegisterVariable( &host_framerate );
Cvar_RegisterVariable( &host_sleeptime ); Cvar_RegisterVariable( &host_sleeptime );
Cvar_RegisterVariable( &host_sleeptime_debug );
Cvar_RegisterVariable( &host_gameloaded ); Cvar_RegisterVariable( &host_gameloaded );
Cvar_RegisterVariable( &host_clientloaded ); Cvar_RegisterVariable( &host_clientloaded );
Cvar_RegisterVariable( &host_limitlocal ); Cvar_RegisterVariable( &host_limitlocal );

View File

@@ -87,6 +87,12 @@ static qboolean Image_KTX2Parse( const ktx2_header_t *header, const byte *buffer
return false; return false;
} }
if( header->levelCount == 0 )
{
Con_DPrintf( S_ERROR "%s: file has no mip levels\n", __FUNCTION__ );
return false;
}
if( header->pixelDepth > 1 ) if( header->pixelDepth > 1 )
{ {
Con_DPrintf( S_ERROR "%s: unsupported KTX2 pixelDepth %d\n", __FUNCTION__, header->pixelDepth ); Con_DPrintf( S_ERROR "%s: unsupported KTX2 pixelDepth %d\n", __FUNCTION__, header->pixelDepth );

View File

@@ -2998,6 +2998,7 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
if( isworld ) if( isworld )
{ {
world.version = bmod->version;
#if !XASH_DEDICATED #if !XASH_DEDICATED
Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc) Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc)
world.deluxedata = bmod->deluxedata_out; // deluxemap data pointer world.deluxedata = bmod->deluxedata_out; // deluxemap data pointer

View File

@@ -113,6 +113,8 @@ typedef struct world_static_s
// tree visualization stuff // tree visualization stuff
int recursion_level; int recursion_level;
int max_recursion; int max_recursion;
uint32_t version; // BSP version
} world_static_t; } world_static_t;
#ifndef REF_DLL #ifndef REF_DLL

View File

@@ -111,6 +111,7 @@ void Mod_FreeModel( model_t *mod )
if( mod->type == mod_brush && FBitSet( mod->flags, MODEL_WORLD ) ) if( mod->type == mod_brush && FBitSet( mod->flags, MODEL_WORLD ) )
{ {
world.version = 0;
world.shadowdata = NULL; world.shadowdata = NULL;
world.deluxedata = NULL; world.deluxedata = NULL;
} }

View File

@@ -305,6 +305,14 @@ extern const char *clc_strings[clc_lastmsg+1];
#define MAX_LEGACY_EDICTS (1 << MAX_LEGACY_ENTITY_BITS) // 4096 edicts #define MAX_LEGACY_EDICTS (1 << MAX_LEGACY_ENTITY_BITS) // 4096 edicts
#define MIN_LEGACY_EDICTS 30 #define MIN_LEGACY_EDICTS 30
// legacy engine features that can be implemented through currently supported features
#define ENGINE_LEGACY_FEATURES_MASK \
( ENGINE_WRITE_LARGE_COORD \
| ENGINE_LOAD_DELUXEDATA \
| ENGINE_LARGE_LIGHTMAPS \
| ENGINE_COMPENSATE_QUAKE_BUG \
| ENGINE_COMPUTE_STUDIO_LERP )
// Master Server protocol // Master Server protocol
#define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0" // TODO: implement IP filter #define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0" // TODO: implement IP filter

View File

@@ -402,7 +402,7 @@ void Sys_Warn( const char *format, ... )
Msg( "Sys_Warn: %s\n", text ); Msg( "Sys_Warn: %s\n", text );
if( !Host_IsDedicated() ) // dedicated server should not hang on messagebox if( !Host_IsDedicated() ) // dedicated server should not hang on messagebox
MSGBOX(text); Platform_MessageBox( "Xash Warning", text, false );
} }
/* /*
@@ -446,8 +446,8 @@ void Sys_Error( const char *error, ... )
#if XASH_WIN32 #if XASH_WIN32
Wcon_ShowConsole( false ); Wcon_ShowConsole( false );
#endif #endif
MSGBOX( text );
Sys_Print( text ); Sys_Print( text );
Platform_MessageBox( "Xash Error", text, false );
} }
else else
{ {
@@ -562,7 +562,7 @@ void Sys_Print( const char *pMsg )
Sys_PrintLog( pMsg ); Sys_PrintLog( pMsg );
Rcon_Print( pMsg ); Rcon_Print( &host.rd, pMsg );
} }
/* /*

View File

@@ -30,9 +30,6 @@ extern "C" {
#include "crtlib.h" #include "crtlib.h"
#include "platform/platform.h" #include "platform/platform.h"
#define MSGBOX( x ) Platform_MessageBox( "Xash Error", (x), false )
#define MSGBOX2( x ) Platform_MessageBox( "Host Error", (x), true )
#define MSGBOX3( x ) Platform_MessageBox( "Host Recursive Error", (x), true )
#define ASSERT( exp ) if(!( exp )) Sys_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ ) #define ASSERT( exp ) if(!( exp )) Sys_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )
/* /*

View File

@@ -143,7 +143,7 @@ typedef struct ui_enginefuncs_s
void *(*pfnKeyGetState)( const char *name ); // for mlook, klook etc void *(*pfnKeyGetState)( const char *name ); // for mlook, klook etc
// engine memory manager // engine memory manager
void* (*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ); void* (*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
void (*pfnMemFree)( void *mem, const char *filename, const int fileline ); void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
// collect info from engine // collect info from engine

View File

@@ -86,7 +86,7 @@ typedef struct server_physics_api_s
const byte *(*pfnGetTextureData)( unsigned int texnum ); const byte *(*pfnGetTextureData)( unsigned int texnum );
// static allocations // static allocations
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ); void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
void (*pfnMemFree)( void *mem, const char *filename, const int fileline ); void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
// trace & contents // trace & contents

View File

@@ -13,10 +13,16 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#define _GNU_SOURCE
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <signal.h>
#include <ucontext.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#include "platform/platform.h" #include "platform/platform.h"
static void *g_hsystemd; static void *g_hsystemd;
@@ -103,3 +109,44 @@ void Linux_Shutdown( void )
g_hsystemd = NULL; g_hsystemd = NULL;
} }
} }
static void Linux_TimerHandler( int sig, siginfo_t *si, void *uc )
{
timer_t *tidp = si->si_value.sival_ptr;
int overrun = timer_getoverrun( *tidp );
Con_Printf( "Frame too long (overrun %d)!\n", overrun );
}
#define DEBUG_TIMER_SIGNAL SIGRTMIN
void Linux_SetTimer( float tm )
{
static timer_t timerid;
if( !timerid && tm )
{
struct sigevent sev = { 0 };
struct sigaction sa = { 0 };
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = Linux_TimerHandler;
sigaction( DEBUG_TIMER_SIGNAL, &sa, NULL );
// this path availiable in POSIX, but may signal wrong thread...
// sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_notify = SIGEV_THREAD_ID;
sev._sigev_un._tid = gettid();
sev.sigev_signo = DEBUG_TIMER_SIGNAL;
sev.sigev_value.sival_ptr = &timerid;
timer_create( CLOCK_REALTIME, &sev, &timerid );
}
if( timerid )
{
struct itimerspec its = {0};
its.it_value.tv_sec = tm;
its.it_value.tv_nsec = 1000000000ULL * fmod( tm, 1.0f );
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = 0;
timer_settime( timerid, 0, &its, NULL );
}
}

View File

@@ -91,6 +91,7 @@ void DOS_Shutdown( void );
#if XASH_LINUX #if XASH_LINUX
void Linux_Init( void ); void Linux_Init( void );
void Linux_Shutdown( void ); void Linux_Shutdown( void );
void Linux_SetTimer( float time );
#endif #endif
static inline void Platform_Init( void ) static inline void Platform_Init( void )
@@ -181,6 +182,13 @@ void Platform_SetClipboardText( const char *buffer );
#define SDL_VERSION_ATLEAST( x, y, z ) 0 #define SDL_VERSION_ATLEAST( x, y, z ) 0
#endif #endif
static void Platform_SetTimer( float time )
{
#if XASH_LINUX
Linux_SetTimer( time );
#endif
}
/* /*
============================================================================== ==============================================================================

View File

@@ -261,6 +261,7 @@ typedef enum
PARM_LOCAL_GAME = -11, PARM_LOCAL_GAME = -11,
PARM_NUMENTITIES = -12, // local game only PARM_NUMENTITIES = -12, // local game only
PARM_NUMMODELS = -13, // cl.nummodels PARM_NUMMODELS = -13, // cl.nummodels
PARM_WORLD_VERSION = -14,
} ref_parm_e; } ref_parm_e;
typedef struct ref_api_s typedef struct ref_api_s
@@ -361,8 +362,8 @@ typedef struct ref_api_s
// memory // memory
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline ); poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline ); void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ); void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ); void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
void (*_Mem_Free)( void *data, const char *filename, int fileline ); void (*_Mem_Free)( void *data, const char *filename, int fileline );
// library management // library management

View File

@@ -564,7 +564,7 @@ qboolean SV_IsPlayerIndex( int idx );
int SV_CalcPing( sv_client_t *cl ); int SV_CalcPing( sv_client_t *cl );
void SV_InitClientMove( void ); void SV_InitClientMove( void );
void SV_UpdateServerInfo( void ); void SV_UpdateServerInfo( void );
void SV_EndRedirect( void ); void SV_EndRedirect( host_redirect_t *rd );
void SV_RejectConnection( netadr_t from, const char *fmt, ... ) _format( 2 ); void SV_RejectConnection( netadr_t from, const char *fmt, ... ) _format( 2 );
void SV_GetPlayerCount( int *clients, int *bots ); void SV_GetPlayerCount( int *clients, int *bots );

View File

@@ -639,7 +639,7 @@ void SV_DropClient( sv_client_t *cl, qboolean crash )
cl->frames = NULL; cl->frames = NULL;
if( NET_CompareBaseAdr( cl->netchan.remote_address, host.rd.address )) if( NET_CompareBaseAdr( cl->netchan.remote_address, host.rd.address ))
SV_EndRedirect(); SV_EndRedirect( &host.rd );
// throw away any residual garbage in the channel. // throw away any residual garbage in the channel.
Netchan_Clear( &cl->netchan ); Netchan_Clear( &cl->netchan );
@@ -676,22 +676,19 @@ SVC COMMAND REDIRECT
============================================================================== ==============================================================================
*/ */
void SV_BeginRedirect( netadr_t adr, rdtype_t target, char *buffer, size_t buffersize, void (*flush)) static void SV_BeginRedirect( host_redirect_t *rd, netadr_t adr, rdtype_t target, char *buffer, size_t buffersize, void (*flush))
{ {
if( !target || !buffer || !buffersize || !flush ) rd->target = target;
return; rd->buffer = buffer;
rd->buffersize = buffersize;
host.rd.target = target; rd->flush = flush;
host.rd.buffer = buffer; rd->address = adr;
host.rd.buffersize = buffersize; rd->buffer[0] = 0;
host.rd.flush = flush; if( rd->lines == 0 )
host.rd.address = adr; rd->lines = -1;
host.rd.buffer[0] = 0;
if( host.rd.lines == 0 )
host.rd.lines = -1;
} }
void SV_FlushRedirect( netadr_t adr, int dest, char *buf ) static void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
{ {
if( sv.current_client && FBitSet( sv.current_client->flags, FCL_FAKECLIENT )) if( sv.current_client && FBitSet( sv.current_client->flags, FCL_FAKECLIENT ))
return; return;
@@ -712,18 +709,18 @@ void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
} }
} }
void SV_EndRedirect( void ) void SV_EndRedirect( host_redirect_t *rd )
{ {
if( host.rd.lines > 0 ) if( rd->lines > 0 )
return; return;
if( host.rd.flush ) if( rd->flush )
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer ); rd->flush( rd->address, rd->target, rd->buffer );
host.rd.target = 0; rd->target = RD_NONE;
host.rd.buffer = NULL; rd->buffer = NULL;
host.rd.buffersize = 0; rd->buffersize = 0;
host.rd.flush = NULL; rd->flush = NULL;
} }
/* /*
@@ -733,24 +730,26 @@ Rcon_Print
Print message to rcon buffer and send to rcon redirect target Print message to rcon buffer and send to rcon redirect target
================ ================
*/ */
void Rcon_Print( const char *pMsg ) void Rcon_Print( host_redirect_t *rd, const char *pMsg )
{ {
if( host.rd.target && host.rd.lines && host.rd.flush && host.rd.buffer ) size_t len;
if( !rd->target || !rd->lines || !rd->flush || !rd->buffer )
return;
len = Q_strncat( rd->buffer, pMsg, rd->buffersize );
if( len && rd->buffer[len - 1] == '\n' )
{ {
size_t len = Q_strncat( host.rd.buffer, pMsg, host.rd.buffersize ); rd->flush( rd->address, rd->target, rd->buffer );
if( len && host.rd.buffer[len-1] == '\n' ) if( rd->lines > 0 )
{ rd->lines--;
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
if( host.rd.lines > 0 ) rd->buffer[0] = 0;
host.rd.lines--;
host.rd.buffer[0] = 0; if( !rd->lines )
Msg( "End of redirection!\n" );
if( !host.rd.lines )
Msg( "End of redirection!\n" );
}
} }
} }
@@ -1090,7 +1089,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
if( Rcon_Validate( )) if( Rcon_Validate( ))
{ {
SV_BeginRedirect( from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect ); SV_BeginRedirect( &host.rd, from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect );
remaining[0] = 0; remaining[0] = 0;
for( i = 2; i < Cmd_Argc(); i++ ) for( i = 2; i < Cmd_Argc(); i++ )
@@ -1101,7 +1100,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
} }
Cmd_ExecuteString( remaining ); Cmd_ExecuteString( remaining );
SV_EndRedirect(); SV_EndRedirect( &host.rd );
} }
else Con_Printf( S_ERROR "Bad rcon_password.\n" ); else Con_Printf( S_ERROR "Bad rcon_password.\n" );
} }

View File

@@ -4525,7 +4525,7 @@ static qboolean GAME_EXPORT pfnVoice_GetClientListening( int iReceiver, int iSen
iReceiver -= 1; iReceiver -= 1;
iSender -= 1; iSender -= 1;
if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender > svs.maxclients ) if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender >= svs.maxclients )
return false; return false;
return (FBitSet( svs.clients[iSender].listeners, BIT( iReceiver )) != 0 ); return (FBitSet( svs.clients[iSender].listeners, BIT( iReceiver )) != 0 );
@@ -4542,7 +4542,7 @@ static qboolean GAME_EXPORT pfnVoice_SetClientListening( int iReceiver, int iSen
iReceiver -= 1; iReceiver -= 1;
iSender -= 1; iSender -= 1;
if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender > svs.maxclients ) if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender >= svs.maxclients )
return false; return false;
if( bListen ) SetBits( svs.clients[iSender].listeners, BIT( iReceiver )); if( bListen ) SetBits( svs.clients[iSender].listeners, BIT( iReceiver ));

View File

@@ -1103,7 +1103,7 @@ void SV_Shutdown( const char *finalmsg )
Con_Printf( "%s", finalmsg ); Con_Printf( "%s", finalmsg );
// rcon will be disconnected // rcon will be disconnected
SV_EndRedirect(); SV_EndRedirect( &host.rd );
if( svs.clients ) if( svs.clients )
SV_FinalMessage( finalmsg, false ); SV_FinalMessage( finalmsg, false );

View File

@@ -2139,8 +2139,8 @@ qboolean SV_InitPhysicsAPI( void )
if( svgame.physFuncs.SV_CheckFeatures != NULL ) if( svgame.physFuncs.SV_CheckFeatures != NULL )
{ {
// grab common engine features (it will be shared across the network) // grab common engine features (it will be shared across the network)
host.features = svgame.physFuncs.SV_CheckFeatures(); host.features = svgame.physFuncs.SV_CheckFeatures() & ENGINE_FEATURES_MASK;
Host_PrintEngineFeatures (); Host_PrintEngineFeatures( host.features );
} }
return true; return true;
} }

View File

@@ -37,8 +37,6 @@ def options(opt):
def configure(conf): def configure(conf):
# check for dedicated server build # check for dedicated server build
if conf.options.DEDICATED: if conf.options.DEDICATED:
if conf.env.DEST_OS == 'linux':
conf.check_cc(lib='rt')
conf.define('XASH_DEDICATED', 1) conf.define('XASH_DEDICATED', 1)
elif conf.env.DEST_OS == 'dos': elif conf.env.DEST_OS == 'dos':
conf.options.STATIC = True conf.options.STATIC = True
@@ -73,12 +71,9 @@ def configure(conf):
# unused, XASH_LINUX without XASH_SDL gives fbdev & alsa support # unused, XASH_LINUX without XASH_SDL gives fbdev & alsa support
# conf.define('XASH_FBDEV', 1) # conf.define('XASH_FBDEV', 1)
conf.check_cc( lib = 'asound' ) conf.check_cc( lib = 'asound' )
conf.check_cc( lib = 'rt' )
elif conf.options.SDL12: elif conf.options.SDL12:
conf.define('XASH_SDL', 12) conf.define('XASH_SDL', 12)
conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' ) conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' )
if conf.env.DEST_OS == 'linux':
conf.check_cc( lib='rt' )
conf.env.HAVE_SDL2 = True conf.env.HAVE_SDL2 = True
else: else:
conf.load('sdl2') conf.load('sdl2')
@@ -97,6 +92,9 @@ def configure(conf):
if not conf.env.DEST_OS in ['win32', 'android'] and not conf.options.NO_ASYNC_RESOLVE: if not conf.env.DEST_OS in ['win32', 'android'] and not conf.options.NO_ASYNC_RESOLVE:
conf.check_pthreads() conf.check_pthreads()
if conf.env.DEST_OS == 'linux':
conf.check_cc(lib='rt')
if hasattr(conf.options, 'DLLEMU'): if hasattr(conf.options, 'DLLEMU'):
conf.define_cond('XASH_DLL_LOADER', conf.options.DLLEMU) conf.define_cond('XASH_DLL_LOADER', conf.options.DLLEMU)

View File

@@ -1677,6 +1677,9 @@ file_t *FS_SysOpen( const char *filepath, const char *mode )
if( file->handle < 0 ) if( file->handle < 0 )
{ {
if( errno != ENOENT )
Con_Printf( S_ERROR "%s: can't open file %s: %s\n", __func__, filepath, strerror( errno ));
Mem_Free( file ); Mem_Free( file );
return NULL; return NULL;
} }

View File

@@ -210,8 +210,8 @@ typedef struct fs_interface_t
// memory // memory
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline ); poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline ); void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ); void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ); void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
void (*_Mem_Free)( void *data, const char *filename, int fileline ); void (*_Mem_Free)( void *data, const char *filename, int fileline );
// platform // platform

View File

@@ -774,6 +774,7 @@ extern convar_t r_lockfrustum;
extern convar_t r_traceglow; extern convar_t r_traceglow;
extern convar_t r_vbo; extern convar_t r_vbo;
extern convar_t r_vbo_dlightmode; extern convar_t r_vbo_dlightmode;
extern convar_t r_vbo_detail;
extern convar_t r_studio_sort_textures; extern convar_t r_studio_sort_textures;
extern convar_t r_studio_drawelements; extern convar_t r_studio_drawelements;
extern convar_t r_ripple; extern convar_t r_ripple;

View File

@@ -29,6 +29,7 @@ CVAR_DEFINE_AUTO( r_lockfrustum, "0", FCVAR_CHEAT, "lock frustrum area at curren
CVAR_DEFINE_AUTO( r_traceglow, "0", FCVAR_GLCONFIG, "cull flares behind models" ); CVAR_DEFINE_AUTO( r_traceglow, "0", FCVAR_GLCONFIG, "cull flares behind models" );
CVAR_DEFINE_AUTO( gl_round_down, "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" ); CVAR_DEFINE_AUTO( gl_round_down, "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" );
CVAR_DEFINE( r_vbo, "gl_vbo", "0", FCVAR_ARCHIVE, "draw world using VBO (known to be glitchy)" ); CVAR_DEFINE( r_vbo, "gl_vbo", "0", FCVAR_ARCHIVE, "draw world using VBO (known to be glitchy)" );
CVAR_DEFINE( r_vbo_detail, "gl_vbo_detail", "0", FCVAR_ARCHIVE, "detail vbo mode (0: disable, 1: multipass, 2: singlepass, broken decal dlights)" );
CVAR_DEFINE( r_vbo_dlightmode, "gl_vbo_dlightmode", "1", FCVAR_ARCHIVE, "vbo dlight rendering mode (0-1)" ); CVAR_DEFINE( r_vbo_dlightmode, "gl_vbo_dlightmode", "1", FCVAR_ARCHIVE, "vbo dlight rendering mode (0-1)" );
CVAR_DEFINE_AUTO( r_ripple, "0", FCVAR_GLCONFIG, "enable software-like water texture ripple simulation" ); CVAR_DEFINE_AUTO( r_ripple, "0", FCVAR_GLCONFIG, "enable software-like water texture ripple simulation" );
CVAR_DEFINE_AUTO( r_ripple_updatetime, "0.05", FCVAR_GLCONFIG, "how fast ripple simulation is" ); CVAR_DEFINE_AUTO( r_ripple_updatetime, "0.05", FCVAR_GLCONFIG, "how fast ripple simulation is" );
@@ -1244,6 +1245,7 @@ static void R_CheckVBO( void )
gEngfuncs.Cvar_RegisterVariable( &r_vbo ); gEngfuncs.Cvar_RegisterVariable( &r_vbo );
gEngfuncs.Cvar_RegisterVariable( &r_vbo_dlightmode ); gEngfuncs.Cvar_RegisterVariable( &r_vbo_dlightmode );
gEngfuncs.Cvar_RegisterVariable( &r_vbo_detail );
} }
/* /*

File diff suppressed because it is too large Load Diff

View File

@@ -385,7 +385,7 @@ static qboolean LoadMDL( const char *modelname )
} }
} }
if( filesize < sizeof( studiohdr_t ) || filesize != model_hdr->length ) if( filesize < sizeof( studiohdr_t ) || filesize != texture_hdr->length )
{ {
fprintf( stderr, "ERROR: Wrong file size! File %s may be corrupted!\n", texturename ); fprintf( stderr, "ERROR: Wrong file size! File %s may be corrupted!\n", texturename );
return false; return false;
@@ -427,7 +427,7 @@ static qboolean LoadMDL( const char *modelname )
return false; return false;
} }
if( filesize < sizeof( studiohdr_t ) || filesize != model_hdr->length ) if( filesize < sizeof( studiohdr_t ) || filesize != anim_hdr[i]->length )
{ {
fprintf( stderr, "ERROR: Wrong file size! File %s may be corrupted!\n", seqgroupname ); fprintf( stderr, "ERROR: Wrong file size! File %s may be corrupted!\n", seqgroupname );
return false; return false;

View File

@@ -123,19 +123,13 @@ ProperBoneRotationZ
*/ */
static void ProperBoneRotationZ( vec_t *motion, float angle ) static void ProperBoneRotationZ( vec_t *motion, float angle )
{ {
float c, s, x, y; float tmp, rot;
float rot;
rot = DEG2RAD( angle ); rot = DEG2RAD( angle );
s = sin( rot ); tmp = motion[0];
c = cos( rot ); motion[0] = motion[1];
motion[1] = -tmp;
x = motion[0];
y = motion[1];
motion[0] = c * x - s * y;
motion[1] = s * x + c * y;
motion[5] += rot; motion[5] += rot;
} }
@@ -440,9 +434,12 @@ static void WriteFrameInfo( FILE *fp, mstudioanim_t *anim, mstudioseqdesc_t *seq
if( bone->parent == -1 ) if( bone->parent == -1 )
{ {
scale = frame / (float)( seqdesc->numframes - 1 ); if( seqdesc->numframes > 1 && frame > 0 )
{
scale = frame / (float)( seqdesc->numframes - 1 );
VectorMA( motion, scale, seqdesc->linearmovement, motion ); VectorMA( motion, scale, seqdesc->linearmovement, motion );
}
ProperBoneRotationZ( motion, 270.0f ); ProperBoneRotationZ( motion, 270.0f );
} }

View File

@@ -74,7 +74,7 @@ SUBDIRS = [
Subproject('3rdparty/gl-wes-v2', lambda x: not x.env.DEDICATED and x.env.GLWES), Subproject('3rdparty/gl-wes-v2', lambda x: not x.env.DEDICATED and x.env.GLWES),
Subproject('3rdparty/gl4es', lambda x: not x.env.DEDICATED and x.env.GL4ES), Subproject('3rdparty/gl4es', lambda x: not x.env.DEDICATED and x.env.GL4ES),
Subproject('ref/gl', lambda x: not x.env.DEDICATED and (x.env.GL or x.env.NANOGL or x.env.GLWES or x.env.GL4ES)), Subproject('ref/gl', lambda x: not x.env.DEDICATED and (x.env.GL or x.env.NANOGL or x.env.GLWES or x.env.GL4ES)),
Subproject('ref/soft', lambda x: not x.env.DEDICATED and x.env.SOFT), Subproject('ref/soft', lambda x: not x.env.DEDICATED and not x.env.SUPPORT_BSP2_FORMAT and x.env.SOFT),
Subproject('3rdparty/mainui', lambda x: not x.env.DEDICATED), Subproject('3rdparty/mainui', lambda x: not x.env.DEDICATED),
Subproject('3rdparty/vgui_support', lambda x: not x.env.DEDICATED), Subproject('3rdparty/vgui_support', lambda x: not x.env.DEDICATED),
Subproject('stub/client', lambda x: not x.env.DEDICATED), Subproject('stub/client', lambda x: not x.env.DEDICATED),
@@ -292,6 +292,7 @@ def configure(conf):
'-fdiagnostics-color=always', '-fdiagnostics-color=always',
# stable diagnostics, forced to error, sorted # stable diagnostics, forced to error, sorted
'-Werror=alloc-size',
'-Werror=bool-compare', '-Werror=bool-compare',
'-Werror=bool-operation', '-Werror=bool-operation',
'-Werror=cast-align=strict', '-Werror=cast-align=strict',
@@ -321,6 +322,7 @@ def configure(conf):
'-Wmisleading-indentation', '-Wmisleading-indentation',
'-Wstringop-overflow', '-Wstringop-overflow',
'-Wunintialized', '-Wunintialized',
'-Walloc-zero',
# disabled, flood # disabled, flood
# '-Wdouble-promotion', # '-Wdouble-promotion',
@@ -356,6 +358,7 @@ def configure(conf):
conf.env.ENABLE_FUZZER = conf.options.ENABLE_FUZZER conf.env.ENABLE_FUZZER = conf.options.ENABLE_FUZZER
conf.env.DEDICATED = conf.options.DEDICATED conf.env.DEDICATED = conf.options.DEDICATED
conf.env.SINGLE_BINARY = conf.options.SINGLE_BINARY or conf.env.DEDICATED conf.env.SINGLE_BINARY = conf.options.SINGLE_BINARY or conf.env.DEDICATED
conf.env.SUPPORT_BSP2_FORMAT = conf.options.SUPPORT_BSP2_FORMAT
if conf.env.SAILFISH == 'aurora': if conf.env.SAILFISH == 'aurora':
conf.env.DEFAULT_RPATH = '/usr/share/su.xash.Engine/lib' conf.env.DEFAULT_RPATH = '/usr/share/su.xash.Engine/lib'