21 Mar 2018

This commit is contained in:
g-cont 2018-03-21 00:00:00 +03:00 committed by Alibek Omarov
parent e0ce0e1b2c
commit 3064013da0
14 changed files with 189 additions and 72 deletions

View File

@ -553,7 +553,7 @@ pfnPlaySound
*/
static void pfnPlaySound( const char *szSound )
{
if( !szSound || !*szSound ) return;
if( !COM_CheckString( szSound )) return;
S_StartLocalSound( szSound, VOL_NORM, false );
}
@ -661,6 +661,19 @@ static void pfnSetPlayerModel( cl_entity_t *ent, const char *path )
ent->curstate.modelindex = MAX_MODELS; // unreachable index
}
/*
====================
pfnClearScene
for drawing playermodel previews
====================
*/
static void pfnClearScene( void )
{
R_PushScene();
R_ClearScene();
}
/*
====================
pfnRenderScene
@ -680,6 +693,7 @@ static void pfnRenderScene( const ref_viewpass_t *rvp )
R_Set2DMode( false );
R_RenderFrame( rvp );
R_Set2DMode( true );
R_PopScene();
}
/*
@ -929,7 +943,7 @@ static ui_enginefuncs_t gEngfuncs =
Con_DefaultColor,
pfnGetPlayerModel,
pfnSetPlayerModel,
R_ClearScene,
pfnClearScene,
pfnRenderScene,
pfnAddEntity,
Host_Error,

View File

@ -21,6 +21,7 @@ GNU General Public License for more details.
#include "cl_tent.h"
#include "shake.h"
#include "hltv.h"
#include "input.h"
#define MSG_COUNT 32 // last 32 messages parsed
#define MSG_MASK (MSG_COUNT - 1)
@ -1161,6 +1162,10 @@ void CL_ParseServerData( sizebuf_t *msg )
else if( !cls.demoplayback )
Key_SetKeyDest( key_menu );
// don't reset cursor in background mode
if( cl.background )
IN_MouseRestorePos();
// will be changed later
cl.viewentity = cl.playernum + 1;
gameui.globals->maxClients = cl.maxclients;

View File

@ -18,6 +18,7 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "vgui_draw.h"
#include "qfont.h"
#include "input.h"
convar_t *scr_centertime;
convar_t *scr_loading;
@ -322,6 +323,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
if( cls.key_dest == key_console )
return;
if( is_background ) IN_MouseSavePos( );
cls.draw_changelevel = !is_background;
SCR_UpdateScreen();
cls.disable_screen = host.realtime;

View File

@ -260,7 +260,6 @@ typedef struct
// server state information
int playernum;
int maxclients;
int num_custombeams; // server beams count
entity_state_t instanced_baseline[MAX_CUSTOM_BASELINES];
int instanced_baseline_count;

View File

@ -1325,7 +1325,6 @@ BEAM *cl_active_beams;
BEAM *cl_free_beams;
BEAM *cl_viewbeams = NULL; // beams pool
cl_entity_t *cl_custombeams[MAX_VISIBLE_PACKET]; // to avoid check of all the ents
/*
================
CL_InitViewBeams
@ -1381,16 +1380,16 @@ Add the beam that encoded as custom entity
*/
void CL_AddCustomBeam( cl_entity_t *pEnvBeam )
{
if( cl.num_custombeams >= MAX_VISIBLE_PACKET )
if( tr.draw_list->num_beam_entities >= MAX_VISIBLE_PACKET )
{
MsgDev( D_ERROR, "Too many custom beams %d!\n", cl.num_custombeams );
MsgDev( D_ERROR, "Too many custom beams %d!\n", tr.draw_list->num_beam_entities );
return;
}
if( pEnvBeam )
{
cl_custombeams[cl.num_custombeams] = pEnvBeam;
cl.num_custombeams++;
tr.draw_list->beam_entities[tr.draw_list->num_beam_entities] = pEnvBeam;
tr.draw_list->num_beam_entities++;
}
}
@ -1506,9 +1505,9 @@ void CL_DrawBeams( int fTrans )
// server beams don't allocate beam chains
// all params are stored in cl_entity_t
for( i = 0; i < cl.num_custombeams; i++ )
for( i = 0; i < tr.draw_list->num_beam_entities; i++ )
{
RI.currentbeam = cl_custombeams[i];
RI.currentbeam = tr.draw_list->beam_entities[i];
flags = RI.currentbeam->curstate.rendermode & 0xF0;
if( fTrans && FBitSet( flags, FBEAM_SOLID ))

View File

@ -34,8 +34,9 @@ extern byte *r_temppool;
#define MAX_LIGHTMAPS 256
#define SUBDIVIDE_SIZE 64
#define MAX_DECAL_SURFS 4096
#define MAX_DRAW_STACK 2 // normal view and menu view
#define SHADEDOT_QUANT 16 // precalculated dot products for quantized angles
#define SHADEDOT_QUANT 16 // precalculated dot products for quantized angles
#define SHADE_LAMBERT 1.495f
// refparams
@ -152,6 +153,16 @@ typedef struct
mplane_t clipPlane;
} ref_instance_t;
typedef struct
{
cl_entity_t *solid_entities[MAX_VISIBLE_PACKET]; // opaque moving or alpha brushes
cl_entity_t *trans_entities[MAX_VISIBLE_PACKET]; // translucent brushes
cl_entity_t *beam_entities[MAX_VISIBLE_PACKET];
uint num_solid_entities;
uint num_trans_entities;
uint num_beam_entities;
} draw_list_t;
typedef struct
{
int cinTexture; // cinematic texture
@ -184,10 +195,9 @@ typedef struct
int skyboxbasenum; // start with 5800
// entity lists
cl_entity_t *solid_entities[MAX_VISIBLE_PACKET]; // opaque moving or alpha brushes
cl_entity_t *trans_entities[MAX_VISIBLE_PACKET]; // translucent brushes
uint num_solid_entities;
uint num_trans_entities;
draw_list_t draw_stack[MAX_DRAW_STACK];
int draw_stack_pos;
draw_list_t *draw_list;
msurface_t *draw_decals[MAX_DECAL_SURFS];
int num_draw_decals;
@ -243,7 +253,7 @@ extern mleaf_t *r_viewleaf, *r_oldviewleaf;
extern mleaf_t *r_viewleaf2, *r_oldviewleaf2;
extern dlight_t cl_dlights[MAX_DLIGHTS];
extern dlight_t cl_elights[MAX_ELIGHTS];
#define r_numEntities (tr.num_solid_entities + tr.num_trans_entities)
#define r_numEntities (tr.draw_list->num_solid_entities + tr.draw_list->num_trans_entities)
#define r_numStatics (r_stats.c_client_ents)
extern struct beam_s *cl_active_beams;
@ -352,6 +362,8 @@ qboolean R_InitRenderAPI( void );
void R_AllowFog( int allowed );
void R_SetupFrustum( void );
void R_FindViewLeaf( void );
void R_PushScene( void );
void R_PopScene( void );
void R_DrawFog( void );
//

View File

@ -192,6 +192,31 @@ void R_ScreenToWorld( const vec3_t screen, vec3_t point )
if( w != 0.0f ) VectorScale( point, ( 1.0f / w ), point );
}
/*
===============
R_PushScene
===============
*/
void R_PushScene( void )
{
if( ++tr.draw_stack_pos >= MAX_DRAW_STACK )
Host_Error( "draw stack overflow\n" );
tr.draw_list = &tr.draw_stack[tr.draw_stack_pos];
}
/*
===============
R_PushScene
===============
*/
void R_PopScene( void )
{
if( --tr.draw_stack_pos < 0 )
Host_Error( "draw stack underflow\n" );
tr.draw_list = &tr.draw_stack[tr.draw_stack_pos];
}
/*
===============
R_ClearScene
@ -199,9 +224,9 @@ R_ClearScene
*/
void R_ClearScene( void )
{
tr.num_solid_entities = 0;
tr.num_trans_entities = 0;
cl.num_custombeams = 0;
tr.draw_list->num_solid_entities = 0;
tr.draw_list->num_trans_entities = 0;
tr.draw_list->num_beam_entities = 0;
}
/*
@ -229,20 +254,20 @@ qboolean R_AddEntity( struct cl_entity_s *clent, int type )
if( R_OpaqueEntity( clent ))
{
// opaque
if( tr.num_solid_entities >= MAX_VISIBLE_PACKET )
if( tr.draw_list->num_solid_entities >= MAX_VISIBLE_PACKET )
return false;
tr.solid_entities[tr.num_solid_entities] = clent;
tr.num_solid_entities++;
tr.draw_list->solid_entities[tr.draw_list->num_solid_entities] = clent;
tr.draw_list->num_solid_entities++;
}
else
{
// translucent
if( tr.num_trans_entities >= MAX_VISIBLE_PACKET )
if( tr.draw_list->num_trans_entities >= MAX_VISIBLE_PACKET )
return false;
tr.trans_entities[tr.num_trans_entities] = clent;
tr.num_trans_entities++;
tr.draw_list->trans_entities[tr.draw_list->num_trans_entities] = clent;
tr.draw_list->num_trans_entities++;
}
return true;
@ -467,7 +492,7 @@ static void R_SetupFrame( void )
if( !gl_nosort->value )
{
// sort translucents entities by rendermode and distance
qsort( tr.trans_entities, tr.num_trans_entities, sizeof( cl_entity_t* ), R_TransEntityCompare );
qsort( tr.draw_list->trans_entities, tr.draw_list->num_trans_entities, sizeof( cl_entity_t* ), R_TransEntityCompare );
}
// current viewleaf
@ -758,9 +783,9 @@ void R_DrawEntitiesOnList( void )
GL_CheckForErrors();
// first draw solid entities
for( i = 0; i < tr.num_solid_entities && !RI.onlyClientDraw; i++ )
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
{
RI.currententity = tr.solid_entities[i];
RI.currententity = tr.draw_list->solid_entities[i];
RI.currentmodel = RI.currententity->model;
Assert( RI.currententity != NULL );
@ -790,9 +815,9 @@ void R_DrawEntitiesOnList( void )
GL_CheckForErrors();
// draw sprites seperately, because of alpha blending
for( i = 0; i < tr.num_solid_entities && !RI.onlyClientDraw; i++ )
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
{
RI.currententity = tr.solid_entities[i];
RI.currententity = tr.draw_list->solid_entities[i];
RI.currentmodel = RI.currententity->model;
Assert( RI.currententity != NULL );
@ -821,9 +846,9 @@ void R_DrawEntitiesOnList( void )
GL_CheckForErrors();
// then draw translucent entities
for( i = 0; i < tr.num_trans_entities && !RI.onlyClientDraw; i++ )
for( i = 0; i < tr.draw_list->num_trans_entities && !RI.onlyClientDraw; i++ )
{
RI.currententity = tr.trans_entities[i];
RI.currententity = tr.draw_list->trans_entities[i];
RI.currentmodel = RI.currententity->model;
// handle studiomodels with custom rendermodes on texture
@ -1400,9 +1425,7 @@ static uint pfnFileBufferCRC32( const void *buffer, const int length )
CRC32_Init( &modelCRC );
CRC32_ProcessBuffer( &modelCRC, buffer, length );
modelCRC = CRC32_Final( modelCRC );
return modelCRC;
return CRC32_Final( modelCRC );
}
/*

View File

@ -147,39 +147,6 @@ void R_StudioInit( void )
m_fDoRemap = false;
}
/*
================
R_GetEntityRenderMode
check for texture flags
================
*/
int R_GetEntityRenderMode( cl_entity_t *ent )
{
studiohdr_t *phdr;
mstudiotexture_t *ptexture;
int i;
if(( phdr = Mod_StudioExtradata( ent->model )) == NULL )
{
// forcing to choose right sorting type
if(( ent->model && ent->model->type == mod_brush ) && FBitSet( ent->model->flags, MODEL_TRANSPARENT ))
return kRenderTransAlpha;
return ent->curstate.rendermode;
}
ptexture = (mstudiotexture_t *)((byte *)phdr + phdr->textureindex);
for( i = 0; i < phdr->numtextures; i++, ptexture++ )
{
// g-cont. this is not fully proper but better than was
if( FBitSet( ptexture->flags, STUDIO_NF_ADDITIVE ))
return kRenderTransAdd;
// if( FBitSet( ptexture->flags, STUDIO_NF_MASKED ))
// return kRenderTransAlpha;
}
return ent->curstate.rendermode;
}
/*
================
R_StudioSetupTimings
@ -2746,6 +2713,50 @@ static model_t *R_StudioSetupPlayerModel( int index )
return state->model;
}
/*
================
R_GetEntityRenderMode
check for texture flags
================
*/
int R_GetEntityRenderMode( cl_entity_t *ent )
{
studiohdr_t *phdr;
mstudiotexture_t *ptexture;
cl_entity_t *oldent;
model_t *model;
int i;
oldent = RI.currententity;
RI.currententity = ent;
if( ent->player ) // check it for real playermodel
model = R_StudioSetupPlayerModel( ent->curstate.number - 1 );
else model = ent->model;
RI.currententity = oldent;
if(( phdr = Mod_StudioExtradata( model )) == NULL )
{
// forcing to choose right sorting type
if(( model && model->type == mod_brush ) && FBitSet( model->flags, MODEL_TRANSPARENT ))
return kRenderTransAlpha;
return ent->curstate.rendermode;
}
ptexture = (mstudiotexture_t *)((byte *)phdr + phdr->textureindex);
for( i = 0; i < phdr->numtextures; i++, ptexture++ )
{
// g-cont. this is not fully proper but better than was
if( FBitSet( ptexture->flags, STUDIO_NF_ADDITIVE ))
return kRenderTransAdd;
// if( FBitSet( ptexture->flags, STUDIO_NF_MASKED ))
// return kRenderTransAlpha;
}
return ent->curstate.rendermode;
}
/*
===============
R_StudioClientEvents

View File

@ -521,6 +521,10 @@ static void GL_SetDefaultState( void )
{
memset( &glState, 0, sizeof( glState ));
GL_SetDefaultTexState ();
// init draw stack
tr.draw_list = &tr.draw_stack[0];
tr.draw_stack_pos = 0;
}
/*

View File

@ -809,7 +809,7 @@ int COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBu
const char *path;
char result[MAX_SYSPATH];
if( !fileName || !*fileName || !nameOutBuffer || nameOutBufferSize <= 0 )
if( !COM_CheckString( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
return 0;
// filename examples:
@ -1011,7 +1011,7 @@ byte* COM_LoadFileForMe( const char *filename, int *pLength )
byte *file, *pfile;
int iLength;
if( !filename || !*filename )
if( !COM_CheckString( filename ))
{
if( pLength )
*pLength = 0;
@ -1059,7 +1059,7 @@ COM_LoadFile
int COM_SaveFile( const char *filename, const void *data, long len )
{
// check for empty filename
if( !filename || !*filename )
if( !COM_CheckString( filename ))
return false;
// check for null data

View File

@ -28,8 +28,10 @@ qboolean in_restore_spi;
qboolean in_mouseinitialized;
int in_mouse_oldbuttonstate;
qboolean in_mouse_suspended;
qboolean in_mouse_savedpos;
int in_mouse_buttons;
RECT window_rect, real_rect;
POINT in_lastvalidpos;
uint in_mouse_wheel;
int wnd_caption;
@ -161,6 +163,38 @@ void IN_SetCursor( HICON hCursor )
IN_ActivateCursor();
}
/*
===========
IN_MouseSavePos
Save mouse pos before state change e.g. changelevel
===========
*/
void IN_MouseSavePos( void )
{
if( !in_mouseactive )
return;
GetCursorPos( &in_lastvalidpos );
in_mouse_savedpos = true;
}
/*
===========
IN_MouseRestorePos
Restore right position for background
===========
*/
void IN_MouseRestorePos( void )
{
if( !in_mouse_savedpos )
return;
SetCursorPos( in_lastvalidpos.x, in_lastvalidpos.y );
in_mouse_savedpos = false;
}
/*
===========
IN_ToggleClientMouse

View File

@ -45,6 +45,8 @@ void IN_Shutdown( void );
void IN_MouseEvent( int mstate );
void IN_ActivateMouse( qboolean force );
void IN_DeactivateMouse( void );
void IN_MouseSavePos( void );
void IN_MouseRestorePos( void );
void IN_ToggleClientMouse( int newstate, int oldstate );
LONG IN_WndProc( HWND hWnd, UINT uMsg, UINT wParam, LONG lParam );
void IN_SetCursor( HICON hCursor );

View File

@ -289,8 +289,10 @@ static void Mod_LoadLump( const byte *in, mlumpinfo_t *info, mlumpstat_t *stat,
if( real_entrysize == sizeof( byte ))
{
if( !FBitSet( flags, LUMP_SILENT ))
{
MsgDev( D_WARN, "map ^2%s^7 has no %s\n", loadstat.name, msg1 );
loadstat.numwarnings++;
loadstat.numwarnings++;
}
}
else if( info->mincount > 0 )
{
@ -1272,6 +1274,13 @@ static qboolean Mod_LoadColoredLighting( dbspmodel_t *bmod )
// skip header bytes
litdatasize -= 8;
if( litdatasize != ( bmod->lightdatasize * 3 ))
{
Con_Printf( S_ERROR "%s has mismatched size (%i should be %i)\n", path, litdatasize, bmod->lightdatasize * 3 );
Mem_Free( in );
return false;
}
loadmodel->lightdata = Mem_Alloc( loadmodel->mempool, litdatasize );
memcpy( loadmodel->lightdata, in + 8, litdatasize );
SetBits( loadmodel->flags, MODEL_COLORED_LIGHTING );

View File

@ -1229,6 +1229,9 @@ void UI_SetActiveMenu( int fActive )
KEY_ClearStates();
uiStatic.framecount = 0;
if( fActive && uiStatic.visible )
return; // don't reset the menu
if( fActive )
{
KEY_SetDest( KEY_MENU );