Compare commits

..

26 Commits

Author SHA1 Message Date
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
Alibek Omarov
20ced857b4 engine: client: use physents array when tracing physents =/ 2023-12-09 16:45:35 +03:00
Alibek Omarov
c6c86f9665 public: make hash case-insensitive again 2023-12-07 06:46:49 +03:00
Alibek Omarov
1e0107944f engine: make sys_timescale non-cheat, like host_framerate 2023-12-07 00:50:56 +03:00
Alibek Omarov
21797f9ac8 ref: gl: fix solor to color 2023-12-06 05:22:02 +03:00
mittorn
c800b34cd4 ref_api: add R_Flush method 2023-12-06 04:13:27 +03:00
Alibek Omarov
1612e2d669 engine: client: GetRefAPI now must return REF_API_VERSION to prevent possible issue when ref library wasn't recompiled on version bump 2023-12-06 04:13:27 +03:00
Alibek Omarov
26d229c8ca engine, ref: RefAPI 5. Simplify remap calls 2023-12-06 04:13:03 +03:00
Alibek Omarov
9c66e86be1 engine, ref: RefAPI 5. Remove unused calls 2023-12-06 04:13:03 +03:00
Alibek Omarov
7e9f87de2d engine, ref: eliminate calls to global arrays, instead store array pointers at renderer side 2023-12-06 04:13:03 +03:00
Alibek Omarov
67737446ac mainui: update 2023-12-06 04:12:33 +03:00
57 changed files with 488 additions and 356 deletions

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 )

View File

@@ -1109,12 +1109,12 @@ void CL_InitEdicts( int maxclients )
clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos ); clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos );
} }
ref.dllFuncs.R_ProcessEntData( true ); ref.dllFuncs.R_ProcessEntData( true, clgame.entities, clgame.maxEntities );
} }
void CL_FreeEdicts( void ) void CL_FreeEdicts( void )
{ {
ref.dllFuncs.R_ProcessEntData( false ); ref.dllFuncs.R_ProcessEntData( false, NULL, 0 );
if( clgame.entities ) if( clgame.entities )
Mem_Free( clgame.entities ); Mem_Free( clgame.entities );
@@ -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

@@ -78,7 +78,7 @@ CL_CreateRawTextureFromPixels
Convert texture_t struct into mstudiotexture_t prototype Convert texture_t struct into mstudiotexture_t prototype
==================== ====================
*/ */
byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor ) static byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
{ {
static mstudiotexture_t pin; static mstudiotexture_t pin;
byte *pal; byte *pal;
@@ -111,7 +111,7 @@ CL_DuplicateTexture
Dupliacte texture with remap pixels Dupliacte texture with remap pixels
==================== ====================
*/ */
void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor ) static void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
{ {
const char *name; const char *name;
texture_t *tx = NULL; texture_t *tx = NULL;
@@ -154,7 +154,7 @@ CL_UpdateStudioTexture
Update texture top and bottom colors Update texture top and bottom colors
==================== ====================
*/ */
void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor ) static void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
{ {
rgbdata_t *pic; rgbdata_t *pic;
texture_t *tx = NULL; texture_t *tx = NULL;
@@ -215,7 +215,7 @@ CL_UpdateAliasTexture
Update texture top and bottom colors Update texture top and bottom colors
==================== ====================
*/ */
void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor ) static void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
{ {
char texname[MAX_QPATH]; char texname[MAX_QPATH];
rgbdata_t skin, *pic; rgbdata_t skin, *pic;
@@ -247,6 +247,68 @@ void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int sk
ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor ); ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
} }
/*
====================
CL_FreeRemapInfo
Release remap info per entity
====================
*/
static void CL_FreeRemapInfo( remap_info_t *info )
{
int i;
Assert( info != NULL );
// release all colormap texture copies
for( i = 0; i < info->numtextures; i++ )
{
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
}
if( info->textures[i] != 0 )
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
}
Mem_Free( info ); // release struct
}
/*
====================
CL_UpdateRemapInfo
Update all remaps per entity
====================
*/
static void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
{
remap_info_t *info;
int i;
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
info = clgame.remap_info[i];
if( !info ) return; // no remap info
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
return; // values is valid
for( i = 0; i < info->numtextures; i++ )
{
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
}
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
}
info->topcolor = topcolor;
info->bottomcolor = bottomcolor;
}
/* /*
==================== ====================
CL_AllocRemapInfo CL_AllocRemapInfo
@@ -255,7 +317,7 @@ Allocate new remap info per entity
and make copy of remap textures and make copy of remap textures
==================== ====================
*/ */
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor ) static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
{ {
remap_info_t *info; remap_info_t *info;
studiohdr_t *phdr; studiohdr_t *phdr;
@@ -362,68 +424,6 @@ void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int b
info->model = model; info->model = model;
} }
/*
====================
CL_UpdateRemapInfo
Update all remaps per entity
====================
*/
void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
{
remap_info_t *info;
int i;
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
info = clgame.remap_info[i];
if( !info ) return; // no remap info
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
return; // values is valid
for( i = 0; i < info->numtextures; i++ )
{
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
}
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
}
info->topcolor = topcolor;
info->bottomcolor = bottomcolor;
}
/*
====================
CL_FreeRemapInfo
Release remap info per entity
====================
*/
void CL_FreeRemapInfo( remap_info_t *info )
{
int i;
Assert( info != NULL );
// release all colormap texture copies
for( i = 0; i < info->numtextures; i++ )
{
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
}
if( info->textures[i] != 0 )
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
}
Mem_Free( info ); // release struct
}
/* /*
==================== ====================
CL_ClearAllRemaps CL_ClearAllRemaps
@@ -446,3 +446,21 @@ void CL_ClearAllRemaps( void )
} }
clgame.remap_info = NULL; clgame.remap_info = NULL;
} }
/*
=============
CL_EntitySetRemapColors
=============
*/
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom )
{
CL_AllocRemapInfo( e, mod, top, bottom );
if( CL_GetRemapInfoForEntity( e ))
{
CL_UpdateRemapInfo( e, top, bottom );
return true;
}
return false;
}

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

@@ -2665,7 +2665,7 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
// update flashlight endpos // update flashlight endpos
dl = CL_AllocDlight( ent->index ); dl = CL_AllocDlight( ent->index );
#if 1 #if 1
hit = CL_GetEntityByIndex( clgame.pmove->visents[trace.ent].info ); hit = CL_GetEntityByIndex( clgame.pmove->physents[trace.ent].info );
if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio )) if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio ))
VectorCopy( hit->origin, dl->origin ); VectorCopy( hit->origin, dl->origin );
else VectorCopy( trace.endpos, dl->origin ); else VectorCopy( trace.endpos, dl->origin );

View File

@@ -996,9 +996,7 @@ void CL_EmitEntities( void );
// cl_remap.c // cl_remap.c
// //
remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e ); remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e );
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor ); qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom );
void CL_FreeRemapInfo( remap_info_t *info );
void CL_UpdateRemapInfo( cl_entity_t *ent, int topcolor, int bottomcolor );
void CL_ClearAllRemaps( void ); void CL_ClearAllRemaps( void );
// //

View File

@@ -104,9 +104,9 @@ 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( void ) // clgame.palette[color]
{ {
return &clgame.palette[color]; return clgame.palette;
} }
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
@@ -158,11 +158,6 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s
0; 0;
} }
static poolhandle_t pfnImage_GetPool( void )
{
return host.imagepool;
}
static const bpc_desc_t *pfnImage_GetPFDesc( int idx ) static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
{ {
return &PFDesc[idx]; return &PFDesc[idx];
@@ -212,6 +207,11 @@ static qboolean R_Init_Video_( const int type )
return R_Init_Video( type ); return R_Init_Video( type );
} }
static model_t **pfnGetModels( void )
{
return cl.models;
}
static ref_api_t gEngfuncs = static ref_api_t gEngfuncs =
{ {
pfnEngineGetParm, pfnEngineGetParm,
@@ -246,9 +246,7 @@ static ref_api_t gEngfuncs =
Con_DrawString, Con_DrawString,
CL_DrawCenterPrint, CL_DrawCenterPrint,
CL_GetLocalPlayer,
CL_GetViewModel, CL_GetViewModel,
CL_GetEntityByIndex,
R_BeamGetEntity, R_BeamGetEntity,
CL_GetWaterEntity, CL_GetWaterEntity,
CL_AddVisibleEntity, CL_AddVisibleEntity,
@@ -272,12 +270,10 @@ static ref_api_t gEngfuncs =
Mod_ForName, Mod_ForName,
pfnMod_Extradata, pfnMod_Extradata,
CL_ModelHandle, pfnGetModels,
CL_EntitySetRemapColors,
CL_GetRemapInfoForEntity, CL_GetRemapInfoForEntity,
CL_AllocRemapInfo,
CL_FreeRemapInfo,
CL_UpdateRemapInfo,
CL_ExtraUpdate, CL_ExtraUpdate,
Host_Error, Host_Error,
@@ -285,7 +281,6 @@ static ref_api_t gEngfuncs =
COM_RandomFloat, COM_RandomFloat,
COM_RandomLong, COM_RandomLong,
pfnRefGetScreenFade, pfnRefGetScreenFade,
CL_TextMessageGet,
pfnGetPredictedOrigin, pfnGetPredictedOrigin,
pfnCL_GetPaletteColor, pfnCL_GetPaletteColor,
pfnCL_GetScreenInfo, pfnCL_GetScreenInfo,
@@ -349,7 +344,6 @@ static ref_api_t gEngfuncs =
FS_CopyImage, FS_CopyImage,
FS_FreeImage, FS_FreeImage,
Image_SetMDLPointer, Image_SetMDLPointer,
pfnImage_GetPool,
pfnImage_GetPFDesc, pfnImage_GetPFDesc,
pfnDrawNormalTriangles, pfnDrawNormalTriangles,
@@ -431,7 +425,7 @@ static qboolean R_LoadProgs( const char *name )
// make local copy of engfuncs to prevent overwrite it with user dll // make local copy of engfuncs to prevent overwrite it with user dll
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs )); memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
if( !GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState )) if( GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ) != REF_API_VERSION )
{ {
COM_FreeLibrary( ref.hInstance ); COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" ); Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" );

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

@@ -52,7 +52,7 @@ struct tests_stats_s tests_stats;
#endif #endif
CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" ); CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" );
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_CHEAT|FCVAR_FILTERABLE, "scale frame time" ); CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_FILTERABLE, "scale frame time" );
CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" ); CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" );
static CVAR_DEFINE_AUTO( host_serverstate, "0", FCVAR_READ_ONLY, "displays current server state" ); static CVAR_DEFINE_AUTO( host_serverstate, "0", FCVAR_READ_ONLY, "displays current server state" );
@@ -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 )
@@ -618,6 +619,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 +707,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 +795,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 +1220,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

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

@@ -34,7 +34,11 @@ GNU General Public License for more details.
// 2. FS functions are removed, instead we have full fs_api_t // 2. FS functions are removed, instead we have full fs_api_t
// 3. SlerpBones, CalcBonePosition/Quaternion calls were moved to libpublic/mathlib // 3. SlerpBones, CalcBonePosition/Quaternion calls were moved to libpublic/mathlib
// 4. R_StudioEstimateFrame now has time argument // 4. R_StudioEstimateFrame now has time argument
#define REF_API_VERSION 4 // 5. Removed GetSomethingByIndex calls, renderers are supposed to cache pointer values
// Removed previously unused calls
// Simplified remapping calls
// GetRefAPI is now expected to return REF_API_VERSION
#define REF_API_VERSION 5
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP) #define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
@@ -257,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
@@ -299,9 +304,7 @@ typedef struct ref_api_s
void (*CL_DrawCenterPrint)( void ); void (*CL_DrawCenterPrint)( void );
// entity management // entity management
struct cl_entity_s *(*GetLocalPlayer)( void );
struct cl_entity_s *(*GetViewModel)( void ); 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 *(*R_BeamGetEntity)( int index );
struct cl_entity_s *(*CL_GetWaterEntity)( const 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 );
@@ -329,13 +332,11 @@ typedef struct ref_api_s
// model management // model management
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC ); model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
void *(*Mod_Extradata)( int type, model_t *model ); void *(*Mod_Extradata)( int type, model_t *model );
struct model_s *(*pfnGetModelByIndex)( int index ); // CL_ModelHandle struct model_s **(*pfnGetModels)( void );
// remap // remap
qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom );
struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e ); struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e );
void (*CL_AllocRemapInfo)( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
void (*CL_FreeRemapInfo)( struct remap_info_s *info );
void (*CL_UpdateRemapInfo)( cl_entity_t *entity, int topcolor, int bottomcolor );
// utils // utils
void (*CL_ExtraUpdate)( void ); void (*CL_ExtraUpdate)( void );
@@ -344,9 +345,8 @@ typedef struct ref_api_s
float (*COM_RandomFloat)( float rmin, float rmax ); float (*COM_RandomFloat)( float rmin, float rmax );
int (*COM_RandomLong)( int rmin, int rmax ); int (*COM_RandomLong)( int rmin, int rmax );
struct screenfade_s *(*GetScreenFade)( void ); struct screenfade_s *(*GetScreenFade)( void );
struct client_textmessage_s *(*pfnTextMessageGet)( const char *pName );
void (*GetPredictedOrigin)( vec3_t v ); void (*GetPredictedOrigin)( vec3_t v );
color24 *(*CL_GetPaletteColor)(int color); // clgame.palette[color] color24 *(*CL_GetPaletteColor)( void ); // 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 );
@@ -362,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
@@ -420,7 +420,6 @@ typedef struct ref_api_s
rgbdata_t *(*FS_CopyImage)( rgbdata_t *in ); rgbdata_t *(*FS_CopyImage)( rgbdata_t *in );
void (*FS_FreeImage)( rgbdata_t *pack ); void (*FS_FreeImage)( rgbdata_t *pack );
void (*Image_SetMDLPointer)( byte *p ); void (*Image_SetMDLPointer)( byte *p );
poolhandle_t (*Image_GetPool)( void );
const struct bpc_desc_s *(*Image_GetPFDesc)( int idx ); const struct bpc_desc_s *(*Image_GetPFDesc)( int idx );
// client exports // client exports
@@ -449,6 +448,7 @@ typedef struct ref_interface_s
void (*GL_InitExtensions)( void ); void (*GL_InitExtensions)( void );
void (*GL_ClearExtensions)( void ); void (*GL_ClearExtensions)( void );
// scene rendering
void (*R_BeginFrame)( qboolean clearScene ); void (*R_BeginFrame)( qboolean clearScene );
void (*R_RenderScene)( void ); void (*R_RenderScene)( void );
void (*R_EndFrame)( void ); void (*R_EndFrame)( void );
@@ -463,7 +463,8 @@ typedef struct ref_interface_s
qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type ); qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type );
void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam ); void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam );
void (*R_ProcessEntData)( qboolean allocate ); void (*R_ProcessEntData)( qboolean allocate, cl_entity_t *entities, unsigned int max_entities );
void (*R_Flush)( unsigned int flush_flags );
// debug // debug
void (*R_ShowTextures)( void ); void (*R_ShowTextures)( void );

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

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

@@ -438,7 +438,10 @@ uint COM_HashKey( const char *string, uint hashSize )
unsigned char i; unsigned char i;
while(( i = *string++ )) while(( i = *string++ ))
{
i = Q_tolower( i );
hashKey = ( hashKey << 5 ) + hashKey + ( i & 0xDF ); hashKey = ( hashKey << 5 ) + hashKey + ( i & 0xDF );
}
return hashKey & ( hashSize - 1 ); return hashKey & ( hashSize - 1 );
} }

View File

@@ -427,7 +427,7 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height )
skin.encode = DXT_ENCODE_DEFAULT; skin.encode = DXT_ENCODE_DEFAULT;
skin.numMips = 1; skin.numMips = 1;
skin.buffer = data; skin.buffer = data;
skin.palette = (byte *)gEngfuncs.CL_GetPaletteColor( 0 ); skin.palette = (byte *)tr.palette;
skin.size = width * height; skin.size = width * height;
if( !gEngfuncs.Image_CustomPalette() ) if( !gEngfuncs.Image_CustomPalette() )
@@ -1002,15 +1002,10 @@ R_AliasSetRemapColors
=============== ===============
*/ */
void R_AliasSetRemapColors( int newTop, int newBottom ) static void R_AliasSetRemapColors( int newTop, int newBottom )
{ {
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom ); if( gEngfuncs.CL_EntitySetRemapColors( RI.currententity, RI.currentmodel, newTop, newBottom ))
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
{
gEngfuncs.CL_UpdateRemapInfo( RI.currententity, newTop, newBottom );
m_fDoRemap = true; m_fDoRemap = true;
}
} }
/* /*
@@ -1261,7 +1256,7 @@ static void R_AliasDrawAbsBBox( cl_entity_t *e, const vec3_t absmin, const vec3_
int i; int i;
// looks ugly, skip // looks ugly, skip
if( r_drawentities->value != 5 || e == gEngfuncs.GetViewModel() ) if( r_drawentities->value != 5 || e == tr.viewent )
return; return;
// compute a full bounding box // compute a full bounding box

View File

@@ -943,7 +943,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
model_t *model; model_t *model;
vec3_t delta; vec3_t delta;
model = gEngfuncs.pfnGetModelByIndex( pbeam->modelIndex ); model = CL_ModelHandle( pbeam->modelIndex );
SetBits( pbeam->flags, FBEAM_ISACTIVE ); SetBits( pbeam->flags, FBEAM_ISACTIVE );
if( !model || model->type != mod_sprite ) if( !model || model->type != mod_sprite )
@@ -1146,7 +1146,7 @@ passed through this
*/ */
static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed ) static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed )
{ {
model_t *sprite = gEngfuncs.pfnGetModelByIndex( modelIndex ); model_t *sprite = CL_ModelHandle( modelIndex );
if( !sprite ) return; if( !sprite ) return;

View File

@@ -295,19 +295,32 @@ const byte *GL_TextureData( unsigned int texnum )
return NULL; return NULL;
} }
void R_ProcessEntData( qboolean allocate ) void R_ProcessEntData( qboolean allocate, cl_entity_t *entities, unsigned int max_entities )
{ {
if( !allocate ) if( !allocate )
{ {
tr.draw_list->num_solid_entities = 0; tr.draw_list->num_solid_entities = 0;
tr.draw_list->num_trans_entities = 0; tr.draw_list->num_trans_entities = 0;
tr.draw_list->num_beam_entities = 0; tr.draw_list->num_beam_entities = 0;
tr.max_entities = 0;
tr.entities = NULL;
}
else
{
tr.max_entities = max_entities;
tr.entities = entities;
} }
if( gEngfuncs.drawFuncs->R_ProcessEntData ) if( gEngfuncs.drawFuncs->R_ProcessEntData )
gEngfuncs.drawFuncs->R_ProcessEntData( allocate ); gEngfuncs.drawFuncs->R_ProcessEntData( allocate );
} }
static void GAME_EXPORT R_Flush( unsigned int flags )
{
// stub
}
qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int offset_y, float scale_x, float scale_y ) qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int offset_y, float scale_x, float scale_y )
{ {
qboolean ret = true; qboolean ret = true;
@@ -372,6 +385,7 @@ ref_interface_t gReffuncs =
R_AddEntity, R_AddEntity,
CL_AddCustomBeam, CL_AddCustomBeam,
R_ProcessEntData, R_ProcessEntData,
R_Flush,
R_ShowTextures, R_ShowTextures,

View File

@@ -42,7 +42,7 @@ R_CullModel
*/ */
int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax ) int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax )
{ {
if( e == gEngfuncs.GetViewModel() ) if( e == tr.viewent )
{ {
if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW )) if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
return 1; return 1;
@@ -77,7 +77,7 @@ int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags )
return CULL_VISIBLE; return CULL_VISIBLE;
// world surfaces can be culled by vis frame too // world surfaces can be culled by vis frame too
if( RI.currententity == gEngfuncs.GetEntityByIndex( 0 ) && surf->visframe != tr.framecount ) if( RI.currententity == CL_GetEntityByIndex( 0 ) && surf->visframe != tr.framecount )
return CULL_VISFRAME; return CULL_VISFRAME;
// only static ents can be culled by frustum // only static ents can be culled by frustum
@@ -92,7 +92,7 @@ int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags )
{ {
vec3_t orthonormal; vec3_t orthonormal;
if( e == gEngfuncs.GetEntityByIndex( 0 ) ) orthonormal[2] = surf->plane->normal[2]; if( e == CL_GetEntityByIndex( 0 )) orthonormal[2] = surf->plane->normal[2];
else Matrix4x4_VectorRotate( RI.objectMatrix, surf->plane->normal, orthonormal ); else Matrix4x4_VectorRotate( RI.objectMatrix, surf->plane->normal, orthonormal );
dist = orthonormal[2]; dist = orthonormal[2];
} }

View File

@@ -28,7 +28,7 @@ GNU General Public License for more details.
// REFTODO: rewrite in triapi // REFTODO: rewrite in triapi
void R_DrawWorldHull( void ) void R_DrawWorldHull( void )
{ {
hull_model_t *hull = &WORLD->hull_models[0]; hull_model_t *hull = &tr.world->hull_models[0];
winding_t *poly; winding_t *poly;
int i; int i;
@@ -69,10 +69,10 @@ void R_DrawModelHull( void )
return; return;
i = atoi( RI.currentmodel->name + 1 ); i = atoi( RI.currentmodel->name + 1 );
if( i < 1 || i >= WORLD->num_hull_models ) if( i < 1 || i >= tr.world->num_hull_models )
return; return;
hull = &WORLD->hull_models[i]; hull = &tr.world->hull_models[i];
pglPolygonOffset( 1.0f, 2.0 ); pglPolygonOffset( 1.0f, 2.0 );
pglEnable( GL_POLYGON_OFFSET_FILL ); pglEnable( GL_POLYGON_OFFSET_FILL );

View File

@@ -750,15 +750,15 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos
if( entityIndex > 0 ) if( entityIndex > 0 )
{ {
ent = gEngfuncs.GetEntityByIndex( entityIndex ); ent = CL_GetEntityByIndex( entityIndex );
if( modelIndex > 0 ) model = gEngfuncs.pfnGetModelByIndex( modelIndex ); if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
else if( ent != NULL ) model = gEngfuncs.pfnGetModelByIndex( ent->curstate.modelindex ); else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
else return; else return;
} }
else if( modelIndex > 0 ) else if( modelIndex > 0 )
model = gEngfuncs.pfnGetModelByIndex( modelIndex ); model = CL_ModelHandle( modelIndex );
else model = WORLDMODEL; else model = CL_ModelHandle( 1 );
if( !model ) return; if( !model ) return;

View File

@@ -1668,11 +1668,11 @@ int GL_LoadTextureArray( const char **names, int flags )
else else
{ {
// create new image // create new image
pic = Mem_Malloc( gEngfuncs.Image_GetPool(), sizeof( rgbdata_t )); pic = Mem_Malloc( r_temppool, sizeof( rgbdata_t ));
memcpy( pic, src, sizeof( rgbdata_t )); memcpy( pic, src, sizeof( rgbdata_t ));
// expand pic buffer for all layers // expand pic buffer for all layers
pic->buffer = Mem_Malloc( gEngfuncs.Image_GetPool(), pic->size * numLayers ); pic->buffer = Mem_Malloc( r_temppool, pic->size * numLayers );
pic->depth = 0; pic->depth = 0;
} }

View File

@@ -57,10 +57,6 @@ void VGL_ShimEndFrame( void );
#include <stdio.h> #include <stdio.h>
#define WORLD (gEngfuncs.GetWorld())
#define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
#define MOVEVARS (gEngfuncs.pfnGetMoveVars())
// make mod_ref.h? // make mod_ref.h?
#define LM_SAMPLE_SIZE 16 #define LM_SAMPLE_SIZE 16
@@ -257,6 +253,16 @@ typedef struct
vec3_t modelorg; // relative to viewpoint vec3_t modelorg; // relative to viewpoint
qboolean fCustomSkybox; qboolean fCustomSkybox;
// get from engine
struct world_static_s *world;
cl_entity_t *entities;
movevars_t *movevars;
model_t **models;
color24 *palette;
cl_entity_t *viewent;
uint max_entities;
} gl_globals_t; } gl_globals_t;
typedef struct typedef struct
@@ -707,7 +713,6 @@ typedef struct
qboolean in2DMode; qboolean in2DMode;
} glstate_t; } glstate_t;
typedef struct typedef struct
{ {
qboolean initialized; // OpenGL subsystem started qboolean initialized; // OpenGL subsystem started
@@ -724,6 +729,21 @@ extern ref_globals_t *gpGlobals;
#define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm) #define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm)
#define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( ( parm ), 0 ) #define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( ( parm ), 0 )
//
// helper funcs
//
static inline cl_entity_t *CL_GetEntityByIndex( int index )
{
return &tr.entities[index];
}
static inline model_t *CL_ModelHandle( int index )
{
return tr.models[index];
}
#define WORLDMODEL (tr.models[1])
// //
// renderer cvars // renderer cvars
// //

View File

@@ -1284,6 +1284,13 @@ qboolean R_Init( void )
return false; return false;
} }
// see R_ProcessEntData for tr.entities initialization
tr.world = gEngfuncs.GetWorld();
tr.models = gEngfuncs.pfnGetModels();
tr.movevars = gEngfuncs.pfnGetMoveVars();
tr.palette = gEngfuncs.CL_GetPaletteColor();
tr.viewent = gEngfuncs.GetViewModel();
GL_SetDefaults(); GL_SetDefaults();
R_CheckVBO(); R_CheckVBO();
R_InitImages(); R_InitImages();

View File

@@ -152,7 +152,7 @@ void R_PushDlights( void )
tr.dlightframecount = tr.framecount; tr.dlightframecount = tr.framecount;
RI.currententity = gEngfuncs.GetEntityByIndex( 0 ); RI.currententity = CL_GetEntityByIndex( 0 );
if( RI.currententity ) if( RI.currententity )
RI.currentmodel = RI.currententity->model; RI.currentmodel = RI.currententity->model;

View File

@@ -324,7 +324,7 @@ R_GetFarClip
static float R_GetFarClip( void ) static float R_GetFarClip( void )
{ {
if( WORLDMODEL && RI.drawWorld ) if( WORLDMODEL && RI.drawWorld )
return MOVEVARS->zmax * 1.73f; return tr.movevars->zmax * 1.73f;
return 2048.0f; return 2048.0f;
} }
@@ -429,7 +429,7 @@ void R_RotateForEntity( cl_entity_t *e )
{ {
float scale = 1.0f; float scale = 1.0f;
if( e == gEngfuncs.GetEntityByIndex( 0 ) ) if( e == CL_GetEntityByIndex( 0 ))
{ {
R_LoadIdentity(); R_LoadIdentity();
return; return;
@@ -455,7 +455,7 @@ void R_TranslateForEntity( cl_entity_t *e )
{ {
float scale = 1.0f; float scale = 1.0f;
if( e == gEngfuncs.GetEntityByIndex( 0 ) ) if( e == CL_GetEntityByIndex( 0 ))
{ {
R_LoadIdentity(); R_LoadIdentity();
return; return;
@@ -669,7 +669,7 @@ static void R_CheckFog( void )
// quake global fog // quake global fog
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE )) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
{ {
if( !MOVEVARS->fog_settings ) if( !tr.movevars->fog_settings )
{ {
if( pglIsEnabled( GL_FOG )) if( pglIsEnabled( GL_FOG ))
pglDisable( GL_FOG ); pglDisable( GL_FOG );
@@ -678,10 +678,10 @@ static void R_CheckFog( void )
} }
// quake-style global fog // quake-style global fog
RI.fogColor[0] = ((MOVEVARS->fog_settings & 0xFF000000) >> 24) / 255.0f; RI.fogColor[0] = ((tr.movevars->fog_settings & 0xFF000000) >> 24) / 255.0f;
RI.fogColor[1] = ((MOVEVARS->fog_settings & 0xFF0000) >> 16) / 255.0f; RI.fogColor[1] = ((tr.movevars->fog_settings & 0xFF0000) >> 16) / 255.0f;
RI.fogColor[2] = ((MOVEVARS->fog_settings & 0xFF00) >> 8) / 255.0f; RI.fogColor[2] = ((tr.movevars->fog_settings & 0xFF00) >> 8) / 255.0f;
RI.fogDensity = ((MOVEVARS->fog_settings & 0xFF) / 255.0f) * 0.01f; RI.fogDensity = ((tr.movevars->fog_settings & 0xFF) / 255.0f) * 0.01f;
RI.fogStart = RI.fogEnd = 0.0f; RI.fogStart = RI.fogEnd = 0.0f;
RI.fogColor[3] = 1.0f; RI.fogColor[3] = 1.0f;
RI.fogCustom = false; RI.fogCustom = false;

View File

@@ -146,7 +146,7 @@ void R_NewMap( void )
tx->texturechain = NULL; tx->texturechain = NULL;
} }
R_SetupSky( MOVEVARS->skyName ); R_SetupSky( tr.movevars->skyName );
GL_BuildLightmaps (); GL_BuildLightmaps ();
R_GenerateVBO(); R_GenerateVBO();

View File

@@ -49,7 +49,7 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
{ {
particle_t *p; particle_t *p;
vec3_t right, up; vec3_t right, up;
color24 *pColor; color24 color;
int alpha; int alpha;
float size; float size;
@@ -85,15 +85,15 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
VectorScale( RI.cull_vup, size, up ); VectorScale( RI.cull_vup, size, up );
p->color = bound( 0, p->color, 255 ); p->color = bound( 0, p->color, 255 );
pColor = gEngfuncs.CL_GetPaletteColor( p->color ); color = tr.palette[p->color];
alpha = 255 * (p->die - gpGlobals->time) * 16.0f; alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
if( alpha > 255 || p->type == pt_static ) if( alpha > 255 || p->type == pt_static )
alpha = 255; alpha = 255;
pglColor4ub( gEngfuncs.LightToTexGamma( pColor->r ), pglColor4ub( gEngfuncs.LightToTexGamma( color.r ),
gEngfuncs.LightToTexGamma( pColor->g ), gEngfuncs.LightToTexGamma( color.g ),
gEngfuncs.LightToTexGamma( pColor->b ), alpha ); gEngfuncs.LightToTexGamma( color.b ), alpha );
pglTexCoord2f( 0.0f, 1.0f ); pglTexCoord2f( 0.0f, 1.0f );
pglVertex3f( p->org[0] - right[0] + up[0], p->org[1] - right[1] + up[1], p->org[2] - right[2] + up[2] ); pglVertex3f( p->org[0] - right[0] + up[0], p->org[1] - right[1] + up[1], p->org[2] - right[2] + up[2] );
@@ -188,7 +188,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
pglDisable( GL_ALPHA_TEST ); pglDisable( GL_ALPHA_TEST );
pglDepthMask( GL_FALSE ); pglDepthMask( GL_FALSE );
gravity = frametime * MOVEVARS->gravity; gravity = frametime * tr.movevars->gravity;
scale = 1.0 - (frametime * 0.9); scale = 1.0 - (frametime * 0.9);
if( scale < 0.0f ) scale = 0.0f; if( scale < 0.0f ) scale = 0.0f;
@@ -205,7 +205,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
{ {
vec3_t verts[4], tmp2; vec3_t verts[4], tmp2;
vec3_t tmp, normal; vec3_t tmp, normal;
color24 *pColor; color24 color;
// Transform point into screen space // Transform point into screen space
TriWorldToScreen( start, screen ); TriWorldToScreen( start, screen );
@@ -235,8 +235,8 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
p->color = 0; p->color = 0;
} }
pColor = &gTracerColors[p->color]; color = gTracerColors[p->color];
pglColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor ); pglColor4ub( color.r, color.g, color.b, p->packedColor );
pglBegin( GL_QUADS ); pglBegin( GL_QUADS );
pglTexCoord2f( 0.0f, 0.8f ); pglTexCoord2f( 0.0f, 0.8f );

View File

@@ -758,7 +758,7 @@ void DrawGLPoly( glpoly_t *p, float xScale, float yScale )
float flRate, flAngle; float flRate, flAngle;
gl_texture_t *texture; gl_texture_t *texture;
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && RI.currententity == gEngfuncs.GetEntityByIndex( 0 ) ) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && RI.currententity == CL_GetEntityByIndex( 0 ))
{ {
// same as doom speed // same as doom speed
flConveyorSpeed = -35.0f; flConveyorSpeed = -35.0f;
@@ -1235,7 +1235,7 @@ void R_DrawTextureChains( void )
GL_SetupFogColorForSurfaces(); GL_SetupFogColorForSurfaces();
// restore worldmodel // restore worldmodel
RI.currententity = gEngfuncs.GetEntityByIndex( 0 ); RI.currententity = CL_GetEntityByIndex( 0 );
RI.currentmodel = RI.currententity->model; RI.currentmodel = RI.currententity->model;
if( ENGINE_GET_PARM( PARM_SKY_SPHERE ) ) if( ENGINE_GET_PARM( PARM_SKY_SPHERE ) )
@@ -1266,7 +1266,7 @@ void R_DrawTextureChains( void )
if( !s || ( i == tr.skytexturenum )) if( !s || ( i == tr.skytexturenum ))
continue; continue;
if(( s->flags & SURF_DRAWTURB ) && MOVEVARS->wateralpha < 1.0f ) if(( s->flags & SURF_DRAWTURB ) && tr.movevars->wateralpha < 1.0f )
continue; // draw translucent water later continue; // draw translucent water later
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && FBitSet( s->flags, SURF_TRANSPARENT )) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && FBitSet( s->flags, SURF_TRANSPARENT ))
@@ -1309,7 +1309,7 @@ void R_DrawAlphaTextureChains( void )
GL_SetupFogColorForSurfaces(); GL_SetupFogColorForSurfaces();
// restore worldmodel // restore worldmodel
RI.currententity = gEngfuncs.GetEntityByIndex( 0 ); RI.currententity = CL_GetEntityByIndex( 0 );
RI.currentmodel = RI.currententity->model; RI.currentmodel = RI.currententity->model;
RI.currententity->curstate.rendermode = kRenderTransAlpha; RI.currententity->curstate.rendermode = kRenderTransAlpha;
draw_alpha_surfaces = false; draw_alpha_surfaces = false;
@@ -1350,11 +1350,11 @@ void R_DrawWaterSurfaces( void )
return; return;
// non-transparent water is already drawed // non-transparent water is already drawed
if( MOVEVARS->wateralpha >= 1.0f ) if( tr.movevars->wateralpha >= 1.0f )
return; return;
// restore worldmodel // restore worldmodel
RI.currententity = gEngfuncs.GetEntityByIndex( 0 ); RI.currententity = CL_GetEntityByIndex( 0 );
RI.currentmodel = RI.currententity->model; RI.currentmodel = RI.currententity->model;
// go back to the world matrix // go back to the world matrix
@@ -1365,7 +1365,7 @@ void R_DrawWaterSurfaces( void )
pglDisable( GL_ALPHA_TEST ); pglDisable( GL_ALPHA_TEST );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglColor4f( 1.0f, 1.0f, 1.0f, MOVEVARS->wateralpha ); pglColor4f( 1.0f, 1.0f, 1.0f, tr.movevars->wateralpha );
for( i = 0; i < WORLDMODEL->numtextures; i++ ) for( i = 0; i < WORLDMODEL->numtextures; i++ )
{ {
@@ -3280,7 +3280,7 @@ void R_DrawWorld( void )
// paranoia issues: when gl_renderer is "0" we need have something valid for currententity // paranoia issues: when gl_renderer is "0" we need have something valid for currententity
// to prevent crashing until HeadShield drawing. // to prevent crashing until HeadShield drawing.
RI.currententity = gEngfuncs.GetEntityByIndex( 0 ); RI.currententity = CL_GetEntityByIndex( 0 );
if( !RI.currententity ) if( !RI.currententity )
return; return;
@@ -3490,7 +3490,7 @@ void GL_RebuildLightmaps( void )
for( i = 0; i < ENGINE_GET_PARM( PARM_NUMMODELS ); i++ ) for( i = 0; i < ENGINE_GET_PARM( PARM_NUMMODELS ); i++ )
{ {
if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL ) if(( m = CL_ModelHandle( i + 1 )) == NULL )
continue; continue;
if( m->name[0] == '*' || m->type != mod_brush ) if( m->name[0] == '*' || m->type != mod_brush )
@@ -3532,7 +3532,8 @@ void GL_BuildLightmaps( void )
memset( &RI, 0, sizeof( RI )); memset( &RI, 0, sizeof( RI ));
// update the lightmap blocksize // update the lightmap blocksize
if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_LARGE_LIGHTMAPS )) if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_LARGE_LIGHTMAPS )
|| ENGINE_GET_PARM( PARM_WORLD_VERSION ) == QBSP2_VERSION )
tr.block_size = BLOCK_SIZE_MAX; tr.block_size = BLOCK_SIZE_MAX;
else tr.block_size = BLOCK_SIZE_DEFAULT; else tr.block_size = BLOCK_SIZE_DEFAULT;
@@ -3554,7 +3555,7 @@ void GL_BuildLightmaps( void )
for( i = 0; i < ENGINE_GET_PARM( PARM_NUMMODELS ); i++ ) for( i = 0; i < ENGINE_GET_PARM( PARM_NUMMODELS ); i++ )
{ {
if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL ) if(( m = CL_ModelHandle( i + 1 )) == NULL )
continue; continue;
if( m->name[0] == '*' || m->type != mod_brush ) if( m->name[0] == '*' || m->type != mod_brush )

View File

@@ -826,7 +826,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
{ {
cl_entity_t *parent; cl_entity_t *parent;
parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment ); parent = CL_GetEntityByIndex( e->curstate.aiment );
if( parent && parent->model ) if( parent && parent->model )
{ {

View File

@@ -196,7 +196,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e )
{ {
if( cl_righthand && cl_righthand->value > 0 ) if( cl_righthand && cl_righthand->value > 0 )
{ {
if( e == gEngfuncs.GetViewModel() ) if( e == tr.viewent )
return true; return true;
} }
@@ -412,7 +412,7 @@ pfnGetViewEntity
*/ */
static cl_entity_t *pfnGetViewEntity( void ) static cl_entity_t *pfnGetViewEntity( void )
{ {
return gEngfuncs.GetViewModel(); return tr.viewent;
} }
/* /*
@@ -1851,7 +1851,7 @@ void R_StudioRenderShadow( int iSprite, float *p1, float *p2, float *p3, float *
if( !p1 || !p2 || !p3 || !p4 ) if( !p1 || !p2 || !p3 || !p4 )
return; return;
if( TriSpriteTexture( gEngfuncs.pfnGetModelByIndex( iSprite ), 0 )) if( TriSpriteTexture( CL_ModelHandle( iSprite ), 0 ))
{ {
TriRenderMode( kRenderTransAlpha ); TriRenderMode( kRenderTransAlpha );
TriColor4f( 0.0f, 0.0f, 0.0f, 1.0f ); TriColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
@@ -2488,7 +2488,7 @@ static void R_StudioDrawAbsBBox( void )
int i; int i;
// looks ugly, skip // looks ugly, skip
if( RI.currententity == gEngfuncs.GetViewModel() ) if( RI.currententity == tr.viewent )
return; return;
if( !R_StudioComputeBBox( p )) if( !R_StudioComputeBBox( p ))
@@ -2624,13 +2624,8 @@ R_StudioSetRemapColors
*/ */
static void R_StudioSetRemapColors( int newTop, int newBottom ) static void R_StudioSetRemapColors( int newTop, int newBottom )
{ {
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom ); if( gEngfuncs.CL_EntitySetRemapColors( RI.currententity, RI.currentmodel, newTop, newBottom ))
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
{
gEngfuncs.CL_UpdateRemapInfo( RI.currententity, newTop, newBottom );
m_fDoRemap = true; m_fDoRemap = true;
}
} }
void R_StudioResetPlayerModels( void ) void R_StudioResetPlayerModels( void )
@@ -3371,7 +3366,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
// copy attachments into global entity array // copy attachments into global entity array
if( RI.currententity->index > 0 ) if( RI.currententity->index > 0 )
{ {
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index ); cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 ); memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
} }
} }
@@ -3414,7 +3409,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
if( pplayer->weaponmodel ) if( pplayer->weaponmodel )
{ {
cl_entity_t saveent = *RI.currententity; cl_entity_t saveent = *RI.currententity;
model_t *pweaponmodel = gEngfuncs.pfnGetModelByIndex( pplayer->weaponmodel ); model_t *pweaponmodel = CL_ModelHandle( pplayer->weaponmodel );
m_pStudioHeader = (studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, pweaponmodel ); m_pStudioHeader = (studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, pweaponmodel );
@@ -3500,7 +3495,7 @@ static int R_StudioDrawModel( int flags )
// copy attachments into global entity array // copy attachments into global entity array
if( RI.currententity->index > 0 ) if( RI.currententity->index > 0 )
{ {
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index ); cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 ); memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
} }
} }
@@ -3569,7 +3564,7 @@ void R_DrawStudioModel( cl_entity_t *e )
{ {
if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 ) if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
{ {
cl_entity_t *parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment ); cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment );
if( parent && parent->model && parent->model->type == mod_studio ) if( parent && parent->model && parent->model->type == mod_studio )
{ {
@@ -3605,7 +3600,7 @@ void R_RunViewmodelEvents( void )
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer()) if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return; return;
RI.currententity = gEngfuncs.GetViewModel(); RI.currententity = tr.viewent;
if( !RI.currententity->model || RI.currententity->model->type != mod_studio ) if( !RI.currententity->model || RI.currententity->model->type != mod_studio )
return; return;
@@ -3627,7 +3622,7 @@ R_GatherPlayerLight
*/ */
void R_GatherPlayerLight( void ) void R_GatherPlayerLight( void )
{ {
cl_entity_t *view = gEngfuncs.GetViewModel(); cl_entity_t *view = tr.viewent;
colorVec c; colorVec c;
tr.ignore_lightgamma = true; tr.ignore_lightgamma = true;
@@ -3643,7 +3638,7 @@ R_DrawViewModel
*/ */
void R_DrawViewModel( void ) void R_DrawViewModel( void )
{ {
cl_entity_t *view = gEngfuncs.GetViewModel(); cl_entity_t *view = tr.viewent;
R_GatherPlayerLight(); R_GatherPlayerLight();
@@ -3828,7 +3823,9 @@ void Mod_StudioUnloadTextures( void *data )
static model_t *pfnModelHandle( int modelindex ) static model_t *pfnModelHandle( int modelindex )
{ {
return gEngfuncs.pfnGetModelByIndex( modelindex ); if( modelindex < 0 || modelindex >= MAX_MODELS )
return NULL;
return CL_ModelHandle( modelindex );
} }
static void *pfnMod_CacheCheck( struct cache_user_s *c ) static void *pfnMod_CacheCheck( struct cache_user_s *c )

View File

@@ -956,7 +956,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
model_t *model; model_t *model;
vec3_t delta; vec3_t delta;
model = gEngfuncs.pfnGetModelByIndex( pbeam->modelIndex ); model = CL_ModelHandle( pbeam->modelIndex );
SetBits( pbeam->flags, FBEAM_ISACTIVE ); SetBits( pbeam->flags, FBEAM_ISACTIVE );
if( !model || model->type != mod_sprite ) if( !model || model->type != mod_sprite )
@@ -1159,7 +1159,7 @@ passed through this
*/ */
static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed ) static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed )
{ {
model_t *sprite = gEngfuncs.pfnGetModelByIndex( modelIndex ); model_t *sprite = CL_ModelHandle( modelIndex );
if( !sprite ) return; if( !sprite ) return;

View File

@@ -949,7 +949,7 @@ void R_RenderWorld (void)
c_drawnode=0; c_drawnode=0;
// auto cycle the world frame for texture animation // auto cycle the world frame for texture animation
RI.currententity = gEngfuncs.GetEntityByIndex(0); RI.currententity = CL_GetEntityByIndex(0);
//RI.currententity->frame = (int)(gpGlobals->time*2); //RI.currententity->frame = (int)(gpGlobals->time*2);
VectorCopy (RI.vieworg, tr.modelorg); VectorCopy (RI.vieworg, tr.modelorg);

View File

@@ -273,9 +273,15 @@ void Mod_UnloadTextures( model_t *mod )
} }
} }
void GAME_EXPORT R_ProcessEntData( qboolean allocate ) void GAME_EXPORT R_ProcessEntData( qboolean allocate, cl_entity_t *entities, unsigned int max_entities )
{ {
tr.entities = entities;
tr.max_entities = max_entities;
}
static void GAME_EXPORT R_Flush( unsigned int flags )
{
// stub
} }
// stubs // stubs
@@ -425,6 +431,7 @@ ref_interface_t gReffuncs =
R_AddEntity, R_AddEntity,
CL_AddCustomBeam, CL_AddCustomBeam,
R_ProcessEntData, R_ProcessEntData,
R_Flush,
R_ShowTextures, R_ShowTextures,

View File

@@ -774,14 +774,14 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
if( entityIndex > 0 ) if( entityIndex > 0 )
{ {
ent = gEngfuncs.GetEntityByIndex( entityIndex ); ent = CL_GetEntityByIndex( entityIndex );
if( modelIndex > 0 ) model = gEngfuncs.pfnGetModelByIndex( modelIndex ); if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
else if( ent != NULL ) model = gEngfuncs.pfnGetModelByIndex( ent->curstate.modelindex ); else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
else return; else return;
} }
else if( modelIndex > 0 ) else if( modelIndex > 0 )
model = gEngfuncs.pfnGetModelByIndex( modelIndex ); model = CL_ModelHandle( modelIndex );
else model = WORLDMODEL; else model = WORLDMODEL;
if( !model ) return; if( !model ) return;

View File

@@ -1118,7 +1118,7 @@ void D_SolidSurf (surf_t *s)
{ {
if( alphaspans ) if( alphaspans )
return; return;
RI.currententity = gEngfuncs.GetEntityByIndex(0); //r_worldentity; RI.currententity = CL_GetEntityByIndex(0); //r_worldentity;
tr.modelviewIdentity = true; tr.modelviewIdentity = true;
} }

View File

@@ -155,7 +155,7 @@ void R_PushDlights( void )
tr.dlightframecount = tr.framecount; tr.dlightframecount = tr.framecount;
RI.currententity = gEngfuncs.GetEntityByIndex( 0 ); RI.currententity = CL_GetEntityByIndex( 0 );
if( RI.currententity ) if( RI.currententity )
RI.currentmodel = RI.currententity->model; RI.currentmodel = RI.currententity->model;

View File

@@ -41,14 +41,9 @@ typedef int fixed16_t;
#include <stdio.h> #include <stdio.h>
#define WORLD (gEngfuncs.GetWorld())
#define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
#define MOVEVARS (gEngfuncs.pfnGetMoveVars())
// make mod_ref.h? // make mod_ref.h?
#define LM_SAMPLE_SIZE 16 #define LM_SAMPLE_SIZE 16
extern poolhandle_t r_temppool; extern poolhandle_t r_temppool;
#define BLOCK_SIZE tr.block_size // lightmap blocksize #define BLOCK_SIZE tr.block_size // lightmap blocksize
@@ -298,6 +293,15 @@ typedef struct
int sample_size; int sample_size;
uint sample_bits; uint sample_bits;
qboolean map_unload; qboolean map_unload;
// get from engine
cl_entity_t *entities;
movevars_t *movevars;
model_t **models;
color24 *palette;
cl_entity_t *viewent;
uint max_entities;
} gl_globals_t; } gl_globals_t;
typedef struct typedef struct
@@ -672,6 +676,21 @@ void TriBrightness( float brightness );
#define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm) #define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm)
#define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( (parm), 0 ) #define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( (parm), 0 )
//
// helper funcs
//
static inline cl_entity_t *CL_GetEntityByIndex( int index )
{
return &tr.entities[index];
}
static inline model_t *CL_ModelHandle( int index )
{
return tr.models[index];
}
#define WORLDMODEL (tr.models[1])
extern ref_api_t gEngfuncs; extern ref_api_t gEngfuncs;
extern ref_globals_t *gpGlobals; extern ref_globals_t *gpGlobals;

View File

@@ -425,7 +425,7 @@ R_GetFarClip
static float R_GetFarClip( void ) static float R_GetFarClip( void )
{ {
if( WORLDMODEL && RI.drawWorld ) if( WORLDMODEL && RI.drawWorld )
return MOVEVARS->zmax * 1.73f; return tr.movevars->zmax * 1.73f;
return 2048.0f; return 2048.0f;
} }
@@ -539,7 +539,7 @@ void R_RotateForEntity( cl_entity_t *e )
#if 0 #if 0
float scale = 1.0f; float scale = 1.0f;
if( e == gEngfuncs.GetEntityByIndex( 0 ) ) if( e == CL_GetEntityByIndex( 0 ) )
{ {
R_LoadIdentity(); R_LoadIdentity();
return; return;
@@ -567,7 +567,7 @@ void R_TranslateForEntity( cl_entity_t *e )
#if 0 #if 0
float scale = 1.0f; float scale = 1.0f;
if( e == gEngfuncs.GetEntityByIndex( 0 ) ) if( e == CL_GetEntityByIndex( 0 ) )
{ {
R_LoadIdentity(); R_LoadIdentity();
return; return;
@@ -784,7 +784,7 @@ void R_DrawEntitiesOnList( void )
//d_aflatcolor = 0; //d_aflatcolor = 0;
tr.blend = 1.0f; tr.blend = 1.0f;
// GL_CheckForErrors(); // GL_CheckForErrors();
//RI.currententity = gEngfuncs.GetEntityByIndex(0); //RI.currententity = CL_GetEntityByIndex(0);
d_pdrawspans = R_PolysetFillSpans8; d_pdrawspans = R_PolysetFillSpans8;
GL_SetRenderMode(kRenderNormal); GL_SetRenderMode(kRenderNormal);
// first draw solid entities // first draw solid entities
@@ -815,7 +815,7 @@ void R_DrawEntitiesOnList( void )
extern void (*d_pdrawspans)(void *); extern void (*d_pdrawspans)(void *);
extern void R_PolysetFillSpans8 ( void * ); extern void R_PolysetFillSpans8 ( void * );
d_pdrawspans = R_PolysetFillSpans8; d_pdrawspans = R_PolysetFillSpans8;
//RI.currententity = gEngfuncs.GetEntityByIndex(0); //RI.currententity = CL_GetEntityByIndex(0);
R_AliasSetUpTransform(); R_AliasSetUpTransform();
image_t *image = R_GetTexture(GL_LoadTexture("gfx/env/desertbk", NULL, 0, 0)); image_t *image = R_GetTexture(GL_LoadTexture("gfx/env/desertbk", NULL, 0, 0));
r_affinetridesc.pskin = image->pixels[0]; r_affinetridesc.pskin = image->pixels[0];
@@ -1938,6 +1938,12 @@ qboolean GAME_EXPORT R_Init( void )
return false; return false;
} }
// see R_ProcessEntData for tr.entities initialization
tr.models = gEngfuncs.pfnGetModels();
tr.movevars = gEngfuncs.pfnGetMoveVars();
tr.palette = gEngfuncs.CL_GetPaletteColor();
tr.viewent = gEngfuncs.GetViewModel();
R_InitBlit( glblit ); R_InitBlit( glblit );
R_InitImages(); R_InitImages();

View File

@@ -49,7 +49,7 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
{ {
particle_t *p; particle_t *p;
vec3_t right, up; vec3_t right, up;
color24 *pColor; color24 color;
int alpha; int alpha;
float size; float size;
@@ -84,17 +84,17 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
VectorScale( RI.cull_vup, size, up ); VectorScale( RI.cull_vup, size, up );
p->color = bound( 0, p->color, 255 ); p->color = bound( 0, p->color, 255 );
pColor = gEngfuncs.CL_GetPaletteColor( p->color ); color = tr.palette[p->color];
alpha = 255 * (p->die - gpGlobals->time) * 16.0f; alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
if( alpha > 255 || p->type == pt_static ) if( alpha > 255 || p->type == pt_static )
alpha = 255; alpha = 255;
//TriColor4ub( gEngfuncs.LightToTexGamma( pColor->r ), //TriColor4ub( gEngfuncs.LightToTexGamma( color.r ),
// gEngfuncs.LightToTexGamma( pColor->g ), // gEngfuncs.LightToTexGamma( color.g ),
// gEngfuncs.LightToTexGamma( pColor->b ), alpha ); // gEngfuncs.LightToTexGamma( color.b ), alpha );
//TriBrightness( alpha / 255.0f ); //TriBrightness( alpha / 255.0f );
_TriColor4f(1.0f*alpha/255/255*pColor->r,1.0f*alpha/255/255*pColor->g,1.0f*alpha/255/255* pColor->b,1.0f ); _TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
TriBegin( TRI_QUADS ); TriBegin( TRI_QUADS );
TriTexCoord2f( 0.0f, 1.0f ); TriTexCoord2f( 0.0f, 1.0f );
@@ -194,7 +194,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
//pglDisable( GL_ALPHA_TEST ); //pglDisable( GL_ALPHA_TEST );
//pglDepthMask( GL_FALSE ); //pglDepthMask( GL_FALSE );
gravity = frametime * MOVEVARS->gravity; gravity = frametime * tr.movevars->gravity;
scale = 1.0 - (frametime * 0.9); scale = 1.0 - (frametime * 0.9);
if( scale < 0.0f ) scale = 0.0f; if( scale < 0.0f ) scale = 0.0f;
@@ -211,7 +211,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
{ {
vec3_t verts[4], tmp2; vec3_t verts[4], tmp2;
vec3_t tmp, normal; vec3_t tmp, normal;
color24 *pColor; color24 color;
short alpha = p->packedColor; short alpha = p->packedColor;
// Transform point into screen space // Transform point into screen space
@@ -242,9 +242,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
p->color = 0; p->color = 0;
} }
pColor = &gTracerColors[p->color]; color = gTracerColors[p->color];
//TriColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor ); //TriColor4ub( color.r, color.g, color.b, p->packedColor );
_TriColor4f(1.0f*alpha/255/255*pColor->r,1.0f*alpha/255/255*pColor->g,1.0f*alpha/255/255* pColor->b,1.0f ); _TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
TriBegin( TRI_QUADS ); TriBegin( TRI_QUADS );

View File

@@ -895,7 +895,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
{ {
cl_entity_t *parent; cl_entity_t *parent;
parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment ); parent = CL_GetEntityByIndex( e->curstate.aiment );
if( parent && parent->model ) if( parent && parent->model )
{ {

View File

@@ -185,7 +185,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e )
{ {
if( cl_righthand && cl_righthand->value > 0 ) if( cl_righthand && cl_righthand->value > 0 )
{ {
if( e == gEngfuncs.GetViewModel() ) if( e == tr.viewent )
return true; return true;
} }
@@ -401,7 +401,7 @@ pfnGetViewEntity
*/ */
static cl_entity_t *pfnGetViewEntity( void ) static cl_entity_t *pfnGetViewEntity( void )
{ {
return gEngfuncs.GetViewModel(); return tr.viewent;
} }
/* /*
@@ -1846,7 +1846,7 @@ void R_StudioRenderShadow( int iSprite, float *p1, float *p2, float *p3, float *
if( !p1 || !p2 || !p3 || !p4 ) if( !p1 || !p2 || !p3 || !p4 )
return; return;
if( TriSpriteTexture( gEngfuncs.pfnGetModelByIndex( iSprite ), 0 )) if( TriSpriteTexture( CL_ModelHandle( iSprite ), 0 ))
{ {
TriRenderMode( kRenderTransAlpha ); TriRenderMode( kRenderTransAlpha );
_TriColor4f( 0.0f, 0.0f, 0.0f, 1.0f ); _TriColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
@@ -2246,7 +2246,7 @@ static void R_StudioDrawAbsBBox( void )
int i; int i;
// looks ugly, skip // looks ugly, skip
if( RI.currententity == gEngfuncs.GetViewModel() ) if( RI.currententity == tr.viewent )
return; return;
if( !R_StudioComputeBBox( p )) if( !R_StudioComputeBBox( p ))
@@ -2384,13 +2384,8 @@ R_StudioSetRemapColors
*/ */
static void R_StudioSetRemapColors( int newTop, int newBottom ) static void R_StudioSetRemapColors( int newTop, int newBottom )
{ {
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom ); if( gEngfuncs.CL_EntitySetRemapColors( RI.currententity, RI.currentmodel, newTop, newBottom ))
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
{
gEngfuncs.CL_UpdateRemapInfo( RI.currententity, newTop, newBottom );
m_fDoRemap = true; m_fDoRemap = true;
}
} }
void R_StudioResetPlayerModels( void ) void R_StudioResetPlayerModels( void )
@@ -3137,7 +3132,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
// copy attachments into global entity array // copy attachments into global entity array
if( RI.currententity->index > 0 ) if( RI.currententity->index > 0 )
{ {
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index ); cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 ); memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
} }
} }
@@ -3180,7 +3175,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
if( pplayer->weaponmodel ) if( pplayer->weaponmodel )
{ {
cl_entity_t saveent = *RI.currententity; cl_entity_t saveent = *RI.currententity;
model_t *pweaponmodel = gEngfuncs.pfnGetModelByIndex( pplayer->weaponmodel ); model_t *pweaponmodel = CL_ModelHandle( pplayer->weaponmodel );
m_pStudioHeader = (studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, pweaponmodel ); m_pStudioHeader = (studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, pweaponmodel );
@@ -3266,7 +3261,7 @@ static int R_StudioDrawModel( int flags )
// copy attachments into global entity array // copy attachments into global entity array
if( RI.currententity->index > 0 ) if( RI.currententity->index > 0 )
{ {
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index ); cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 ); memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
} }
} }
@@ -3335,7 +3330,7 @@ void R_DrawStudioModel( cl_entity_t *e )
{ {
if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 ) if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
{ {
cl_entity_t *parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment ); cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment );
if( parent && parent->model && parent->model->type == mod_studio ) if( parent && parent->model && parent->model->type == mod_studio )
{ {
@@ -3371,7 +3366,7 @@ void R_RunViewmodelEvents( void )
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer()) if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return; return;
RI.currententity = gEngfuncs.GetViewModel(); RI.currententity = tr.viewent;
if( !RI.currententity->model || RI.currententity->model->type != mod_studio ) if( !RI.currententity->model || RI.currententity->model->type != mod_studio )
return; return;
@@ -3393,7 +3388,7 @@ R_GatherPlayerLight
*/ */
void R_GatherPlayerLight( void ) void R_GatherPlayerLight( void )
{ {
cl_entity_t *view = gEngfuncs.GetViewModel(); cl_entity_t *view = tr.viewent;
colorVec c; colorVec c;
tr.ignore_lightgamma = true; tr.ignore_lightgamma = true;
@@ -3409,7 +3404,7 @@ R_DrawViewModel
*/ */
void R_DrawViewModel( void ) void R_DrawViewModel( void )
{ {
cl_entity_t *view = gEngfuncs.GetViewModel(); cl_entity_t *view = tr.viewent;
R_GatherPlayerLight(); R_GatherPlayerLight();
@@ -3610,7 +3605,7 @@ void Mod_StudioUnloadTextures( void *data )
static model_t *pfnModelHandle( int modelindex ) static model_t *pfnModelHandle( int modelindex )
{ {
return gEngfuncs.pfnGetModelByIndex( modelindex ); return CL_ModelHandle( modelindex );
} }
static void *pfnMod_CacheCheck( struct cache_user_s *c ) static void *pfnMod_CacheCheck( struct cache_user_s *c )

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'