04 Dec 2009

This commit is contained in:
g-cont 2009-12-04 00:00:00 +03:00 committed by Alibek Omarov
parent a92d0a4499
commit 6b15abe0d3
14 changed files with 593 additions and 296 deletions

View File

@ -118,7 +118,6 @@ int HUD_Redraw( float flTime, int state )
case CL_ACTIVE:
case CL_PAUSED:
gHUD.Redraw( flTime );
DrawCrosshair();
DrawPause();
break;
}

View File

@ -13,12 +13,21 @@
#define FREE( x ) (*g_engfuncs.pfnMemFree)( x, __FILE__, __LINE__ )
// screen handlers
#define SPR_Load( x ) (*g_engfuncs.pfnLoadShader)( x, true )
#define SPR_Frames (*g_engfuncs.pfnSPR_Frames)
#define SPR_Width (*g_engfuncs.pfnSPR_Width)
#define SPR_Height (*g_engfuncs.pfnSPR_Height)
#define SPR_EnableScissor (*g_engfuncs.pfnSPR_EnableScissor)
#define SPR_DisableScissor (*g_engfuncs.pfnSPR_DisableScissor)
#define FillRGBA (*g_engfuncs.pfnFillRGBA)
#define GetScreenInfo (*g_engfuncs.pfnGetScreenInfo)
#define SPR_Load (*g_engfuncs.pfnSPR_Load)
#define TEX_Load( x ) (*g_engfuncs.pfnLoadShader)( x, false )
#define DrawImageExt (*g_engfuncs.pfnDrawImageExt)
#define SetColor (*g_engfuncs.pfnSetColor)
#define SetParms (*g_engfuncs.pfnSetParms)
#define GetScreenInfo (*g_engfuncs.pfnGetScreenInfo)
#define SetCrosshair (*g_engfuncs.pfnSetCrosshair)
#define CVAR_REGISTER (*g_engfuncs.pfnRegisterVariable)
#define CVAR_SET_FLOAT (*g_engfuncs.pfnCvarSetValue)
#define CVAR_GET_FLOAT (*g_engfuncs.pfnGetCvarFloat)
@ -32,6 +41,56 @@
#define CMD_ARGV (*g_engfuncs.pfnCmdArgv)
#define ALERT (*g_engfuncs.pfnAlertMessage)
inline void SPR_Set( HSPRITE hPic, int r, int g, int b )
{
g_engfuncs.pfnSPR_Set( hPic, r, g, b, 255 );
}
inline void SPR_Set( HSPRITE hPic, int r, int g, int b, int a )
{
g_engfuncs.pfnSPR_Set( hPic, r, g, b, a );
}
inline void SPR_Draw( int frame, int x, int y, const wrect_t *prc )
{
g_engfuncs.pfnSPR_Draw( frame, x, y, -1, -1, prc );
}
inline void SPR_Draw( int frame, int x, int y, int width, int height )
{
g_engfuncs.pfnSPR_Draw( frame, x, y, width, height, NULL );
}
inline void SPR_DrawTransColor( int frame, int x, int y, const wrect_t *prc )
{
g_engfuncs.pfnSPR_DrawTrans( frame, x, y, -1, -1, prc );
}
inline void SPR_DrawTransColor( int frame, int x, int y, int width, int height )
{
g_engfuncs.pfnSPR_DrawTrans( frame, x, y, width, height, NULL );
}
inline void SPR_DrawHoles( int frame, int x, int y, const wrect_t *prc )
{
g_engfuncs.pfnSPR_DrawHoles( frame, x, y, -1, -1, prc );
}
inline void SPR_DrawHoles( int frame, int x, int y, int width, int height )
{
g_engfuncs.pfnSPR_DrawHoles( frame, x, y, width, height, NULL );
}
inline void SPR_DrawAdditive( int frame, int x, int y, const wrect_t *prc )
{
g_engfuncs.pfnSPR_DrawAdditive( frame, x, y, -1, -1, prc );
}
inline void SPR_DrawAdditive( int frame, int x, int y, int width, int height )
{
g_engfuncs.pfnSPR_DrawAdditive( frame, x, y, width, height, NULL );
}
inline void CL_PlaySound( const char *szSound, float flVolume, float pitch = PITCH_NORM )
{
g_engfuncs.pfnPlaySoundByName( szSound, flVolume, pitch, NULL );

View File

@ -174,54 +174,8 @@ Vector READ_DIR( void )
return BitsToDir( READ_BYTE() );
}
//
// Sprites draw stuff
//
typedef struct
{
// temp handle
HSPRITE hSprite;
HSPRITE hPause; // pause pic
// crosshair members
HSPRITE hCrosshair;
wrect_t rcCrosshair;
byte rgbCrosshair[3];
bool noCrosshair;
} draw_stuff_t;
static draw_stuff_t ds;
int SPR_Frames( HSPRITE hPic )
{
int Frames;
GetParms( NULL, NULL, &Frames, 0, hPic );
return Frames;
}
int SPR_Height( HSPRITE hPic, int frame )
{
int Height;
GetParms( NULL, &Height, NULL, frame, hPic );
return Height;
}
int SPR_Width( HSPRITE hPic, int frame )
{
int Width;
GetParms( &Width, NULL, NULL, frame, hPic );
return Width;
}
void Draw_VidInit( void )
{
memset( &ds, 0, sizeof( ds ));
}
/*
@ -342,18 +296,6 @@ client_sprite_t *SPR_GetList( const char *psz, int *piCount )
return phud;
}
void SPR_Set( HSPRITE hPic, int r, int g, int b )
{
ds.hSprite = hPic;
SetColor( r, g, b, 255 );
}
void SPR_Set( HSPRITE hPic, int r, int g, int b, int a )
{
ds.hSprite = hPic;
SetColor( r, g, b, a );
}
inline static void SPR_AdjustSize( float *x, float *y, float *w, float *h )
{
if( !x && !y && !w && !h ) return;
@ -394,39 +336,6 @@ inline static void SPR_DrawChar( HSPRITE hFont, int xpos, int ypos, int width, i
DrawImageExt( hFont, ax, ay, aw, ah, fcol, frow, fcol + size, frow + size );
}
inline static void SPR_DrawGeneric( int frame, float x, float y, float width, float height, const wrect_t *prc )
{
float s1, s2, t1, t2;
if( width == -1 && height == -1 )
{
int w, h;
GetParms( &w, &h, NULL, frame, ds.hSprite );
width = w;
height = h;
}
if( prc )
{
// calc rectangle
s1 = (float)prc->left / width;
t1 = (float)prc->top / height;
s2 = (float)prc->right / width;
t2 = (float)prc->bottom / height;
width = prc->right - prc->left;
height = prc->bottom - prc->top;
}
else
{
s1 = t1 = 0.0f;
s2 = t2 = 1.0f;
}
// scale for screen sizes
SPR_AdjustSize( &x, &y, &width, &height );
DrawImageExt( ds.hSprite, x, y, width, height, s1, t1, s2, t2 );
}
void TextMessageDrawChar( int xpos, int ypos, int number, int r, int g, int b )
{
// tune char size by taste
@ -434,92 +343,6 @@ void TextMessageDrawChar( int xpos, int ypos, int number, int r, int g, int b )
SPR_DrawChar( gHUD.m_hHudFont, xpos, ypos, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, number );
}
void FillRGBA( float x, float y, float width, float height, int r, int g, int b, int a )
{
SPR_AdjustSize( &x, &y, &width, &height );
g_engfuncs.pfnFillRGBA( x, y, width, height, r, g, b, a );
}
void SPR_Draw( int frame, int x, int y, const wrect_t *prc )
{
SetParms( ds.hSprite, kRenderNormal, frame );
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
}
void SPR_Draw( int frame, int x, int y, int width, int height )
{
SetParms( ds.hSprite, kRenderNormal, frame );
SPR_DrawGeneric( frame, x, y, width, height, NULL );
}
void SPR_DrawTransColor( int frame, int x, int y, const wrect_t *prc )
{
SetParms( ds.hSprite, kRenderTransColor, frame );
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
}
void SPR_DrawTransColor( int frame, int x, int y, int width, int height )
{
SetParms( ds.hSprite, kRenderTransColor, frame );
SPR_DrawGeneric( frame, x, y, width, height, NULL );
}
void SPR_DrawHoles( int frame, int x, int y, const wrect_t *prc )
{
SetParms( ds.hSprite, kRenderTransAlpha, frame );
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
}
void SPR_DrawHoles( int frame, int x, int y, int width, int height )
{
SetParms( ds.hSprite, kRenderTransAlpha, frame );
SPR_DrawGeneric( frame, x, y, width, height, NULL );
}
void SPR_DrawAdditive( int frame, int x, int y, const wrect_t *prc )
{
SetParms( ds.hSprite, kRenderTransAdd, frame );
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
}
void SPR_DrawAdditive( int frame, int x, int y, int width, int height )
{
SetParms( ds.hSprite, kRenderTransAdd, frame );
SPR_DrawGeneric( frame, x, y, width, height, NULL );
}
void SetCrosshair( HSPRITE hspr, wrect_t rc, int r, int g, int b )
{
ds.rgbCrosshair[0] = (byte)r;
ds.rgbCrosshair[1] = (byte)g;
ds.rgbCrosshair[2] = (byte)b;
ds.hCrosshair = hspr;
ds.rcCrosshair = rc;
}
void HideCrosshair( bool hide )
{
ds.noCrosshair = hide;
}
void DrawCrosshair( void )
{
if( ds.hCrosshair == 0 || ds.noCrosshair || !CVAR_GET_FLOAT( "cl_crosshair" ))
return;
int x = (ScreenWidth - (ds.rcCrosshair.right - ds.rcCrosshair.left)) / 2;
int y = (ScreenHeight - (ds.rcCrosshair.bottom - ds.rcCrosshair.top)) / 2;
// FIXME: apply crosshair angles properly
x += gHUD.m_CrosshairAngles.x;
y += gHUD.m_CrosshairAngles.y;
ds.hSprite = ds.hCrosshair;
SetParms( ds.hCrosshair, kRenderTransAlpha, 0 );
SetColor( ds.rgbCrosshair[0], ds.rgbCrosshair[1], ds.rgbCrosshair[2], 255 );
SPR_DrawGeneric( 0, x, y, -1, -1, &ds.rcCrosshair );
}
void DrawPause( void )
{
// pause image
@ -527,11 +350,6 @@ void DrawPause( void )
DrawImageBar( 100, "m_pause" ); // HACKHACK
}
void DrawImageRectangle( HSPRITE hImage )
{
DrawImageExt( hImage, 0, 0, ActualWidth, ActualHeight, 0, 0, 1, 1 );
}
void DrawImageBar( float percent, const char *szSpriteName )
{
int m_loading = gHUD.GetSpriteIndex( szSpriteName );

View File

@ -172,26 +172,9 @@ extern Vector READ_DIR( void );
extern void END_READ( void );
// drawing stuff
extern int SPR_Frames( HSPRITE hPic );
extern int SPR_Height( HSPRITE hPic, int frame );
extern int SPR_Width( HSPRITE hPic, int frame );
extern client_sprite_t *SPR_GetList( const char *name, int *count );
extern void ParseHudSprite( const char **pfile, char *psz, client_sprite_t *result );
extern void SPR_Set( HSPRITE hPic, int r, int g, int b );
extern void SPR_Set( HSPRITE hPic, int r, int g, int b, int a );
extern void SPR_Draw( int frame, int x, int y, const wrect_t *prc );
extern void SPR_Draw( int frame, int x, int y, int width, int height );
extern void SPR_DrawHoles( int frame, int x, int y, const wrect_t *prc );
extern void SPR_DrawHoles( int frame, int x, int y, int width, int height );
extern void SPR_DrawTransColor( int frame, int x, int y, int width, int height );
extern void SPR_DrawTransColor( int frame, int x, int y, const wrect_t *prc );
extern void SPR_DrawAdditive( int frame, int x, int y, const wrect_t *prc );
extern void SPR_DrawAdditive( int frame, int x, int y, int width, int height );
extern void TextMessageDrawChar( int xpos, int ypos, int number, int r, int g, int b );
extern void FillRGBA( float x, float y, float width, float height, int r, int g, int b, int a );
extern void SetCrosshair( HSPRITE hspr, wrect_t rc, int r, int g, int b );
extern void HideCrosshair( bool hide );
extern void DrawCrosshair( void );
extern void DrawPause( void );
extern void SetScreenFade( Vector fadeColor, float alpha, float duration, float holdTime, int fadeFlags );
extern void ClearAllFades( void );
@ -207,6 +190,7 @@ extern void Draw_VidInit( void );
extern void DrawProgressBar( void );
extern edict_t *spot;
extern int v_paused;
extern float v_idlescale;
// stdio stuff
extern char *va( const char *format, ... );

View File

@ -292,9 +292,6 @@ void V_PreRender( ref_params_t *pparams )
if( gHUD.m_iCameraMode ) pparams->flags |= RDF_THIRDPERSON;
else pparams->flags &= ~RDF_THIRDPERSON;
// output
gHUD.m_CrosshairAngles = pparams->crosshairangle;
pparams->fov_x = gHUD.m_flFOV; // this is a final fov value
pparams->fov_y = V_CalcFov( pparams->fov_x, pparams->viewport[2], pparams->viewport[3] );
}
@ -532,14 +529,14 @@ void V_CalcCameraRefdef( ref_params_t *pparams )
if( gHUD.viewFlags & INVERSE_X ) // inverse X coordinate
v_angles[0] = -v_angles[0];
HideCrosshair( true );
pparams->crosshairangle[ROLL] = 1; // crosshair is hided
// refresh position
pparams->viewangles = v_angles;
pparams->vieworg = v_origin;
}
}
else HideCrosshair( false ); // show crosshair again
else pparams->crosshairangle[ROLL] = 0; // show crosshair again
}
edict_t *V_FindIntermisionSpot( ref_params_t *pparams )

View File

@ -30,7 +30,6 @@ void CHud :: Init( void )
m_MOTD.Init();
MsgFunc_ResetHUD( 0, 0, NULL );
CVAR_REGISTER( "cl_crosshair", "1", FCVAR_ARCHIVE, "show weapon chrosshair" );
}
CHud :: ~CHud( void )
@ -204,7 +203,8 @@ int CHud :: UpdateClientData( client_data_t *cdata, float time )
Think();
cdata->iKeyBits = m_iKeyBits;
cdata->v_idlescale = m_iConcussionEffect;
v_idlescale = m_iConcussionEffect;
if( m_flMouseSensitivity )
cdata->mouse_sensitivity = m_flMouseSensitivity;

View File

@ -586,7 +586,6 @@ public:
int m_Teamplay;
int m_iRes;
Vector m_vecSkyPos;
Vector m_CrosshairAngles;
int m_iSkyMode;
int m_iCameraMode;
int m_iLastCameraMode;

View File

@ -45,7 +45,9 @@ typedef struct
char *name;
short ping;
byte thisplayer; // TRUE if this is the calling player
byte packetloss; // TRUE if current packet is loose
byte spectator;
byte packetloss;
const char *model;
short topcolor;
short bottomcolor;
@ -73,7 +75,6 @@ typedef struct client_data_s
int iKeyBits; // Keyboard bits
int iWeaponBits; // came from pev->weapons
float v_idlescale; // view shake/rotate
float mouse_sensitivity; // used for menus and zoomed weapons
} client_data_t;
@ -96,7 +97,7 @@ typedef struct cl_globalvars_s
BOOL coop;
BOOL teamplay;
int serverflags;
int serverflags; // shared serverflags
int maxClients;
int numClients;
int maxEntities;
@ -108,6 +109,25 @@ typedef struct cl_enginefuncs_s
// interface validator
size_t api_size; // must matched with sizeof(cl_enginefuncs_t)
// sprite handlers
HSPRITE (*pfnSPR_Load)( const char *szPicName );
int (*pfnSPR_Frames)( HSPRITE hPic );
int (*pfnSPR_Height)( HSPRITE hPic, int frame );
int (*pfnSPR_Width)( HSPRITE hPic, int frame );
void (*pfnSPR_Set)( HSPRITE hPic, int r, int g, int b, int a );
void (*pfnSPR_Draw)( int frame, int x, int y, int width, int height, const wrect_t *prc );
void (*pfnSPR_DrawHoles)( int frame, int x, int y, int width, int height, const wrect_t *prc );
void (*pfnSPR_DrawTrans)( int frame, int x, int y, int width, int height, const wrect_t *prc ); // Xash3D ext
void (*pfnSPR_DrawAdditive)( int frame, int x, int y, int width, int height, const wrect_t *prc );
void (*pfnSPR_EnableScissor)( int x, int y, int width, int height );
void (*pfnSPR_DisableScissor)( void );
client_sprite_t *(*pfnSPR_GetList)( char *psz, int *piCount );
// screen handlers
void (*pfnFillRGBA)( int x, int y, int width, int height, int r, int g, int b, int a );
int (*pfnGetScreenInfo)( SCREENINFO *pscrinfo );
void (*pfnSetCrosshair)( HSPRITE hspr, wrect_t rc, int r, int g, int b );
// engine memory manager
void* (*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
void (*pfnMemCopy)( void *dest, const void *src, size_t cb, const char *filename, const int fileline );
@ -115,7 +135,6 @@ typedef struct cl_enginefuncs_s
// screen handlers
HSPRITE (*pfnLoadShader)( const char *szShaderName, int fShaderNoMip );
void (*pfnFillRGBA)( int x, int y, int width, int height, byte r, byte g, byte b, byte alpha );
void (*pfnDrawImageExt)( HSPRITE shader, float x, float y, float w, float h, float s1, float t1, float s2, float t2 );
void (*pfnSetColor)( byte r, byte g, byte b, byte a );
@ -165,7 +184,6 @@ typedef struct cl_enginefuncs_s
edict_t* (*pfnGetViewModel)( void );
void* (*pfnGetModelPtr)( edict_t* pEdict );
int (*pfnGetScreenInfo)( SCREENINFO *pscrinfo );
void (*pfnGetAttachment)( const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles );
int (*pfnPointContents)( const float *rgflVector );

View File

@ -129,6 +129,127 @@ prevframe_t *CL_GetPrevFrame( int entityIndex )
return &pEnt->pvClientData->latched;
}
/*
====================
SPR_AdjustSize
draw hudsprite routine
====================
*/
static void SPR_AdjustSize( float *x, float *y, float *w, float *h )
{
float xscale, yscale;
if( !x && !y && !w && !h ) return;
// scale for screen sizes
xscale = clgame.scrInfo.iRealWidth / (float)clgame.scrInfo.iWidth;
yscale = clgame.scrInfo.iRealHeight / (float)clgame.scrInfo.iHeight;
if( x ) *x *= xscale;
if( y ) *y *= yscale;
if( w ) *w *= xscale;
if( h ) *h *= yscale;
}
static bool SPR_Scissor( float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 )
{
float dudx, dvdy;
// clip sub rect to sprite
if(( width == 0 ) || ( height == 0 ))
return false;
if( *x + *width <= clgame.ds.scissor_x )
return false;
if( *x >= clgame.ds.scissor_x + clgame.ds.scissor_width )
return false;
if( *y + *height <= clgame.ds.scissor_y )
return false;
if( *y >= clgame.ds.scissor_y + clgame.ds.scissor_height )
return false;
dudx = (*u1 - *u0) / *width;
dvdy = (*v1 - *v0) / *height;
if( *x < clgame.ds.scissor_x )
{
*u0 += (clgame.ds.scissor_x - *x) * dudx;
*width -= clgame.ds.scissor_x - *x;
*x = clgame.ds.scissor_x;
}
if( *x + *width > clgame.ds.scissor_x + clgame.ds.scissor_width )
{
*u1 -= (*x + *width - (clgame.ds.scissor_x + clgame.ds.scissor_width)) * dudx;
*width = clgame.ds.scissor_x + clgame.ds.scissor_width - *x;
}
if( *y < clgame.ds.scissor_y )
{
*v0 += (clgame.ds.scissor_y - *y) * dvdy;
*height -= clgame.ds.scissor_y - *y;
*y = clgame.ds.scissor_y;
}
if( *y + *height > clgame.ds.scissor_y + clgame.ds.scissor_height )
{
*v1 -= (*y + *height - (clgame.ds.scissor_y + clgame.ds.scissor_height)) * dvdy;
*height = clgame.ds.scissor_y + clgame.ds.scissor_height - *y;
}
return true;
}
/*
====================
SPR_DrawGeneric
draw hudsprite routine
====================
*/
static void SPR_DrawGeneric( int frame, float x, float y, float width, float height, const wrect_t *prc )
{
float s1, s2, t1, t2;
if( !re ) return;
if( width == -1 && height == -1 )
{
int w, h;
// undoc feature: get drawsizes from image
re->GetParms( &w, &h, NULL, frame, clgame.ds.hSprite );
width = w;
height = h;
}
if( prc )
{
// calc user-defined rectangle
s1 = (float)prc->left / width;
t1 = (float)prc->top / height;
s2 = (float)prc->right / width;
t2 = (float)prc->bottom / height;
width = prc->right - prc->left;
height = prc->bottom - prc->top;
}
else
{
s1 = t1 = 0.0f;
s2 = t2 = 1.0f;
}
// pass scissor test if supposed
if( clgame.ds.scissor_test && !SPR_Scissor( &x, &y, &width, &height, &s1, &t1, &s2, &t2 ))
return;
// scale for screen sizes
SPR_AdjustSize( &x, &y, &width, &height );
re->DrawStretchPic( x, y, width, height, s1, t1, s2, t2, clgame.ds.hSprite );
re->SetColor( NULL );
}
/*
====================
CL_InitTitles
@ -316,6 +437,55 @@ void CL_FadeAlpha( float starttime, float endtime, rgba_t color )
else color[3] = 255;
}
void CL_DrawCrosshair( void )
{
int x, y;
if( !re || clgame.ds.hCrosshair <= 0 || cl.refdef.crosshairangle[2] || !cl_crosshair->integer )
return;
#if 0
if ( pPlayer && !pPlayer->IsAlive() )
return;
m_curViewAngles = CurrentViewAngles();
m_curViewOrigin = CurrentViewOrigin();
float x, y;
QAngle angles;
Vector forward;
Vector point, screen;
x = ScreenWidth()/2;
y = ScreenHeight()/2;
// this code is wrong
angles = m_curViewAngles + m_vecCrossHairOffsetAngle;
AngleVectors( angles, &forward );
VectorAdd( m_curViewOrigin, forward, point );
ScreenTransform( point, screen );
x += 0.5f * screen[0] * ScreenWidth() + 0.5f;
y += 0.5f * screen[1] * ScreenHeight() + 0.5f;
m_pCrosshair->DrawSelf(
x - 0.5f * m_pCrosshair->Width(),
y - 0.5f * m_pCrosshair->Height(),
m_clrCrosshair );
#endif
x = (clgame.scrInfo.iWidth - (clgame.ds.rcCrosshair.right - clgame.ds.rcCrosshair.left)) / 2;
y = (clgame.scrInfo.iHeight - (clgame.ds.rcCrosshair.bottom - clgame.ds.rcCrosshair.top)) / 2;
// FIXME: apply crosshair angles properly
x += cl.refdef.crosshairangle[0];
y += cl.refdef.crosshairangle[1];
clgame.ds.hSprite = clgame.ds.hCrosshair;
re->SetColor( clgame.ds.rgbaCrosshair );
re->SetParms( clgame.ds.hSprite, kRenderTransAlpha, 0 );
SPR_DrawGeneric( 0, x, y, -1, -1, &clgame.ds.rcCrosshair );
}
void CL_DrawHUD( int state )
{
if( state == CL_ACTIVE && !cl.video_prepped )
@ -326,6 +496,9 @@ void CL_DrawHUD( int state )
clgame.dllFuncs.pfnRedraw( cl.time * 0.001f, state );
if( state == CL_ACTIVE || state == CL_PAUSED )
CL_DrawCrosshair();
if( state == CL_ACTIVE )
clgame.dllFuncs.pfnFrame( cl.time * 0.001f );
}
@ -394,9 +567,33 @@ void CL_LinkUserMessage( char *pszName, const int svc_num )
CL_CreateUserMessage( i, msgName, svc_num, msgSize, NULL );
}
/*
=======================
CL_MsgNumbers
=======================
*/
static int CL_MsgNumbers( const void *a, const void *b )
{
user_message_t *msga, *msgb;
msga = (user_message_t *)a;
msgb = (user_message_t *)b;
if( msga == NULL )
{
if ( msgb == NULL ) return 0;
else return -1;
}
else if ( msgb == NULL ) return 1;
if( msga->number < msgb->number )
return -1;
return 1;
}
void CL_SortUserMessages( void )
{
// FIXME: implement
// qsort( clgame.msg, clgame.numMessages, sizeof( user_message_t ), CL_MsgNumbers );
}
void CL_ParseUserMessage( sizebuf_t *net_buffer, int svc_num )
@ -641,6 +838,268 @@ const char *CL_ClassName( const edict_t *e )
===============================================================================
*/
/*
=========
pfnSPR_Load
=========
*/
HSPRITE pfnSPR_Load( const char *szPicName )
{
if( !re ) return 0; // render not initialized
if( !szPicName || !*szPicName )
{
MsgDev( D_ERROR, "CL_SpriteLoad: invalid spritename\n" );
return -1;
}
return re->RegisterShader( szPicName, SHADER_NOMIP ); // replace with SHADER_GENERIC ?
}
/*
=========
pfnSPR_Load
=========
*/
static int pfnSPR_Frames( HSPRITE hPic )
{
int numFrames;
if( !re ) return 1;
re->GetParms( NULL, NULL, &numFrames, 0, hPic );
return numFrames;
}
/*
=========
pfnSPR_Load
=========
*/
static int pfnSPR_Height( HSPRITE hPic, int frame )
{
int sprHeight;
if( !re ) return 0;
re->GetParms( NULL, &sprHeight, NULL, frame, hPic );
return sprHeight;
}
/*
=========
pfnSPR_Load
=========
*/
static int pfnSPR_Width( HSPRITE hPic, int frame )
{
int sprWidth;
if( !re ) return 0;
re->GetParms( &sprWidth, NULL, NULL, frame, hPic );
return sprWidth;
}
/*
=========
pfnSPR_Load
=========
*/
static void pfnSPR_Set( HSPRITE hPic, int r, int g, int b, int a )
{
rgba_t color;
if( !re ) return; // render not initialized
clgame.ds.hSprite = hPic;
MakeRGBA( color, r, g, b, a );
re->SetColor( color );
}
/*
=========
pfnSPR_Draw
=========
*/
static void pfnSPR_Draw( int frame, int x, int y, int width, int height, const wrect_t *prc )
{
if( !re ) return; // render not initialized
re->SetParms( clgame.ds.hSprite, kRenderNormal, frame );
SPR_DrawGeneric( frame, x, y, width, height, prc );
}
/*
=========
pfnSPR_DrawTrans
=========
*/
static void pfnSPR_DrawTrans( int frame, int x, int y, int width, int height, const wrect_t *prc )
{
if( !re ) return; // render not initialized
re->SetParms( clgame.ds.hSprite, kRenderTransColor, frame );
SPR_DrawGeneric( frame, x, y, width, height, prc );
}
/*
=========
pfnSPR_DrawHoles
=========
*/
static void pfnSPR_DrawHoles( int frame, int x, int y, int width, int height, const wrect_t *prc )
{
if( !re ) return; // render not initialized
re->SetParms( clgame.ds.hSprite, kRenderTransAlpha, frame );
SPR_DrawGeneric( frame, x, y, width, height, prc );
}
/*
=========
pfnSPR_DrawAdditive
=========
*/
static void pfnSPR_DrawAdditive( int frame, int x, int y, int width, int height, const wrect_t *prc )
{
if( !re ) return; // render not initialized
re->SetParms( clgame.ds.hSprite, kRenderTransAdd, frame );
SPR_DrawGeneric( frame, x, y, width, height, prc );
}
/*
=========
pfnSPR_EnableScissor
=========
*/
static void pfnSPR_EnableScissor( int x, int y, int width, int height )
{
// check bounds
x = bound( 0, x, clgame.scrInfo.iWidth );
y = bound( 0, y, clgame.scrInfo.iHeight );
width = bound( 0, width, clgame.scrInfo.iWidth - x );
height = bound( 0, height, clgame.scrInfo.iHeight - y );
clgame.ds.scissor_x = x;
clgame.ds.scissor_width = width;
clgame.ds.scissor_y = y;
clgame.ds.scissor_height = height;
clgame.ds.scissor_test = true;
}
/*
=========
pfnSPR_DisableScissor
=========
*/
static void pfnSPR_DisableScissor( void )
{
clgame.ds.scissor_x = 0;
clgame.ds.scissor_width = 0;
clgame.ds.scissor_y = 0;
clgame.ds.scissor_height = 0;
clgame.ds.scissor_test = false;
}
/*
=========
pfnSPR_GetList
FIXME: implement original hl1 SPR_GetList
=========
*/
static client_sprite_t *pfnSPR_GetList( char *psz, int *piCount )
{
return NULL;
}
/*
=============
pfnFillRGBA
=============
*/
static void pfnFillRGBA( int x, int y, int width, int height, int r, int g, int b, int a )
{
rgba_t color;
if( !re ) return;
MakeRGBA( color, r, g, b, a );
re->SetColor( color );
SPR_AdjustSize( (float *)&x, (float *)&y, (float *)&width, (float *)&height );
re->DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.fillShader );
re->SetColor( NULL );
}
/*
=============
pfnGetScreenInfo
get actual screen info
=============
*/
static int pfnGetScreenInfo( SCREENINFO *pscrinfo )
{
int i;
// setup screen info
clgame.scrInfo.iRealWidth = scr_width->integer;
clgame.scrInfo.iRealHeight = scr_height->integer;
if( pscrinfo && pscrinfo->iFlags & SCRINFO_VIRTUALSPACE )
{
// virtual screen space 640x480
// see cl_screen.c from Quake3 code for more details
clgame.scrInfo.iWidth = SCREEN_WIDTH;
clgame.scrInfo.iHeight = SCREEN_HEIGHT;
}
else
{
clgame.scrInfo.iWidth = scr_width->integer;
clgame.scrInfo.iHeight = scr_height->integer;
}
// TODO: build real table of fonts widthInChars
for( i = 0; i < 256; i++ )
clgame.scrInfo.charWidths[i] = SMALLCHAR_WIDTH;
clgame.scrInfo.iCharHeight = SMALLCHAR_HEIGHT;
if( !pscrinfo ) return 0;
*pscrinfo = clgame.scrInfo; // copy screeninfo out
return 1;
}
/*
=============
pfnSetCrosshair
setup auto-aim crosshair
=============
*/
static void pfnSetCrosshair( HSPRITE hspr, wrect_t rc, int r, int g, int b )
{
clgame.ds.rgbaCrosshair[0] = (byte)r;
clgame.ds.rgbaCrosshair[1] = (byte)g;
clgame.ds.rgbaCrosshair[2] = (byte)b;
clgame.ds.rgbaCrosshair[3] = (byte)0xFF;
clgame.ds.hCrosshair = hspr;
clgame.ds.rcCrosshair = rc;
}
/*
=========
@ -684,23 +1143,6 @@ shader_t pfnLoadShader( const char *szShaderName, int fShaderNoMip )
return re->RegisterShader( szShaderName, SHADER_GENERIC );
}
/*
=============
pfnFillRGBA
=============
*/
void pfnFillRGBA( int x, int y, int width, int height, byte r, byte g, byte b, byte alpha )
{
rgba_t color;
if( !re ) return;
MakeRGBA( color, r, g, b, alpha );
re->SetColor( color );
re->DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.fillShader );
re->SetColor( NULL );
}
/*
=============
@ -1177,44 +1619,6 @@ static void *pfnGetModelPtr( edict_t *pEdict )
return Mod_Extradata( pEdict->v.modelindex );
}
/*
=============
pfnGetScreenInfo
get actual screen info
=============
*/
int pfnGetScreenInfo( SCREENINFO *pscrinfo )
{
int i;
if( !pscrinfo ) return 0;
// setup screen info
pscrinfo->iRealWidth = scr_width->integer;
pscrinfo->iRealHeight = scr_height->integer;
if(pscrinfo->iFlags & SCRINFO_VIRTUALSPACE )
{
// virtual screen space 640x480
// see cl_screen.c from Quake3 code for more details
pscrinfo->iWidth = SCREEN_WIDTH;
pscrinfo->iHeight = SCREEN_HEIGHT;
}
else
{
pscrinfo->iWidth = scr_width->integer;
pscrinfo->iHeight = scr_height->integer;
}
// TODO: build real table of fonts widthInChars
for( i = 0; i < 256; i++ )
pscrinfo->charWidths[i] = SMALLCHAR_WIDTH;
pscrinfo->iCharHeight = SMALLCHAR_HEIGHT;
return 1;
}
/*
=============
pfnGetAttachment
@ -1835,11 +2239,25 @@ static efxapi_t gEfxApi =
static cl_enginefuncs_t gEngfuncs =
{
sizeof( cl_enginefuncs_t ),
pfnSPR_Load,
pfnSPR_Frames,
pfnSPR_Height,
pfnSPR_Width,
pfnSPR_Set,
pfnSPR_Draw,
pfnSPR_DrawHoles,
pfnSPR_DrawTrans,
pfnSPR_DrawAdditive,
pfnSPR_EnableScissor,
pfnSPR_DisableScissor,
pfnSPR_GetList,
pfnFillRGBA,
pfnGetScreenInfo,
pfnSetCrosshair,
pfnMemAlloc,
pfnMemCopy,
pfnMemFree,
pfnLoadShader,
pfnFillRGBA,
pfnDrawImageExt,
pfnSetColor,
pfnCVarRegister,
@ -1875,7 +2293,6 @@ static cl_enginefuncs_t gEngfuncs =
pfnGetMaxClients,
pfnGetViewModel,
pfnGetModelPtr,
pfnGetScreenInfo,
pfnGetAttachment,
pfnPointContents,
pfnTraceLine,

View File

@ -17,7 +17,7 @@ cvar_t *cl_maxfps;
cvar_t *cl_particles;
cvar_t *cl_particlelod;
cvar_t *cl_crosshair;
cvar_t *cl_shownet;
cvar_t *cl_showmiss;
cvar_t *cl_mouselook;
@ -1082,6 +1082,7 @@ void CL_InitLocal( void )
cl_maxfps = Cvar_Get( "cl_maxfps", "1000", 0, "maximum client fps" );
cl_particles = Cvar_Get( "cl_particles", "1", CVAR_ARCHIVE, "disables particle effects" );
cl_particlelod = Cvar_Get( "cl_lod_particle", "0", CVAR_ARCHIVE, "enables particle LOD (1, 2, 3)" );
cl_crosshair = Cvar_Get( "crosshair", "1", CVAR_ARCHIVE|CVAR_USERINFO, "show weapon chrosshair" );
cl_upspeed = Cvar_Get( "cl_upspeed", "200", 0, "client upspeed limit" );
cl_forwardspeed = Cvar_Get( "cl_forwardspeed", "200", 0, "client forward speed limit" );

View File

@ -435,6 +435,7 @@ void SCR_RegisterShaders( void )
// vid_state has changed
if( clgame.hInstance ) clgame.dllFuncs.pfnVidInit();
Mem_Set( &clgame.ds, 0, sizeof( clgame.ds )); // reset a draw state
g_console_field_width = scr_width->integer / SMALLCHAR_WIDTH - 2;
g_consoleField.widthInChars = g_console_field_width;
cls.drawplaque = true;

View File

@ -218,6 +218,24 @@ typedef struct
pfnEventHook func; // user-defined function
} user_event_t;
typedef struct
{
// temp handle
HSPRITE hSprite;
// scissor test
int scissor_x;
int scissor_y;
int scissor_width;
int scissor_height;
bool scissor_test;
// crosshair members
HSPRITE hCrosshair;
wrect_t rcCrosshair;
rgba_t rgbaCrosshair;
} draw_stuff_t;
#define MAX_TRIPOLYS 2048
#define MAX_TRIVERTS 128
#define MAX_TRIELEMS MAX_TRIVERTS * 6
@ -285,6 +303,9 @@ typedef struct
user_event_t *events[MAX_EVENTS]; // keep static to avoid fragment memory
entity_state_t *baselines;
draw_stuff_t ds; // draw2d stuff (hud, weaponmenu etc)
SCREENINFO scrInfo; // actual screen info
tri_state_t *pTri;
client_textmessage_t titles[MAX_GAME_TITLES];
@ -383,6 +404,7 @@ extern cvar_t *cl_pitchspeed;
extern cvar_t *cl_envshot_size;
extern cvar_t *cl_run;
extern cvar_t *cl_font;
extern cvar_t *cl_crosshair;
extern cvar_t *cl_anglespeedkey;
extern cvar_t *cl_showmiss;
extern cvar_t *cl_particles;

View File

@ -440,6 +440,10 @@ static void SV_ClipToLinks( areanode_t *node, moveclip_t *clip )
if( clip->passedict && !VectorIsNull( clip->passedict->v.size ) && VectorIsNull( touch->v.size ))
continue; // points never interact
// custom user filter
if( !svgame.dllFuncs.pfnShouldCollide( touch, clip->passedict ))
continue;
if( clip->flags & FTRACE_IGNORE_GLASS && CM_GetModelType( touch->v.modelindex ) == mod_brush )
{
vec3_t point;

View File

@ -1,22 +0,0 @@
//=======================================================================
// Copyright (C) Shambler Team 2004
// bullets.h - shared bullets enum
//=======================================================================
#ifndef BULLETS_H
#define BULLETS_H
// bullet types
typedef enum
{
BULLET_NONE = 0,
BULLET_9MM, // glock
BULLET_MP5, // mp5
BULLET_357, // python
BULLET_12MM, // sentry turret
BULLET_556, // m249 bullet
BULLET_762, // sniper bullet
BULLET_BUCKSHOT, // shotgun
BULLET_CROWBAR, // crowbar swipe
} Bullet;
#endif //BULLETS_H