Format all files and add clang-format configuration file

Resolves #84
This commit is contained in:
Sam V 2021-11-28 16:54:48 +01:00
parent adf708f026
commit 08755342d0
282 changed files with 46893 additions and 46874 deletions

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -57,9 +57,9 @@ R_StudioDrawPlayer
====================
*/
int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
int R_StudioDrawPlayer(int flags, entity_state_t* pplayer)
{
return static_cast<int>(g_StudioRenderer.StudioDrawPlayer( flags, pplayer ));
return static_cast<int>(g_StudioRenderer.StudioDrawPlayer(flags, pplayer));
}
/*
@ -68,9 +68,9 @@ R_StudioDrawModel
====================
*/
int R_StudioDrawModel( int flags )
int R_StudioDrawModel(int flags)
{
return static_cast<int>(g_StudioRenderer.StudioDrawModel( flags ));
return static_cast<int>(g_StudioRenderer.StudioDrawModel(flags));
}
/*
@ -86,10 +86,10 @@ void R_StudioInit()
// The simple drawing interface we'll pass back to the engine
r_studio_interface_t studio =
{
STUDIO_INTERFACE_VERSION,
R_StudioDrawModel,
R_StudioDrawPlayer,
{
STUDIO_INTERFACE_VERSION,
R_StudioDrawModel,
R_StudioDrawPlayer,
};
/*
@ -99,18 +99,18 @@ HUD_GetStudioModelInterface
Export this function for the engine to use the studio renderer class to render objects.
====================
*/
int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
int DLLEXPORT HUD_GetStudioModelInterface(int version, struct r_studio_interface_s** ppinterface, struct engine_studio_api_s* pstudio)
{
// RecClStudioInterface(version, ppinterface, pstudio);
// RecClStudioInterface(version, ppinterface, pstudio);
if ( version != STUDIO_INTERFACE_VERSION )
if (version != STUDIO_INTERFACE_VERSION)
return 0;
// Point the engine to our callbacks
*ppinterface = &studio;
// Copy in engine helper functions
memcpy( &IEngineStudio, pstudio, sizeof( IEngineStudio ) );
memcpy(&IEngineStudio, pstudio, sizeof(IEngineStudio));
// Initialize local variables, etc.
R_StudioInit();

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -23,161 +23,160 @@ public:
// Initialization
virtual void Init();
public:
public:
// Public Interfaces
virtual bool StudioDrawModel ( int flags );
virtual bool StudioDrawPlayer ( int flags, struct entity_state_s *pplayer );
virtual bool StudioDrawModel(int flags);
virtual bool StudioDrawPlayer(int flags, struct entity_state_s* pplayer);
public:
// Local interfaces
//
// Look up animation data for sequence
virtual mstudioanim_t *StudioGetAnim ( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
virtual mstudioanim_t* StudioGetAnim(model_t* m_pSubModel, mstudioseqdesc_t* pseqdesc);
// Interpolate model position and angles and set up matrices
virtual void StudioSetUpTransform (bool trivial_accept);
virtual void StudioSetUpTransform(bool trivial_accept);
// Set up model bone positions
virtual void StudioSetupBones ();
virtual void StudioSetupBones();
// Find final attachment points
virtual void StudioCalcAttachments ();
virtual void StudioCalcAttachments();
// Save bone matrices and names
virtual void StudioSaveBones();
// Merge cached bones with current bones for model
virtual void StudioMergeBones ( model_t *m_pSubModel );
virtual void StudioMergeBones(model_t* m_pSubModel);
// Determine interpolation fraction
virtual float StudioEstimateInterpolant();
// Determine current frame for rendering
virtual float StudioEstimateFrame ( mstudioseqdesc_t *pseqdesc );
virtual float StudioEstimateFrame(mstudioseqdesc_t* pseqdesc);
// Apply special effects to transform matrix
virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] );
virtual void StudioFxTransform(cl_entity_t* ent, float transform[3][4]);
// Spherical interpolation of bones
virtual void StudioSlerpBones ( vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s );
virtual void StudioSlerpBones(vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s);
// Compute bone adjustments ( bone controllers )
virtual void StudioCalcBoneAdj ( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen );
virtual void StudioCalcBoneAdj(float dadt, float* adj, const byte* pcontroller1, const byte* pcontroller2, byte mouthopen);
// Get bone quaternions
virtual void StudioCalcBoneQuaterion ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q );
virtual void StudioCalcBoneQuaterion(int frame, float s, mstudiobone_t* pbone, mstudioanim_t* panim, float* adj, float* q);
// Get bone positions
virtual void StudioCalcBonePosition ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos );
virtual void StudioCalcBonePosition(int frame, float s, mstudiobone_t* pbone, mstudioanim_t* panim, float* adj, float* pos);
// Compute rotations
virtual void StudioCalcRotations ( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f );
virtual void StudioCalcRotations(float pos[][3], vec4_t* q, mstudioseqdesc_t* pseqdesc, mstudioanim_t* panim, float f);
// Send bones and verts to renderer
virtual void StudioRenderModel ();
virtual void StudioRenderModel();
// Finalize rendering
virtual void StudioRenderFinal ();
virtual void StudioRenderFinal();
// GL&D3D vs. Software renderer finishing functions
virtual void StudioRenderFinal_Software ();
virtual void StudioRenderFinal_Hardware ();
virtual void StudioRenderFinal_Software();
virtual void StudioRenderFinal_Hardware();
// Player specific data
// Determine pitch and blending amounts for players
virtual void StudioPlayerBlend ( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch );
virtual void StudioPlayerBlend(mstudioseqdesc_t* pseqdesc, int* pBlend, float* pPitch);
// Estimate gait frame for player
virtual void StudioEstimateGait ( entity_state_t *pplayer );
virtual void StudioEstimateGait(entity_state_t* pplayer);
// Process movement of player
virtual void StudioProcessGait ( entity_state_t *pplayer );
virtual void StudioProcessGait(entity_state_t* pplayer);
public:
// Client clock
double m_clTime;
double m_clTime;
// Old Client clock
double m_clOldTime;
double m_clOldTime;
// Do interpolation?
bool m_fDoInterp;
bool m_fDoInterp;
// Do gait estimation?
bool m_fGaitEstimation;
bool m_fGaitEstimation;
// Current render frame #
int m_nFrameCount;
int m_nFrameCount;
// Cvars that studio model code needs to reference
//
// Use high quality models?
cvar_t *m_pCvarHiModels;
cvar_t* m_pCvarHiModels;
// Developer debug output desired?
cvar_t *m_pCvarDeveloper;
cvar_t* m_pCvarDeveloper;
// Draw entities bone hit boxes, etc?
cvar_t *m_pCvarDrawEntities;
cvar_t* m_pCvarDrawEntities;
// The entity which we are currently rendering.
cl_entity_t *m_pCurrentEntity;
cl_entity_t* m_pCurrentEntity;
// The model for the entity being rendered
model_t *m_pRenderModel;
model_t* m_pRenderModel;
// Player info for current player, if drawing a player
player_info_t *m_pPlayerInfo;
player_info_t* m_pPlayerInfo;
// The index of the player being drawn
int m_nPlayerIndex;
int m_nPlayerIndex;
// The player's gait movement
float m_flGaitMovement;
float m_flGaitMovement;
// Pointer to header block for studio model data
studiohdr_t *m_pStudioHeader;
studiohdr_t* m_pStudioHeader;
// Pointers to current body part and submodel
mstudiobodyparts_t *m_pBodyPart;
mstudiomodel_t *m_pSubModel;
mstudiobodyparts_t* m_pBodyPart;
mstudiomodel_t* m_pSubModel;
// Palette substition for top and bottom of model
int m_nTopColor;
int m_nBottomColor;
int m_nTopColor;
int m_nBottomColor;
//
// Sprite model used for drawing studio model chrome
model_t *m_pChromeSprite;
model_t* m_pChromeSprite;
// Caching
// Number of bones in bone cache
int m_nCachedBones;
int m_nCachedBones;
// Names of cached bones
char m_nCachedBoneNames[ MAXSTUDIOBONES ][ 32 ];
char m_nCachedBoneNames[MAXSTUDIOBONES][32];
// Cached bone & light transformation matrices
float m_rgCachedBoneTransform [ MAXSTUDIOBONES ][ 3 ][ 4 ];
float m_rgCachedLightTransform[ MAXSTUDIOBONES ][ 3 ][ 4 ];
float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4];
float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4];
// Software renderer scale factors
float m_fSoftwareXScale, m_fSoftwareYScale;
float m_fSoftwareXScale, m_fSoftwareYScale;
// Current view vectors and render origin
float m_vUp[ 3 ];
float m_vRight[ 3 ];
float m_vNormal[ 3 ];
float m_vUp[3];
float m_vRight[3];
float m_vNormal[3];
float m_vRenderOrigin[3];
float m_vRenderOrigin[ 3 ];
// Model render counters ( from engine )
int *m_pStudioModelCount;
int *m_pModelsDrawn;
int* m_pStudioModelCount;
int* m_pModelsDrawn;
// Matrices
// Model to world transformation
float (*m_protationmatrix)[ 3 ][ 4 ];
float (*m_protationmatrix)[3][4];
// Model to view transformation
float (*m_paliastransform)[ 3 ][ 4 ];
float (*m_paliastransform)[3][4];
// Concatenated bone and light transforms
float (*m_pbonetransform) [ MAXSTUDIOBONES ][ 3 ][ 4 ];
float (*m_plighttransform)[ MAXSTUDIOBONES ][ 3 ][ 4 ];
float (*m_pbonetransform)[MAXSTUDIOBONES][3][4];
float (*m_plighttransform)[MAXSTUDIOBONES][3][4];
};

File diff suppressed because it is too large Load diff

View file

@ -18,30 +18,30 @@
#define MAX_WEAPON_NAME 128
#define WEAPON_FLAGS_SELECTONEMPTY 1
#define WEAPON_FLAGS_SELECTONEMPTY 1
#define WEAPON_IS_ONTARGET 0x40
struct WEAPON
{
char szName[MAX_WEAPON_NAME];
int iAmmoType;
int iAmmo2Type;
int iMax1;
int iMax2;
int iSlot;
int iSlotPos;
int iFlags;
int iId;
int iClip;
char szName[MAX_WEAPON_NAME];
int iAmmoType;
int iAmmo2Type;
int iMax1;
int iMax2;
int iSlot;
int iSlotPos;
int iFlags;
int iId;
int iClip;
int iCount; // # of itesm in plist
int iCount; // # of itesm in plist
HSPRITE hActive;
Rect rcActive;
HSPRITE hInactive;
Rect rcInactive;
HSPRITE hAmmo;
HSPRITE hAmmo;
Rect rcAmmo;
HSPRITE hAmmo2;
Rect rcAmmo2;

View file

@ -24,86 +24,86 @@
#include <stdio.h>
#include "parsemsg.h"
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
DECLARE_MESSAGE(m_AmmoSecondary, SecAmmoVal);
DECLARE_MESSAGE(m_AmmoSecondary, SecAmmoIcon);
bool CHudAmmoSecondary :: Init()
bool CHudAmmoSecondary ::Init()
{
HOOK_MESSAGE( SecAmmoVal );
HOOK_MESSAGE( SecAmmoIcon );
HOOK_MESSAGE(SecAmmoVal);
HOOK_MESSAGE(SecAmmoIcon);
gHUD.AddHudElem(this);
m_HUD_ammoicon = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
for (int i = 0; i < MAX_SEC_AMMO_VALUES; i++)
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
Reset();
return true;
}
void CHudAmmoSecondary :: Reset()
void CHudAmmoSecondary ::Reset()
{
m_fFade = 0;
}
bool CHudAmmoSecondary :: VidInit()
bool CHudAmmoSecondary ::VidInit()
{
return true;
}
bool CHudAmmoSecondary :: Draw(float flTime)
bool CHudAmmoSecondary ::Draw(float flTime)
{
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) != 0)
if ((gHUD.m_iHideHUDDisplay & (HIDEHUD_WEAPONS | HIDEHUD_ALL)) != 0)
return true;
// draw secondary ammo icons above normal ammo readout
int a, x, y, r, g, b, AmmoWidth;
UnpackRGB( r, g, b, RGB_YELLOWISH );
a = (int) V_max( MIN_ALPHA, m_fFade );
UnpackRGB(r, g, b, RGB_YELLOWISH);
a = (int)V_max(MIN_ALPHA, m_fFade);
if (m_fFade > 0)
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
ScaleColors( r, g, b, a );
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
ScaleColors(r, g, b, a);
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values
y = ScreenHeight - (gHUD.m_iFontHeight * 4); // this is one font height higher than the weapon ammo values
x = ScreenWidth - AmmoWidth;
if ( 0 != m_HUD_ammoicon )
if (0 != m_HUD_ammoicon)
{
// Draw the ammo icon
x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left);
y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom);
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
SPR_Set(gHUD.GetSprite(m_HUD_ammoicon), r, g, b);
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon));
}
else
{ // move the cursor by the '0' char instead, since we don't have an icon to work with
{ // move the cursor by the '0' char instead, since we don't have an icon to work with
x -= AmmoWidth;
y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom);
}
// draw the ammo counts, in reverse order, from right to left
for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
for (int i = MAX_SEC_AMMO_VALUES - 1; i >= 0; i--)
{
if ( m_iAmmoAmounts[i] < 0 )
if (m_iAmmoAmounts[i] < 0)
continue; // negative ammo amounts imply that they shouldn't be drawn
// half a char gap between the ammo number and the previous pic
x -= (AmmoWidth / 2);
// draw the number, right-aligned
x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
x -= (gHUD.GetNumWidth(m_iAmmoAmounts[i], DHN_DRAWZERO) * AmmoWidth);
gHUD.DrawHudNumber(x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b);
if ( i != 0 )
if (i != 0)
{
// draw the divider bar
x -= (AmmoWidth / 2);
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
FillRGBA(x, y, (AmmoWidth / 10), gHUD.m_iFontHeight, r, g, b, a);
}
}
@ -113,10 +113,10 @@ bool CHudAmmoSecondary :: Draw(float flTime)
// Message handler for Secondary Ammo Value
// accepts one value:
// string: sprite name
bool CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
bool CHudAmmoSecondary ::MsgFunc_SecAmmoIcon(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
BEGIN_READ(pbuf, iSize);
m_HUD_ammoicon = gHUD.GetSpriteIndex(READ_STRING());
return true;
}
@ -126,12 +126,12 @@ bool CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, v
// takes two values:
// byte: ammo index
// byte: ammo value
bool CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
bool CHudAmmoSecondary ::MsgFunc_SecAmmoVal(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int index = READ_BYTE();
if ( index < 0 || index >= MAX_SEC_AMMO_VALUES )
if (index < 0 || index >= MAX_SEC_AMMO_VALUES)
return true;
m_iAmmoAmounts[index] = READ_BYTE();
@ -139,13 +139,13 @@ bool CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, vo
// check to see if there is anything left to draw
int count = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
for (int i = 0; i < MAX_SEC_AMMO_VALUES; i++)
{
count += V_max( 0, m_iAmmoAmounts[i] );
count += V_max(0, m_iAmmoAmounts[i]);
}
if ( count == 0 )
{ // the ammo fields are all empty, so turn off this hud area
if (count == 0)
{ // the ammo fields are all empty, so turn off this hud area
m_iFlags &= ~HUD_ACTIVE;
return true;
}
@ -155,5 +155,3 @@ bool CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, vo
return true;
}

View file

@ -28,11 +28,11 @@
HistoryResource gHR;
#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5)
#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2))
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100)
#define AMMO_PICKUP_GAP (gHR.iHistoryGap + 5)
#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2))
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100)
#define MAX_ITEM_NAME 32
#define MAX_ITEM_NAME 32
int HISTORY_DRAW_TIME = 5;
// keep a list of items
@ -43,19 +43,19 @@ struct ITEM_INFO
Rect rect;
};
void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
void HistoryResource ::AddToHistory(int iType, int iId, int iCount)
{
if ( iType == HISTSLOT_AMMO && 0 == iCount )
return; // no amount, so don't add
if (iType == HISTSLOT_AMMO && 0 == iCount)
return; // no amount, so don't add
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
{ // the pic would have to be drawn too high
if ((((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY))
{ // the pic would have to be drawn too high
// so start from the bottom
iCurrentHistorySlot = 0;
}
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
HIST_ITEM* freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
HISTORY_DRAW_TIME = CVAR_GET_FLOAT("hud_drawhistory_time");
freeslot->type = iType;
freeslot->iId = iId;
@ -63,39 +63,39 @@ void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
}
void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount )
void HistoryResource ::AddToHistory(int iType, const char* szName, int iCount)
{
if ( iType != HISTSLOT_ITEM )
if (iType != HISTSLOT_ITEM)
return;
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
{ // the pic would have to be drawn too high
if ((((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY))
{ // the pic would have to be drawn too high
// so start from the bottom
iCurrentHistorySlot = 0;
}
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
HIST_ITEM* freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
// I am really unhappy with all the code in this file
int i = gHUD.GetSpriteIndex( szName );
if ( i == -1 )
return; // unknown sprite name, don't add it to history
int i = gHUD.GetSpriteIndex(szName);
if (i == -1)
return; // unknown sprite name, don't add it to history
freeslot->iId = i;
freeslot->type = iType;
freeslot->iCount = iCount;
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
HISTORY_DRAW_TIME = CVAR_GET_FLOAT("hud_drawhistory_time");
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
}
void HistoryResource :: CheckClearHistory()
void HistoryResource ::CheckClearHistory()
{
for ( int i = 0; i < MAX_HISTORY; i++ )
for (int i = 0; i < MAX_HISTORY; i++)
{
if (HISTSLOT_EMPTY != rgAmmoHistory[i].type )
if (HISTSLOT_EMPTY != rgAmmoHistory[i].type)
return;
}
@ -105,80 +105,80 @@ void HistoryResource :: CheckClearHistory()
//
// Draw Ammo pickup history
//
bool HistoryResource :: DrawAmmoHistory( float flTime )
bool HistoryResource ::DrawAmmoHistory(float flTime)
{
for ( int i = 0; i < MAX_HISTORY; i++ )
for (int i = 0; i < MAX_HISTORY; i++)
{
if (HISTSLOT_EMPTY != rgAmmoHistory[i].type )
if (HISTSLOT_EMPTY != rgAmmoHistory[i].type)
{
rgAmmoHistory[i].DisplayTime = V_min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
rgAmmoHistory[i].DisplayTime = V_min(rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME);
if ( rgAmmoHistory[i].DisplayTime <= flTime )
{ // pic drawing time has expired
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
if (rgAmmoHistory[i].DisplayTime <= flTime)
{ // pic drawing time has expired
memset(&rgAmmoHistory[i], 0, sizeof(HIST_ITEM));
CheckClearHistory();
}
else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO )
else if (rgAmmoHistory[i].type == HISTSLOT_AMMO)
{
Rect rcPic;
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
HSPRITE* spr = gWR.GetAmmoPicFromWeapon(rgAmmoHistory[i].iId, rcPic);
int r, g, b;
UnpackRGB(r,g,b, RGB_YELLOWISH);
UnpackRGB(r, g, b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, V_min(scale, 255) );
ScaleColors(r, g, b, V_min(scale, 255));
// Draw the pic
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - 24;
if ( spr && 0 != *spr ) // weapon isn't loaded yet so just don't draw the pic
{ // the dll has to make sure it has sent info the weapons you need
SPR_Set( *spr, r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
if (spr && 0 != *spr) // weapon isn't loaded yet so just don't draw the pic
{ // the dll has to make sure it has sent info the weapons you need
SPR_Set(*spr, r, g, b);
SPR_DrawAdditive(0, xpos, ypos, &rcPic);
}
// Draw the number
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
gHUD.DrawHudNumberString(xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b);
}
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
else if (rgAmmoHistory[i].type == HISTSLOT_WEAP)
{
WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
WEAPON* weap = gWR.GetWeapon(rgAmmoHistory[i].iId);
if ( !weap )
return true; // we don't know about the weapon yet, so don't draw anything
if (!weap)
return true; // we don't know about the weapon yet, so don't draw anything
int r, g, b;
UnpackRGB(r,g,b, RGB_YELLOWISH);
UnpackRGB(r, g, b, RGB_YELLOWISH);
if ( !gWR.HasAmmo( weap ) )
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
if (!gWR.HasAmmo(weap))
UnpackRGB(r, g, b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, V_min(scale, 255) );
ScaleColors(r, g, b, V_min(scale, 255));
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
SPR_Set( weap->hInactive, r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
SPR_Set(weap->hInactive, r, g, b);
SPR_DrawAdditive(0, xpos, ypos, &weap->rcInactive);
}
else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM )
else if (rgAmmoHistory[i].type == HISTSLOT_ITEM)
{
int r, g, b;
if ( 0 == rgAmmoHistory[i].iId )
continue; // sprite not loaded
if (0 == rgAmmoHistory[i].iId)
continue; // sprite not loaded
Rect rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
Rect rect = gHUD.GetSpriteRect(rgAmmoHistory[i].iId);
UnpackRGB(r,g,b, RGB_YELLOWISH);
UnpackRGB(r, g, b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, V_min(scale, 255) );
ScaleColors(r, g, b, V_min(scale, 255));
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (rect.right - rect.left) - 10;
SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &rect );
SPR_Set(gHUD.GetSprite(rgAmmoHistory[i].iId), r, g, b);
SPR_DrawAdditive(0, xpos, ypos, &rect);
}
}
}
@ -186,5 +186,3 @@ bool HistoryResource :: DrawAmmoHistory( float flTime )
return true;
}

View file

@ -19,86 +19,87 @@
#pragma once
// this is the max number of items in each bucket
#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS
#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS
class WeaponsResource
{
private:
// Information about weapons & ammo
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
// counts of weapons * ammo
WEAPON* rgSlots[MAX_WEAPON_SLOTS+1][MAX_WEAPON_POSITIONS+1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there
int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type
WEAPON* rgSlots[MAX_WEAPON_SLOTS + 1][MAX_WEAPON_POSITIONS + 1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there
int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type
public:
void Init()
{
memset( rgWeapons, 0, sizeof rgWeapons );
memset(rgWeapons, 0, sizeof rgWeapons);
Reset();
}
void Reset()
{
iOldWeaponBits = 0;
memset( rgSlots, 0, sizeof rgSlots );
memset( riAmmo, 0, sizeof riAmmo );
memset(rgSlots, 0, sizeof rgSlots);
memset(riAmmo, 0, sizeof riAmmo);
}
///// WEAPON /////
int iOldWeaponBits;
///// WEAPON /////
int iOldWeaponBits;
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
void AddWeapon( WEAPON *wp )
{
rgWeapons[ wp->iId ] = *wp;
LoadWeaponSprites( &rgWeapons[ wp->iId ] );
}
void PickupWeapon( WEAPON *wp )
WEAPON* GetWeapon(int iId) { return &rgWeapons[iId]; }
void AddWeapon(WEAPON* wp)
{
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
rgWeapons[wp->iId] = *wp;
LoadWeaponSprites(&rgWeapons[wp->iId]);
}
void DropWeapon( WEAPON *wp )
void PickupWeapon(WEAPON* wp)
{
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
rgSlots[wp->iSlot][wp->iSlotPos] = wp;
}
void DropWeapon(WEAPON* wp)
{
rgSlots[wp->iSlot][wp->iSlotPos] = NULL;
}
void DropAllWeapons()
{
for ( int i = 0; i < MAX_WEAPONS; i++ )
for (int i = 0; i < MAX_WEAPONS; i++)
{
if ( rgWeapons[i].iId )
DropWeapon( &rgWeapons[i] );
if (rgWeapons[i].iId)
DropWeapon(&rgWeapons[i]);
}
}
WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
WEAPON* GetWeaponSlot(int slot, int pos) { return rgSlots[slot][pos]; }
void LoadWeaponSprites( WEAPON* wp );
void LoadWeaponSprites(WEAPON* wp);
void LoadAllWeaponSprites();
WEAPON* GetFirstPos( int iSlot );
void SelectSlot( int iSlot, bool fAdvance, int iDirection );
WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
WEAPON* GetFirstPos(int iSlot);
void SelectSlot(int iSlot, bool fAdvance, int iDirection);
WEAPON* GetNextActivePos(int iSlot, int iSlotPos);
bool HasAmmo( WEAPON *p );
bool HasAmmo(WEAPON* p);
///// AMMO /////
AMMO GetAmmo( int iId ) { return iId; }
///// AMMO /////
AMMO GetAmmo(int iId) { return iId; }
void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; }
void SetAmmo(int iId, int iCount) { riAmmo[iId] = iCount; }
int CountAmmo( int iId );
int CountAmmo(int iId);
HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, Rect& rect );
HSPRITE* GetAmmoPicFromWeapon(int iAmmoId, Rect& rect);
};
extern WeaponsResource gWR;
#define MAX_HISTORY 12
enum {
enum
{
HISTSLOT_EMPTY,
HISTSLOT_AMMO,
HISTSLOT_WEAP,
@ -108,9 +109,10 @@ enum {
class HistoryResource
{
private:
struct HIST_ITEM {
struct HIST_ITEM
{
int type;
float DisplayTime; // the time at which this item should be removed from the history
float DisplayTime; // the time at which this item should be removed from the history
int iCount;
int iId;
};
@ -118,7 +120,6 @@ private:
HIST_ITEM rgAmmoHistory[MAX_HISTORY];
public:
void Init()
{
Reset();
@ -126,20 +127,17 @@ public:
void Reset()
{
memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
memset(rgAmmoHistory, 0, sizeof rgAmmoHistory);
}
int iHistoryGap;
int iCurrentHistorySlot;
void AddToHistory( int iType, int iId, int iCount = 0 );
void AddToHistory( int iType, const char *szName, int iCount = 0 );
void AddToHistory(int iType, int iId, int iCount = 0);
void AddToHistory(int iType, const char* szName, int iCount = 0);
void CheckClearHistory();
bool DrawAmmoHistory( float flTime );
bool DrawAmmoHistory(float flTime);
};
extern HistoryResource gHR;

View file

@ -43,35 +43,35 @@ bool CHudBattery::Init()
bool CHudBattery::VidInit()
{
int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" );
int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" );
int HUD_suit_empty = gHUD.GetSpriteIndex("suit_empty");
int HUD_suit_full = gHUD.GetSpriteIndex("suit_full");
m_hSprite1 = m_hSprite2 = 0; // delaying get sprite handles until we know the sprites are loaded
m_prc1 = &gHUD.GetSpriteRect( HUD_suit_empty );
m_prc2 = &gHUD.GetSpriteRect( HUD_suit_full );
m_hSprite1 = m_hSprite2 = 0; // delaying get sprite handles until we know the sprites are loaded
m_prc1 = &gHUD.GetSpriteRect(HUD_suit_empty);
m_prc2 = &gHUD.GetSpriteRect(HUD_suit_full);
m_iHeight = m_prc2->bottom - m_prc1->top;
m_fFade = 0;
return true;
};
bool CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
bool CHudBattery::MsgFunc_Battery(const char* pszName, int iSize, void* pbuf)
{
m_iFlags |= HUD_ACTIVE;
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int x = READ_SHORT();
#if defined( _TFC )
#if defined(_TFC)
int y = READ_SHORT();
if ( x != m_iBat || y != m_iBatMax )
if (x != m_iBat || y != m_iBatMax)
{
m_fFade = FADE_TIME;
m_iBat = x;
m_iBatMax = y;
}
#else
if ( x != m_iBat )
if (x != m_iBat)
{
m_fFade = FADE_TIME;
m_iBat = x;
@ -84,7 +84,7 @@ bool CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
bool CHudBattery::Draw(float flTime)
{
if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) != 0)
if ((gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) != 0)
return true;
int r, g, b, x, y, a;
@ -92,20 +92,20 @@ bool CHudBattery::Draw(float flTime)
rc = *m_prc2;
#if defined( _TFC )
#if defined(_TFC)
float fScale = 0.0;
if ( m_iBatMax > 0 )
if (m_iBatMax > 0)
fScale = 1.0 / (float)m_iBatMax;
rc.top += m_iHeight * ((float)(m_iBatMax-(V_min(m_iBatMax,m_iBat))) * fScale); // battery can go from 0 to m_iBatMax so * fScale goes from 0 to 1
rc.top += m_iHeight * ((float)(m_iBatMax - (V_min(m_iBatMax, m_iBat))) * fScale); // battery can go from 0 to m_iBatMax so * fScale goes from 0 to 1
#else
rc.top += m_iHeight * ((float)(100-(V_min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
rc.top += m_iHeight * ((float)(100 - (V_min(100, m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
#endif
UnpackRGB(r,g,b, RGB_YELLOWISH);
UnpackRGB(r, g, b, RGB_YELLOWISH);
if ((gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ) == 0)
if ((gHUD.m_iWeaponBits & (1 << (WEAPON_SUIT))) == 0)
return true;
// Has health changed? Flash the health #
@ -123,32 +123,31 @@ bool CHudBattery::Draw(float flTime)
// Fade the health number back to dim
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
a = MIN_ALPHA + (m_fFade / FADE_TIME) * 128;
}
else
a = MIN_ALPHA;
ScaleColors(r, g, b, a );
int iOffset = (m_prc1->bottom - m_prc1->top)/6;
ScaleColors(r, g, b, a);
int iOffset = (m_prc1->bottom - m_prc1->top) / 6;
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = ScreenWidth/4;
x = ScreenWidth / 4;
// make sure we have the right sprite handles
if ( 0 == m_hSprite1 )
m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
if ( 0 == m_hSprite2 )
m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
if (0 == m_hSprite1)
m_hSprite1 = gHUD.GetSprite(gHUD.GetSpriteIndex("suit_empty"));
if (0 == m_hSprite2)
m_hSprite2 = gHUD.GetSprite(gHUD.GetSpriteIndex("suit_full"));
SPR_Set(m_hSprite1, r, g, b );
SPR_DrawAdditive( 0, x, y - iOffset, m_prc1);
SPR_Set(m_hSprite1, r, g, b);
SPR_DrawAdditive(0, x, y - iOffset, m_prc1);
if (rc.bottom > rc.top)
{
SPR_Set(m_hSprite2, r, g, b );
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
SPR_Set(m_hSprite2, r, g, b);
SPR_DrawAdditive(0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
}
x += (m_prc1->right - m_prc1->left);

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================

View file

@ -37,17 +37,17 @@
cl_enginefunc_t gEngfuncs;
CHud gHUD;
TeamFortressViewport *gViewPort = NULL;
TeamFortressViewport* gViewPort = NULL;
#include "particleman.h"
CSysModule *g_hParticleManModule = NULL;
IParticleMan *g_pParticleMan = NULL;
CSysModule* g_hParticleManModule = NULL;
IParticleMan* g_pParticleMan = NULL;
void CL_LoadParticleMan();
void CL_UnloadParticleMan();
void InitInput ();
void InitInput();
void EV_HookEvents();
void IN_Commands();
@ -58,25 +58,25 @@ HUD_GetHullBounds
Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist.
================================
*/
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
int DLLEXPORT HUD_GetHullBounds(int hullnumber, float* mins, float* maxs)
{
// RecClGetHullBounds(hullnumber, mins, maxs);
// RecClGetHullBounds(hullnumber, mins, maxs);
int iret = 0;
switch (hullnumber)
{
case 0: // Normal player
case 0: // Normal player
memcpy(mins, &VEC_HULL_MIN, sizeof(VEC_HULL_MIN));
memcpy(maxs, &VEC_HULL_MAX, sizeof(VEC_HULL_MAX));
iret = 1;
break;
case 1: // Crouched player
case 1: // Crouched player
memcpy(mins, &VEC_DUCK_HULL_MIN, sizeof(VEC_DUCK_HULL_MIN));
memcpy(maxs, &VEC_DUCK_HULL_MAX, sizeof(VEC_DUCK_HULL_MAX));
iret = 1;
break;
case 2: // Point based hull
case 2: // Point based hull
memcpy(mins, &g_vecZero, sizeof(g_vecZero));
memcpy(maxs, &g_vecZero, sizeof(g_vecZero));
iret = 1;
@ -94,9 +94,9 @@ HUD_ConnectionlessPacket
size of the response_buffer, so you must zero it out if you choose not to respond.
================================
*/
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
int DLLEXPORT HUD_ConnectionlessPacket(const struct netadr_s* net_from, const char* args, char* response_buffer, int* response_buffer_size)
{
// RecClConnectionlessPacket(net_from, args, response_buffer, response_buffer_size);
// RecClConnectionlessPacket(net_from, args, response_buffer, response_buffer_size);
// Parse stuff from args
int max_buffer_size = *response_buffer_size;
@ -110,32 +110,32 @@ int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const c
return 0;
}
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
void DLLEXPORT HUD_PlayerMoveInit(struct playermove_s* ppmove)
{
// RecClClientMoveInit(ppmove);
// RecClClientMoveInit(ppmove);
PM_Init( ppmove );
PM_Init(ppmove);
}
char DLLEXPORT HUD_PlayerMoveTexture( char *name )
char DLLEXPORT HUD_PlayerMoveTexture(char* name)
{
// RecClClientTextureType(name);
// RecClClientTextureType(name);
return PM_FindTextureType( name );
return PM_FindTextureType(name);
}
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
void DLLEXPORT HUD_PlayerMove(struct playermove_s* ppmove, int server)
{
// RecClClientMove(ppmove, server);
// RecClClientMove(ppmove, server);
PM_Move( ppmove, server );
PM_Move(ppmove, server);
}
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
int DLLEXPORT Initialize(cl_enginefunc_t* pEnginefuncs, int iVersion)
{
gEngfuncs = *pEnginefuncs;
// RecClInitialize(pEnginefuncs, iVersion);
// RecClInitialize(pEnginefuncs, iVersion);
if (iVersion != CLDLL_INTERFACE_VERSION)
return 0;
@ -162,7 +162,7 @@ so the HUD can reinitialize itself.
int DLLEXPORT HUD_VidInit()
{
// RecClHudVidInit();
// RecClHudVidInit();
gHUD.VidInit();
VGui_Startup();
@ -182,7 +182,7 @@ the hud variables.
void DLLEXPORT HUD_Init()
{
// RecClHudInit();
// RecClHudInit();
InitInput();
gHUD.Init();
Scheme_Init();
@ -198,11 +198,11 @@ redraw the HUD.
===========================
*/
int DLLEXPORT HUD_Redraw( float time, int intermission )
int DLLEXPORT HUD_Redraw(float time, int intermission)
{
// RecClHudRedraw(time, intermission);
// RecClHudRedraw(time, intermission);
gHUD.Redraw( time, 0 != intermission );
gHUD.Redraw(time, 0 != intermission);
return 1;
}
@ -221,13 +221,13 @@ returns 1 if anything has been changed, 0 otherwise.
==========================
*/
int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime )
int DLLEXPORT HUD_UpdateClientData(client_data_t* pcldata, float flTime)
{
// RecClHudUpdateClientData(pcldata, flTime);
// RecClHudUpdateClientData(pcldata, flTime);
IN_Commands();
return static_cast<int>(gHUD.UpdateClientData(pcldata, flTime ));
return static_cast<int>(gHUD.UpdateClientData(pcldata, flTime));
}
/*
@ -240,7 +240,7 @@ Called at start and end of demos to restore to "non"HUD state.
void DLLEXPORT HUD_Reset()
{
// RecClHudReset();
// RecClHudReset();
gHUD.VidInit();
}
@ -253,9 +253,9 @@ Called by engine every frame that client .dll is loaded
==========================
*/
void DLLEXPORT HUD_Frame( double time )
void DLLEXPORT HUD_Frame(double time)
{
// RecClHudFrame(time);
// RecClHudFrame(time);
GetClientVoiceMgr()->Frame(time);
}
@ -271,7 +271,7 @@ Called when a player starts or stops talking.
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking)
{
//// RecClVoiceStatus(entindex, bTalking);
//// RecClVoiceStatus(entindex, bTalking);
GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, 0 != bTalking);
}
@ -284,16 +284,16 @@ Called when a director event message was received
==========================
*/
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )
void DLLEXPORT HUD_DirectorMessage(int iSize, void* pbuf)
{
// RecClDirectorMessage(iSize, pbuf);
// RecClDirectorMessage(iSize, pbuf);
gHUD.m_Spectator.DirectorMessage( iSize, pbuf );
gHUD.m_Spectator.DirectorMessage(iSize, pbuf);
}
void CL_UnloadParticleMan()
{
Sys_UnloadModule( g_hParticleManModule );
Sys_UnloadModule(g_hParticleManModule);
g_pParticleMan = NULL;
g_hParticleManModule = NULL;
@ -303,82 +303,82 @@ void CL_LoadParticleMan()
{
char szPDir[512];
if ( gEngfuncs.COM_ExpandFilename( PARTICLEMAN_DLLNAME, szPDir, sizeof( szPDir ) ) == 0 )
if (gEngfuncs.COM_ExpandFilename(PARTICLEMAN_DLLNAME, szPDir, sizeof(szPDir)) == 0)
{
g_pParticleMan = NULL;
g_hParticleManModule = NULL;
return;
}
g_hParticleManModule = Sys_LoadModule( szPDir );
CreateInterfaceFn particleManFactory = Sys_GetFactory( g_hParticleManModule );
g_hParticleManModule = Sys_LoadModule(szPDir);
CreateInterfaceFn particleManFactory = Sys_GetFactory(g_hParticleManModule);
if ( particleManFactory == NULL )
if (particleManFactory == NULL)
{
g_pParticleMan = NULL;
g_hParticleManModule = NULL;
return;
}
g_pParticleMan = (IParticleMan *)particleManFactory( PARTICLEMAN_INTERFACE, NULL);
g_pParticleMan = (IParticleMan*)particleManFactory(PARTICLEMAN_INTERFACE, NULL);
if ( g_pParticleMan )
if (g_pParticleMan)
{
g_pParticleMan->SetUp( &gEngfuncs );
g_pParticleMan->SetUp(&gEngfuncs);
// Add custom particle classes here BEFORE calling anything else or you will die.
g_pParticleMan->AddCustomParticleClassSize ( sizeof ( CBaseParticle ) );
// Add custom particle classes here BEFORE calling anything else or you will die.
g_pParticleMan->AddCustomParticleClassSize(sizeof(CBaseParticle));
}
}
extern "C" void DLLEXPORT F(void *pv)
extern "C" void DLLEXPORT F(void* pv)
{
cldll_func_t *pcldll_func = (cldll_func_t *)pv;
cldll_func_t* pcldll_func = (cldll_func_t*)pv;
cldll_func_t cldll_func =
{
Initialize,
HUD_Init,
HUD_VidInit,
HUD_Redraw,
HUD_UpdateClientData,
HUD_Reset,
HUD_PlayerMove,
HUD_PlayerMoveInit,
HUD_PlayerMoveTexture,
IN_ActivateMouse,
IN_DeactivateMouse,
IN_MouseEvent,
IN_ClearStates,
IN_Accumulate,
CL_CreateMove,
CL_IsThirdPerson,
CL_CameraOffset,
KB_Find,
CAM_Think,
V_CalcRefdef,
HUD_AddEntity,
HUD_CreateEntities,
HUD_DrawNormalTriangles,
HUD_DrawTransparentTriangles,
HUD_StudioEvent,
HUD_PostRunCmd,
HUD_Shutdown,
HUD_TxferLocalOverrides,
HUD_ProcessPlayerState,
HUD_TxferPredictionData,
Demo_ReadBuffer,
HUD_ConnectionlessPacket,
HUD_GetHullBounds,
HUD_Frame,
HUD_Key_Event,
HUD_TempEntUpdate,
HUD_GetUserEntity,
HUD_VoiceStatus,
HUD_DirectorMessage,
HUD_GetStudioModelInterface,
HUD_ChatInputPosition,
};
cldll_func_t cldll_func =
{
Initialize,
HUD_Init,
HUD_VidInit,
HUD_Redraw,
HUD_UpdateClientData,
HUD_Reset,
HUD_PlayerMove,
HUD_PlayerMoveInit,
HUD_PlayerMoveTexture,
IN_ActivateMouse,
IN_DeactivateMouse,
IN_MouseEvent,
IN_ClearStates,
IN_Accumulate,
CL_CreateMove,
CL_IsThirdPerson,
CL_CameraOffset,
KB_Find,
CAM_Think,
V_CalcRefdef,
HUD_AddEntity,
HUD_CreateEntities,
HUD_DrawNormalTriangles,
HUD_DrawTransparentTriangles,
HUD_StudioEvent,
HUD_PostRunCmd,
HUD_Shutdown,
HUD_TxferLocalOverrides,
HUD_ProcessPlayerState,
HUD_TxferPredictionData,
Demo_ReadBuffer,
HUD_ConnectionlessPacket,
HUD_GetHullBounds,
HUD_Frame,
HUD_Key_Event,
HUD_TempEntUpdate,
HUD_GetUserEntity,
HUD_VoiceStatus,
HUD_DirectorMessage,
HUD_GetStudioModelInterface,
HUD_ChatInputPosition,
};
*pcldll_func = cldll_func;
}
@ -392,7 +392,7 @@ class CClientExports : public IGameClientExports
{
public:
// returns the name of the server the user is connected to, if any
const char *GetServerHostName() override
const char* GetServerHostName() override
{
/*if (gViewPortInterface)
{

View file

@ -30,7 +30,7 @@
#include "Platform.h"
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
typedef int (*pfnUserMsgHook)(const char* pszName, int iSize, void* pbuf);
#include "mathlib.h"

View file

@ -23,23 +23,25 @@
#include "Platform.h"
// Macros to hook function calls into the HUD object
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x);
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
{ \
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \
}
#define DECLARE_MESSAGE(y, x) \
int __MsgFunc_##x(const char* pszName, int iSize, void* pbuf) \
{ \
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf); \
}
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x() \
{ \
gHUD.y.UserCmd_##x( ); \
}
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand(x, __CmdFunc_##y);
#define DECLARE_COMMAND(y, x) \
void __CmdFunc_##x() \
{ \
gHUD.y.UserCmd_##x(); \
}
inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); }
inline const char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); }
inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); }
inline float CVAR_GET_FLOAT(const char* x) { return gEngfuncs.pfnGetCvarFloat((char*)x); }
inline const char* CVAR_GET_STRING(const char* x) { return gEngfuncs.pfnGetCvarString((char*)x); }
inline struct cvar_s* CVAR_CREATE(const char* cv, const char* val, const int flags) { return gEngfuncs.pfnRegisterVariable((char*)cv, (char*)val, flags); }
#define SPR_Load (*gEngfuncs.pfnSPR_Load)
#define SPR_Set (*gEngfuncs.pfnSPR_Set)
@ -69,11 +71,11 @@ inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int fl
#define BASE_XRES 640.f
// use this to project world coordinates to screen coordinates
#define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f )
#define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f )
#define XPROJECT(x) ((1.0f + (x)) * ScreenWidth * 0.5f)
#define YPROJECT(y) ((1.0f - (y)) * ScreenHeight * 0.5f)
#define XRES(x) (x * ((float)ScreenWidth / 640))
#define YRES(y) (y * ((float)ScreenHeight / 480))
#define XRES(x) (x * ((float)ScreenWidth / 640))
#define YRES(y) (y * ((float)ScreenHeight / 480))
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
#define ServerCmd (*gEngfuncs.pfnServerCmd)
@ -83,98 +85,98 @@ inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int fl
// Gets the height & width of a sprite, at the specified frame
inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); }
inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); }
inline int SPR_Height(HSPRITE x, int f) { return gEngfuncs.pfnSPR_Height(x, f); }
inline int SPR_Width(HSPRITE x, int f) { return gEngfuncs.pfnSPR_Width(x, f); }
inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); }
inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
{
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
}
inline int DrawConsoleString( int x, int y, const char *string )
inline client_textmessage_t* TextMessageGet(const char* pName) { return gEngfuncs.pfnTextMessageGet(pName); }
inline int TextMessageDrawChar(int x, int y, int number, int r, int g, int b)
{
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
return gEngfuncs.pfnDrawCharacter(x, y, number, r, g, b);
}
inline void GetConsoleStringSize( const char *string, int *width, int *height )
inline int DrawConsoleString(int x, int y, const char* string)
{
gEngfuncs.pfnDrawConsoleStringLen( string, width, height );
return gEngfuncs.pfnDrawConsoleString(x, y, (char*)string);
}
inline int ConsoleStringLen( const char *string )
inline void GetConsoleStringSize(const char* string, int* width, int* height)
{
gEngfuncs.pfnDrawConsoleStringLen(string, width, height);
}
inline int ConsoleStringLen(const char* string)
{
int _width, _height;
GetConsoleStringSize( string, &_width, &_height );
GetConsoleStringSize(string, &_width, &_height);
return _width;
}
inline void ConsolePrint( const char *string )
inline void ConsolePrint(const char* string)
{
gEngfuncs.pfnConsolePrint( string );
gEngfuncs.pfnConsolePrint(string);
}
inline void CenterPrint( const char *string )
inline void CenterPrint(const char* string)
{
gEngfuncs.pfnCenterPrint( string );
gEngfuncs.pfnCenterPrint(string);
}
inline char *safe_strcpy( char *dst, const char *src, int len_dst)
inline char* safe_strcpy(char* dst, const char* src, int len_dst)
{
if( len_dst <= 0 )
if (len_dst <= 0)
{
return NULL; // this is bad
}
strncpy(dst,src,len_dst);
dst[ len_dst - 1 ] = '\0';
strncpy(dst, src, len_dst);
dst[len_dst - 1] = '\0';
return dst;
}
inline int safe_sprintf( char *dst, int len_dst, const char *format, ...)
inline int safe_sprintf(char* dst, int len_dst, const char* format, ...)
{
if( len_dst <= 0 )
if (len_dst <= 0)
{
return -1; // this is bad
}
va_list v;
va_start(v, format);
va_start(v, format);
vsnprintf(dst,len_dst,format,v);
vsnprintf(dst, len_dst, format, v);
va_end(v);
dst[ len_dst - 1 ] = '\0';
dst[len_dst - 1] = '\0';
return 0;
}
// sound functions
inline void PlaySound( const char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
inline void PlaySound(const char* szSound, float vol) { gEngfuncs.pfnPlaySoundByName(szSound, vol); }
inline void PlaySound(int iSound, float vol) { gEngfuncs.pfnPlaySoundByIndex(iSound, vol); }
void ScaleColors( int &r, int &g, int &b, int a );
void ScaleColors(int& r, int& g, int& b, int a);
float Length(const float *v);
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc);
void VectorScale (const float *in, float scale, float *out);
float VectorNormalize (float *v);
void VectorInverse ( float *v );
float Length(const float* v);
void VectorMA(const float* veca, float scale, const float* vecb, float* vecc);
void VectorScale(const float* in, float scale, float* out);
float VectorNormalize(float* v);
void VectorInverse(float* v);
// disable 'possible loss of data converting float to int' warning message
#pragma warning( disable: 4244 )
#pragma warning(disable : 4244)
// disable 'truncation from 'const double' to 'float' warning message
#pragma warning( disable: 4305 )
#pragma warning(disable : 4305)
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\
{\
r = (ulRGB & 0xFF0000) >>16;\
g = (ulRGB & 0xFF00) >> 8;\
b = ulRGB & 0xFF;\
inline void UnpackRGB(int& r, int& g, int& b, unsigned long ulRGB)
{
r = (ulRGB & 0xFF0000) >> 16;
g = (ulRGB & 0xFF00) >> 8;
b = ulRGB & 0xFF;
}
HSPRITE LoadSprite(const char *pszName);
HSPRITE LoadSprite(const char* pszName);

View file

@ -32,7 +32,7 @@ bool g_runfuncs = false;
// During our weapon prediction processing, we'll need to reference some data that is part of
// the final state passed into the postthink functionality. We'll set this pointer and then
// reset it to NULL as appropriate
struct local_state_s *g_finalstate = NULL;
struct local_state_s* g_finalstate = NULL;
/*
====================
@ -41,14 +41,14 @@ COM_Log
Log debug messages to file ( appends )
====================
*/
void COM_Log( const char *pszFile, const char *fmt, ...)
void COM_Log(const char* pszFile, const char* fmt, ...)
{
va_list argptr;
char string[1024];
FILE *fp;
const char *pfilename;
if ( !pszFile )
va_list argptr;
char string[1024];
FILE* fp;
const char* pfilename;
if (!pszFile)
{
pfilename = "c:\\hllog.txt";
}
@ -57,11 +57,11 @@ void COM_Log( const char *pszFile, const char *fmt, ...)
pfilename = pszFile;
}
va_start (argptr,fmt);
vsprintf (string, fmt,argptr);
va_end (argptr);
va_start(argptr, fmt);
vsprintf(string, fmt, argptr);
va_end(argptr);
fp = fopen( pfilename, "a+t");
fp = fopen(pfilename, "a+t");
if (fp)
{
fprintf(fp, "%s", string);
@ -80,16 +80,16 @@ HUD_SendWeaponAnim
Change weapon model animation
=====================
*/
void HUD_SendWeaponAnim( int iAnim, int body, bool force )
void HUD_SendWeaponAnim(int iAnim, int body, bool force)
{
// Don't actually change it.
if ( !g_runfuncs && !force )
if (!g_runfuncs && !force)
return;
g_currentanim = iAnim;
// Tell animation system new info
gEngfuncs.pfnWeaponAnim( iAnim, body );
gEngfuncs.pfnWeaponAnim(iAnim, body);
}
/*
@ -111,12 +111,12 @@ HUD_PlaySound
Play a sound, if we are seeing this command for the first time
=====================
*/
void HUD_PlaySound( const char *sound, float volume )
void HUD_PlaySound(const char* sound, float volume)
{
if ( !g_runfuncs || !g_finalstate )
if (!g_runfuncs || !g_finalstate)
return;
gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin );
gEngfuncs.pfnPlaySoundByNameAtLocation(sound, volume, (float*)&g_finalstate->playerstate.origin);
}
/*
@ -126,19 +126,19 @@ HUD_PlaybackEvent
Directly queue up an event on the client
=====================
*/
void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay,
const float *origin, const float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 )
void HUD_PlaybackEvent(int flags, const edict_t* pInvoker, unsigned short eventindex, float delay,
const float* origin, const float* angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2)
{
Vector org;
Vector ang;
if ( !g_runfuncs || !g_finalstate )
return;
if (!g_runfuncs || !g_finalstate)
return;
// Weapon prediction events are assumed to occur at the player's origin
org = g_finalstate->playerstate.origin;
ang = v_client_aimangles;
gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, org, ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 );
org = g_finalstate->playerstate.origin;
ang = v_client_aimangles;
gEngfuncs.pfnPlaybackEvent(flags, pInvoker, eventindex, delay, org, ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2);
}
/*
@ -147,7 +147,7 @@ HUD_SetMaxSpeed
=====================
*/
void HUD_SetMaxSpeed( const edict_t *ed, float speed )
void HUD_SetMaxSpeed(const edict_t* ed, float speed)
{
}
@ -165,39 +165,38 @@ float UTIL_WeaponTimeBase()
return 0.0;
}
static unsigned int glSeed = 0;
static unsigned int glSeed = 0;
unsigned int seed_table[ 256 ] =
unsigned int seed_table[256] =
{
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103,
27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315,
26766, 907, 24102, 12370, 9674, 2972, 10472, 16492, 22683, 11529, 27968, 30406, 13213, 2319, 23620, 16823,
10013, 23772, 21567, 1251, 19579, 20313, 18241, 30130, 8402, 20807, 27354, 7169, 21211, 17293, 5410, 19223,
10255, 22480, 27388, 9946, 15628, 24389, 17308, 2370, 9530, 31683, 25927, 23567, 11694, 26397, 32602, 15031,
18255, 17582, 1422, 28835, 23607, 12597, 20602, 10138, 5212, 1252, 10074, 23166, 19823, 31667, 5902, 24630,
18948, 14330, 14950, 8939, 23540, 21311, 22428, 22391, 3583, 29004, 30498, 18714, 4278, 2437, 22430, 3439,
28313, 23161, 25396, 13471, 19324, 15287, 2563, 18901, 13103, 16867, 9714, 14322, 15197, 26889, 19372, 26241,
31925, 14640, 11497, 8941, 10056, 6451, 28656, 10737, 13874, 17356, 8281, 25937, 1661, 4850, 7448, 12744,
21826, 5477, 10167, 16705, 26897, 8839, 30947, 27978, 27283, 24685, 32298, 3525, 12398, 28726, 9475, 10208,
617, 13467, 22287, 2376, 6097, 26312, 2974, 9114, 21787, 28010, 4725, 15387, 3274, 10762, 31695, 17320,
18324, 12441, 16801, 27376, 22464, 7500, 5666, 18144, 15314, 31914, 31627, 6495, 5226, 31203, 2331, 4668,
12650, 18275, 351, 7268, 31319, 30119, 7600, 2905, 13826, 11343, 13053, 15583, 30055, 31093, 5067, 761,
9685, 11070, 21369, 27155, 3663, 26542, 20169, 12161, 15411, 30401, 7580, 31784, 8985, 29367, 20989, 14203,
29694, 21167, 10337, 1706, 28578, 887, 3373, 19477, 14382, 675, 7033, 15111, 26138, 12252, 30996, 21409,
25678, 18555, 13256, 23316, 22407, 16727, 991, 9236, 5373, 29402, 6117, 15241, 27715, 19291, 19888, 19847};
unsigned int U_Random()
{
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103,
27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315,
26766, 907, 24102, 12370, 9674, 2972, 10472, 16492, 22683, 11529, 27968, 30406, 13213, 2319, 23620, 16823,
10013, 23772, 21567, 1251, 19579, 20313, 18241, 30130, 8402, 20807, 27354, 7169, 21211, 17293, 5410, 19223,
10255, 22480, 27388, 9946, 15628, 24389, 17308, 2370, 9530, 31683, 25927, 23567, 11694, 26397, 32602, 15031,
18255, 17582, 1422, 28835, 23607, 12597, 20602, 10138, 5212, 1252, 10074, 23166, 19823, 31667, 5902, 24630,
18948, 14330, 14950, 8939, 23540, 21311, 22428, 22391, 3583, 29004, 30498, 18714, 4278, 2437, 22430, 3439,
28313, 23161, 25396, 13471, 19324, 15287, 2563, 18901, 13103, 16867, 9714, 14322, 15197, 26889, 19372, 26241,
31925, 14640, 11497, 8941, 10056, 6451, 28656, 10737, 13874, 17356, 8281, 25937, 1661, 4850, 7448, 12744,
21826, 5477, 10167, 16705, 26897, 8839, 30947, 27978, 27283, 24685, 32298, 3525, 12398, 28726, 9475, 10208,
617, 13467, 22287, 2376, 6097, 26312, 2974, 9114, 21787, 28010, 4725, 15387, 3274, 10762, 31695, 17320,
18324, 12441, 16801, 27376, 22464, 7500, 5666, 18144, 15314, 31914, 31627, 6495, 5226, 31203, 2331, 4668,
12650, 18275, 351, 7268, 31319, 30119, 7600, 2905, 13826, 11343, 13053, 15583, 30055, 31093, 5067, 761,
9685, 11070, 21369, 27155, 3663, 26542, 20169, 12161, 15411, 30401, 7580, 31784, 8985, 29367, 20989, 14203,
29694, 21167, 10337, 1706, 28578, 887, 3373, 19477, 14382, 675, 7033, 15111, 26138, 12252, 30996, 21409,
25678, 18555, 13256, 23316, 22407, 16727, 991, 9236, 5373, 29402, 6117, 15241, 27715, 19291, 19888, 19847
};
glSeed *= 69069;
glSeed += seed_table[glSeed & 0xff];
unsigned int U_Random()
{
glSeed *= 69069;
glSeed += seed_table[ glSeed & 0xff ];
return ( ++glSeed & 0x0fffffff );
}
return (++glSeed & 0x0fffffff);
}
void U_Srand( unsigned int seed )
void U_Srand(unsigned int seed)
{
glSeed = seed_table[ seed & 0xff ];
glSeed = seed_table[seed & 0xff];
}
/*
@ -205,14 +204,14 @@ void U_Srand( unsigned int seed )
UTIL_SharedRandomLong
=====================
*/
int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
int UTIL_SharedRandomLong(unsigned int seed, int low, int high)
{
unsigned int range;
U_Srand( (int)seed + low + high );
U_Srand((int)seed + low + high);
range = high - low + 1;
if ( 0 == (range - 1) )
if (0 == (range - 1))
{
return low;
}
@ -234,18 +233,18 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
UTIL_SharedRandomFloat
=====================
*/
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
float UTIL_SharedRandomFloat(unsigned int seed, float low, float high)
{
//
unsigned int range;
U_Srand( (int)seed + *(int *)&low + *(int *)&high );
U_Srand((int)seed + *(int*)&low + *(int*)&high);
U_Random();
U_Random();
range = high - low;
if ( 0 == range )
if (0 == range)
{
return low;
}
@ -258,7 +257,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
offset = (float)tensixrand / 65536.0;
return (low + offset * range );
return (low + offset * range);
}
}
@ -270,8 +269,8 @@ stub functions for such things as precaching. So we don't have to modify weapon
is compiled into both game and client .dlls.
======================
*/
int stub_PrecacheModel ( const char* s ) { return 0; }
int stub_PrecacheSound ( const char* s ) { return 0; }
unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; }
const char *stub_NameForFunction ( uint32 function ) { return "func"; }
void stub_SetModel ( edict_t *e, const char *m ) {}
int stub_PrecacheModel(const char* s) { return 0; }
int stub_PrecacheSound(const char* s) { return 0; }
unsigned short stub_PrecacheEvent(int type, const char* s) { return 0; }
const char* stub_NameForFunction(uint32 function) { return "func"; }
void stub_SetModel(edict_t* e, const char* m) {}

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -12,28 +12,28 @@
#include "Exports.h"
void COM_Log( const char *pszFile, const char *fmt, ...);
bool CL_IsDead();
void COM_Log(const char* pszFile, const char* fmt, ...);
bool CL_IsDead();
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
int UTIL_SharedRandomLong( unsigned int seed, int low, int high );
float UTIL_SharedRandomFloat(unsigned int seed, float low, float high);
int UTIL_SharedRandomLong(unsigned int seed, int low, int high);
int HUD_GetWeaponAnim();
void HUD_SendWeaponAnim( int iAnim, int body, bool force );
void HUD_PlaySound( const char *sound, float volume );
void HUD_PlaybackEvent( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, const float *origin, const float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
void HUD_SetMaxSpeed( const struct edict_s *ed, float speed );
int stub_PrecacheModel( const char* s );
int stub_PrecacheSound( const char* s );
unsigned short stub_PrecacheEvent( int type, const char *s );
const char *stub_NameForFunction ( uint32 function );
void stub_SetModel ( struct edict_s *e, const char *m );
int HUD_GetWeaponAnim();
void HUD_SendWeaponAnim(int iAnim, int body, bool force);
void HUD_PlaySound(const char* sound, float volume);
void HUD_PlaybackEvent(int flags, const struct edict_s* pInvoker, unsigned short eventindex, float delay, const float* origin, const float* angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
void HUD_SetMaxSpeed(const struct edict_s* ed, float speed);
int stub_PrecacheModel(const char* s);
int stub_PrecacheSound(const char* s);
unsigned short stub_PrecacheEvent(int type, const char* s);
const char* stub_NameForFunction(uint32 function);
void stub_SetModel(struct edict_s* e, const char* m);
extern cvar_t *cl_lw;
extern cvar_t* cl_lw;
extern bool g_runfuncs;
extern Vector v_angles;
extern Vector v_client_aimangles;
extern float g_lastFOV;
extern struct local_state_s *g_finalstate;
extern struct local_state_s* g_finalstate;

View file

@ -24,130 +24,141 @@
#include "vgui_TeamFortressViewport.h"
DECLARE_MESSAGE( m_DeathNotice, DeathMsg );
DECLARE_MESSAGE(m_DeathNotice, DeathMsg);
struct DeathNoticeItem {
char szKiller[MAX_PLAYER_NAME_LENGTH*2];
char szVictim[MAX_PLAYER_NAME_LENGTH*2];
int iId; // the index number of the associated sprite
struct DeathNoticeItem
{
char szKiller[MAX_PLAYER_NAME_LENGTH * 2];
char szVictim[MAX_PLAYER_NAME_LENGTH * 2];
int iId; // the index number of the associated sprite
bool iSuicide;
bool iTeamKill;
bool iNonPlayerKill;
float flDisplayTime;
float *KillerColor;
float *VictimColor;
float* KillerColor;
float* VictimColor;
};
#define MAX_DEATHNOTICES 4
#define MAX_DEATHNOTICES 4
static int DEATHNOTICE_DISPLAY_TIME = 6;
#define DEATHNOTICE_TOP 64
#define DEATHNOTICE_TOP 64
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
DeathNoticeItem rgDeathNoticeList[MAX_DEATHNOTICES + 1];
float g_ColorBlue[3] = { 0.6, 0.8, 1.0 };
float g_ColorRed[3] = { 1.0, 0.25, 0.25 };
float g_ColorGreen[3] = { 0.6, 1.0, 0.6 };
float g_ColorYellow[3] = { 1.0, 0.7, 0.0 };
float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
float g_ColorBlue[3] = {0.6, 0.8, 1.0};
float g_ColorRed[3] = {1.0, 0.25, 0.25};
float g_ColorGreen[3] = {0.6, 1.0, 0.6};
float g_ColorYellow[3] = {1.0, 0.7, 0.0};
float g_ColorGrey[3] = {0.8, 0.8, 0.8};
float *GetClientColor( int clientIndex )
float* GetClientColor(int clientIndex)
{
switch ( g_PlayerExtraInfo[clientIndex].teamnumber )
switch (g_PlayerExtraInfo[clientIndex].teamnumber)
{
case 1: return g_ColorBlue;
case 2: return g_ColorRed;
case 3: return g_ColorYellow;
case 4: return g_ColorGreen;
case 0: return g_ColorYellow;
case 1:
return g_ColorBlue;
case 2:
return g_ColorRed;
case 3:
return g_ColorYellow;
case 4:
return g_ColorGreen;
case 0:
return g_ColorYellow;
default : return g_ColorGrey;
default:
return g_ColorGrey;
}
return NULL;
}
bool CHudDeathNotice :: Init()
bool CHudDeathNotice ::Init()
{
gHUD.AddHudElem( this );
gHUD.AddHudElem(this);
HOOK_MESSAGE( DeathMsg );
HOOK_MESSAGE(DeathMsg);
CVAR_CREATE( "hud_deathnotice_time", "6", 0 );
CVAR_CREATE("hud_deathnotice_time", "6", 0);
return true;
}
void CHudDeathNotice :: InitHUDData()
void CHudDeathNotice ::InitHUDData()
{
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
memset(rgDeathNoticeList, 0, sizeof(rgDeathNoticeList));
}
bool CHudDeathNotice :: VidInit()
bool CHudDeathNotice ::VidInit()
{
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
m_HUD_d_skull = gHUD.GetSpriteIndex("d_skull");
return true;
}
bool CHudDeathNotice :: Draw( float flTime )
bool CHudDeathNotice ::Draw(float flTime)
{
int x, y, r, g, b;
for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
for (int i = 0; i < MAX_DEATHNOTICES; i++)
{
if ( rgDeathNoticeList[i].iId == 0 )
break; // we've gone through them all
if (rgDeathNoticeList[i].iId == 0)
break; // we've gone through them all
if ( rgDeathNoticeList[i].flDisplayTime < flTime )
if (rgDeathNoticeList[i].flDisplayTime < flTime)
{ // display time has expired
// remove the current item from the list
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) );
i--; // continue on the next item; stop the counter getting incremented
memmove(&rgDeathNoticeList[i], &rgDeathNoticeList[i + 1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i));
i--; // continue on the next item; stop the counter getting incremented
continue;
}
rgDeathNoticeList[i].flDisplayTime = V_min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
rgDeathNoticeList[i].flDisplayTime = V_min(rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME);
// Only draw if the viewport will let me
if ( gViewPort && gViewPort->AllowedToPrintText() )
if (gViewPort && gViewPort->AllowedToPrintText())
{
// Draw the death notice
y = DEATHNOTICE_TOP + 2 + (20 * i); //!!!
y = DEATHNOTICE_TOP + 2 + (20 * i); //!!!
int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId;
x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
if ( !rgDeathNoticeList[i].iSuicide )
if (!rgDeathNoticeList[i].iSuicide)
{
x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
x -= (5 + ConsoleStringLen(rgDeathNoticeList[i].szKiller));
// Draw killers name
if ( rgDeathNoticeList[i].KillerColor )
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
if (rgDeathNoticeList[i].KillerColor)
gEngfuncs.pfnDrawSetTextColor(rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2]);
x = 5 + DrawConsoleString(x, y, rgDeathNoticeList[i].szKiller);
}
r = 255; g = 80; b = 0;
if ( rgDeathNoticeList[i].iTeamKill )
r = 255;
g = 80;
b = 0;
if (rgDeathNoticeList[i].iTeamKill)
{
r = 10; g = 240; b = 10; // display it in sickly green
r = 10;
g = 240;
b = 10; // display it in sickly green
}
// Draw death weapon
SPR_Set( gHUD.GetSprite(id), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );
SPR_Set(gHUD.GetSprite(id), r, g, b);
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(id));
x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
// Draw victims name (if it was a player that was killed)
if (!rgDeathNoticeList[i].iNonPlayerKill)
{
if ( rgDeathNoticeList[i].VictimColor )
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
if (rgDeathNoticeList[i].VictimColor)
gEngfuncs.pfnDrawSetTextColor(rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2]);
x = DrawConsoleString(x, y, rgDeathNoticeList[i].szVictim);
}
}
}
@ -156,32 +167,32 @@ bool CHudDeathNotice :: Draw( float flTime )
}
// This message handler may be better off elsewhere
bool CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
bool CHudDeathNotice ::MsgFunc_DeathMsg(const char* pszName, int iSize, void* pbuf)
{
m_iFlags |= HUD_ACTIVE;
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int killer = READ_BYTE();
int victim = READ_BYTE();
char killedwith[32];
strcpy( killedwith, "d_" );
strncat( killedwith, READ_STRING(), 32 );
strcpy(killedwith, "d_");
strncat(killedwith, READ_STRING(), 32);
if (gViewPort)
gViewPort->DeathMsg( killer, victim );
gViewPort->DeathMsg(killer, victim);
gHUD.m_Spectator.DeathMessage(victim);
int i;
for ( i = 0; i < MAX_DEATHNOTICES; i++ )
for (i = 0; i < MAX_DEATHNOTICES; i++)
{
if ( rgDeathNoticeList[i].iId == 0 )
if (rgDeathNoticeList[i].iId == 0)
break;
}
if ( i == MAX_DEATHNOTICES )
if (i == MAX_DEATHNOTICES)
{ // move the rest of the list forward to make room for this item
memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
memmove(rgDeathNoticeList, rgDeathNoticeList + 1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES);
i = MAX_DEATHNOTICES - 1;
}
@ -189,116 +200,112 @@ bool CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *
gViewPort->GetAllPlayersInfo();
// Get the Killer's name
const char *killer_name = g_PlayerInfoList[ killer ].name;
if ( !killer_name )
const char* killer_name = g_PlayerInfoList[killer].name;
if (!killer_name)
{
killer_name = "";
rgDeathNoticeList[i].szKiller[0] = 0;
}
else
{
rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0;
rgDeathNoticeList[i].KillerColor = GetClientColor(killer);
strncpy(rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH);
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH - 1] = 0;
}
// Get the Victim's name
const char *victim_name = NULL;
const char* victim_name = NULL;
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
if ( ((char)victim) != -1 )
victim_name = g_PlayerInfoList[ victim ].name;
if ( !victim_name )
if (((char)victim) != -1)
victim_name = g_PlayerInfoList[victim].name;
if (!victim_name)
{
victim_name = "";
rgDeathNoticeList[i].szVictim[0] = 0;
}
else
{
rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0;
rgDeathNoticeList[i].VictimColor = GetClientColor(victim);
strncpy(rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH);
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH - 1] = 0;
}
// Is it a non-player object kill?
if ( ((char)victim) == -1 )
if (((char)victim) == -1)
{
rgDeathNoticeList[i].iNonPlayerKill = true;
// Store the object's name in the Victim slot (skip the d_ bit)
strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 );
strcpy(rgDeathNoticeList[i].szVictim, killedwith + 2);
}
else
{
if ( killer == victim || killer == 0 )
if (killer == victim || killer == 0)
rgDeathNoticeList[i].iSuicide = true;
if ( 0 == strcmp( killedwith, "d_teammate" ) )
if (0 == strcmp(killedwith, "d_teammate"))
rgDeathNoticeList[i].iTeamKill = true;
}
// Find the sprite in the list
int spr = gHUD.GetSpriteIndex( killedwith );
int spr = gHUD.GetSpriteIndex(killedwith);
rgDeathNoticeList[i].iId = spr;
DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" );
DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT("hud_deathnotice_time");
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME;
if (rgDeathNoticeList[i].iNonPlayerKill)
{
ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed a " );
ConsolePrint( rgDeathNoticeList[i].szVictim );
ConsolePrint( "\n" );
ConsolePrint(rgDeathNoticeList[i].szKiller);
ConsolePrint(" killed a ");
ConsolePrint(rgDeathNoticeList[i].szVictim);
ConsolePrint("\n");
}
else
{
// record the death notice in the console
if ( rgDeathNoticeList[i].iSuicide )
if (rgDeathNoticeList[i].iSuicide)
{
ConsolePrint( rgDeathNoticeList[i].szVictim );
ConsolePrint(rgDeathNoticeList[i].szVictim);
if ( 0 == strcmp( killedwith, "d_world" ) )
if (0 == strcmp(killedwith, "d_world"))
{
ConsolePrint( " died" );
ConsolePrint(" died");
}
else
{
ConsolePrint( " killed self" );
ConsolePrint(" killed self");
}
}
else if ( rgDeathNoticeList[i].iTeamKill )
else if (rgDeathNoticeList[i].iTeamKill)
{
ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed his teammate " );
ConsolePrint( rgDeathNoticeList[i].szVictim );
ConsolePrint(rgDeathNoticeList[i].szKiller);
ConsolePrint(" killed his teammate ");
ConsolePrint(rgDeathNoticeList[i].szVictim);
}
else
{
ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed " );
ConsolePrint( rgDeathNoticeList[i].szVictim );
ConsolePrint(rgDeathNoticeList[i].szKiller);
ConsolePrint(" killed ");
ConsolePrint(rgDeathNoticeList[i].szVictim);
}
if ( killedwith && '\0' != *killedwith && (*killedwith > 13) && 0 != strcmp(killedwith, "d_world") && !rgDeathNoticeList[i].iTeamKill)
if (killedwith && '\0' != *killedwith && (*killedwith > 13) && 0 != strcmp(killedwith, "d_world") && !rgDeathNoticeList[i].iTeamKill)
{
ConsolePrint( " with " );
ConsolePrint(" with ");
// replace the code names with the 'real' names
if ( 0 == strcmp( killedwith+2, "egon" ) )
strcpy( killedwith, "d_gluon gun" );
if ( 0 == strcmp( killedwith+2, "gauss" ) )
strcpy( killedwith, "d_tau cannon" );
if (0 == strcmp(killedwith + 2, "egon"))
strcpy(killedwith, "d_gluon gun");
if (0 == strcmp(killedwith + 2, "gauss"))
strcpy(killedwith, "d_tau cannon");
ConsolePrint( killedwith+2 ); // skip over the "d_" part
ConsolePrint(killedwith + 2); // skip over the "d_" part
}
ConsolePrint( "\n" );
ConsolePrint("\n");
}
return true;
}

View file

@ -34,17 +34,17 @@ Demo_WriteBuffer
Write some data to the demo stream
=====================
*/
void Demo_WriteBuffer( int type, int size, unsigned char *buffer )
void Demo_WriteBuffer(int type, int size, unsigned char* buffer)
{
int pos = 0;
unsigned char buf[ 32 * 1024 ];
*( int * )&buf[pos] = type;
pos+=sizeof( int );
unsigned char buf[32 * 1024];
*(int*)&buf[pos] = type;
pos += sizeof(int);
memcpy( &buf[pos], buffer, size );
memcpy(&buf[pos], buffer, size);
// Write full buffer out
gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf );
gEngfuncs.pDemoAPI->WriteBuffer(size + sizeof(int), buf);
}
/*
@ -54,46 +54,46 @@ Demo_ReadBuffer
Engine wants us to parse some data from the demo stream
=====================
*/
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
void DLLEXPORT Demo_ReadBuffer(int size, unsigned char* buffer)
{
// RecClReadDemoBuffer(size, buffer);
// RecClReadDemoBuffer(size, buffer);
int type;
int i = 0;
type = *( int * )buffer;
i += sizeof( int );
switch ( type )
type = *(int*)buffer;
i += sizeof(int);
switch (type)
{
case TYPE_SNIPERDOT:
g_demosniper = *(int * )&buffer[ i ];
i += sizeof( int );
if ( 0 != g_demosniper )
{
g_demosniperdamage = *( int * )&buffer[ i ];
i += sizeof( int );
g_demosniper = *(int*)&buffer[i];
i += sizeof(int);
g_demosniperangles[ 0 ] = *(float *)&buffer[i];
i += sizeof( float );
g_demosniperangles[ 1 ] = *(float *)&buffer[i];
i += sizeof( float );
g_demosniperangles[ 2 ] = *(float *)&buffer[i];
i += sizeof( float );
g_demosniperorg[ 0 ] = *(float *)&buffer[i];
i += sizeof( float );
g_demosniperorg[ 1 ] = *(float *)&buffer[i];
i += sizeof( float );
g_demosniperorg[ 2 ] = *(float *)&buffer[i];
i += sizeof( float );
if (0 != g_demosniper)
{
g_demosniperdamage = *(int*)&buffer[i];
i += sizeof(int);
g_demosniperangles[0] = *(float*)&buffer[i];
i += sizeof(float);
g_demosniperangles[1] = *(float*)&buffer[i];
i += sizeof(float);
g_demosniperangles[2] = *(float*)&buffer[i];
i += sizeof(float);
g_demosniperorg[0] = *(float*)&buffer[i];
i += sizeof(float);
g_demosniperorg[1] = *(float*)&buffer[i];
i += sizeof(float);
g_demosniperorg[2] = *(float*)&buffer[i];
i += sizeof(float);
}
break;
case TYPE_ZOOM:
g_demozoom = *(float * )&buffer[ i ];
i += sizeof( float );
g_demozoom = *(float*)&buffer[i];
i += sizeof(float);
break;
default:
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
gEngfuncs.Con_DPrintf("Unknown demo buffer type, skipping.\n");
break;
}
}

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -14,7 +14,7 @@ enum
TYPE_ZOOM
};
void Demo_WriteBuffer( int type, int size, unsigned char *buffer );
void Demo_WriteBuffer(int type, int size, unsigned char* buffer);
extern int g_demosniper;
extern int g_demosniperdamage;

View file

@ -10,12 +10,12 @@
#include "r_efx.h"
#include "event_api.h"
#include "pm_defs.h"
#include "pmtrace.h"
#include "pmtrace.h"
#include "pm_shared.h"
#include "Exports.h"
#include "particleman.h"
extern IParticleMan *g_pParticleMan;
extern IParticleMan* g_pParticleMan;
void Game_AddObjects();
@ -29,11 +29,11 @@ HUD_AddEntity
Return 0 to filter entity from visible list for rendering
========================
*/
int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname )
int DLLEXPORT HUD_AddEntity(int type, struct cl_entity_s* ent, const char* modelname)
{
// RecClAddEntity(type, ent, modelname);
// RecClAddEntity(type, ent, modelname);
switch ( type )
switch (type)
{
case ET_NORMAL:
break;
@ -46,17 +46,16 @@ int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *mode
}
// each frame every entity passes this function, so the overview hooks it to filter the overview entities
// in spectator mode:
// each frame every entity passes this function, so the overview hooks
// each frame every entity passes this function, so the overview hooks
// it to filter the overview entities
if ( 0 != g_iUser1 )
if (0 != g_iUser1)
{
gHUD.m_Spectator.AddOverviewEntity( type, ent, modelname );
if ( ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) &&
ent->index == g_iUser2 )
return 0; // don't draw the player we are following in eye
gHUD.m_Spectator.AddOverviewEntity(type, ent, modelname);
if ((g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE) &&
ent->index == g_iUser2)
return 0; // don't draw the player we are following in eye
}
return 1;
@ -71,11 +70,11 @@ playerstate update in entity_state_t. In order for these overrides to eventuall
structure, we need to copy them into the state structure at this point.
=========================
*/
void DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client )
void DLLEXPORT HUD_TxferLocalOverrides(struct entity_state_s* state, const struct clientdata_s* client)
{
// RecClTxferLocalOverrides(state, client);
// RecClTxferLocalOverrides(state, client);
VectorCopy( client->origin, state->origin );
VectorCopy(client->origin, state->origin);
// Spectator
state->iuser1 = client->iuser1;
@ -96,58 +95,58 @@ We have received entity_state_t for this player over the network. We need to co
playerstate structure
=========================
*/
void DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src )
void DLLEXPORT HUD_ProcessPlayerState(struct entity_state_s* dst, const struct entity_state_s* src)
{
// RecClProcessPlayerState(dst, src);
// RecClProcessPlayerState(dst, src);
// Copy in network data
VectorCopy( src->origin, dst->origin );
VectorCopy( src->angles, dst->angles );
VectorCopy(src->origin, dst->origin);
VectorCopy(src->angles, dst->angles);
VectorCopy( src->velocity, dst->velocity );
VectorCopy(src->velocity, dst->velocity);
dst->frame = src->frame;
dst->modelindex = src->modelindex;
dst->skin = src->skin;
dst->effects = src->effects;
dst->weaponmodel = src->weaponmodel;
dst->movetype = src->movetype;
dst->sequence = src->sequence;
dst->animtime = src->animtime;
dst->solid = src->solid;
dst->rendermode = src->rendermode;
dst->renderamt = src->renderamt;
dst->rendercolor.r = src->rendercolor.r;
dst->rendercolor.g = src->rendercolor.g;
dst->rendercolor.b = src->rendercolor.b;
dst->renderfx = src->renderfx;
dst->frame = src->frame;
dst->modelindex = src->modelindex;
dst->skin = src->skin;
dst->effects = src->effects;
dst->weaponmodel = src->weaponmodel;
dst->movetype = src->movetype;
dst->sequence = src->sequence;
dst->animtime = src->animtime;
dst->framerate = src->framerate;
dst->body = src->body;
dst->solid = src->solid;
memcpy( &dst->controller[0], &src->controller[0], 4 * sizeof( byte ) );
memcpy( &dst->blending[0], &src->blending[0], 2 * sizeof( byte ) );
dst->rendermode = src->rendermode;
dst->renderamt = src->renderamt;
dst->rendercolor.r = src->rendercolor.r;
dst->rendercolor.g = src->rendercolor.g;
dst->rendercolor.b = src->rendercolor.b;
dst->renderfx = src->renderfx;
VectorCopy( src->basevelocity, dst->basevelocity );
dst->framerate = src->framerate;
dst->body = src->body;
dst->friction = src->friction;
dst->gravity = src->gravity;
dst->gaitsequence = src->gaitsequence;
dst->spectator = src->spectator;
dst->usehull = src->usehull;
dst->playerclass = src->playerclass;
dst->team = src->team;
dst->colormap = src->colormap;
memcpy(&dst->controller[0], &src->controller[0], 4 * sizeof(byte));
memcpy(&dst->blending[0], &src->blending[0], 2 * sizeof(byte));
#if defined( _TFC )
dst->fuser1 = src->fuser1;
VectorCopy(src->basevelocity, dst->basevelocity);
dst->friction = src->friction;
dst->gravity = src->gravity;
dst->gaitsequence = src->gaitsequence;
dst->spectator = src->spectator;
dst->usehull = src->usehull;
dst->playerclass = src->playerclass;
dst->team = src->team;
dst->colormap = src->colormap;
#if defined(_TFC)
dst->fuser1 = src->fuser1;
#endif
// Save off some data so other areas of the Client DLL can get to it
cl_entity_t *player = gEngfuncs.GetLocalPlayer(); // Get the local player's index
if ( dst->number == player->index )
cl_entity_t* player = gEngfuncs.GetLocalPlayer(); // Get the local player's index
if (dst->number == player->index)
{
g_iPlayerClass = dst->playerclass;
g_iTeamNumber = dst->team;
@ -168,44 +167,44 @@ Because we can predict an arbitrary number of frames before the server responds
update is occupying.
=========================
*/
void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd )
void DLLEXPORT HUD_TxferPredictionData(struct entity_state_s* ps, const struct entity_state_s* pps, struct clientdata_s* pcd, const struct clientdata_s* ppcd, struct weapon_data_s* wd, const struct weapon_data_s* pwd)
{
// RecClTxferPredictionData(ps, pps, pcd, ppcd, wd, pwd);
// RecClTxferPredictionData(ps, pps, pcd, ppcd, wd, pwd);
ps->oldbuttons = pps->oldbuttons;
ps->flFallVelocity = pps->flFallVelocity;
ps->iStepLeft = pps->iStepLeft;
ps->playerclass = pps->playerclass;
ps->oldbuttons = pps->oldbuttons;
ps->flFallVelocity = pps->flFallVelocity;
ps->iStepLeft = pps->iStepLeft;
ps->playerclass = pps->playerclass;
pcd->viewmodel = ppcd->viewmodel;
pcd->m_iId = ppcd->m_iId;
pcd->ammo_shells = ppcd->ammo_shells;
pcd->ammo_nails = ppcd->ammo_nails;
pcd->ammo_cells = ppcd->ammo_cells;
pcd->ammo_rockets = ppcd->ammo_rockets;
pcd->m_flNextAttack = ppcd->m_flNextAttack;
pcd->fov = ppcd->fov;
pcd->weaponanim = ppcd->weaponanim;
pcd->tfstate = ppcd->tfstate;
pcd->maxspeed = ppcd->maxspeed;
pcd->viewmodel = ppcd->viewmodel;
pcd->m_iId = ppcd->m_iId;
pcd->ammo_shells = ppcd->ammo_shells;
pcd->ammo_nails = ppcd->ammo_nails;
pcd->ammo_cells = ppcd->ammo_cells;
pcd->ammo_rockets = ppcd->ammo_rockets;
pcd->m_flNextAttack = ppcd->m_flNextAttack;
pcd->fov = ppcd->fov;
pcd->weaponanim = ppcd->weaponanim;
pcd->tfstate = ppcd->tfstate;
pcd->maxspeed = ppcd->maxspeed;
pcd->deadflag = ppcd->deadflag;
pcd->deadflag = ppcd->deadflag;
// Spectating or not dead == get control over view angles.
g_iAlive = ( 0 != ppcd->iuser1 || ( pcd->deadflag == DEAD_NO ) );
g_iAlive = (0 != ppcd->iuser1 || (pcd->deadflag == DEAD_NO));
// Spectator
pcd->iuser1 = ppcd->iuser1;
pcd->iuser2 = ppcd->iuser2;
pcd->iuser1 = ppcd->iuser1;
pcd->iuser2 = ppcd->iuser2;
// Duck prevention
pcd->iuser3 = ppcd->iuser3;
if ( 0 != gEngfuncs.IsSpectateOnly() )
if (0 != gEngfuncs.IsSpectateOnly())
{
// in specator mode we tell the engine who we want to spectate and how
// iuser3 is not used for duck prevention (since the spectator can't duck at all)
pcd->iuser1 = g_iUser1; // observer mode
pcd->iuser1 = g_iUser1; // observer mode
pcd->iuser2 = g_iUser2; // first target
pcd->iuser3 = g_iUser3; // second target
}
@ -213,45 +212,45 @@ void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct
// Fire prevention
pcd->iuser4 = ppcd->iuser4;
pcd->fuser2 = ppcd->fuser2;
pcd->fuser3 = ppcd->fuser3;
pcd->fuser2 = ppcd->fuser2;
pcd->fuser3 = ppcd->fuser3;
VectorCopy( ppcd->vuser1, pcd->vuser1 );
VectorCopy( ppcd->vuser2, pcd->vuser2 );
VectorCopy( ppcd->vuser3, pcd->vuser3 );
VectorCopy( ppcd->vuser4, pcd->vuser4 );
VectorCopy(ppcd->vuser1, pcd->vuser1);
VectorCopy(ppcd->vuser2, pcd->vuser2);
VectorCopy(ppcd->vuser3, pcd->vuser3);
VectorCopy(ppcd->vuser4, pcd->vuser4);
memcpy( wd, pwd, 32 * sizeof( weapon_data_t ) );
memcpy(wd, pwd, 32 * sizeof(weapon_data_t));
}
#if defined( BEAM_TEST )
#if defined(BEAM_TEST)
// Note can't index beam[ 0 ] in Beam callback, so don't use that index
// Room for 1 beam ( 0 can't be used )
static cl_entity_t beams[ 2 ];
static cl_entity_t beams[2];
void BeamEndModel()
{
cl_entity_t *player, *model;
int modelindex;
struct model_s *mod;
struct model_s* mod;
// Load it up with some bogus data
player = gEngfuncs.GetLocalPlayer();
if ( !player )
if (!player)
return;
mod = gEngfuncs.CL_LoadModel( "models/sentry3.mdl", &modelindex );
if ( !mod )
mod = gEngfuncs.CL_LoadModel("models/sentry3.mdl", &modelindex);
if (!mod)
return;
// Slot 1
model = &beams[ 1 ];
model = &beams[1];
*model = *player;
model->player = 0;
model->model = mod;
model->curstate.modelindex = modelindex;
// Move it out a bit
model->origin[0] = player->origin[0] - 100;
model->origin[1] = player->origin[1];
@ -261,37 +260,37 @@ void BeamEndModel()
model->attachment[2] = model->origin;
model->attachment[3] = model->origin;
gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, model );
gEngfuncs.CL_CreateVisibleEntity(ET_NORMAL, model);
}
void Beams()
{
static float lasttime;
float curtime;
struct model_s *mod;
struct model_s* mod;
int index;
BeamEndModel();
curtime = gEngfuncs.GetClientTime();
float end[ 3 ];
if ( ( curtime - lasttime ) < 10.0 )
curtime = gEngfuncs.GetClientTime();
float end[3];
if ((curtime - lasttime) < 10.0)
return;
mod = gEngfuncs.CL_LoadModel( "sprites/laserbeam.spr", &index );
if ( !mod )
mod = gEngfuncs.CL_LoadModel("sprites/laserbeam.spr", &index);
if (!mod)
return;
lasttime = curtime;
end [ 0 ] = v_origin.x + 100;
end [ 1 ] = v_origin.y + 100;
end [ 2 ] = v_origin.z;
end[0] = v_origin.x + 100;
end[1] = v_origin.y + 100;
end[2] = v_origin.z;
BEAM *p1;
p1 = gEngfuncs.pEfxAPI->R_BeamEntPoint( -1, end, index,
10.0, 2.0, 0.3, 1.0, 5.0, 0.0, 1.0, 1.0, 1.0, 1.0 );
BEAM* p1;
p1 = gEngfuncs.pEfxAPI->R_BeamEntPoint(-1, end, index,
10.0, 2.0, 0.3, 1.0, 5.0, 0.0, 1.0, 1.0, 1.0, 1.0);
}
#endif
@ -304,9 +303,9 @@ Gives us a chance to add additional entities to the render this frame
*/
void DLLEXPORT HUD_CreateEntities()
{
// RecClCreateEntities();
// RecClCreateEntities();
#if defined( BEAM_TEST )
#if defined(BEAM_TEST)
Beams();
#endif
@ -316,9 +315,9 @@ void DLLEXPORT HUD_CreateEntities()
GetClientVoiceMgr()->CreateEntities();
}
#if defined( _TFC )
#if defined(_TFC)
extern int g_bACSpinning[33];
#endif
#endif
/*
=========================
@ -328,43 +327,43 @@ The entity's studio model description indicated an event was
fired during this frame, handle the event by it's tag ( e.g., muzzleflash, sound )
=========================
*/
void DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity )
void DLLEXPORT HUD_StudioEvent(const struct mstudioevent_s* event, const struct cl_entity_s* entity)
{
// RecClStudioEvent(event, entity);
// RecClStudioEvent(event, entity);
bool iMuzzleFlash = true;
#if defined( _TFC )
#if defined(_TFC)
if ( g_bACSpinning[ entity->index - 1 ] )
if (g_bACSpinning[entity->index - 1])
iMuzzleFlash = false;
#endif
#endif
switch( event->event )
switch (event->event)
{
case 5001:
if ( iMuzzleFlash )
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[0], atoi( event->options) );
if (iMuzzleFlash)
gEngfuncs.pEfxAPI->R_MuzzleFlash((float*)&entity->attachment[0], atoi(event->options));
break;
case 5011:
if ( iMuzzleFlash )
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[1], atoi( event->options) );
if (iMuzzleFlash)
gEngfuncs.pEfxAPI->R_MuzzleFlash((float*)&entity->attachment[1], atoi(event->options));
break;
case 5021:
if ( iMuzzleFlash )
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[2], atoi( event->options) );
if (iMuzzleFlash)
gEngfuncs.pEfxAPI->R_MuzzleFlash((float*)&entity->attachment[2], atoi(event->options));
break;
case 5031:
if ( iMuzzleFlash )
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[3], atoi( event->options) );
if (iMuzzleFlash)
gEngfuncs.pEfxAPI->R_MuzzleFlash((float*)&entity->attachment[3], atoi(event->options));
break;
case 5002:
gEngfuncs.pEfxAPI->R_SparkEffect( (float *)&entity->attachment[0], atoi( event->options), -100, 100 );
gEngfuncs.pEfxAPI->R_SparkEffect((float*)&entity->attachment[0], atoi(event->options), -100, 100);
break;
// Client side sound
case 5004:
gEngfuncs.pfnPlaySoundByNameAtLocation( (char *)event->options, 1.0, (float *)&entity->attachment[0] );
case 5004:
gEngfuncs.pfnPlaySoundByNameAtLocation((char*)event->options, 1.0, (float*)&entity->attachment[0]);
break;
default:
break;
@ -378,58 +377,58 @@ CL_UpdateTEnts
Simulation and cleanup of temporary entities
=================
*/
void DLLEXPORT HUD_TempEntUpdate (
double frametime, // Simulation time
double client_time, // Absolute time on client
double cl_gravity, // True gravity on client
TEMPENTITY **ppTempEntFree, // List of freed temporary ents
TEMPENTITY **ppTempEntActive, // List
int ( *Callback_AddVisibleEntity )( cl_entity_t *pEntity ),
void ( *Callback_TempEntPlaySound )( TEMPENTITY *pTemp, float damp ) )
void DLLEXPORT HUD_TempEntUpdate(
double frametime, // Simulation time
double client_time, // Absolute time on client
double cl_gravity, // True gravity on client
TEMPENTITY** ppTempEntFree, // List of freed temporary ents
TEMPENTITY** ppTempEntActive, // List
int (*Callback_AddVisibleEntity)(cl_entity_t* pEntity),
void (*Callback_TempEntPlaySound)(TEMPENTITY* pTemp, float damp))
{
// RecClTempEntUpdate(frametime, client_time, cl_gravity, ppTempEntFree, ppTempEntActive, Callback_AddVisibleEntity, Callback_TempEntPlaySound);
// RecClTempEntUpdate(frametime, client_time, cl_gravity, ppTempEntFree, ppTempEntActive, Callback_AddVisibleEntity, Callback_TempEntPlaySound);
static int gTempEntFrame = 0;
int i;
TEMPENTITY *pTemp, *pnext, *pprev;
float freq, gravity, gravitySlow, life, fastFreq;
int i;
TEMPENTITY *pTemp, *pnext, *pprev;
float freq, gravity, gravitySlow, life, fastFreq;
Vector vAngles;
Vector vAngles;
gEngfuncs.GetViewAngles( (float*)vAngles );
gEngfuncs.GetViewAngles((float*)vAngles);
if ( g_pParticleMan )
g_pParticleMan->SetVariables( cl_gravity, vAngles );
if (g_pParticleMan)
g_pParticleMan->SetVariables(cl_gravity, vAngles);
// Nothing to simulate
if ( !*ppTempEntActive )
if (!*ppTempEntActive)
return;
// in order to have tents collide with players, we have to run the player prediction code so
// that the client has the player list. We run this code once when we detect any COLLIDEALL
// that the client has the player list. We run this code once when we detect any COLLIDEALL
// tent, then set this bool to true so the code doesn't get run again if there's more than
// one COLLIDEALL ent for this update. (often are).
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( 0, 1 );
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction(0, 1);
// Store off the old count
gEngfuncs.pEventAPI->EV_PushPMStates();
// Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( -1 );
gEngfuncs.pEventAPI->EV_SetSolidPlayers(-1);
// !!!BUGBUG -- This needs to be time based
gTempEntFrame = (gTempEntFrame+1) & 31;
gTempEntFrame = (gTempEntFrame + 1) & 31;
pTemp = *ppTempEntActive;
// !!! Don't simulate while paused.... This is sort of a hack, revisit.
if ( frametime <= 0 )
if (frametime <= 0)
{
while ( pTemp )
while (pTemp)
{
if ( (pTemp->flags & FTENT_NOMODEL ) == 0)
if ((pTemp->flags & FTENT_NOMODEL) == 0)
{
Callback_AddVisibleEntity( &pTemp->entity );
Callback_AddVisibleEntity(&pTemp->entity);
}
pTemp = pTemp->next;
}
@ -442,7 +441,7 @@ void DLLEXPORT HUD_TempEntUpdate (
gravity = -frametime * cl_gravity;
gravitySlow = gravity * 0.5;
while ( pTemp )
while (pTemp)
{
bool active;
@ -450,25 +449,24 @@ void DLLEXPORT HUD_TempEntUpdate (
life = pTemp->die - client_time;
pnext = pTemp->next;
if ( life < 0 )
if (life < 0)
{
if ( (pTemp->flags & FTENT_FADEOUT ) != 0)
if ((pTemp->flags & FTENT_FADEOUT) != 0)
{
if (pTemp->entity.curstate.rendermode == kRenderNormal)
pTemp->entity.curstate.rendermode = kRenderTransTexture;
pTemp->entity.curstate.renderamt = pTemp->entity.baseline.renderamt * ( 1 + life * pTemp->fadeSpeed );
if ( pTemp->entity.curstate.renderamt <= 0 )
pTemp->entity.curstate.renderamt = pTemp->entity.baseline.renderamt * (1 + life * pTemp->fadeSpeed);
if (pTemp->entity.curstate.renderamt <= 0)
active = false;
}
else
else
active = false;
}
if ( !active ) // Kill it
if (!active) // Kill it
{
pTemp->next = *ppTempEntFree;
*ppTempEntFree = pTemp;
if ( !pprev ) // Deleting at head of list
if (!pprev) // Deleting at head of list
*ppTempEntActive = pnext;
else
pprev->next = pnext;
@ -476,22 +474,22 @@ void DLLEXPORT HUD_TempEntUpdate (
else
{
pprev = pTemp;
VectorCopy( pTemp->entity.origin, pTemp->entity.prevstate.origin );
if ( (pTemp->flags & FTENT_SPARKSHOWER ) != 0)
VectorCopy(pTemp->entity.origin, pTemp->entity.prevstate.origin);
if ((pTemp->flags & FTENT_SPARKSHOWER) != 0)
{
// Adjust speed if it's time
// Scale is next think time
if ( client_time > pTemp->entity.baseline.scale )
if (client_time > pTemp->entity.baseline.scale)
{
// Show Sparks
gEngfuncs.pEfxAPI->R_SparkEffect( pTemp->entity.origin, 8, -200, 200 );
gEngfuncs.pEfxAPI->R_SparkEffect(pTemp->entity.origin, 8, -200, 200);
// Reduce life
pTemp->entity.baseline.framerate -= 0.1;
if ( pTemp->entity.baseline.framerate <= 0.0 )
if (pTemp->entity.baseline.framerate <= 0.0)
{
pTemp->die = client_time;
}
@ -505,48 +503,48 @@ void DLLEXPORT HUD_TempEntUpdate (
}
}
}
else if ( (pTemp->flags & FTENT_PLYRATTACHMENT ) != 0)
else if ((pTemp->flags & FTENT_PLYRATTACHMENT) != 0)
{
cl_entity_t *pClient;
cl_entity_t* pClient;
pClient = gEngfuncs.GetEntityByIndex( pTemp->clientIndex );
pClient = gEngfuncs.GetEntityByIndex(pTemp->clientIndex);
VectorAdd( pClient->origin, pTemp->tentOffset, pTemp->entity.origin );
VectorAdd(pClient->origin, pTemp->tentOffset, pTemp->entity.origin);
}
else if ( (pTemp->flags & FTENT_SINEWAVE ) != 0)
else if ((pTemp->flags & FTENT_SINEWAVE) != 0)
{
pTemp->x += pTemp->entity.baseline.origin[0] * frametime;
pTemp->y += pTemp->entity.baseline.origin[1] * frametime;
pTemp->entity.origin[0] = pTemp->x + sin( pTemp->entity.baseline.origin[2] + client_time * pTemp->entity.prevstate.frame ) * (10*pTemp->entity.curstate.framerate);
pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7 ) * (8*pTemp->entity.curstate.framerate);
pTemp->entity.origin[0] = pTemp->x + sin(pTemp->entity.baseline.origin[2] + client_time * pTemp->entity.prevstate.frame) * (10 * pTemp->entity.curstate.framerate);
pTemp->entity.origin[1] = pTemp->y + sin(pTemp->entity.baseline.origin[2] + fastFreq + 0.7) * (8 * pTemp->entity.curstate.framerate);
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime;
}
else if ( (pTemp->flags & FTENT_SPIRAL ) != 0)
else if ((pTemp->flags & FTENT_SPIRAL) != 0)
{
float s, c;
s = sin( pTemp->entity.baseline.origin[2] + fastFreq );
c = cos( pTemp->entity.baseline.origin[2] + fastFreq );
s = sin(pTemp->entity.baseline.origin[2] + fastFreq);
c = cos(pTemp->entity.baseline.origin[2] + fastFreq);
pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (int)pTemp );
pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)pTemp );
pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin(client_time * 20 + (int)pTemp);
pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin(client_time * 30 + (int)pTemp);
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime;
}
else
else
{
for ( i = 0; i < 3; i++ )
for (i = 0; i < 3; i++)
pTemp->entity.origin[i] += pTemp->entity.baseline.origin[i] * frametime;
}
if ( (pTemp->flags & FTENT_SPRANIMATE ) != 0)
if ((pTemp->flags & FTENT_SPRANIMATE) != 0)
{
pTemp->entity.curstate.frame += frametime * pTemp->entity.curstate.framerate;
if ( pTemp->entity.curstate.frame >= pTemp->frameMax )
if (pTemp->entity.curstate.frame >= pTemp->frameMax)
{
pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)(pTemp->entity.curstate.frame);
if ( (pTemp->flags & FTENT_SPRANIMATELOOP) == 0)
if ((pTemp->flags & FTENT_SPRANIMATELOOP) == 0)
{
// this animating sprite isn't set to loop, so destroy it.
pTemp->die = client_time;
@ -555,10 +553,10 @@ void DLLEXPORT HUD_TempEntUpdate (
}
}
}
else if ( (pTemp->flags & FTENT_SPRCYCLE ) != 0)
else if ((pTemp->flags & FTENT_SPRCYCLE) != 0)
{
pTemp->entity.curstate.frame += frametime * 10;
if ( pTemp->entity.curstate.frame >= pTemp->frameMax )
if (pTemp->entity.curstate.frame >= pTemp->frameMax)
{
pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)(pTemp->entity.curstate.frame);
}
@ -569,95 +567,95 @@ void DLLEXPORT HUD_TempEntUpdate (
pTemp->entity.curstate.framerate += 20.0 * (frametime / pTemp->entity.curstate.framerate);
#endif
if ( (pTemp->flags & FTENT_ROTATE ) != 0)
if ((pTemp->flags & FTENT_ROTATE) != 0)
{
pTemp->entity.angles[0] += pTemp->entity.baseline.angles[0] * frametime;
pTemp->entity.angles[1] += pTemp->entity.baseline.angles[1] * frametime;
pTemp->entity.angles[2] += pTemp->entity.baseline.angles[2] * frametime;
VectorCopy( pTemp->entity.angles, pTemp->entity.latched.prevangles );
VectorCopy(pTemp->entity.angles, pTemp->entity.latched.prevangles);
}
if ( (pTemp->flags & (FTENT_COLLIDEALL | FTENT_COLLIDEWORLD) ) != 0)
if ((pTemp->flags & (FTENT_COLLIDEALL | FTENT_COLLIDEWORLD)) != 0)
{
Vector traceNormal;
float traceFraction = 1;
Vector traceNormal;
float traceFraction = 1;
if ( (pTemp->flags & FTENT_COLLIDEALL ) != 0)
if ((pTemp->flags & FTENT_COLLIDEALL) != 0)
{
pmtrace_t pmtrace;
physent_t *pe;
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
physent_t* pe;
gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX, -1, &pmtrace );
gEngfuncs.pEventAPI->EV_SetTraceHull(2);
gEngfuncs.pEventAPI->EV_PlayerTrace(pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX, -1, &pmtrace);
if ( pmtrace.fraction != 1 )
if (pmtrace.fraction != 1)
{
pe = gEngfuncs.pEventAPI->EV_GetPhysent( pmtrace.ent );
pe = gEngfuncs.pEventAPI->EV_GetPhysent(pmtrace.ent);
if ( 0 == pmtrace.ent || ( pe->info != pTemp->clientIndex ) )
if (0 == pmtrace.ent || (pe->info != pTemp->clientIndex))
{
traceFraction = pmtrace.fraction;
VectorCopy( pmtrace.plane.normal, traceNormal );
VectorCopy(pmtrace.plane.normal, traceNormal);
if ( pTemp->hitcallback )
if (pTemp->hitcallback)
{
(*pTemp->hitcallback)( pTemp, &pmtrace );
(*pTemp->hitcallback)(pTemp, &pmtrace);
}
}
}
}
else if ( (pTemp->flags & FTENT_COLLIDEWORLD ) != 0)
else if ((pTemp->flags & FTENT_COLLIDEWORLD) != 0)
{
pmtrace_t pmtrace;
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX | PM_WORLD_ONLY, -1, &pmtrace );
gEngfuncs.pEventAPI->EV_SetTraceHull(2);
if ( pmtrace.fraction != 1 )
gEngfuncs.pEventAPI->EV_PlayerTrace(pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX | PM_WORLD_ONLY, -1, &pmtrace);
if (pmtrace.fraction != 1)
{
traceFraction = pmtrace.fraction;
VectorCopy( pmtrace.plane.normal, traceNormal );
VectorCopy(pmtrace.plane.normal, traceNormal);
if ( (pTemp->flags & FTENT_SPARKSHOWER ) != 0)
if ((pTemp->flags & FTENT_SPARKSHOWER) != 0)
{
// Chop spark speeds a bit more
//
VectorScale( pTemp->entity.baseline.origin, 0.6, pTemp->entity.baseline.origin );
VectorScale(pTemp->entity.baseline.origin, 0.6, pTemp->entity.baseline.origin);
if ( Length( pTemp->entity.baseline.origin ) < 10 )
if (Length(pTemp->entity.baseline.origin) < 10)
{
pTemp->entity.baseline.framerate = 0.0;
pTemp->entity.baseline.framerate = 0.0;
}
}
if ( pTemp->hitcallback )
if (pTemp->hitcallback)
{
(*pTemp->hitcallback)( pTemp, &pmtrace );
(*pTemp->hitcallback)(pTemp, &pmtrace);
}
}
}
if ( traceFraction != 1 ) // Decent collision now, and damping works
if (traceFraction != 1) // Decent collision now, and damping works
{
float proj, damp;
float proj, damp;
// Place at contact point
VectorMA( pTemp->entity.prevstate.origin, traceFraction*frametime, pTemp->entity.baseline.origin, pTemp->entity.origin );
VectorMA(pTemp->entity.prevstate.origin, traceFraction * frametime, pTemp->entity.baseline.origin, pTemp->entity.origin);
// Damp velocity
damp = pTemp->bounceFactor;
if ( (pTemp->flags & (FTENT_GRAVITY|FTENT_SLOWGRAVITY) ) != 0)
if ((pTemp->flags & (FTENT_GRAVITY | FTENT_SLOWGRAVITY)) != 0)
{
damp *= 0.5;
if ( traceNormal[2] > 0.9 ) // Hit floor?
if (traceNormal[2] > 0.9) // Hit floor?
{
if ( pTemp->entity.baseline.origin[2] <= 0 && pTemp->entity.baseline.origin[2] >= gravity*3 )
if (pTemp->entity.baseline.origin[2] <= 0 && pTemp->entity.baseline.origin[2] >= gravity * 3)
{
damp = 0; // Stop
pTemp->flags &= ~(FTENT_ROTATE|FTENT_GRAVITY|FTENT_SLOWGRAVITY|FTENT_COLLIDEWORLD|FTENT_SMOKETRAIL);
damp = 0; // Stop
pTemp->flags &= ~(FTENT_ROTATE | FTENT_GRAVITY | FTENT_SLOWGRAVITY | FTENT_COLLIDEWORLD | FTENT_SMOKETRAIL);
pTemp->entity.angles[0] = 0;
pTemp->entity.angles[2] = 0;
}
@ -672,36 +670,36 @@ void DLLEXPORT HUD_TempEntUpdate (
if ((pTemp->flags & FTENT_COLLIDEKILL) != 0)
{
// die on impact
pTemp->flags &= ~FTENT_FADEOUT;
pTemp->die = client_time;
pTemp->flags &= ~FTENT_FADEOUT;
pTemp->die = client_time;
}
else
{
// Reflect velocity
if ( damp != 0 )
if (damp != 0)
{
proj = DotProduct( pTemp->entity.baseline.origin, traceNormal );
VectorMA( pTemp->entity.baseline.origin, -proj*2, traceNormal, pTemp->entity.baseline.origin );
proj = DotProduct(pTemp->entity.baseline.origin, traceNormal);
VectorMA(pTemp->entity.baseline.origin, -proj * 2, traceNormal, pTemp->entity.baseline.origin);
// Reflect rotation (fake)
pTemp->entity.angles[1] = -pTemp->entity.angles[1];
}
if ( damp != 1 )
if (damp != 1)
{
VectorScale( pTemp->entity.baseline.origin, damp, pTemp->entity.baseline.origin );
VectorScale( pTemp->entity.angles, 0.9, pTemp->entity.angles );
VectorScale(pTemp->entity.baseline.origin, damp, pTemp->entity.baseline.origin);
VectorScale(pTemp->entity.angles, 0.9, pTemp->entity.angles);
}
}
}
}
if ( (pTemp->flags & FTENT_FLICKER) != 0 && gTempEntFrame == pTemp->entity.curstate.effects )
if ((pTemp->flags & FTENT_FLICKER) != 0 && gTempEntFrame == pTemp->entity.curstate.effects)
{
dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight (0);
VectorCopy (pTemp->entity.origin, dl->origin);
dlight_t* dl = gEngfuncs.pEfxAPI->CL_AllocDlight(0);
VectorCopy(pTemp->entity.origin, dl->origin);
dl->radius = 60;
dl->color.r = 255;
dl->color.g = 120;
@ -709,33 +707,33 @@ void DLLEXPORT HUD_TempEntUpdate (
dl->die = client_time + 0.01;
}
if ( (pTemp->flags & FTENT_SMOKETRAIL ) != 0)
if ((pTemp->flags & FTENT_SMOKETRAIL) != 0)
{
gEngfuncs.pEfxAPI->R_RocketTrail (pTemp->entity.prevstate.origin, pTemp->entity.origin, 1);
gEngfuncs.pEfxAPI->R_RocketTrail(pTemp->entity.prevstate.origin, pTemp->entity.origin, 1);
}
if ( (pTemp->flags & FTENT_GRAVITY ) != 0)
if ((pTemp->flags & FTENT_GRAVITY) != 0)
pTemp->entity.baseline.origin[2] += gravity;
else if ( (pTemp->flags & FTENT_SLOWGRAVITY ) != 0)
else if ((pTemp->flags & FTENT_SLOWGRAVITY) != 0)
pTemp->entity.baseline.origin[2] += gravitySlow;
if ( (pTemp->flags & FTENT_CLIENTCUSTOM ) != 0)
if ((pTemp->flags & FTENT_CLIENTCUSTOM) != 0)
{
if ( pTemp->callback )
if (pTemp->callback)
{
( *pTemp->callback )( pTemp, frametime, client_time );
(*pTemp->callback)(pTemp, frametime, client_time);
}
}
// Cull to PVS (not frustum cull, just PVS)
if ( (pTemp->flags & FTENT_NOMODEL ) == 0)
if ((pTemp->flags & FTENT_NOMODEL) == 0)
{
if ( 0 == Callback_AddVisibleEntity( &pTemp->entity ) )
if (0 == Callback_AddVisibleEntity(&pTemp->entity))
{
if ( (pTemp->flags & FTENT_PERSIST) == 0)
if ((pTemp->flags & FTENT_PERSIST) == 0)
{
pTemp->die = client_time; // If we can't draw it this frame, just dump it.
pTemp->flags &= ~FTENT_FADEOUT; // Don't fade out, just die
pTemp->die = client_time; // If we can't draw it this frame, just dump it.
pTemp->flags &= ~FTENT_FADEOUT; // Don't fade out, just die
}
}
}
@ -759,16 +757,16 @@ If you specify negative numbers for beam start and end point entities, then
Indices must start at 1, not zero.
=================
*/
cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index )
cl_entity_t DLLEXPORT* HUD_GetUserEntity(int index)
{
// RecClGetUserEntity(index);
// RecClGetUserEntity(index);
#if defined( BEAM_TEST )
#if defined(BEAM_TEST)
// None by default, you would return a valic pointer if you create a client side
// beam and attach it to a client side entity.
if ( index > 0 && index <= 1 )
if (index > 0 && index <= 1)
{
return &beams[ index ];
return &beams[index];
}
else
{
@ -778,4 +776,3 @@ cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index )
return NULL;
#endif
}

View file

@ -25,7 +25,7 @@
#include "event_api.h"
#include "pm_shared.h"
#define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) )
#define IS_FIRSTPERSON_SPEC (g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)))
/*
=================
GetEntity
@ -33,9 +33,9 @@ GetEntity
Return's the requested cl_entity_t
=================
*/
struct cl_entity_s *GetEntity( int idx )
struct cl_entity_s* GetEntity(int idx)
{
return gEngfuncs.GetEntityByIndex( idx );
return gEngfuncs.GetEntityByIndex(idx);
}
/*
@ -45,7 +45,7 @@ GetViewEntity
Return's the current weapon/view model
=================
*/
struct cl_entity_s *GetViewEntity()
struct cl_entity_s* GetViewEntity()
{
return gEngfuncs.GetViewModel();
}
@ -57,9 +57,9 @@ EV_CreateTracer
Creates a tracer effect
=================
*/
void EV_CreateTracer( float *start, float *end )
void EV_CreateTracer(float* start, float* end)
{
gEngfuncs.pEfxAPI->R_TracerEffect( start, end );
gEngfuncs.pEfxAPI->R_TracerEffect(start, end);
}
/*
@ -69,9 +69,9 @@ EV_IsPlayer
Is the entity's index in the player range?
=================
*/
bool EV_IsPlayer( int idx )
bool EV_IsPlayer(int idx)
{
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
if (idx >= 1 && idx <= gEngfuncs.GetMaxClients())
return true;
return false;
@ -84,13 +84,13 @@ EV_IsLocal
Is the entity == the local player
=================
*/
bool EV_IsLocal( int idx )
bool EV_IsLocal(int idx)
{
// check if we are in some way in first person spec mode
if ( IS_FIRSTPERSON_SPEC )
if (IS_FIRSTPERSON_SPEC)
return (g_iUser2 == idx);
else
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) != 0;
return gEngfuncs.pEventAPI->EV_IsLocal(idx - 1) != 0;
}
/*
@ -100,7 +100,7 @@ EV_GetGunPosition
Figure out the height of the gun
=================
*/
void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
void EV_GetGunPosition(event_args_t* args, float* pos, float* origin)
{
int idx;
@ -108,21 +108,21 @@ void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
Vector view_ofs = VEC_VIEW;
if ( EV_IsPlayer( idx ) )
if (EV_IsPlayer(idx))
{
// in spec mode use entity viewheigh, not own
if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC )
if (EV_IsLocal(idx) && !IS_FIRSTPERSON_SPEC)
{
// Grab predicted result for local player
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight(view_ofs);
}
else if ( args->ducking == 1 )
else if (args->ducking == 1)
{
view_ofs = VEC_DUCK_VIEW;
}
}
VectorAdd( origin, view_ofs, pos );
VectorAdd(origin, view_ofs, pos);
}
/*
@ -132,12 +132,12 @@ EV_EjectBrass
Bullet shell casings
=================
*/
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype )
void EV_EjectBrass(float* origin, float* velocity, float rotation, int model, int soundtype)
{
Vector endpos;
VectorClear( endpos );
VectorClear(endpos);
endpos[1] = rotation;
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, 2.5, model, soundtype );
gEngfuncs.pEfxAPI->R_TempModel(origin, velocity, endpos, 2.5, model, soundtype);
}
/*
@ -147,7 +147,7 @@ EV_GetDefaultShellInfo
Determine where to eject shells from
=================
*/
void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale )
void EV_GetDefaultShellInfo(event_args_t* args, float* origin, float* velocity, float* ShellVelocity, float* ShellOrigin, float* forward, float* right, float* up, float forwardScale, float upScale, float rightScale)
{
int i;
float fR, fU;
@ -158,25 +158,25 @@ void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity,
Vector view_ofs = VEC_VIEW;
if ( EV_IsPlayer( idx ) )
if (EV_IsPlayer(idx))
{
if ( EV_IsLocal( idx ) )
if (EV_IsLocal(idx))
{
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight(view_ofs);
}
else if ( args->ducking == 1 )
else if (args->ducking == 1)
{
view_ofs = VEC_DUCK_VIEW;
}
}
fR = gEngfuncs.pfnRandomFloat( 50, 70 );
fU = gEngfuncs.pfnRandomFloat( 100, 150 );
fR = gEngfuncs.pfnRandomFloat(50, 70);
fU = gEngfuncs.pfnRandomFloat(100, 150);
for ( i = 0; i < 3; i++ )
for (i = 0; i < 3; i++)
{
ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25;
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
}
}
@ -190,8 +190,8 @@ Flag weapon/view model for muzzle flash
void EV_MuzzleFlash()
{
// Add muzzle flash to current weapon model
cl_entity_t *ent = GetViewEntity();
if ( !ent )
cl_entity_t* ent = GetViewEntity();
if (!ent)
{
return;
}

File diff suppressed because it is too large Load diff

View file

@ -1,16 +1,16 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName );
void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType );
bool EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount );
void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY );
void EV_HLDM_GunshotDecalTrace(pmtrace_t* pTrace, char* decalName);
void EV_HLDM_DecalGunshot(pmtrace_t* pTrace, int iBulletType);
bool EV_HLDM_CheckTracer(int idx, float* vecSrc, float* end, float* forward, float* right, int iBulletType, int iTracerFreq, int* tracerCount);
void EV_HLDM_FireBullets(int idx, float* forward, float* right, float* up, int cShots, float* vecSrc, float* vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int* tracerCount, float flSpreadX, float flSpreadY);
// HLDM
void EV_FireGlock1(event_args_t* args);

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -10,13 +10,13 @@
#pragma once
// Some of these are HL/TFC specific?
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype );
void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin );
void EV_GetDefaultShellInfo( struct event_args_s *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale );
bool EV_IsLocal( int idx );
bool EV_IsPlayer( int idx );
void EV_CreateTracer( float *start, float *end );
void EV_EjectBrass(float* origin, float* velocity, float rotation, int model, int soundtype);
void EV_GetGunPosition(struct event_args_s* args, float* pos, float* origin);
void EV_GetDefaultShellInfo(struct event_args_s* args, float* origin, float* velocity, float* ShellVelocity, float* ShellOrigin, float* forward, float* right, float* up, float forwardScale, float upScale, float rightScale);
bool EV_IsLocal(int idx);
bool EV_IsPlayer(int idx);
void EV_CreateTracer(float* start, float* end);
struct cl_entity_s *GetEntity( int idx );
struct cl_entity_s *GetViewEntity();
struct cl_entity_s* GetEntity(int idx);
struct cl_entity_s* GetViewEntity();
void EV_MuzzleFlash();

View file

@ -55,9 +55,9 @@ void CHudFlashlight::Reset()
bool CHudFlashlight::VidInit()
{
int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" );
int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" );
int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" );
int HUD_flash_empty = gHUD.GetSpriteIndex("flash_empty");
int HUD_flash_full = gHUD.GetSpriteIndex("flash_full");
int HUD_flash_beam = gHUD.GetSpriteIndex("flash_beam");
m_hSprite1 = gHUD.GetSprite(HUD_flash_empty);
m_hSprite2 = gHUD.GetSprite(HUD_flash_full);
@ -70,39 +70,39 @@ bool CHudFlashlight::VidInit()
return true;
};
bool CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf )
bool CHudFlashlight::MsgFunc_FlashBat(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int x = READ_BYTE();
m_iBat = x;
m_flBat = ((float)x)/100.0;
m_flBat = ((float)x) / 100.0;
return true;
}
bool CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf )
bool CHudFlashlight::MsgFunc_Flashlight(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
m_fOn = READ_BYTE() != 0;
int x = READ_BYTE();
m_iBat = x;
m_flBat = ((float)x)/100.0;
m_flBat = ((float)x) / 100.0;
return true;
}
bool CHudFlashlight::Draw(float flTime)
{
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) ) != 0)
if ((gHUD.m_iHideHUDDisplay & (HIDEHUD_FLASHLIGHT | HIDEHUD_ALL)) != 0)
return true;
int r, g, b, x, y, a;
Rect rc;
if ((gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ) == 0)
if ((gHUD.m_iWeaponBits & (1 << (WEAPON_SUIT))) == 0)
return true;
if (m_fOn)
@ -111,37 +111,37 @@ bool CHudFlashlight::Draw(float flTime)
a = MIN_ALPHA;
if (m_flBat < 0.20)
UnpackRGB(r,g,b, RGB_REDISH);
UnpackRGB(r, g, b, RGB_REDISH);
else
UnpackRGB(r,g,b, RGB_YELLOWISH);
UnpackRGB(r, g, b, RGB_YELLOWISH);
ScaleColors(r, g, b, a);
y = (m_prc1->bottom - m_prc2->top)/2;
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
y = (m_prc1->bottom - m_prc2->top) / 2;
x = ScreenWidth - m_iWidth - m_iWidth / 2;
// Draw the flashlight casing
SPR_Set(m_hSprite1, r, g, b );
SPR_DrawAdditive( 0, x, y, m_prc1);
SPR_Set(m_hSprite1, r, g, b);
SPR_DrawAdditive(0, x, y, m_prc1);
if ( m_fOn )
{ // draw the flashlight beam
x = ScreenWidth - m_iWidth/2;
if (m_fOn)
{ // draw the flashlight beam
x = ScreenWidth - m_iWidth / 2;
SPR_Set( m_hBeam, r, g, b );
SPR_DrawAdditive( 0, x, y, m_prcBeam );
SPR_Set(m_hBeam, r, g, b);
SPR_DrawAdditive(0, x, y, m_prcBeam);
}
// draw the flashlight energy level
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
x = ScreenWidth - m_iWidth - m_iWidth / 2;
int iOffset = m_iWidth * (1.0 - m_flBat);
if (iOffset < m_iWidth)
{
rc = *m_prc2;
rc.left += iOffset;
SPR_Set(m_hSprite2, r, g, b );
SPR_DrawAdditive( 0, x + iOffset, y, &rc);
SPR_Set(m_hSprite2, r, g, b);
SPR_DrawAdditive(0, x + iOffset, y, &rc);
}

View file

@ -26,18 +26,18 @@
#include "parsemsg.h"
DECLARE_MESSAGE(m_Geiger, Geiger )
DECLARE_MESSAGE(m_Geiger, Geiger)
bool CHudGeiger::Init()
{
HOOK_MESSAGE( Geiger );
HOOK_MESSAGE(Geiger);
m_iGeigerRange = 0;
m_iFlags = 0;
gHUD.AddHudElem(this);
srand( (unsigned)time( NULL ) );
srand((unsigned)time(NULL));
return true;
};
@ -47,34 +47,34 @@ bool CHudGeiger::VidInit()
return true;
};
bool CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
bool CHudGeiger::MsgFunc_Geiger(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
// update geiger data
m_iGeigerRange = READ_BYTE();
m_iGeigerRange = m_iGeigerRange << 2;
m_iFlags |= HUD_ACTIVE;
return true;
}
bool CHudGeiger::Draw (float flTime)
bool CHudGeiger::Draw(float flTime)
{
int pct;
float flvol;
int rg[3];
int i;
if (m_iGeigerRange <= 800 && m_iGeigerRange > 0)
{
// peicewise linear is better than continuous formula for this
if (m_iGeigerRange > 600)
{
pct = 2;
flvol = 0.4; //Con_Printf ( "range > 600\n");
flvol = 0.4; //Con_Printf ( "range > 600\n");
rg[0] = 1;
rg[1] = 1;
i = 2;
@ -82,7 +82,7 @@ bool CHudGeiger::Draw (float flTime)
else if (m_iGeigerRange > 500)
{
pct = 4;
flvol = 0.5; //Con_Printf ( "range > 500\n");
flvol = 0.5; //Con_Printf ( "range > 500\n");
rg[0] = 1;
rg[1] = 2;
i = 2;
@ -90,7 +90,7 @@ bool CHudGeiger::Draw (float flTime)
else if (m_iGeigerRange > 400)
{
pct = 8;
flvol = 0.6; //Con_Printf ( "range > 400\n");
flvol = 0.6; //Con_Printf ( "range > 400\n");
rg[0] = 1;
rg[1] = 2;
rg[2] = 3;
@ -99,7 +99,7 @@ bool CHudGeiger::Draw (float flTime)
else if (m_iGeigerRange > 300)
{
pct = 8;
flvol = 0.7; //Con_Printf ( "range > 300\n");
flvol = 0.7; //Con_Printf ( "range > 300\n");
rg[0] = 2;
rg[1] = 3;
rg[2] = 4;
@ -108,7 +108,7 @@ bool CHudGeiger::Draw (float flTime)
else if (m_iGeigerRange > 200)
{
pct = 28;
flvol = 0.78; //Con_Printf ( "range > 200\n");
flvol = 0.78; //Con_Printf ( "range > 200\n");
rg[0] = 2;
rg[1] = 3;
rg[2] = 4;
@ -117,7 +117,7 @@ bool CHudGeiger::Draw (float flTime)
else if (m_iGeigerRange > 150)
{
pct = 40;
flvol = 0.80; //Con_Printf ( "range > 150\n");
flvol = 0.80; //Con_Printf ( "range > 150\n");
rg[0] = 3;
rg[1] = 4;
rg[2] = 5;
@ -126,7 +126,7 @@ bool CHudGeiger::Draw (float flTime)
else if (m_iGeigerRange > 100)
{
pct = 60;
flvol = 0.85; //Con_Printf ( "range > 100\n");
flvol = 0.85; //Con_Printf ( "range > 100\n");
rg[0] = 3;
rg[1] = 4;
rg[2] = 5;
@ -135,7 +135,7 @@ bool CHudGeiger::Draw (float flTime)
else if (m_iGeigerRange > 75)
{
pct = 80;
flvol = 0.9; //Con_Printf ( "range > 75\n");
flvol = 0.9; //Con_Printf ( "range > 75\n");
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
rg[0] = 4;
rg[1] = 5;
@ -145,7 +145,7 @@ bool CHudGeiger::Draw (float flTime)
else if (m_iGeigerRange > 50)
{
pct = 90;
flvol = 0.95; //Con_Printf ( "range > 50\n");
flvol = 0.95; //Con_Printf ( "range > 50\n");
rg[0] = 5;
rg[1] = 6;
i = 2;
@ -153,7 +153,7 @@ bool CHudGeiger::Draw (float flTime)
else
{
pct = 95;
flvol = 1.0; //Con_Printf ( "range < 50\n");
flvol = 1.0; //Con_Printf ( "range < 50\n");
rg[0] = 5;
rg[1] = 6;
i = 2;
@ -163,16 +163,15 @@ bool CHudGeiger::Draw (float flTime)
if ((rand() & 127) < pct || (rand() & 127) < pct)
{
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100);
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100);
char sz[256];
int j = rand() & 1;
if (i > 2)
j += rand() & 1;
sprintf(sz, "player/geiger%d.wav", j + 1);
PlaySound(sz, flvol);
}
}

View file

@ -27,29 +27,28 @@
#include <string.h>
DECLARE_MESSAGE(m_Health, Health )
DECLARE_MESSAGE(m_Health, Damage )
DECLARE_MESSAGE(m_Health, Health)
DECLARE_MESSAGE(m_Health, Damage)
#define PAIN_NAME "sprites/%d_pain.spr"
#define DAMAGE_NAME "sprites/%d_dmg.spr"
int giDmgHeight, giDmgWidth;
int giDmgFlags[NUM_DMG_TYPES] =
{
DMG_POISON,
DMG_ACID,
DMG_FREEZE|DMG_SLOWFREEZE,
DMG_DROWN,
DMG_BURN|DMG_SLOWBURN,
DMG_NERVEGAS,
DMG_RADIATION,
DMG_SHOCK,
DMG_CALTROP,
DMG_TRANQ,
DMG_CONCUSS,
DMG_HALLUC
};
int giDmgFlags[NUM_DMG_TYPES] =
{
DMG_POISON,
DMG_ACID,
DMG_FREEZE | DMG_SLOWFREEZE,
DMG_DROWN,
DMG_BURN | DMG_SLOWBURN,
DMG_NERVEGAS,
DMG_RADIATION,
DMG_SHOCK,
DMG_CALTROP,
DMG_TRANQ,
DMG_CONCUSS,
DMG_HALLUC};
bool CHudHealth::Init()
{
@ -78,7 +77,7 @@ void CHudHealth::Reset()
// force all the flashing damage icons to expire
m_bitsDamage = 0;
for ( int i = 0; i < NUM_DMG_TYPES; i++ )
for (int i = 0; i < NUM_DMG_TYPES; i++)
{
m_dmg[i].fExpire = 0;
}
@ -88,18 +87,18 @@ bool CHudHealth::VidInit()
{
m_hSprite = 0;
m_HUD_dmg_bio = gHUD.GetSpriteIndex( "dmg_bio" ) + 1;
m_HUD_cross = gHUD.GetSpriteIndex( "cross" );
m_HUD_dmg_bio = gHUD.GetSpriteIndex("dmg_bio") + 1;
m_HUD_cross = gHUD.GetSpriteIndex("cross");
giDmgHeight = gHUD.GetSpriteRect(m_HUD_dmg_bio).right - gHUD.GetSpriteRect(m_HUD_dmg_bio).left;
giDmgWidth = gHUD.GetSpriteRect(m_HUD_dmg_bio).bottom - gHUD.GetSpriteRect(m_HUD_dmg_bio).top;
return true;
}
bool CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf )
bool CHudHealth::MsgFunc_Health(const char* pszName, int iSize, void* pbuf)
{
// TODO: update local health data
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int x = READ_SHORT();
m_iFlags |= HUD_ACTIVE;
@ -115,23 +114,23 @@ bool CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf )
}
bool CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
bool CHudHealth::MsgFunc_Damage(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int armor = READ_BYTE(); // armor
int damageTaken = READ_BYTE(); // health
int armor = READ_BYTE(); // armor
int damageTaken = READ_BYTE(); // health
long bitsDamage = READ_LONG(); // damage bits
Vector vecFrom;
for ( int i = 0 ; i < 3 ; i++)
for (int i = 0; i < 3; i++)
vecFrom[i] = READ_COORD();
UpdateTiles(gHUD.m_flTime, bitsDamage);
// Actually took damage?
if ( damageTaken > 0 || armor > 0 )
if (damageTaken > 0 || armor > 0)
CalcDamageDirection(vecFrom);
return true;
@ -140,13 +139,13 @@ bool CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
// Returns back a color from the
// Green <-> Yellow <-> Red ramp
void CHudHealth::GetPainColor( int &r, int &g, int &b )
void CHudHealth::GetPainColor(int& r, int& g, int& b)
{
int iHealth = m_iHealth;
if (iHealth > 25)
iHealth -= 25;
else if ( iHealth < 0 )
else if (iHealth < 0)
iHealth = 0;
#if 0
g = iHealth * 255 / 100;
@ -155,7 +154,7 @@ void CHudHealth::GetPainColor( int &r, int &g, int &b )
#else
if (m_iHealth > 25)
{
UnpackRGB(r,g,b, RGB_YELLOWISH);
UnpackRGB(r, g, b, RGB_YELLOWISH);
}
else
{
@ -163,7 +162,7 @@ void CHudHealth::GetPainColor( int &r, int &g, int &b )
g = 0;
b = 0;
}
#endif
#endif
}
bool CHudHealth::Draw(float flTime)
@ -172,12 +171,12 @@ bool CHudHealth::Draw(float flTime)
int a = 0, x, y;
int HealthWidth;
if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) != 0 || 0 != gEngfuncs.IsSpectateOnly() )
if ((gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) != 0 || 0 != gEngfuncs.IsSpectateOnly())
return true;
if ( 0 == m_hSprite )
if (0 == m_hSprite)
m_hSprite = LoadSprite(PAIN_NAME);
// Has health changed? Flash the health #
if (0 != m_fFade)
{
@ -190,8 +189,7 @@ bool CHudHealth::Draw(float flTime)
// Fade the health number back to dim
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
a = MIN_ALPHA + (m_fFade / FADE_TIME) * 128;
}
else
a = MIN_ALPHA;
@ -199,18 +197,18 @@ bool CHudHealth::Draw(float flTime)
// If health is getting low, make it bright red
if (m_iHealth <= 15)
a = 255;
GetPainColor( r, g, b );
ScaleColors(r, g, b, a );
GetPainColor(r, g, b);
ScaleColors(r, g, b, a);
// Only draw health if we have the suit.
if ((gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT))) != 0)
if ((gHUD.m_iWeaponBits & (1 << (WEAPON_SUIT))) != 0)
{
HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = CrossWidth /2;
x = CrossWidth / 2;
SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));
@ -224,10 +222,10 @@ bool CHudHealth::Draw(float flTime)
//x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
x += HealthWidth/2;
x += HealthWidth / 2;
int iHeight = gHUD.m_iFontHeight;
int iWidth = HealthWidth/10;
int iWidth = HealthWidth / 10;
UnpackRGB(r, g, b, RGB_YELLOWISH);
FillRGBA(x, y, iWidth, iHeight, r, g, b, a);
}
@ -238,8 +236,8 @@ bool CHudHealth::Draw(float flTime)
void CHudHealth::CalcDamageDirection(Vector vecFrom)
{
Vector forward, right, up;
float side, front;
Vector forward, right, up;
float side, front;
Vector vecOrigin, vecAngles;
if (vecFrom == g_vecZero)
@ -253,21 +251,21 @@ void CHudHealth::CalcDamageDirection(Vector vecFrom)
memcpy(vecAngles, gHUD.m_vecAngles, sizeof(Vector));
VectorSubtract (vecFrom, vecOrigin, vecFrom);
VectorSubtract(vecFrom, vecOrigin, vecFrom);
float flDistToTarget = vecFrom.Length();
vecFrom = vecFrom.Normalize();
AngleVectors (vecAngles, forward, right, up);
AngleVectors(vecAngles, forward, right, up);
front = DotProduct (vecFrom, right);
side = DotProduct (vecFrom, forward);
front = DotProduct(vecFrom, right);
side = DotProduct(vecFrom, forward);
if (flDistToTarget <= 50)
{
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 1;
}
else
else
{
if (side > 0)
{
@ -304,66 +302,70 @@ bool CHudHealth::DrawPain(float flTime)
int x, y, a, shade;
// TODO: get the shift value of the health
a = 255; // max brightness until then
a = 255; // max brightness until then
float fFade = gHUD.m_flTimeDelta * 2;
// SPR_Draw top
if (m_fAttackFront > 0.4)
{
GetPainColor(r,g,b);
shade = a * V_max( m_fAttackFront, 0.5 );
GetPainColor(r, g, b);
shade = a * V_max(m_fAttackFront, 0.5);
ScaleColors(r, g, b, shade);
SPR_Set(m_hSprite, r, g, b );
SPR_Set(m_hSprite, r, g, b);
x = ScreenWidth/2 - SPR_Width(m_hSprite, 0)/2;
y = ScreenHeight/2 - SPR_Height(m_hSprite,0) * 3;
x = ScreenWidth / 2 - SPR_Width(m_hSprite, 0) / 2;
y = ScreenHeight / 2 - SPR_Height(m_hSprite, 0) * 3;
SPR_DrawAdditive(0, x, y, NULL);
m_fAttackFront = V_max( 0, m_fAttackFront - fFade );
} else
m_fAttackFront = V_max(0, m_fAttackFront - fFade);
}
else
m_fAttackFront = 0;
if (m_fAttackRight > 0.4)
{
GetPainColor(r,g,b);
shade = a * V_max( m_fAttackRight, 0.5 );
GetPainColor(r, g, b);
shade = a * V_max(m_fAttackRight, 0.5);
ScaleColors(r, g, b, shade);
SPR_Set(m_hSprite, r, g, b );
SPR_Set(m_hSprite, r, g, b);
x = ScreenWidth/2 + SPR_Width(m_hSprite, 1) * 2;
y = ScreenHeight/2 - SPR_Height(m_hSprite,1)/2;
x = ScreenWidth / 2 + SPR_Width(m_hSprite, 1) * 2;
y = ScreenHeight / 2 - SPR_Height(m_hSprite, 1) / 2;
SPR_DrawAdditive(1, x, y, NULL);
m_fAttackRight = V_max( 0, m_fAttackRight - fFade );
} else
m_fAttackRight = V_max(0, m_fAttackRight - fFade);
}
else
m_fAttackRight = 0;
if (m_fAttackRear > 0.4)
{
GetPainColor(r,g,b);
shade = a * V_max( m_fAttackRear, 0.5 );
GetPainColor(r, g, b);
shade = a * V_max(m_fAttackRear, 0.5);
ScaleColors(r, g, b, shade);
SPR_Set(m_hSprite, r, g, b );
SPR_Set(m_hSprite, r, g, b);
x = ScreenWidth/2 - SPR_Width(m_hSprite, 2)/2;
y = ScreenHeight/2 + SPR_Height(m_hSprite,2) * 2;
x = ScreenWidth / 2 - SPR_Width(m_hSprite, 2) / 2;
y = ScreenHeight / 2 + SPR_Height(m_hSprite, 2) * 2;
SPR_DrawAdditive(2, x, y, NULL);
m_fAttackRear = V_max( 0, m_fAttackRear - fFade );
} else
m_fAttackRear = V_max(0, m_fAttackRear - fFade);
}
else
m_fAttackRear = 0;
if (m_fAttackLeft > 0.4)
{
GetPainColor(r,g,b);
shade = a * V_max( m_fAttackLeft, 0.5 );
GetPainColor(r, g, b);
shade = a * V_max(m_fAttackLeft, 0.5);
ScaleColors(r, g, b, shade);
SPR_Set(m_hSprite, r, g, b );
SPR_Set(m_hSprite, r, g, b);
x = ScreenWidth/2 - SPR_Width(m_hSprite, 3) * 3;
y = ScreenHeight/2 - SPR_Height(m_hSprite,3)/2;
x = ScreenWidth / 2 - SPR_Width(m_hSprite, 3) * 3;
y = ScreenHeight / 2 - SPR_Height(m_hSprite, 3) / 2;
SPR_DrawAdditive(3, x, y, NULL);
m_fAttackLeft = V_max( 0, m_fAttackLeft - fFade );
} else
m_fAttackLeft = V_max(0, m_fAttackLeft - fFade);
}
else
m_fAttackLeft = 0;
return true;
@ -372,41 +374,41 @@ bool CHudHealth::DrawPain(float flTime)
bool CHudHealth::DrawDamage(float flTime)
{
int r, g, b, a;
DAMAGE_IMAGE *pdmg;
DAMAGE_IMAGE* pdmg;
if (0 == m_bitsDamage)
return true;
UnpackRGB(r,g,b, RGB_YELLOWISH);
a = (int)( fabs(sin(flTime*2)) * 256.0);
UnpackRGB(r, g, b, RGB_YELLOWISH);
a = (int)(fabs(sin(flTime * 2)) * 256.0);
ScaleColors(r, g, b, a);
// Draw all the items
int i;
for ( i = 0; i < NUM_DMG_TYPES; i++)
for (i = 0; i < NUM_DMG_TYPES; i++)
{
if ((m_bitsDamage & giDmgFlags[i]) != 0)
{
pdmg = &m_dmg[i];
SPR_Set(gHUD.GetSprite(m_HUD_dmg_bio + i), r, g, b );
SPR_Set(gHUD.GetSprite(m_HUD_dmg_bio + i), r, g, b);
SPR_DrawAdditive(0, pdmg->x, pdmg->y, &gHUD.GetSpriteRect(m_HUD_dmg_bio + i));
}
}
// check for bits that should be expired
for ( i = 0; i < NUM_DMG_TYPES; i++ )
for (i = 0; i < NUM_DMG_TYPES; i++)
{
DAMAGE_IMAGE *pdmg = &m_dmg[i];
DAMAGE_IMAGE* pdmg = &m_dmg[i];
if ( (m_bitsDamage & giDmgFlags[i] ) != 0)
if ((m_bitsDamage & giDmgFlags[i]) != 0)
{
pdmg->fExpire = V_min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire );
pdmg->fExpire = V_min(flTime + DMG_IMAGE_LIFE, pdmg->fExpire);
if ( pdmg->fExpire <= flTime // when the time has expired
&& a < 40 ) // and the flash is at the low point of the cycle
if (pdmg->fExpire <= flTime // when the time has expired
&& a < 40) // and the flash is at the low point of the cycle
{
pdmg->fExpire = 0;
@ -419,25 +421,24 @@ bool CHudHealth::DrawDamage(float flTime)
pdmg = &m_dmg[j];
if (0 != pdmg->y && (pdmg->y < y))
pdmg->y += giDmgHeight;
}
m_bitsDamage &= ~giDmgFlags[i]; // clear the bits
m_bitsDamage &= ~giDmgFlags[i]; // clear the bits
}
}
}
return true;
}
void CHudHealth::UpdateTiles(float flTime, long bitsDamage)
{
DAMAGE_IMAGE *pdmg;
{
DAMAGE_IMAGE* pdmg;
// Which types are new?
long bitsOn = ~m_bitsDamage & bitsDamage;
for (int i = 0; i < NUM_DMG_TYPES; i++)
{
pdmg = &m_dmg[i];
@ -454,10 +455,10 @@ void CHudHealth::UpdateTiles(float flTime, long bitsDamage)
if ((bitsOn & giDmgFlags[i]) != 0)
{
// put this one at the bottom
pdmg->x = giDmgWidth/8;
pdmg->x = giDmgWidth / 8;
pdmg->y = ScreenHeight - giDmgHeight * 2;
pdmg->fExpire=flTime + DMG_IMAGE_LIFE;
pdmg->fExpire = flTime + DMG_IMAGE_LIFE;
// move everyone else up
for (int j = 0; j < NUM_DMG_TYPES; j++)
{
@ -467,11 +468,10 @@ void CHudHealth::UpdateTiles(float flTime, long bitsDamage)
pdmg = &m_dmg[j];
if (0 != pdmg->y)
pdmg->y -= giDmgHeight;
}
pdmg = &m_dmg[i];
}
}
}
}
// damage bits are only turned on here; they are turned off when the draw time has expired (in DrawDamage())
m_bitsDamage |= bitsDamage;

View file

@ -15,58 +15,58 @@
#pragma once
#define DMG_IMAGE_LIFE 2 // seconds that image is up
#define DMG_IMAGE_LIFE 2 // seconds that image is up
#define DMG_IMAGE_POISON 0
#define DMG_IMAGE_ACID 1
#define DMG_IMAGE_COLD 2
#define DMG_IMAGE_DROWN 3
#define DMG_IMAGE_BURN 4
#define DMG_IMAGE_NERVE 5
#define DMG_IMAGE_RAD 6
#define DMG_IMAGE_SHOCK 7
#define DMG_IMAGE_POISON 0
#define DMG_IMAGE_ACID 1
#define DMG_IMAGE_COLD 2
#define DMG_IMAGE_DROWN 3
#define DMG_IMAGE_BURN 4
#define DMG_IMAGE_NERVE 5
#define DMG_IMAGE_RAD 6
#define DMG_IMAGE_SHOCK 7
//tf defines
#define DMG_IMAGE_CALTROP 8
#define DMG_IMAGE_TRANQ 9
#define DMG_IMAGE_CONCUSS 10
#define DMG_IMAGE_HALLUC 11
#define NUM_DMG_TYPES 12
#define DMG_IMAGE_CALTROP 8
#define DMG_IMAGE_TRANQ 9
#define DMG_IMAGE_CONCUSS 10
#define DMG_IMAGE_HALLUC 11
#define NUM_DMG_TYPES 12
// instant damage
typedef struct
{
float fExpire;
float fBaseline;
int x, y;
int x, y;
} DAMAGE_IMAGE;
//
//-----------------------------------------------------
//
class CHudHealth: public CHudBase
class CHudHealth : public CHudBase
{
public:
bool Init() override;
bool VidInit() override;
bool Draw(float fTime) override;
void Reset() override;
bool MsgFunc_Health(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_Damage(const char *pszName, int iSize, void *pbuf);
void Reset() override;
bool MsgFunc_Health(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_Damage(const char* pszName, int iSize, void* pbuf);
int m_iHealth;
int m_HUD_dmg_bio;
int m_HUD_cross;
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
void GetPainColor( int &r, int &g, int &b );
void GetPainColor(int& r, int& g, int& b);
float m_fFade;
private:
HSPRITE m_hSprite;
HSPRITE m_hDamage;
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
int m_bitsDamage;
int m_bitsDamage;
bool DrawPain(float fTime);
bool DrawDamage(float fTime);
void CalcDamageDirection(Vector vecFrom);
void UpdateTiles(float fTime, long bits);
};
};

View file

@ -21,327 +21,327 @@ This file contains "stubs" of class member implementations so that we can predic
add in the functionality you need.
==========================
*/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "player.h"
#include "weapons.h"
#include "nodes.h"
#include "soundent.h"
#include "skill.h"
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "player.h"
#include "weapons.h"
#include "nodes.h"
#include "soundent.h"
#include "skill.h"
// Globals used by game logic
int gmsgWeapPickup = 0;
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
globalvars_t* gpGlobals;
ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS];
AmmoInfo CBasePlayerItem::AmmoInfoArray[MAX_AMMO_SLOTS];
void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch) { }
void EMIT_SOUND_DYN(edict_t* entity, int channel, const char* sample, float volume, float attenuation, int flags, int pitch) {}
// CBaseEntity Stubs
bool CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) { return true; }
bool CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { return true; }
CBaseEntity *CBaseEntity::GetNextTarget() { return NULL; }
bool CBaseEntity::Save( CSave &save ) { return true; }
bool CBaseEntity::Restore( CRestore &restore ) { return true; }
void CBaseEntity::SetObjectCollisionBox() { }
bool CBaseEntity :: Intersects( CBaseEntity *pOther ) { return false; }
void CBaseEntity :: MakeDormant() { }
bool CBaseEntity :: IsDormant() { return false; }
bool CBaseEntity :: IsInWorld() { return true; }
bool CBaseEntity::ShouldToggle( USE_TYPE useType, bool currentState ) { return false; }
int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; }
CBaseEntity * CBaseEntity::Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; }
void CBaseEntity::SUB_Remove() { }
bool CBaseEntity ::TakeHealth(float flHealth, int bitsDamageType) { return true; }
bool CBaseEntity ::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) { return true; }
CBaseEntity* CBaseEntity::GetNextTarget() { return NULL; }
bool CBaseEntity::Save(CSave& save) { return true; }
bool CBaseEntity::Restore(CRestore& restore) { return true; }
void CBaseEntity::SetObjectCollisionBox() {}
bool CBaseEntity ::Intersects(CBaseEntity* pOther) { return false; }
void CBaseEntity ::MakeDormant() {}
bool CBaseEntity ::IsDormant() { return false; }
bool CBaseEntity ::IsInWorld() { return true; }
bool CBaseEntity::ShouldToggle(USE_TYPE useType, bool currentState) { return false; }
int CBaseEntity ::DamageDecal(int bitsDamageType) { return -1; }
CBaseEntity* CBaseEntity::Create(const char* szName, const Vector& vecOrigin, const Vector& vecAngles, edict_t* pentOwner) { return NULL; }
void CBaseEntity::SUB_Remove() {}
// CBaseDelay Stubs
bool CBaseDelay::KeyValue(struct KeyValueData_s*) { return false; }
bool CBaseDelay::Restore( class CRestore & ) { return true; }
bool CBaseDelay::Save( class CSave & ) { return true; }
bool CBaseDelay::Restore(class CRestore&) { return true; }
bool CBaseDelay::Save(class CSave&) { return true; }
// CBaseAnimating Stubs
bool CBaseAnimating::Restore( class CRestore & ) { return true; }
bool CBaseAnimating::Save( class CSave & ) { return true; }
bool CBaseAnimating::Restore(class CRestore&) { return true; }
bool CBaseAnimating::Save(class CSave&) { return true; }
// DEBUG Stubs
edict_t *DBG_EntOfVars( const entvars_t *pev ) { return NULL; }
void DBG_AssertFunction(bool fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage) { }
edict_t* DBG_EntOfVars(const entvars_t* pev) { return NULL; }
void DBG_AssertFunction(bool fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage) {}
// UTIL_* Stubs
void UTIL_PrecacheOther( const char *szClassname ) { }
void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ) { }
void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) { }
void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) { }
void UTIL_MakeVectors( const Vector &vecAngles ) { }
bool UTIL_IsValidEntity( edict_t *pent ) { return true; }
void UTIL_SetOrigin( entvars_t *, const Vector &org ) { }
bool UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { return true; }
void UTIL_LogPrintf(char *,...) { }
void UTIL_ClientPrintAll( int,char const *,char const *,char const *,char const *,char const *) { }
void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 ) { }
void UTIL_PrecacheOther(const char* szClassname) {}
void UTIL_BloodDrips(const Vector& origin, const Vector& direction, int color, int amount) {}
void UTIL_DecalTrace(TraceResult* pTrace, int decalNumber) {}
void UTIL_GunshotDecalTrace(TraceResult* pTrace, int decalNumber) {}
void UTIL_MakeVectors(const Vector& vecAngles) {}
bool UTIL_IsValidEntity(edict_t* pent) { return true; }
void UTIL_SetOrigin(entvars_t*, const Vector& org) {}
bool UTIL_GetNextBestWeapon(CBasePlayer* pPlayer, CBasePlayerItem* pCurrentWeapon) { return true; }
void UTIL_LogPrintf(char*, ...) {}
void UTIL_ClientPrintAll(int, char const*, char const*, char const*, char const*, char const*) {}
void ClientPrint(entvars_t* client, int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4) {}
// CBaseToggle Stubs
bool CBaseToggle::Restore( class CRestore & ) { return true; }
bool CBaseToggle::Save( class CSave & ) { return true; }
bool CBaseToggle :: KeyValue( struct KeyValueData_s * ) { return false; }
bool CBaseToggle::Restore(class CRestore&) { return true; }
bool CBaseToggle::Save(class CSave&) { return true; }
bool CBaseToggle ::KeyValue(struct KeyValueData_s*) { return false; }
// CGrenade Stubs
void CGrenade::BounceSound() { }
void CGrenade::Explode( Vector, Vector ) { }
void CGrenade::Explode( TraceResult *, int ) { }
void CGrenade::Killed( entvars_t *, int ) { }
void CGrenade::Spawn() { }
CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ){ return 0; }
CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ){ return 0; }
void CGrenade::DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ){ }
void CGrenade::BounceSound() {}
void CGrenade::Explode(Vector, Vector) {}
void CGrenade::Explode(TraceResult*, int) {}
void CGrenade::Killed(entvars_t*, int) {}
void CGrenade::Spawn() {}
CGrenade* CGrenade::ShootTimed(entvars_t* pevOwner, Vector vecStart, Vector vecVelocity, float time) { return 0; }
CGrenade* CGrenade::ShootContact(entvars_t* pevOwner, Vector vecStart, Vector vecVelocity) { return 0; }
void CGrenade::DetonateUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value) {}
void UTIL_Remove( CBaseEntity *pEntity ){ }
struct skilldata_t gSkillData;
void UTIL_SetSize( entvars_t *pev, const Vector &vecMin, const Vector &vecMax ){ }
CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius ){ return 0;}
void UTIL_Remove(CBaseEntity* pEntity) {}
struct skilldata_t gSkillData;
void UTIL_SetSize(entvars_t* pev, const Vector& vecMin, const Vector& vecMax) {}
CBaseEntity* UTIL_FindEntityInSphere(CBaseEntity* pStartEntity, const Vector& vecCenter, float flRadius) { return 0; }
Vector UTIL_VecToAngles( const Vector &vec ){ return 0; }
CSprite *CSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, bool animate ) { return 0; }
void CBeam::PointEntInit( const Vector &start, int endIndex ) { }
CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { return NULL; }
void CSprite::Expand( float scaleSpeed, float fadeSpeed ) { }
Vector UTIL_VecToAngles(const Vector& vec) { return 0; }
CSprite* CSprite::SpriteCreate(const char* pSpriteName, const Vector& origin, bool animate) { return 0; }
void CBeam::PointEntInit(const Vector& start, int endIndex) {}
CBeam* CBeam::BeamCreate(const char* pSpriteName, int width) { return NULL; }
void CSprite::Expand(float scaleSpeed, float fadeSpeed) {}
CBaseEntity* CBaseMonster :: CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { return NULL; }
void CBaseMonster :: Eat ( float flFullDuration ) { }
bool CBaseMonster :: FShouldEat () { return true; }
void CBaseMonster :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { }
void CBaseMonster :: BarnacleVictimReleased () { }
void CBaseMonster :: Listen () { }
float CBaseMonster :: FLSoundVolume ( CSound *pSound ) { return 0.0; }
bool CBaseMonster :: FValidateHintType ( short sHint ) { return false; }
void CBaseMonster :: Look ( int iDistance ) { }
int CBaseMonster :: ISoundMask () { return 0; }
CSound* CBaseMonster :: PBestSound () { return NULL; }
CSound* CBaseMonster :: PBestScent () { return NULL; }
float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) { return 0.0; }
void CBaseMonster :: MonsterThink () { }
void CBaseMonster :: MonsterUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { }
int CBaseMonster :: IgnoreConditions () { return 0; }
void CBaseMonster :: RouteClear () { }
void CBaseMonster :: RouteNew () { }
bool CBaseMonster :: FRouteClear () { return false; }
bool CBaseMonster :: FRefreshRoute () { return false; }
bool CBaseMonster::MoveToEnemy( Activity movementAct, float waitTime ) { return false; }
bool CBaseMonster::MoveToLocation( Activity movementAct, float waitTime, const Vector &goal ) { return false; }
bool CBaseMonster::MoveToTarget( Activity movementAct, float waitTime ) { return false; }
bool CBaseMonster::MoveToNode( Activity movementAct, float waitTime, const Vector &goal ) { return false; }
bool ShouldSimplify( int routeType ) { return true; }
void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) { }
bool CBaseMonster :: FBecomeProne () { return true; }
bool CBaseMonster :: CheckRangeAttack1 ( float flDot, float flDist ) { return false; }
bool CBaseMonster :: CheckRangeAttack2 ( float flDot, float flDist ) { return false; }
bool CBaseMonster :: CheckMeleeAttack1 ( float flDot, float flDist ) { return false; }
bool CBaseMonster :: CheckMeleeAttack2 ( float flDot, float flDist ) { return false; }
void CBaseMonster :: CheckAttacks ( CBaseEntity *pTarget, float flDist ) { }
bool CBaseMonster :: FCanCheckAttacks () { return false; }
bool CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) { return false; }
void CBaseMonster :: PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { }
bool CBaseMonster :: PopEnemy( ) { return false; }
void CBaseMonster :: SetActivity ( Activity NewActivity ) { }
void CBaseMonster :: SetSequenceByName ( const char *szSequence ) { }
int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { return 0; }
float CBaseMonster :: OpenDoorAndWait( entvars_t *pevDoor ) { return 0.0; }
void CBaseMonster :: AdvanceRoute ( float distance ) { }
int CBaseMonster :: RouteClassify( int iMoveFlag ) { return 0; }
bool CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ) { return false; }
void CBaseMonster :: InsertWaypoint ( Vector vecLocation, int afMoveFlags ) { }
bool CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) { return false; }
void CBaseMonster :: Move ( float flInterval ) { }
bool CBaseMonster:: ShouldAdvanceRoute( float flWaypointDist ) { return false; }
void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { }
void CBaseMonster :: MonsterInit () { }
void CBaseMonster :: MonsterInitThink () { }
void CBaseMonster :: StartMonster () { }
void CBaseMonster :: MovementComplete() { }
CBaseEntity* CBaseMonster ::CheckTraceHullAttack(float flDist, int iDamage, int iDmgType) { return NULL; }
void CBaseMonster ::Eat(float flFullDuration) {}
bool CBaseMonster ::FShouldEat() { return true; }
void CBaseMonster ::BarnacleVictimBitten(entvars_t* pevBarnacle) {}
void CBaseMonster ::BarnacleVictimReleased() {}
void CBaseMonster ::Listen() {}
float CBaseMonster ::FLSoundVolume(CSound* pSound) { return 0.0; }
bool CBaseMonster ::FValidateHintType(short sHint) { return false; }
void CBaseMonster ::Look(int iDistance) {}
int CBaseMonster ::ISoundMask() { return 0; }
CSound* CBaseMonster ::PBestSound() { return NULL; }
CSound* CBaseMonster ::PBestScent() { return NULL; }
float CBaseAnimating ::StudioFrameAdvance(float flInterval) { return 0.0; }
void CBaseMonster ::MonsterThink() {}
void CBaseMonster ::MonsterUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value) {}
int CBaseMonster ::IgnoreConditions() { return 0; }
void CBaseMonster ::RouteClear() {}
void CBaseMonster ::RouteNew() {}
bool CBaseMonster ::FRouteClear() { return false; }
bool CBaseMonster ::FRefreshRoute() { return false; }
bool CBaseMonster::MoveToEnemy(Activity movementAct, float waitTime) { return false; }
bool CBaseMonster::MoveToLocation(Activity movementAct, float waitTime, const Vector& goal) { return false; }
bool CBaseMonster::MoveToTarget(Activity movementAct, float waitTime) { return false; }
bool CBaseMonster::MoveToNode(Activity movementAct, float waitTime, const Vector& goal) { return false; }
bool ShouldSimplify(int routeType) { return true; }
void CBaseMonster ::RouteSimplify(CBaseEntity* pTargetEnt) {}
bool CBaseMonster ::FBecomeProne() { return true; }
bool CBaseMonster ::CheckRangeAttack1(float flDot, float flDist) { return false; }
bool CBaseMonster ::CheckRangeAttack2(float flDot, float flDist) { return false; }
bool CBaseMonster ::CheckMeleeAttack1(float flDot, float flDist) { return false; }
bool CBaseMonster ::CheckMeleeAttack2(float flDot, float flDist) { return false; }
void CBaseMonster ::CheckAttacks(CBaseEntity* pTarget, float flDist) {}
bool CBaseMonster ::FCanCheckAttacks() { return false; }
bool CBaseMonster ::CheckEnemy(CBaseEntity* pEnemy) { return false; }
void CBaseMonster ::PushEnemy(CBaseEntity* pEnemy, Vector& vecLastKnownPos) {}
bool CBaseMonster ::PopEnemy() { return false; }
void CBaseMonster ::SetActivity(Activity NewActivity) {}
void CBaseMonster ::SetSequenceByName(const char* szSequence) {}
int CBaseMonster ::CheckLocalMove(const Vector& vecStart, const Vector& vecEnd, CBaseEntity* pTarget, float* pflDist) { return 0; }
float CBaseMonster ::OpenDoorAndWait(entvars_t* pevDoor) { return 0.0; }
void CBaseMonster ::AdvanceRoute(float distance) {}
int CBaseMonster ::RouteClassify(int iMoveFlag) { return 0; }
bool CBaseMonster ::BuildRoute(const Vector& vecGoal, int iMoveFlag, CBaseEntity* pTarget) { return false; }
void CBaseMonster ::InsertWaypoint(Vector vecLocation, int afMoveFlags) {}
bool CBaseMonster ::FTriangulate(const Vector& vecStart, const Vector& vecEnd, float flDist, CBaseEntity* pTargetEnt, Vector* pApex) { return false; }
void CBaseMonster ::Move(float flInterval) {}
bool CBaseMonster::ShouldAdvanceRoute(float flWaypointDist) { return false; }
void CBaseMonster::MoveExecute(CBaseEntity* pTargetEnt, const Vector& vecDir, float flInterval) {}
void CBaseMonster ::MonsterInit() {}
void CBaseMonster ::MonsterInitThink() {}
void CBaseMonster ::StartMonster() {}
void CBaseMonster ::MovementComplete() {}
bool CBaseMonster::TaskIsRunning() { return false; }
int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) { return 0; }
bool CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return false; }
bool CBaseMonster :: BuildNearestRoute ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return false; }
CBaseEntity *CBaseMonster :: BestVisibleEnemy () { return NULL; }
bool CBaseMonster :: FInViewCone ( CBaseEntity *pEntity ) { return false; }
bool CBaseMonster :: FInViewCone ( Vector *pOrigin ) { return false; }
bool CBaseEntity :: FVisible ( CBaseEntity *pEntity ) { return false; }
bool CBaseEntity :: FVisible ( const Vector &vecOrigin ) { return false; }
void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { }
float CBaseMonster::FlYawDiff () { return 0.0; }
float CBaseMonster::ChangeYaw ( int yawSpeed ) { return 0; }
float CBaseMonster::VecToYaw ( Vector vecDir ) { return 0.0; }
int CBaseAnimating :: LookupActivity ( int activity ) { return 0; }
int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; }
void CBaseMonster :: SetEyePosition () { }
int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; }
void CBaseAnimating :: ResetSequenceInfo ( ) { }
int CBaseAnimating :: GetSequenceFlags( ) { return 0; }
void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { }
void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) { }
float CBaseAnimating :: SetBoneController ( int iController, float flValue ) { return 0.0; }
void CBaseAnimating :: InitBoneControllers () { }
float CBaseAnimating :: SetBlending ( int iBlender, float flValue ) { return 0; }
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) { }
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) { }
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; }
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { }
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) { }
int CBaseAnimating :: GetBodygroup( int iGroup ) { return 0; }
Vector CBaseMonster :: GetGunPosition() { return g_vecZero; }
void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
void CBaseEntity::FireBullets(unsigned int cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) { }
void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { }
void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) { }
bool CBaseMonster :: FGetNodeRoute ( Vector vecDest ) { return true; }
int CBaseMonster :: FindHintNode () { return NO_NODE; }
void CBaseMonster::ReportAIState() { }
bool CBaseMonster :: KeyValue( KeyValueData *pkvd ) { return false; }
bool CBaseMonster :: FCheckAITrigger () { return false; }
bool CBaseMonster :: CanPlaySequence(bool fDisregardMonsterState, int interruptLevel ) { return false; }
bool CBaseMonster :: FindLateralCover ( const Vector &vecThreat, const Vector &vecViewOffset ) { return false; }
Vector CBaseMonster :: ShootAtEnemy( const Vector &shootOrigin ) { return g_vecZero; }
bool CBaseMonster :: FacingIdeal() { return false; }
bool CBaseMonster :: FCanActiveIdle () { return false; }
void CBaseMonster::PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ) { }
void CBaseMonster::PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, bool bConcurrent, CBaseEntity *pListener ) { }
void CBaseMonster::SentenceStop() { }
void CBaseMonster::CorpseFallThink() { }
void CBaseMonster :: MonsterInitDead() { }
bool CBaseMonster :: BBoxFlat () { return true; }
bool CBaseMonster :: GetEnemy () { return false; }
void CBaseMonster :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
CBaseEntity* CBaseMonster :: DropItem ( const char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; }
bool CBaseMonster :: ShouldFadeOnDeath() { return false; }
void CBaseMonster :: RadiusDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { }
void CBaseMonster :: RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { }
void CBaseMonster::FadeMonster() { }
void CBaseMonster :: GibMonster() { }
bool CBaseMonster :: HasHumanGibs() { return false; }
bool CBaseMonster :: HasAlienGibs() { return false; }
Activity CBaseMonster :: GetDeathActivity () { return ACT_DIE_HEADSHOT; }
MONSTERSTATE CBaseMonster :: GetIdealState () { return MONSTERSTATE_ALERT; }
Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type ) { return NULL; }
Schedule_t *CBaseMonster :: GetSchedule () { return NULL; }
void CBaseMonster :: RunTask ( Task_t *pTask ) { }
void CBaseMonster :: StartTask ( Task_t *pTask ) { }
Schedule_t *CBaseMonster::ScheduleFromName( const char *pName ) { return NULL;}
int CBaseMonster::IRelationship(CBaseEntity* pTarget) { return 0; }
bool CBaseMonster ::FindCover(Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist) { return false; }
bool CBaseMonster ::BuildNearestRoute(Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist) { return false; }
CBaseEntity* CBaseMonster ::BestVisibleEnemy() { return NULL; }
bool CBaseMonster ::FInViewCone(CBaseEntity* pEntity) { return false; }
bool CBaseMonster ::FInViewCone(Vector* pOrigin) { return false; }
bool CBaseEntity ::FVisible(CBaseEntity* pEntity) { return false; }
bool CBaseEntity ::FVisible(const Vector& vecOrigin) { return false; }
void CBaseMonster ::MakeIdealYaw(Vector vecTarget) {}
float CBaseMonster::FlYawDiff() { return 0.0; }
float CBaseMonster::ChangeYaw(int yawSpeed) { return 0; }
float CBaseMonster::VecToYaw(Vector vecDir) { return 0.0; }
int CBaseAnimating ::LookupActivity(int activity) { return 0; }
int CBaseAnimating ::LookupActivityHeaviest(int activity) { return 0; }
void CBaseMonster ::SetEyePosition() {}
int CBaseAnimating ::LookupSequence(const char* label) { return 0; }
void CBaseAnimating ::ResetSequenceInfo() {}
int CBaseAnimating ::GetSequenceFlags() { return 0; }
void CBaseAnimating ::DispatchAnimEvents(float flInterval) {}
void CBaseMonster ::HandleAnimEvent(MonsterEvent_t* pEvent) {}
float CBaseAnimating ::SetBoneController(int iController, float flValue) { return 0.0; }
void CBaseAnimating ::InitBoneControllers() {}
float CBaseAnimating ::SetBlending(int iBlender, float flValue) { return 0; }
void CBaseAnimating ::GetBonePosition(int iBone, Vector& origin, Vector& angles) {}
void CBaseAnimating ::GetAttachment(int iAttachment, Vector& origin, Vector& angles) {}
int CBaseAnimating ::FindTransition(int iEndingSequence, int iGoalSequence, int* piDir) { return -1; }
void CBaseAnimating ::GetAutomovement(Vector& origin, Vector& angles, float flInterval) {}
void CBaseAnimating ::SetBodygroup(int iGroup, int iValue) {}
int CBaseAnimating ::GetBodygroup(int iGroup) { return 0; }
Vector CBaseMonster ::GetGunPosition() { return g_vecZero; }
void CBaseEntity::TraceAttack(entvars_t* pevAttacker, float flDamage, Vector vecDir, TraceResult* ptr, int bitsDamageType) {}
void CBaseEntity::FireBullets(unsigned int cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t* pevAttacker) {}
void CBaseEntity ::TraceBleed(float flDamage, Vector vecDir, TraceResult* ptr, int bitsDamageType) {}
void CBaseMonster ::MakeDamageBloodDecal(int cCount, float flNoise, TraceResult* ptr, const Vector& vecDir) {}
bool CBaseMonster ::FGetNodeRoute(Vector vecDest) { return true; }
int CBaseMonster ::FindHintNode() { return NO_NODE; }
void CBaseMonster::ReportAIState() {}
bool CBaseMonster ::KeyValue(KeyValueData* pkvd) { return false; }
bool CBaseMonster ::FCheckAITrigger() { return false; }
bool CBaseMonster ::CanPlaySequence(bool fDisregardMonsterState, int interruptLevel) { return false; }
bool CBaseMonster ::FindLateralCover(const Vector& vecThreat, const Vector& vecViewOffset) { return false; }
Vector CBaseMonster ::ShootAtEnemy(const Vector& shootOrigin) { return g_vecZero; }
bool CBaseMonster ::FacingIdeal() { return false; }
bool CBaseMonster ::FCanActiveIdle() { return false; }
void CBaseMonster::PlaySentence(const char* pszSentence, float duration, float volume, float attenuation) {}
void CBaseMonster::PlayScriptedSentence(const char* pszSentence, float duration, float volume, float attenuation, bool bConcurrent, CBaseEntity* pListener) {}
void CBaseMonster::SentenceStop() {}
void CBaseMonster::CorpseFallThink() {}
void CBaseMonster ::MonsterInitDead() {}
bool CBaseMonster ::BBoxFlat() { return true; }
bool CBaseMonster ::GetEnemy() { return false; }
void CBaseMonster ::TraceAttack(entvars_t* pevAttacker, float flDamage, Vector vecDir, TraceResult* ptr, int bitsDamageType) {}
CBaseEntity* CBaseMonster ::DropItem(const char* pszItemName, const Vector& vecPos, const Vector& vecAng) { return NULL; }
bool CBaseMonster ::ShouldFadeOnDeath() { return false; }
void CBaseMonster ::RadiusDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) {}
void CBaseMonster ::RadiusDamage(Vector vecSrc, entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) {}
void CBaseMonster::FadeMonster() {}
void CBaseMonster ::GibMonster() {}
bool CBaseMonster ::HasHumanGibs() { return false; }
bool CBaseMonster ::HasAlienGibs() { return false; }
Activity CBaseMonster ::GetDeathActivity() { return ACT_DIE_HEADSHOT; }
MONSTERSTATE CBaseMonster ::GetIdealState() { return MONSTERSTATE_ALERT; }
Schedule_t* CBaseMonster ::GetScheduleOfType(int Type) { return NULL; }
Schedule_t* CBaseMonster ::GetSchedule() { return NULL; }
void CBaseMonster ::RunTask(Task_t* pTask) {}
void CBaseMonster ::StartTask(Task_t* pTask) {}
Schedule_t* CBaseMonster::ScheduleFromName(const char* pName) { return NULL; }
void CBaseMonster::BecomeDead() {}
void CBaseMonster :: RunAI () {}
void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) {}
bool CBaseMonster :: TakeHealth (float flHealth, int bitsDamageType) { return false; }
bool CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return false; }
bool CBaseMonster::Restore( class CRestore & ) { return true; }
bool CBaseMonster::Save( class CSave & ) { return true; }
void CBaseMonster ::RunAI() {}
void CBaseMonster ::Killed(entvars_t* pevAttacker, int iGib) {}
bool CBaseMonster ::TakeHealth(float flHealth, int bitsDamageType) { return false; }
bool CBaseMonster ::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) { return false; }
bool CBaseMonster::Restore(class CRestore&) { return true; }
bool CBaseMonster::Save(class CSave&) { return true; }
int TrainSpeed(int iSpeed, int iMax) { return 0; }
void CBasePlayer :: DeathSound() { }
bool CBasePlayer :: TakeHealth( float flHealth, int bitsDamageType ) { return false; }
void CBasePlayer :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
bool CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return false; }
void CBasePlayer::PackDeadPlayerItems() { }
void CBasePlayer::RemoveAllItems(bool removeSuit ) { }
void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) { }
void CBasePlayer::WaterMove() { }
int TrainSpeed(int iSpeed, int iMax) { return 0; }
void CBasePlayer ::DeathSound() {}
bool CBasePlayer ::TakeHealth(float flHealth, int bitsDamageType) { return false; }
void CBasePlayer ::TraceAttack(entvars_t* pevAttacker, float flDamage, Vector vecDir, TraceResult* ptr, int bitsDamageType) {}
bool CBasePlayer ::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) { return false; }
void CBasePlayer::PackDeadPlayerItems() {}
void CBasePlayer::RemoveAllItems(bool removeSuit) {}
void CBasePlayer::SetAnimation(PLAYER_ANIM playerAnim) {}
void CBasePlayer::WaterMove() {}
bool CBasePlayer::IsOnLadder() { return false; }
void CBasePlayer::PlayerDeathThink() { }
void CBasePlayer::StartDeathCam() { }
void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { }
void CBasePlayer::PlayerUse () { }
void CBasePlayer::Jump() { }
void CBasePlayer::Duck( ) { }
int CBasePlayer::Classify () { return 0; }
void CBasePlayer::PreThink() { }
void CBasePlayer::CheckTimeBasedDamage() { }
void CBasePlayer :: UpdateGeigerCounter() { }
void CBasePlayer::CheckSuitUpdate() { }
void CBasePlayer::SetSuitUpdate(const char *name, bool fgroup, int iNoRepeatTime) { }
void CBasePlayer :: UpdatePlayerSound () { }
void CBasePlayer::PostThink() { }
void CBasePlayer :: Precache() { }
bool CBasePlayer::Save( CSave &save ) { return false; }
void CBasePlayer::RenewItems() { }
bool CBasePlayer::Restore( CRestore &restore ) { return false; }
void CBasePlayer::SelectNextItem( int iItem ) { }
void CBasePlayer::PlayerDeathThink() {}
void CBasePlayer::StartDeathCam() {}
void CBasePlayer::StartObserver(Vector vecPosition, Vector vecViewAngle) {}
void CBasePlayer::PlayerUse() {}
void CBasePlayer::Jump() {}
void CBasePlayer::Duck() {}
int CBasePlayer::Classify() { return 0; }
void CBasePlayer::PreThink() {}
void CBasePlayer::CheckTimeBasedDamage() {}
void CBasePlayer ::UpdateGeigerCounter() {}
void CBasePlayer::CheckSuitUpdate() {}
void CBasePlayer::SetSuitUpdate(const char* name, bool fgroup, int iNoRepeatTime) {}
void CBasePlayer ::UpdatePlayerSound() {}
void CBasePlayer::PostThink() {}
void CBasePlayer ::Precache() {}
bool CBasePlayer::Save(CSave& save) { return false; }
void CBasePlayer::RenewItems() {}
bool CBasePlayer::Restore(CRestore& restore) { return false; }
void CBasePlayer::SelectNextItem(int iItem) {}
bool CBasePlayer::HasWeapons() { return false; }
void CBasePlayer::SelectPrevItem( int iItem ) { }
bool CBasePlayer :: FlashlightIsOn() { return false; }
void CBasePlayer :: FlashlightTurnOn() { }
void CBasePlayer :: FlashlightTurnOff() { }
void CBasePlayer :: ForceClientDllUpdate() { }
void CBasePlayer::ImpulseCommands( ) { }
void CBasePlayer::CheatImpulseCommands( int iImpulse ) { }
bool CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return false; }
bool CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return false; }
void CBasePlayer::ItemPreFrame() { }
void CBasePlayer::ItemPostFrame() { }
int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; }
int CBasePlayer::GetAmmoIndex(const char *psz) { return -1; }
void CBasePlayer::SendAmmoUpdate() { }
void CBasePlayer :: UpdateClientData() { }
bool CBasePlayer :: FBecomeProne () { return true; }
void CBasePlayer :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { }
void CBasePlayer :: BarnacleVictimReleased () { }
int CBasePlayer :: Illumination() { return 0; }
void CBasePlayer :: EnableControl(bool fControl) { }
Vector CBasePlayer :: GetAutoaimVector( float flDelta ) { return g_vecZero; }
Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; }
void CBasePlayer :: ResetAutoaim( ) { }
void CBasePlayer :: SetCustomDecalFrames( int nFrames ) { }
int CBasePlayer :: GetCustomDecalFrames() { return -1; }
void CBasePlayer::DropPlayerItem ( char *pszItemName ) { }
bool CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return false; }
bool CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return false; }
Vector CBasePlayer :: GetGunPosition() { return g_vecZero; }
const char *CBasePlayer::TeamID() { return ""; }
int CBasePlayer :: GiveAmmo( int iCount, const char *szName, int iMax ) { return 0; }
void CBasePlayer::AddPoints( int score, bool bAllowNegativeScore ) { }
void CBasePlayer::AddPointsToTeam( int score, bool bAllowNegativeScore ) { }
void CBasePlayer::SelectPrevItem(int iItem) {}
bool CBasePlayer ::FlashlightIsOn() { return false; }
void CBasePlayer ::FlashlightTurnOn() {}
void CBasePlayer ::FlashlightTurnOff() {}
void CBasePlayer ::ForceClientDllUpdate() {}
void CBasePlayer::ImpulseCommands() {}
void CBasePlayer::CheatImpulseCommands(int iImpulse) {}
bool CBasePlayer::AddPlayerItem(CBasePlayerItem* pItem) { return false; }
bool CBasePlayer::RemovePlayerItem(CBasePlayerItem* pItem) { return false; }
void CBasePlayer::ItemPreFrame() {}
void CBasePlayer::ItemPostFrame() {}
int CBasePlayer::AmmoInventory(int iAmmoIndex) { return -1; }
int CBasePlayer::GetAmmoIndex(const char* psz) { return -1; }
void CBasePlayer::SendAmmoUpdate() {}
void CBasePlayer ::UpdateClientData() {}
bool CBasePlayer ::FBecomeProne() { return true; }
void CBasePlayer ::BarnacleVictimBitten(entvars_t* pevBarnacle) {}
void CBasePlayer ::BarnacleVictimReleased() {}
int CBasePlayer ::Illumination() { return 0; }
void CBasePlayer ::EnableControl(bool fControl) {}
Vector CBasePlayer ::GetAutoaimVector(float flDelta) { return g_vecZero; }
Vector CBasePlayer ::AutoaimDeflection(Vector& vecSrc, float flDist, float flDelta) { return g_vecZero; }
void CBasePlayer ::ResetAutoaim() {}
void CBasePlayer ::SetCustomDecalFrames(int nFrames) {}
int CBasePlayer ::GetCustomDecalFrames() { return -1; }
void CBasePlayer::DropPlayerItem(char* pszItemName) {}
bool CBasePlayer::HasPlayerItem(CBasePlayerItem* pCheckItem) { return false; }
bool CBasePlayer ::SwitchWeapon(CBasePlayerItem* pWeapon) { return false; }
Vector CBasePlayer ::GetGunPosition() { return g_vecZero; }
const char* CBasePlayer::TeamID() { return ""; }
int CBasePlayer ::GiveAmmo(int iCount, const char* szName, int iMax) { return 0; }
void CBasePlayer::AddPoints(int score, bool bAllowNegativeScore) {}
void CBasePlayer::AddPointsToTeam(int score, bool bAllowNegativeScore) {}
void CBasePlayer::TabulateAmmo() {}
void ClearMultiDamage() { }
void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) { }
void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { }
void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) { }
int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { return 0; }
void DecalGunshot( TraceResult *pTrace, int iBulletType ) { }
void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { }
bool CBasePlayerItem::Restore( class CRestore & ) { return true; }
bool CBasePlayerItem::Save( class CSave & ) { return true; }
bool CBasePlayerWeapon::Restore( class CRestore & ) { return true; }
bool CBasePlayerWeapon::Save( class CSave & ) { return true; }
float CBasePlayerWeapon::GetNextAttackDelay( float flTime ) { return flTime; }
void CBasePlayerItem :: SetObjectCollisionBox() { }
void CBasePlayerItem :: FallInit() { }
void CBasePlayerItem::FallThink () { }
void CBasePlayerItem::Materialize() { }
void CBasePlayerItem::AttemptToMaterialize() { }
void CBasePlayerItem :: CheckRespawn () { }
void ClearMultiDamage() {}
void ApplyMultiDamage(entvars_t* pevInflictor, entvars_t* pevAttacker) {}
void AddMultiDamage(entvars_t* pevInflictor, CBaseEntity* pEntity, float flDamage, int bitsDamageType) {}
void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) {}
int DamageDecal(CBaseEntity* pEntity, int bitsDamageType) { return 0; }
void DecalGunshot(TraceResult* pTrace, int iBulletType) {}
void EjectBrass(const Vector& vecOrigin, const Vector& vecVelocity, float rotation, int model, int soundtype) {}
bool CBasePlayerItem::Restore(class CRestore&) { return true; }
bool CBasePlayerItem::Save(class CSave&) { return true; }
bool CBasePlayerWeapon::Restore(class CRestore&) { return true; }
bool CBasePlayerWeapon::Save(class CSave&) { return true; }
float CBasePlayerWeapon::GetNextAttackDelay(float flTime) { return flTime; }
void CBasePlayerItem ::SetObjectCollisionBox() {}
void CBasePlayerItem ::FallInit() {}
void CBasePlayerItem::FallThink() {}
void CBasePlayerItem::Materialize() {}
void CBasePlayerItem::AttemptToMaterialize() {}
void CBasePlayerItem ::CheckRespawn() {}
CBaseEntity* CBasePlayerItem::Respawn() { return NULL; }
void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { }
void CBasePlayerItem::DestroyItem() { }
bool CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) { return true; }
void CBasePlayerItem::Drop() { }
void CBasePlayerItem::Kill() { }
void CBasePlayerItem::Holster() { }
void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { }
bool CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return false; }
bool CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return false; }
bool CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return false; }
bool CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return true; }
bool CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return true; }
bool CBasePlayerWeapon :: IsUseable() { return true; }
void CBasePlayerItem::DefaultTouch(CBaseEntity* pOther) {}
void CBasePlayerItem::DestroyItem() {}
bool CBasePlayerItem::AddToPlayer(CBasePlayer* pPlayer) { return true; }
void CBasePlayerItem::Drop() {}
void CBasePlayerItem::Kill() {}
void CBasePlayerItem::Holster() {}
void CBasePlayerItem::AttachToPlayer(CBasePlayer* pPlayer) {}
bool CBasePlayerWeapon::AddDuplicate(CBasePlayerItem* pOriginal) { return false; }
bool CBasePlayerWeapon::AddToPlayer(CBasePlayer* pPlayer) { return false; }
bool CBasePlayerWeapon::UpdateClientData(CBasePlayer* pPlayer) { return false; }
bool CBasePlayerWeapon ::AddPrimaryAmmo(int iCount, char* szName, int iMaxClip, int iMaxCarry) { return true; }
bool CBasePlayerWeapon ::AddSecondaryAmmo(int iCount, char* szName, int iMax) { return true; }
bool CBasePlayerWeapon ::IsUseable() { return true; }
int CBasePlayerWeapon::PrimaryAmmoIndex() { return m_iPrimaryAmmoType; }
int CBasePlayerWeapon::SecondaryAmmoIndex() { return m_iSecondaryAmmoType; }
void CBasePlayerAmmo::Spawn() { }
int CBasePlayerWeapon::SecondaryAmmoIndex() { return m_iSecondaryAmmoType; }
void CBasePlayerAmmo::Spawn() {}
CBaseEntity* CBasePlayerAmmo::Respawn() { return this; }
void CBasePlayerAmmo::Materialize() { }
void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther ) { }
bool CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { return false; }
bool CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return false; }
void CBasePlayerWeapon::RetireWeapon() { }
void CSoundEnt::InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {}
void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){}
void CBasePlayerAmmo::Materialize() {}
void CBasePlayerAmmo ::DefaultTouch(CBaseEntity* pOther) {}
bool CBasePlayerWeapon::ExtractAmmo(CBasePlayerWeapon* pWeapon) { return false; }
bool CBasePlayerWeapon::ExtractClipAmmo(CBasePlayerWeapon* pWeapon) { return false; }
void CBasePlayerWeapon::RetireWeapon() {}
void CSoundEnt::InsertSound(int iType, const Vector& vecOrigin, int iVolume, float flDuration) {}
void RadiusDamage(Vector vecSrc, entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType) {}

View file

@ -32,23 +32,23 @@ That was what we were going to do, but we ran out of time...oh well.
*/
void Game_HookEvents()
{
gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 );
gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 );
gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle );
gEngfuncs.pfnHookEvent( "events/shotgun2.sc", EV_FireShotGunDouble );
gEngfuncs.pfnHookEvent( "events/mp5.sc", EV_FireMP5 );
gEngfuncs.pfnHookEvent( "events/mp52.sc", EV_FireMP52 );
gEngfuncs.pfnHookEvent( "events/python.sc", EV_FirePython );
gEngfuncs.pfnHookEvent( "events/gauss.sc", EV_FireGauss );
gEngfuncs.pfnHookEvent( "events/gaussspin.sc", EV_SpinGauss );
gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust );
gEngfuncs.pfnHookEvent( "events/crowbar.sc", EV_Crowbar );
gEngfuncs.pfnHookEvent( "events/crossbow1.sc", EV_FireCrossbow );
gEngfuncs.pfnHookEvent( "events/crossbow2.sc", EV_FireCrossbow2 );
gEngfuncs.pfnHookEvent( "events/rpg.sc", EV_FireRpg );
gEngfuncs.pfnHookEvent( "events/egon_fire.sc", EV_EgonFire );
gEngfuncs.pfnHookEvent( "events/egon_stop.sc", EV_EgonStop );
gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire );
gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire );
gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire );
gEngfuncs.pfnHookEvent("events/glock1.sc", EV_FireGlock1);
gEngfuncs.pfnHookEvent("events/glock2.sc", EV_FireGlock2);
gEngfuncs.pfnHookEvent("events/shotgun1.sc", EV_FireShotGunSingle);
gEngfuncs.pfnHookEvent("events/shotgun2.sc", EV_FireShotGunDouble);
gEngfuncs.pfnHookEvent("events/mp5.sc", EV_FireMP5);
gEngfuncs.pfnHookEvent("events/mp52.sc", EV_FireMP52);
gEngfuncs.pfnHookEvent("events/python.sc", EV_FirePython);
gEngfuncs.pfnHookEvent("events/gauss.sc", EV_FireGauss);
gEngfuncs.pfnHookEvent("events/gaussspin.sc", EV_SpinGauss);
gEngfuncs.pfnHookEvent("events/train.sc", EV_TrainPitchAdjust);
gEngfuncs.pfnHookEvent("events/crowbar.sc", EV_Crowbar);
gEngfuncs.pfnHookEvent("events/crossbow1.sc", EV_FireCrossbow);
gEngfuncs.pfnHookEvent("events/crossbow2.sc", EV_FireCrossbow2);
gEngfuncs.pfnHookEvent("events/rpg.sc", EV_FireRpg);
gEngfuncs.pfnHookEvent("events/egon_fire.sc", EV_EgonFire);
gEngfuncs.pfnHookEvent("events/egon_stop.sc", EV_EgonStop);
gEngfuncs.pfnHookEvent("events/firehornet.sc", EV_HornetGunFire);
gEngfuncs.pfnHookEvent("events/tripfire.sc", EV_TripmineFire);
gEngfuncs.pfnHookEvent("events/snarkfire.sc", EV_SnarkFire);
}

View file

@ -26,66 +26,66 @@
#include "entity_types.h"
#include "r_efx.h"
extern BEAM *pBeam;
extern BEAM *pBeam2;
extern TEMPENTITY* pFlare; // Vit_amiN: egon's energy flare
void HUD_GetLastOrg( float *org );
extern BEAM* pBeam;
extern BEAM* pBeam2;
extern TEMPENTITY* pFlare; // Vit_amiN: egon's energy flare
void HUD_GetLastOrg(float* org);
void UpdateBeams ()
void UpdateBeams()
{
Vector forward, vecSrc, vecEnd, origin, angles, right, up;
Vector view_ofs;
pmtrace_t tr;
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer();
cl_entity_t* pthisplayer = gEngfuncs.GetLocalPlayer();
int idx = pthisplayer->index;
// Get our exact viewangles from engine
gEngfuncs.GetViewAngles( (float *)angles );
gEngfuncs.GetViewAngles((float*)angles);
// Determine our last predicted origin
HUD_GetLastOrg( (float *)&origin );
HUD_GetLastOrg((float*)&origin);
AngleVectors( angles, forward, right, up );
AngleVectors(angles, forward, right, up);
VectorCopy( origin, vecSrc );
VectorMA( vecSrc, 2048, forward, vecEnd );
VectorCopy(origin, vecSrc);
VectorMA(vecSrc, 2048, forward, vecEnd);
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction(0, 1);
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( 0, 1 );
// Store off the old count
gEngfuncs.pEventAPI->EV_PushPMStates();
// Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr );
// Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers(idx - 1);
gEngfuncs.pEventAPI->EV_SetTraceHull(2);
gEngfuncs.pEventAPI->EV_PlayerTrace(vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr);
gEngfuncs.pEventAPI->EV_PopPMStates();
if ( pBeam )
if (pBeam)
{
pBeam->target = tr.endpos;
pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
}
if ( pBeam2 )
{
pBeam2->target = tr.endpos;
pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
}
if (pFlare) // Vit_amiN: beam flare
if (pBeam2)
{
pBeam2->target = tr.endpos;
pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
}
if (pFlare) // Vit_amiN: beam flare
{
pFlare->entity.origin = tr.endpos;
pFlare->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case.
if (gEngfuncs.GetMaxClients() != 1) // Singleplayer always draws the egon's energy beam flare
if (gEngfuncs.GetMaxClients() != 1) // Singleplayer always draws the egon's energy beam flare
{
pFlare->flags |= FTENT_NOMODEL;
if (!(0 != tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0f)) // Beam hit some non-world entity
if (!(0 != tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0f)) // Beam hit some non-world entity
{
physent_t* pEntity = gEngfuncs.pEventAPI->EV_GetPhysent(tr.ent);
@ -108,6 +108,6 @@ Add game specific, client-side objects here
*/
void Game_AddObjects()
{
if ( pBeam || pBeam2 || pFlare)
if (pBeam || pBeam2 || pFlare)
UpdateBeams();
}

File diff suppressed because it is too large Load diff

View file

@ -30,8 +30,8 @@
#include "demo_api.h"
#include "vgui_ScorePanel.h"
hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine
extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll
hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine
extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll
class CHLVoiceStatusHelper : public IVoiceStatusHelper
{
@ -40,11 +40,11 @@ public:
{
color[0] = color[1] = color[2] = 255;
if( entindex >= 0 && entindex < sizeof(g_PlayerExtraInfo)/sizeof(g_PlayerExtraInfo[0]) )
if (entindex >= 0 && entindex < sizeof(g_PlayerExtraInfo) / sizeof(g_PlayerExtraInfo[0]))
{
int iTeam = g_PlayerExtraInfo[entindex].teamnumber;
if ( iTeam < 0 )
if (iTeam < 0)
{
iTeam = 0;
}
@ -62,14 +62,14 @@ public:
gViewPort->UpdateCursorState();
}
int GetAckIconHeight() override
int GetAckIconHeight() override
{
return ScreenHeight - gHUD.m_iFontHeight*3 - 6;
return ScreenHeight - gHUD.m_iFontHeight * 3 - 6;
}
bool CanShowSpeakerLabels() override
{
if( gViewPort && gViewPort->m_pScoreBoard )
if (gViewPort && gViewPort->m_pScoreBoard)
return !gViewPort->m_pScoreBoard->isVisible();
else
return false;
@ -78,68 +78,68 @@ public:
static CHLVoiceStatusHelper g_VoiceStatusHelper;
extern client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, int iRes, int iCount);
extern client_sprite_t* GetSpriteList(client_sprite_t* pList, const char* psz, int iRes, int iCount);
extern cvar_t *sensitivity;
cvar_t *cl_lw = NULL;
extern cvar_t* sensitivity;
cvar_t* cl_lw = NULL;
cvar_t* cl_rollangle = nullptr;
cvar_t* cl_rollspeed = nullptr;
cvar_t* cl_bobtilt = nullptr;
void ShutdownInput ();
void ShutdownInput();
//DECLARE_MESSAGE(m_Logo, Logo)
int __MsgFunc_Logo(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_Logo(const char* pszName, int iSize, void* pbuf)
{
return static_cast<int>(gHUD.MsgFunc_Logo(pszName, iSize, pbuf ));
return static_cast<int>(gHUD.MsgFunc_Logo(pszName, iSize, pbuf));
}
//DECLARE_MESSAGE(m_Logo, Logo)
int __MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_ResetHUD(const char* pszName, int iSize, void* pbuf)
{
return static_cast<int>(gHUD.MsgFunc_ResetHUD(pszName, iSize, pbuf ));
return static_cast<int>(gHUD.MsgFunc_ResetHUD(pszName, iSize, pbuf));
}
int __MsgFunc_InitHUD(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_InitHUD(const char* pszName, int iSize, void* pbuf)
{
gHUD.MsgFunc_InitHUD( pszName, iSize, pbuf );
gHUD.MsgFunc_InitHUD(pszName, iSize, pbuf);
return 1;
}
int __MsgFunc_ViewMode(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_ViewMode(const char* pszName, int iSize, void* pbuf)
{
gHUD.MsgFunc_ViewMode( pszName, iSize, pbuf );
gHUD.MsgFunc_ViewMode(pszName, iSize, pbuf);
return 1;
}
int __MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_SetFOV(const char* pszName, int iSize, void* pbuf)
{
return static_cast<int>(gHUD.MsgFunc_SetFOV( pszName, iSize, pbuf ));
return static_cast<int>(gHUD.MsgFunc_SetFOV(pszName, iSize, pbuf));
}
int __MsgFunc_Concuss(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_Concuss(const char* pszName, int iSize, void* pbuf)
{
return static_cast<int>(gHUD.MsgFunc_Concuss( pszName, iSize, pbuf ));
return static_cast<int>(gHUD.MsgFunc_Concuss(pszName, iSize, pbuf));
}
int __MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
int __MsgFunc_GameMode(const char* pszName, int iSize, void* pbuf)
{
return static_cast<int>(gHUD.MsgFunc_GameMode( pszName, iSize, pbuf ));
return static_cast<int>(gHUD.MsgFunc_GameMode(pszName, iSize, pbuf));
}
// TFFree Command Menu
void __CmdFunc_OpenCommandMenu()
{
if ( gViewPort )
if (gViewPort)
{
gViewPort->ShowCommandMenu( gViewPort->m_StandardMenu );
gViewPort->ShowCommandMenu(gViewPort->m_StandardMenu);
}
}
// TFC "special" command
void __CmdFunc_InputPlayerSpecial()
{
if ( gViewPort )
if (gViewPort)
{
gViewPort->InputPlayerSpecial();
}
@ -147,7 +147,7 @@ void __CmdFunc_InputPlayerSpecial()
void __CmdFunc_CloseCommandMenu()
{
if ( gViewPort )
if (gViewPort)
{
gViewPort->InputSignalHideCommandMenu();
}
@ -155,176 +155,176 @@ void __CmdFunc_CloseCommandMenu()
void __CmdFunc_ForceCloseCommandMenu()
{
if ( gViewPort )
if (gViewPort)
{
gViewPort->HideCommandMenu();
}
}
// TFFree Command Menu Message Handlers
int __MsgFunc_ValClass(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_ValClass(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_ValClass( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_ValClass(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_TeamNames(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_TeamNames(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_TeamNames( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_TeamNames(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_Feign(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_Feign(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_Feign( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_Feign(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_Detpack(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_Detpack(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_Detpack( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_Detpack(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_VGUIMenu(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_VGUIMenu(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_VGUIMenu( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_VGUIMenu(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_MOTD(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_MOTD(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_MOTD( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_MOTD(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_BuildSt(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_BuildSt(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_BuildSt( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_BuildSt(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_RandomPC(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_RandomPC(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_RandomPC( pszName, iSize, pbuf ));
return 0;
}
int __MsgFunc_ServerName(const char *pszName, int iSize, void *pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_ServerName( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_RandomPC(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_ScoreInfo(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_ServerName(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_ScoreInfo( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_ServerName(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_TeamScore(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_ScoreInfo(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_TeamScore( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_ScoreInfo(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_TeamInfo(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_TeamScore(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_TeamInfo( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_TeamScore(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_Spectator(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_TeamInfo(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_Spectator( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_TeamInfo(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_SpecFade(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_Spectator(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_SpecFade( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_Spectator(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_ResetFade(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_SpecFade(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_ResetFade( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_SpecFade(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_AllowSpec(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_ResetFade(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_AllowSpec( pszName, iSize, pbuf ));
return static_cast<int>(gViewPort->MsgFunc_ResetFade(pszName, iSize, pbuf));
return 0;
}
int __MsgFunc_AllowSpec(const char* pszName, int iSize, void* pbuf)
{
if (gViewPort)
return static_cast<int>(gViewPort->MsgFunc_AllowSpec(pszName, iSize, pbuf));
return 0;
}
// This is called every time the DLL is loaded
void CHud :: Init()
void CHud ::Init()
{
HOOK_MESSAGE( Logo );
HOOK_MESSAGE( ResetHUD );
HOOK_MESSAGE( GameMode );
HOOK_MESSAGE( InitHUD );
HOOK_MESSAGE( ViewMode );
HOOK_MESSAGE( SetFOV );
HOOK_MESSAGE( Concuss );
HOOK_MESSAGE(Logo);
HOOK_MESSAGE(ResetHUD);
HOOK_MESSAGE(GameMode);
HOOK_MESSAGE(InitHUD);
HOOK_MESSAGE(ViewMode);
HOOK_MESSAGE(SetFOV);
HOOK_MESSAGE(Concuss);
// TFFree CommandMenu
HOOK_COMMAND( "+commandmenu", OpenCommandMenu );
HOOK_COMMAND( "-commandmenu", CloseCommandMenu );
HOOK_COMMAND( "ForceCloseCommandMenu", ForceCloseCommandMenu );
HOOK_COMMAND( "special", InputPlayerSpecial );
HOOK_COMMAND("+commandmenu", OpenCommandMenu);
HOOK_COMMAND("-commandmenu", CloseCommandMenu);
HOOK_COMMAND("ForceCloseCommandMenu", ForceCloseCommandMenu);
HOOK_COMMAND("special", InputPlayerSpecial);
HOOK_MESSAGE( ValClass );
HOOK_MESSAGE( TeamNames );
HOOK_MESSAGE( Feign );
HOOK_MESSAGE( Detpack );
HOOK_MESSAGE( MOTD );
HOOK_MESSAGE( BuildSt );
HOOK_MESSAGE( RandomPC );
HOOK_MESSAGE( ServerName );
HOOK_MESSAGE( ScoreInfo );
HOOK_MESSAGE( TeamScore );
HOOK_MESSAGE( TeamInfo );
HOOK_MESSAGE(ValClass);
HOOK_MESSAGE(TeamNames);
HOOK_MESSAGE(Feign);
HOOK_MESSAGE(Detpack);
HOOK_MESSAGE(MOTD);
HOOK_MESSAGE(BuildSt);
HOOK_MESSAGE(RandomPC);
HOOK_MESSAGE(ServerName);
HOOK_MESSAGE(ScoreInfo);
HOOK_MESSAGE(TeamScore);
HOOK_MESSAGE(TeamInfo);
HOOK_MESSAGE( Spectator );
HOOK_MESSAGE( AllowSpec );
HOOK_MESSAGE( SpecFade );
HOOK_MESSAGE( ResetFade );
HOOK_MESSAGE(Spectator);
HOOK_MESSAGE(AllowSpec);
HOOK_MESSAGE(SpecFade);
HOOK_MESSAGE(ResetFade);
// VGUI Menus
HOOK_MESSAGE( VGUIMenu );
HOOK_MESSAGE(VGUIMenu);
CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); // controls whether or not to suicide immediately on TF class switch
CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE ); // controls whether or not to automatically take screenshots at the end of a round
CVAR_CREATE("hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO); // controls whether or not to suicide immediately on TF class switch
CVAR_CREATE("hud_takesshots", "0", FCVAR_ARCHIVE); // controls whether or not to automatically take screenshots at the end of a round
m_iLogo = 0;
m_iFOV = 0;
CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 );
CVAR_CREATE("zoom_sensitivity_ratio", "1.2", 0);
CVAR_CREATE("cl_autowepswitch", "1", FCVAR_ARCHIVE | FCVAR_USERINFO);
default_fov = CVAR_CREATE( "default_fov", "90", FCVAR_ARCHIVE);
m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE );
m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE );
cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" );
default_fov = CVAR_CREATE("default_fov", "90", FCVAR_ARCHIVE);
m_pCvarStealMouse = CVAR_CREATE("hud_capturemouse", "1", FCVAR_ARCHIVE);
m_pCvarDraw = CVAR_CREATE("hud_draw", "1", FCVAR_ARCHIVE);
cl_lw = gEngfuncs.pfnGetCvarPointer("cl_lw");
cl_rollangle = CVAR_CREATE("cl_rollangle", "2.0", FCVAR_ARCHIVE);
cl_rollspeed = CVAR_CREATE("cl_rollspeed", "200", FCVAR_ARCHIVE);
cl_bobtilt = CVAR_CREATE("cl_bobtilt", "0", FCVAR_ARCHIVE);
@ -332,14 +332,14 @@ void CHud :: Init()
m_pSpriteList = NULL;
// Clear any old HUD list
if ( m_pHudList )
if (m_pHudList)
{
HUDLIST *pList;
while ( m_pHudList )
HUDLIST* pList;
while (m_pHudList)
{
pList = m_pHudList;
m_pHudList = m_pHudList->pNext;
free( pList );
free(pList);
}
m_pHudList = NULL;
}
@ -364,26 +364,26 @@ void CHud :: Init()
GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort);
m_Menu.Init();
MsgFunc_ResetHUD(0, 0, NULL );
MsgFunc_ResetHUD(0, 0, NULL);
}
// CHud destructor
// cleans up memory allocated for m_rg* arrays
CHud :: ~CHud()
CHud ::~CHud()
{
delete [] m_rghSprites;
delete [] m_rgrcRects;
delete [] m_rgszSpriteNames;
delete[] m_rghSprites;
delete[] m_rgrcRects;
delete[] m_rgszSpriteNames;
if ( m_pHudList )
if (m_pHudList)
{
HUDLIST *pList;
while ( m_pHudList )
HUDLIST* pList;
while (m_pHudList)
{
pList = m_pHudList;
m_pHudList = m_pHudList->pNext;
free( pList );
free(pList);
}
m_pHudList = NULL;
}
@ -393,19 +393,19 @@ CHud :: ~CHud()
// searches through the sprite list loaded from hud.txt for a name matching SpriteName
// returns an index into the gHUD.m_rghSprites[] array
// returns 0 if sprite not found
int CHud :: GetSpriteIndex( const char *SpriteName )
int CHud ::GetSpriteIndex(const char* SpriteName)
{
// look through the loaded sprite name list for SpriteName
for ( int i = 0; i < m_iSpriteCount; i++ )
for (int i = 0; i < m_iSpriteCount; i++)
{
if ( strncmp( SpriteName, m_rgszSpriteNames + (i * MAX_SPRITE_NAME_LENGTH), MAX_SPRITE_NAME_LENGTH ) == 0 )
if (strncmp(SpriteName, m_rgszSpriteNames + (i * MAX_SPRITE_NAME_LENGTH), MAX_SPRITE_NAME_LENGTH) == 0)
return i;
}
return -1; // invalid sprite
}
void CHud :: VidInit()
void CHud ::VidInit()
{
m_scrinfo.iSize = sizeof(m_scrinfo);
GetScreenInfo(&m_scrinfo);
@ -413,9 +413,9 @@ void CHud :: VidInit()
// ----------
// Load Sprites
// ---------
// m_hsprFont = LoadSprite("sprites/%d_font.spr");
m_hsprLogo = 0;
// m_hsprFont = LoadSprite("sprites/%d_font.spr");
m_hsprLogo = 0;
m_hsprCursor = 0;
if (ScreenWidth < 640)
@ -424,7 +424,7 @@ void CHud :: VidInit()
m_iRes = 640;
// Only load this once
if ( !m_pSpriteList )
if (!m_pSpriteList)
{
// we need to load the hud.txt, and all sprites within
m_pSpriteList = SPR_GetList("sprites/hud.txt", &m_iSpriteCountAllRes);
@ -433,31 +433,31 @@ void CHud :: VidInit()
{
// count the number of sprites of the appropriate res
m_iSpriteCount = 0;
client_sprite_t *p = m_pSpriteList;
client_sprite_t* p = m_pSpriteList;
int j;
for ( j = 0; j < m_iSpriteCountAllRes; j++ )
for (j = 0; j < m_iSpriteCountAllRes; j++)
{
if ( p->iRes == m_iRes )
if (p->iRes == m_iRes)
m_iSpriteCount++;
p++;
}
// allocated memory for sprite handle arrays
m_rghSprites = new HSPRITE[m_iSpriteCount];
m_rghSprites = new HSPRITE[m_iSpriteCount];
m_rgrcRects = new Rect[m_iSpriteCount];
m_rgszSpriteNames = new char[m_iSpriteCount * MAX_SPRITE_NAME_LENGTH];
p = m_pSpriteList;
int index = 0;
for ( j = 0; j < m_iSpriteCountAllRes; j++ )
for (j = 0; j < m_iSpriteCountAllRes; j++)
{
if ( p->iRes == m_iRes )
if (p->iRes == m_iRes)
{
char sz[256];
sprintf(sz, "sprites/%s.spr", p->szSprite);
m_rghSprites[index] = SPR_Load(sz);
m_rgrcRects[index] = p->rc;
strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH );
strncpy(&m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH);
index++;
}
@ -470,14 +470,14 @@ void CHud :: VidInit()
{
// we have already have loaded the sprite reference from hud.txt, but
// we need to make sure all the sprites have been loaded (we've gone through a transition, or loaded a save game)
client_sprite_t *p = m_pSpriteList;
client_sprite_t* p = m_pSpriteList;
int index = 0;
for ( int j = 0; j < m_iSpriteCountAllRes; j++ )
for (int j = 0; j < m_iSpriteCountAllRes; j++)
{
if ( p->iRes == m_iRes )
if (p->iRes == m_iRes)
{
char sz[256];
sprintf( sz, "sprites/%s.spr", p->szSprite );
sprintf(sz, "sprites/%s.spr", p->szSprite);
m_rghSprites[index] = SPR_Load(sz);
index++;
}
@ -487,7 +487,7 @@ void CHud :: VidInit()
}
// assumption: number_1, number_2, etc, are all listed and loaded sequentially
m_HUD_number_0 = GetSpriteIndex( "number_0" );
m_HUD_number_0 = GetSpriteIndex("number_0");
m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top;
@ -509,9 +509,9 @@ void CHud :: VidInit()
GetClientVoiceMgr()->VidInit();
}
bool CHud::MsgFunc_Logo(const char *pszName, int iSize, void *pbuf)
bool CHud::MsgFunc_Logo(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
// update Train data
m_iLogo = READ_BYTE();
@ -527,38 +527,38 @@ COM_FileBase
============
*/
// Extracts the base name of a file (no path, no extension, assumes '/' as path separator)
void COM_FileBase ( const char *in, char *out)
void COM_FileBase(const char* in, char* out)
{
int len, start, end;
len = strlen( in );
len = strlen(in);
// scan backward for '.'
end = len - 1;
while ( 0 != end && in[end] != '.' && in[end] != '/' && in[end] != '\\' )
while (0 != end && in[end] != '.' && in[end] != '/' && in[end] != '\\')
end--;
if ( in[end] != '.' ) // no '.', copy to end
end = len-1;
else
end--; // Found ',', copy to left of '.'
if (in[end] != '.') // no '.', copy to end
end = len - 1;
else
end--; // Found ',', copy to left of '.'
// Scan backward for '/'
start = len-1;
while ( start >= 0 && in[start] != '/' && in[start] != '\\' )
start = len - 1;
while (start >= 0 && in[start] != '/' && in[start] != '\\')
start--;
if ( in[start] != '/' && in[start] != '\\' )
if (in[start] != '/' && in[start] != '\\')
start = 0;
else
else
start++;
// Length of new sting
len = end - start + 1;
// Copy partial string
strncpy( out, &in[start], len );
strncpy(out, &in[start], len);
// Terminate it
out[len] = 0;
}
@ -569,16 +569,16 @@ HUD_IsGame
=================
*/
bool HUD_IsGame( const char *game )
bool HUD_IsGame(const char* game)
{
const char *gamedir;
char gd[ 1024 ];
const char* gamedir;
char gd[1024];
gamedir = gEngfuncs.pfnGetGameDirectory();
if ( gamedir && '\0' != gamedir[0])
if (gamedir && '\0' != gamedir[0])
{
COM_FileBase( gamedir, gd );
if ( !stricmp( gd, game ) )
COM_FileBase(gamedir, gd);
if (!stricmp(gd, game))
return true;
}
return false;
@ -593,32 +593,32 @@ Returns last FOV
*/
float HUD_GetFOV()
{
if ( 0 != gEngfuncs.pDemoAPI->IsRecording() )
if (0 != gEngfuncs.pDemoAPI->IsRecording())
{
// Write it
int i = 0;
unsigned char buf[ 100 ];
unsigned char buf[100];
// Active
*( float * )&buf[ i ] = g_lastFOV;
i += sizeof( float );
*(float*)&buf[i] = g_lastFOV;
i += sizeof(float);
Demo_WriteBuffer( TYPE_ZOOM, i, buf );
Demo_WriteBuffer(TYPE_ZOOM, i, buf);
}
if ( 0 != gEngfuncs.pDemoAPI->IsPlayingback() )
if (0 != gEngfuncs.pDemoAPI->IsPlayingback())
{
g_lastFOV = g_demozoom;
}
return g_lastFOV;
}
bool CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
bool CHud::MsgFunc_SetFOV(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int newfov = READ_BYTE();
int def_fov = CVAR_GET_FLOAT( "default_fov" );
int def_fov = CVAR_GET_FLOAT("default_fov");
//Weapon prediction already takes care of changing the fog. ( g_lastFOV ).
//But it doesn't restore correctly so this still needs to be used
@ -629,7 +629,7 @@ bool CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
g_lastFOV = newfov;
if ( newfov == 0 )
if (newfov == 0)
{
m_iFOV = def_fov;
}
@ -641,13 +641,13 @@ bool CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
// the clients fov is actually set in the client data update section of the hud
// Set a new sensitivity
if ( m_iFOV == def_fov )
{
if (m_iFOV == def_fov)
{
// reset to saved sensitivity
m_flMouseSensitivity = 0;
}
else
{
{
// set a new sensitivity that is proportional to the change from the FOV default
m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)def_fov) * CVAR_GET_FLOAT("zoom_sensitivity_ratio");
}
@ -656,16 +656,16 @@ bool CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
}
void CHud::AddHudElem(CHudBase *phudelem)
void CHud::AddHudElem(CHudBase* phudelem)
{
HUDLIST *pdl, *ptemp;
//phudelem->Think();
//phudelem->Think();
if (!phudelem)
return;
pdl = (HUDLIST *)malloc(sizeof(HUDLIST));
pdl = (HUDLIST*)malloc(sizeof(HUDLIST));
if (!pdl)
return;
@ -690,5 +690,3 @@ float CHud::GetSensitivity()
{
return m_flMouseSensitivity;
}

View file

@ -12,7 +12,7 @@
* without written permission from Valve LLC.
*
****/
//
//
// hud.h
//
// class CHud declaration
@ -23,39 +23,41 @@
#pragma once
#define RGB_YELLOWISH 0x00FFA000 //255,160,0
#define RGB_REDISH 0x00FF1010 //255,160,0
#define RGB_GREENISH 0x0000A000 //0,160,0
#define RGB_REDISH 0x00FF1010 //255,160,0
#define RGB_GREENISH 0x0000A000 //0,160,0
#include "common_types.h"
#include "cl_dll.h"
#include "ammo.h"
#define DHN_DRAWZERO 1
#define DHN_2DIGITS 2
#define DHN_3DIGITS 4
#define MIN_ALPHA 100
#define DHN_2DIGITS 2
#define DHN_3DIGITS 4
#define MIN_ALPHA 100
#define HUDELEM_ACTIVE 1
#define HUDELEM_ACTIVE 1
typedef struct {
typedef struct
{
int x, y;
} POSITION;
#include "global_consts.h"
typedef struct {
unsigned char r,g,b,a;
typedef struct
{
unsigned char r, g, b, a;
} RGBA;
typedef struct cvar_s cvar_t;
#define HUD_ACTIVE 1
#define HUD_ACTIVE 1
#define HUD_INTERMISSION 2
#define MAX_PLAYER_NAME_LENGTH 32
#define MAX_PLAYER_NAME_LENGTH 32
#define MAX_MOTD_LENGTH 1536
#define MAX_MOTD_LENGTH 1536
//
//-----------------------------------------------------
@ -63,22 +65,22 @@ typedef struct cvar_s cvar_t;
class CHudBase
{
public:
POSITION m_pos;
int m_type;
int m_iFlags; // active, moving,
virtual ~CHudBase() {}
virtual bool Init() {return false;}
virtual bool VidInit() {return false;}
virtual bool Draw(float flTime) {return false;}
POSITION m_pos;
int m_type;
int m_iFlags; // active, moving,
virtual ~CHudBase() {}
virtual bool Init() { return false; }
virtual bool VidInit() { return false; }
virtual bool Draw(float flTime) { return false; }
virtual void Think() {}
virtual void Reset() {}
virtual void InitHUDData() {} // called every time a server is connected to
virtual void InitHUDData() {} // called every time a server is connected to
};
struct HUDLIST {
CHudBase *p;
HUDLIST *pNext;
struct HUDLIST
{
CHudBase* p;
HUDLIST* pNext;
};
@ -93,7 +95,7 @@ struct HUDLIST {
//
//-----------------------------------------------------
//
class CHudAmmo: public CHudBase
class CHudAmmo : public CHudBase
{
public:
bool Init() override;
@ -102,15 +104,15 @@ public:
void Think() override;
void Reset() override;
bool DrawWList(float flTime);
bool MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_AmmoX(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_WeapPickup( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_ItemPickup( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_CurWeapon(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_WeaponList(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_AmmoX(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_AmmoPickup(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_WeapPickup(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_ItemPickup(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_HideWeapon(const char* pszName, int iSize, void* pbuf);
void SlotInput( int iSlot );
void SlotInput(int iSlot);
void UserCmd_Slot1();
void UserCmd_Slot2();
void UserCmd_Slot3();
@ -127,18 +129,17 @@ public:
private:
float m_fFade;
RGBA m_rgba;
WEAPON *m_pWeapon;
int m_HUD_bucket0;
RGBA m_rgba;
WEAPON* m_pWeapon;
int m_HUD_bucket0;
int m_HUD_selection;
};
//
//-----------------------------------------------------
//
class CHudAmmoSecondary: public CHudBase
class CHudAmmoSecondary : public CHudBase
{
public:
bool Init() override;
@ -146,11 +147,12 @@ public:
void Reset() override;
bool Draw(float flTime) override;
bool MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_SecAmmoVal(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_SecAmmoIcon(const char* pszName, int iSize, void* pbuf);
private:
enum {
enum
{
MAX_SEC_AMMO_VALUES = 4
};
@ -169,34 +171,32 @@ private:
//
//-----------------------------------------------------
//
class CHudGeiger: public CHudBase
class CHudGeiger : public CHudBase
{
public:
bool Init() override;
bool VidInit() override;
bool Draw(float flTime) override;
bool MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_Geiger(const char* pszName, int iSize, void* pbuf);
private:
int m_iGeigerRange;
};
//
//-----------------------------------------------------
//
class CHudTrain: public CHudBase
class CHudTrain : public CHudBase
{
public:
bool Init() override;
bool VidInit() override;
bool Draw(float flTime) override;
bool MsgFunc_Train(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_Train(const char* pszName, int iSize, void* pbuf);
private:
HSPRITE m_hSprite;
int m_iPos;
};
//
@ -207,42 +207,43 @@ class CHudStatusBar : public CHudBase
public:
bool Init() override;
bool VidInit() override;
bool Draw( float flTime ) override;
bool Draw(float flTime) override;
void Reset() override;
void ParseStatusString( int line_num );
void ParseStatusString(int line_num);
bool MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_StatusText(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_StatusValue(const char* pszName, int iSize, void* pbuf);
protected:
enum {
enum
{
MAX_STATUSTEXT_LENGTH = 128,
MAX_STATUSBAR_VALUES = 8,
MAX_STATUSBAR_LINES = 3,
};
char m_szStatusText[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // a text string describing how the status bar is to be drawn
char m_szStatusBar[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // the constructed bar that is drawn
int m_iStatusValues[MAX_STATUSBAR_VALUES]; // an array of values for use in the status bar
char m_szStatusText[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // a text string describing how the status bar is to be drawn
char m_szStatusBar[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // the constructed bar that is drawn
int m_iStatusValues[MAX_STATUSBAR_VALUES]; // an array of values for use in the status bar
bool m_bReparseString; // set to true whenever the m_szStatusBar needs to be recalculated
// an array of colors...one color for each line
float *m_pflNameColors[MAX_STATUSBAR_LINES];
float* m_pflNameColors[MAX_STATUSBAR_LINES];
};
struct extra_player_info_t
struct extra_player_info_t
{
short frags;
short deaths;
short playerclass;
short health; // UNUSED currently, spectator UI would like this
bool dead; // UNUSED currently, spectator UI would like this
bool dead; // UNUSED currently, spectator UI would like this
short teamnumber;
char teamname[MAX_TEAM_NAME];
};
struct team_info_t
struct team_info_t
{
char name[MAX_TEAM_NAME];
short frags;
@ -267,11 +268,11 @@ public:
bool Init() override;
void InitHUDData() override;
bool VidInit() override;
bool Draw( float flTime ) override;
bool MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf );
bool Draw(float flTime) override;
bool MsgFunc_DeathMsg(const char* pszName, int iSize, void* pbuf);
private:
int m_HUD_d_skull; // sprite index of skull icon
int m_HUD_d_skull; // sprite index of skull icon
};
//
@ -284,10 +285,10 @@ public:
void InitHUDData() override;
bool VidInit() override;
void Reset() override;
bool Draw( float flTime ) override;
bool MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf );
bool Draw(float flTime) override;
bool MsgFunc_ShowMenu(const char* pszName, int iSize, void* pbuf);
void SelectMenuItem( int menu_item );
void SelectMenuItem(int menu_item);
bool m_fMenuDisplayed;
int m_bitsValidSlots;
@ -304,66 +305,65 @@ public:
bool Init() override;
void InitHUDData() override;
bool VidInit() override;
bool Draw( float flTime ) override;
bool MsgFunc_SayText( const char *pszName, int iSize, void *pbuf );
void SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex = -1 );
void EnsureTextFitsInOneLineAndWrapIfHaveTo( int line );
friend class CHudSpectator;
bool Draw(float flTime) override;
bool MsgFunc_SayText(const char* pszName, int iSize, void* pbuf);
void SayTextPrint(const char* pszBuf, int iBufSize, int clientIndex = -1);
void EnsureTextFitsInOneLineAndWrapIfHaveTo(int line);
friend class CHudSpectator;
private:
struct cvar_s * m_HUD_saytext;
struct cvar_s * m_HUD_saytext_time;
struct cvar_s* m_HUD_saytext;
struct cvar_s* m_HUD_saytext_time;
};
//
//-----------------------------------------------------
//
class CHudBattery: public CHudBase
class CHudBattery : public CHudBase
{
public:
bool Init() override;
bool VidInit() override;
bool Draw(float flTime) override;
bool MsgFunc_Battery(const char *pszName, int iSize, void *pbuf );
bool MsgFunc_Battery(const char* pszName, int iSize, void* pbuf);
private:
HSPRITE m_hSprite1;
HSPRITE m_hSprite2;
Rect *m_prc1;
Rect *m_prc2;
int m_iBat;
int m_iBatMax;
Rect* m_prc1;
Rect* m_prc2;
int m_iBat;
int m_iBatMax;
float m_fFade;
int m_iHeight; // width of the battery innards
int m_iHeight; // width of the battery innards
};
//
//-----------------------------------------------------
//
class CHudFlashlight: public CHudBase
class CHudFlashlight : public CHudBase
{
public:
bool Init() override;
bool VidInit() override;
bool Draw(float flTime) override;
void Reset() override;
bool MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf );
bool MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf );
bool MsgFunc_Flashlight(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_FlashBat(const char* pszName, int iSize, void* pbuf);
private:
HSPRITE m_hSprite1;
HSPRITE m_hSprite2;
HSPRITE m_hBeam;
Rect *m_prc1;
Rect *m_prc2;
Rect *m_prcBeam;
float m_flBat;
int m_iBat;
bool m_fOn;
Rect* m_prc1;
Rect* m_prc2;
Rect* m_prcBeam;
float m_flBat;
int m_iBat;
bool m_fOn;
float m_fFade;
int m_iWidth; // width of the battery innards
int m_iWidth; // width of the battery innards
};
//
@ -372,10 +372,10 @@ private:
const int maxHUDMessages = 16;
struct message_parms_t
{
client_textmessage_t *pMessage;
float time;
client_textmessage_t* pMessage;
float time;
int x, y;
int totalWidth, totalHeight;
int totalWidth, totalHeight;
int width;
int lines;
int lineLength;
@ -391,47 +391,47 @@ struct message_parms_t
//-----------------------------------------------------
//
class CHudTextMessage: public CHudBase
class CHudTextMessage : public CHudBase
{
public:
bool Init() override;
static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size );
static char *BufferedLocaliseTextString( const char *msg );
const char *LookupString( const char *msg_name, int *msg_dest = NULL );
bool MsgFunc_TextMsg(const char *pszName, int iSize, void *pbuf);
static char* LocaliseTextString(const char* msg, char* dst_buffer, int buffer_size);
static char* BufferedLocaliseTextString(const char* msg);
const char* LookupString(const char* msg_name, int* msg_dest = NULL);
bool MsgFunc_TextMsg(const char* pszName, int iSize, void* pbuf);
};
//
//-----------------------------------------------------
//
class CHudMessage: public CHudBase
class CHudMessage : public CHudBase
{
public:
bool Init() override;
bool VidInit() override;
bool Draw(float flTime) override;
bool MsgFunc_HudText(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_HudTextPro(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_GameTitle(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_HudText(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_HudTextPro(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_GameTitle(const char* pszName, int iSize, void* pbuf);
float FadeBlend( float fadein, float fadeout, float hold, float localTime );
int XPosition( float x, int width, int lineWidth );
int YPosition( float y, int height );
float FadeBlend(float fadein, float fadeout, float hold, float localTime);
int XPosition(float x, int width, int lineWidth);
int YPosition(float y, int height);
void MessageAdd( const char *pName, float time );
void MessageAdd(client_textmessage_t * newMessage );
void MessageDrawScan( client_textmessage_t *pMessage, float time );
void MessageAdd(const char* pName, float time);
void MessageAdd(client_textmessage_t* newMessage);
void MessageDrawScan(client_textmessage_t* pMessage, float time);
void MessageScanStart();
void MessageScanNextChar();
void Reset() override;
private:
client_textmessage_t *m_pMessages[maxHUDMessages];
float m_startTime[maxHUDMessages];
message_parms_t m_parms;
float m_gameTitleTime;
client_textmessage_t *m_pGameTitle;
client_textmessage_t* m_pMessages[maxHUDMessages];
float m_startTime[maxHUDMessages];
message_parms_t m_parms;
float m_gameTitleTime;
client_textmessage_t* m_pGameTitle;
int m_HUD_title_life;
int m_HUD_title_half;
@ -440,30 +440,30 @@ private:
//
//-----------------------------------------------------
//
#define MAX_SPRITE_NAME_LENGTH 24
#define MAX_SPRITE_NAME_LENGTH 24
class CHudStatusIcons: public CHudBase
class CHudStatusIcons : public CHudBase
{
public:
bool Init() override;
bool VidInit() override;
void Reset() override;
bool Draw(float flTime) override;
bool MsgFunc_StatusIcon(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_StatusIcon(const char* pszName, int iSize, void* pbuf);
enum {
enum
{
MAX_ICONSPRITENAME_LENGTH = MAX_SPRITE_NAME_LENGTH,
MAX_ICONSPRITES = 4,
};
//had to make these public so CHud could access them (to enable concussion icon)
//could use a friend declaration instead...
void EnableIcon( const char *pszIconName, unsigned char red, unsigned char green, unsigned char blue );
void DisableIcon( const char *pszIconName );
void EnableIcon(const char* pszIconName, unsigned char red, unsigned char green, unsigned char blue);
void DisableIcon(const char* pszIconName);
private:
typedef struct
{
char szSpriteName[MAX_ICONSPRITENAME_LENGTH];
@ -473,7 +473,6 @@ private:
} icon_sprite_t;
icon_sprite_t m_IconList[MAX_ICONSPRITES];
};
//
@ -484,36 +483,35 @@ private:
class CHud
{
private:
HUDLIST *m_pHudList;
HSPRITE m_hsprLogo;
int m_iLogo;
client_sprite_t *m_pSpriteList;
int m_iSpriteCount;
int m_iSpriteCountAllRes;
float m_flMouseSensitivity;
int m_iConcussionEffect;
HUDLIST* m_pHudList;
HSPRITE m_hsprLogo;
int m_iLogo;
client_sprite_t* m_pSpriteList;
int m_iSpriteCount;
int m_iSpriteCountAllRes;
float m_flMouseSensitivity;
int m_iConcussionEffect;
public:
HSPRITE m_hsprCursor;
float m_flTime; // the current client time
float m_fOldTime; // the time at which the HUD was last redrawn
HSPRITE m_hsprCursor;
float m_flTime; // the current client time
float m_fOldTime; // the time at which the HUD was last redrawn
double m_flTimeDelta; // the difference between flTime and fOldTime
Vector m_vecOrigin;
Vector m_vecAngles;
int m_iKeyBits;
int m_iHideHUDDisplay;
int m_iFOV;
bool m_Teamplay;
int m_iRes;
cvar_t *m_pCvarStealMouse;
cvar_t *m_pCvarDraw;
Vector m_vecOrigin;
Vector m_vecAngles;
int m_iKeyBits;
int m_iHideHUDDisplay;
int m_iFOV;
bool m_Teamplay;
int m_iRes;
cvar_t* m_pCvarStealMouse;
cvar_t* m_pCvarDraw;
int m_iFontHeight;
int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b );
int DrawHudString(int x, int y, int iMaxX, const char *szString, int r, int g, int b );
int DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b );
int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b );
int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b);
int DrawHudString(int x, int y, int iMaxX, const char* szString, int r, int g, int b);
int DrawHudStringReverse(int xpos, int ypos, int iMinX, const char* szString, int r, int g, int b);
int DrawHudNumberString(int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b);
int GetNumWidth(int iNumber, int iFlags);
int GetHudNumberWidth(int number, int width, int flags);
@ -522,64 +520,65 @@ public:
private:
// the memory for these arrays are allocated in the first call to CHud::VidInit(), when the hud.txt and associated sprites are loaded.
// freed in ~CHud()
HSPRITE *m_rghSprites; /*[HUD_SPRITE_COUNT]*/ // the sprites loaded from hud.txt
Rect *m_rgrcRects; /*[HUD_SPRITE_COUNT]*/
char *m_rgszSpriteNames; /*[HUD_SPRITE_COUNT][MAX_SPRITE_NAME_LENGTH]*/
HSPRITE* m_rghSprites; /*[HUD_SPRITE_COUNT]*/ // the sprites loaded from hud.txt
Rect* m_rgrcRects; /*[HUD_SPRITE_COUNT]*/
char* m_rgszSpriteNames; /*[HUD_SPRITE_COUNT][MAX_SPRITE_NAME_LENGTH]*/
struct cvar_s* default_fov;
struct cvar_s *default_fov;
public:
HSPRITE GetSprite( int index )
HSPRITE GetSprite(int index)
{
return (index < 0) ? 0 : m_rghSprites[index];
}
Rect& GetSpriteRect( int index )
Rect& GetSpriteRect(int index)
{
return m_rgrcRects[index];
}
int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array
CHudAmmo m_Ammo;
CHudHealth m_Health;
CHudSpectator m_Spectator;
CHudGeiger m_Geiger;
CHudBattery m_Battery;
CHudTrain m_Train;
CHudFlashlight m_Flash;
CHudMessage m_Message;
CHudStatusBar m_StatusBar;
int GetSpriteIndex(const char* SpriteName); // gets a sprite index, for use in the m_rghSprites[] array
CHudAmmo m_Ammo;
CHudHealth m_Health;
CHudSpectator m_Spectator;
CHudGeiger m_Geiger;
CHudBattery m_Battery;
CHudTrain m_Train;
CHudFlashlight m_Flash;
CHudMessage m_Message;
CHudStatusBar m_StatusBar;
CHudDeathNotice m_DeathNotice;
CHudSayText m_SayText;
CHudMenu m_Menu;
CHudAmmoSecondary m_AmmoSecondary;
CHudSayText m_SayText;
CHudMenu m_Menu;
CHudAmmoSecondary m_AmmoSecondary;
CHudTextMessage m_TextMessage;
CHudStatusIcons m_StatusIcons;
void Init();
void VidInit();
void Think();
bool Redraw( float flTime, bool intermission );
bool UpdateClientData( client_data_t *cdata, float time );
bool Redraw(float flTime, bool intermission);
bool UpdateClientData(client_data_t* cdata, float time);
CHud() : m_iSpriteCount(0), m_pHudList(NULL) {}
~CHud(); // destructor, frees allocated memory
CHud() : m_iSpriteCount(0), m_pHudList(NULL) {}
~CHud(); // destructor, frees allocated memory
// user messages
bool MsgFunc_Damage(const char *pszName, int iSize, void *pbuf );
bool MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf );
bool MsgFunc_Logo(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf);
void MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf );
void MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf);
bool MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf );
bool MsgFunc_Damage(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_GameMode(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_Logo(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_ResetHUD(const char* pszName, int iSize, void* pbuf);
void MsgFunc_InitHUD(const char* pszName, int iSize, void* pbuf);
void MsgFunc_ViewMode(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_SetFOV(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_Concuss(const char* pszName, int iSize, void* pbuf);
// Screen information
SCREENINFO m_scrinfo;
SCREENINFO m_scrinfo;
int m_iWeaponBits;
int m_iWeaponBits;
bool m_fPlayerDead;
bool m_iIntermission;
@ -587,10 +586,9 @@ public:
int m_HUD_number_0;
void AddHudElem(CHudBase *p);
void AddHudElem(CHudBase* p);
float GetSensitivity();
};
extern CHud gHUD;
@ -600,4 +598,3 @@ extern int g_iTeamNumber;
extern int g_iUser1;
extern int g_iUser2;
extern int g_iUser3;

View file

@ -22,32 +22,32 @@
#include "r_efx.h"
#include "particleman.h"
extern IParticleMan *g_pParticleMan;
extern IParticleMan* g_pParticleMan;
#define MAX_CLIENTS 32
#if !defined( _TFC )
extern BEAM *pBeam;
extern BEAM *pBeam2;
extern TEMPENTITY* pFlare; // Vit_amiN
#endif
#if !defined(_TFC)
extern BEAM* pBeam;
extern BEAM* pBeam2;
extern TEMPENTITY* pFlare; // Vit_amiN
#endif
#if defined( _TFC )
#if defined(_TFC)
void ClearEventList();
#endif
/// USER-DEFINED SERVER MESSAGE HANDLERS
bool CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
bool CHud ::MsgFunc_ResetHUD(const char* pszName, int iSize, void* pbuf)
{
ASSERT( iSize == 0 );
ASSERT(iSize == 0);
// clear all hud data
HUDLIST *pList = m_pHudList;
HUDLIST* pList = m_pHudList;
while ( pList )
while (pList)
{
if ( pList->p )
if (pList->p)
pList->p->Reset();
pList = pList->pNext;
}
@ -63,44 +63,44 @@ bool CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
void CAM_ToFirstPerson();
void CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
void CHud ::MsgFunc_ViewMode(const char* pszName, int iSize, void* pbuf)
{
CAM_ToFirstPerson();
}
void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
void CHud ::MsgFunc_InitHUD(const char* pszName, int iSize, void* pbuf)
{
// prepare all hud data
HUDLIST *pList = m_pHudList;
HUDLIST* pList = m_pHudList;
while (pList)
{
if ( pList->p )
if (pList->p)
pList->p->InitHUDData();
pList = pList->pNext;
}
#if defined( _TFC )
#if defined(_TFC)
ClearEventList();
// catch up on any building events that are going on
gEngfuncs.pfnServerCmd("sendevents");
#endif
if ( g_pParticleMan )
g_pParticleMan->ResetParticles();
if (g_pParticleMan)
g_pParticleMan->ResetParticles();
#if !defined( _TFC )
#if !defined(_TFC)
//Probably not a good place to put this.
pBeam = pBeam2 = NULL;
pFlare = NULL; // Vit_amiN: clear egon's beam flare
pFlare = NULL; // Vit_amiN: clear egon's beam flare
#endif
}
bool CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
bool CHud ::MsgFunc_GameMode(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
//Note: this user message could be updated to include multiple gamemodes, so make sure this checks for game mode 1
//See CHalfLifeTeamplay::UpdateGameMode
//TODO: define game mode constants
@ -110,18 +110,18 @@ bool CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
}
bool CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
bool CHud ::MsgFunc_Damage(const char* pszName, int iSize, void* pbuf)
{
int armor, blood;
Vector from;
int i;
float count;
BEGIN_READ( pbuf, iSize );
int armor, blood;
Vector from;
int i;
float count;
BEGIN_READ(pbuf, iSize);
armor = READ_BYTE();
blood = READ_BYTE();
for (i=0 ; i<3 ; i++)
for (i = 0; i < 3; i++)
from[i] = READ_COORD();
count = (blood * 0.5) + (armor * 0.5);
@ -134,9 +134,9 @@ bool CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
return true;
}
bool CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
bool CHud ::MsgFunc_Concuss(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
m_iConcussionEffect = READ_BYTE();
if (0 != m_iConcussionEffect)
{

View file

@ -22,19 +22,18 @@
#define MAX_LOGO_FRAMES 56
int grgLogoFrame[MAX_LOGO_FRAMES] =
{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, 13, 13, 13, 12, 11, 10, 9, 8, 14, 15,
16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31
};
int grgLogoFrame[MAX_LOGO_FRAMES] =
{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, 13, 13, 13, 12, 11, 10, 9, 8, 14, 15,
16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31};
extern bool g_iVisibleMouse;
float HUD_GetFOV();
extern cvar_t *sensitivity;
extern cvar_t* sensitivity;
// Think
void CHud::Think()
@ -43,7 +42,7 @@ void CHud::Think()
GetScreenInfo(&m_scrinfo);
int newfov;
HUDLIST *pList = m_pHudList;
HUDLIST* pList = m_pHudList;
while (pList)
{
@ -53,7 +52,7 @@ void CHud::Think()
}
newfov = HUD_GetFOV();
if ( newfov == 0 )
if (newfov == 0)
{
m_iFOV = default_fov->value;
}
@ -65,47 +64,47 @@ void CHud::Think()
// the clients fov is actually set in the client data update section of the hud
// Set a new sensitivity
if ( m_iFOV == default_fov->value )
{
if (m_iFOV == default_fov->value)
{
// reset to saved sensitivity
m_flMouseSensitivity = 0;
}
else
{
{
// set a new sensitivity that is proportional to the change from the FOV default
m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)default_fov->value) * CVAR_GET_FLOAT("zoom_sensitivity_ratio");
}
// think about default fov
if ( m_iFOV == 0 )
{ // only let players adjust up in fov, and only if they are not overriden by something else
m_iFOV = V_max( default_fov->value, 90 );
if (m_iFOV == 0)
{ // only let players adjust up in fov, and only if they are not overriden by something else
m_iFOV = V_max(default_fov->value, 90);
}
if (0 != gEngfuncs.IsSpectateOnly() )
if (0 != gEngfuncs.IsSpectateOnly())
{
m_iFOV = gHUD.m_Spectator.GetFOV(); // default_fov->value;
m_iFOV = gHUD.m_Spectator.GetFOV(); // default_fov->value;
}
}
// Redraw
// step through the local data, placing the appropriate graphics & text as appropriate
// returns 1 if they've changed, 0 otherwise
bool CHud :: Redraw( float flTime, bool intermission )
bool CHud ::Redraw(float flTime, bool intermission)
{
m_fOldTime = m_flTime; // save time of previous redraw
m_fOldTime = m_flTime; // save time of previous redraw
m_flTime = flTime;
m_flTimeDelta = (double)m_flTime - m_fOldTime;
static float m_flShotTime = 0;
// Clock was reset, reset delta
if ( m_flTimeDelta < 0 )
if (m_flTimeDelta < 0)
m_flTimeDelta = 0;
// Bring up the scoreboard during intermission
if (gViewPort)
{
if ( m_iIntermission && !intermission )
if (m_iIntermission && !intermission)
{
// Have to do this here so the scoreboard goes away
m_iIntermission = intermission;
@ -113,7 +112,7 @@ bool CHud :: Redraw( float flTime, bool intermission )
gViewPort->HideScoreBoard();
gViewPort->UpdateSpectatorPanel();
}
else if ( !m_iIntermission && intermission )
else if (!m_iIntermission && intermission)
{
m_iIntermission = intermission;
gViewPort->HideCommandMenu();
@ -122,8 +121,8 @@ bool CHud :: Redraw( float flTime, bool intermission )
gViewPort->UpdateSpectatorPanel();
// Take a screenshot if the client's got the cvar set
if ( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
m_flShotTime = flTime + 1.0; // Take a screenshot in a second
if (CVAR_GET_FLOAT("hud_takesshots") != 0)
m_flShotTime = flTime + 1.0; // Take a screenshot in a second
}
}
@ -137,23 +136,23 @@ bool CHud :: Redraw( float flTime, bool intermission )
// if no redrawing is necessary
// return 0;
// draw all registered HUD elements
if ( 0 != m_pCvarDraw->value )
if (0 != m_pCvarDraw->value)
{
HUDLIST *pList = m_pHudList;
HUDLIST* pList = m_pHudList;
while (pList)
{
if ( !intermission )
if (!intermission)
{
if ( (pList->p->m_iFlags & HUD_ACTIVE) != 0 && (m_iHideHUDDisplay & HIDEHUD_ALL) == 0)
if ((pList->p->m_iFlags & HUD_ACTIVE) != 0 && (m_iHideHUDDisplay & HIDEHUD_ALL) == 0)
pList->p->Draw(flTime);
}
else
{ // it's an intermission, so only draw hud elements that are set to draw during intermissions
if ( (pList->p->m_iFlags & HUD_INTERMISSION ) != 0)
pList->p->Draw( flTime );
{ // it's an intermission, so only draw hud elements that are set to draw during intermissions
if ((pList->p->m_iFlags & HUD_INTERMISSION) != 0)
pList->p->Draw(flTime);
}
pList = pList->pNext;
@ -168,11 +167,11 @@ bool CHud :: Redraw( float flTime, bool intermission )
if (m_hsprLogo == 0)
m_hsprLogo = LoadSprite("sprites/%d_logo.spr");
SPR_Set(m_hsprLogo, 250, 250, 250 );
SPR_Set(m_hsprLogo, 250, 250, 250);
x = SPR_Width(m_hsprLogo, 0);
x = ScreenWidth - x;
y = SPR_Height(m_hsprLogo, 0)/2;
y = SPR_Height(m_hsprLogo, 0) / 2;
// Draw the logo at 20 fps
int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
@ -206,7 +205,7 @@ bool CHud :: Redraw( float flTime, bool intermission )
return true;
}
void ScaleColors( int &r, int &g, int &b, int a )
void ScaleColors(int& r, int& g, int& b, int a)
{
float x = (float)a / 255;
r = (int)(r * x);
@ -214,38 +213,37 @@ void ScaleColors( int &r, int &g, int &b, int a )
b = (int)(b * x);
}
int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b )
int CHud ::DrawHudString(int xpos, int ypos, int iMaxX, const char* szIt, int r, int g, int b)
{
return xpos + gEngfuncs.pfnDrawString( xpos, ypos, szIt, r, g, b);
return xpos + gEngfuncs.pfnDrawString(xpos, ypos, szIt, r, g, b);
}
int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
int CHud ::DrawHudNumberString(int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b)
{
char szString[32];
sprintf( szString, "%d", iNumber );
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
sprintf(szString, "%d", iNumber);
return DrawHudStringReverse(xpos, ypos, iMinX, szString, r, g, b);
}
// draws a string from right to left (right-aligned)
int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b )
int CHud ::DrawHudStringReverse(int xpos, int ypos, int iMinX, const char* szString, int r, int g, int b)
{
return xpos - gEngfuncs.pfnDrawStringReverse( xpos, ypos, szString, r, g, b);
return xpos - gEngfuncs.pfnDrawStringReverse(xpos, ypos, szString, r, g, b);
}
int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b)
int CHud ::DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b)
{
int iWidth = GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left;
int k;
if (iNumber > 0)
{
// SPR_Draw 100's
if (iNumber >= 100)
{
k = iNumber/100;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
k = iNumber / 100;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b);
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
x += iWidth;
}
else if ((iFlags & DHN_3DIGITS) != 0)
@ -257,9 +255,9 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g,
// SPR_Draw 10's
if (iNumber >= 10)
{
k = (iNumber % 100)/10;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
k = (iNumber % 100) / 10;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b);
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
x += iWidth;
}
else if ((iFlags & (DHN_3DIGITS | DHN_2DIGITS)) != 0)
@ -270,13 +268,13 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g,
// SPR_Draw ones
k = iNumber % 10;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b);
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
x += iWidth;
}
}
else if ((iFlags & DHN_DRAWZERO) != 0)
{
SPR_Set(GetSprite(m_HUD_number_0), r, g, b );
SPR_Set(GetSprite(m_HUD_number_0), r, g, b);
// SPR_Draw 100's
if ((iFlags & DHN_3DIGITS) != 0)
@ -292,8 +290,8 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g,
}
// SPR_Draw ones
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0));
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0));
x += iWidth;
}
@ -301,7 +299,7 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g,
}
int CHud::GetNumWidth( int iNumber, int iFlags )
int CHud::GetNumWidth(int iNumber, int iFlags)
{
if ((iFlags & DHN_3DIGITS) != 0)
return 3;
@ -324,8 +322,7 @@ int CHud::GetNumWidth( int iNumber, int iFlags )
return 2;
return 3;
}
}
int CHud::GetHudNumberWidth(int number, int width, int flags)
{
@ -367,10 +364,8 @@ int CHud::DrawHudNumberReverse(int x, int y, int number, int flags, int r, int g
SPR_DrawAdditive(0, x, y, &GetSpriteRect(digitSpriteIndex));
remainder /= 10;
}
while (remainder > 0);
} while (remainder > 0);
}
return x;
}

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
//========= Copyright <20> 1996-2001, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -11,142 +11,144 @@
#include "interpolation.h"
#define INSET_OFF 0
#define INSET_CHASE_FREE 1
#define INSET_IN_EYE 2
#define INSET_MAP_FREE 3
#define INSET_MAP_CHASE 4
#define INSET_OFF 0
#define INSET_CHASE_FREE 1
#define INSET_IN_EYE 2
#define INSET_MAP_FREE 3
#define INSET_MAP_CHASE 4
#define MAX_SPEC_HUD_MESSAGES 8
#define MAX_SPEC_HUD_MESSAGES 8
#define OVERVIEW_TILE_SIZE 128 // don't change this
#define OVERVIEW_MAX_LAYERS 1
#define OVERVIEW_TILE_SIZE 128 // don't change this
#define OVERVIEW_MAX_LAYERS 1
extern void VectorAngles( const float *forward, float *angles );
void NormalizeAngles( float* angles );
extern void VectorAngles(const float* forward, float* angles);
void NormalizeAngles(float* angles);
//-----------------------------------------------------------------------------
// Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it )
//-----------------------------------------------------------------------------
typedef struct overviewInfo_s {
char map[64]; // cl.levelname or empty
Vector origin; // center of map
float zoom; // zoom of map images
int layers; // how may layers do we have
float layersHeights[OVERVIEW_MAX_LAYERS];
char layersImages[OVERVIEW_MAX_LAYERS][255];
bool rotated; // are map images rotated (90 degrees) ?
int insetWindowX;
int insetWindowY;
int insetWindowHeight;
int insetWindowWidth;
typedef struct overviewInfo_s
{
char map[64]; // cl.levelname or empty
Vector origin; // center of map
float zoom; // zoom of map images
int layers; // how may layers do we have
float layersHeights[OVERVIEW_MAX_LAYERS];
char layersImages[OVERVIEW_MAX_LAYERS][255];
bool rotated; // are map images rotated (90 degrees) ?
int insetWindowX;
int insetWindowY;
int insetWindowHeight;
int insetWindowWidth;
} overviewInfo_t;
typedef struct overviewEntity_s {
typedef struct overviewEntity_s
{
HSPRITE hSprite;
struct cl_entity_s * entity;
double killTime;
HSPRITE hSprite;
struct cl_entity_s* entity;
double killTime;
} overviewEntity_t;
typedef struct cameraWayPoint_s
typedef struct cameraWayPoint_s
{
float time;
Vector position;
Vector angle;
float fov;
int flags;
float time;
Vector position;
Vector angle;
float fov;
int flags;
} cameraWayPoint_t;
#define MAX_OVERVIEW_ENTITIES 128
#define MAX_CAM_WAYPOINTS 32
#define MAX_OVERVIEW_ENTITIES 128
#define MAX_CAM_WAYPOINTS 32
class CHudSpectator : public CHudBase
{
public:
void Reset() override;
int ToggleInset(bool allowOff);
int ToggleInset(bool allowOff);
void CheckSettings();
void InitHUDData() override;
bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime);
bool AddOverviewEntityToList(HSPRITE sprite, cl_entity_t* ent, double killTime);
void DeathMessage(int victim);
bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname );
bool AddOverviewEntity(int type, struct cl_entity_s* ent, const char* modelname);
void CheckOverviewEntities();
void DrawOverview();
void DrawOverviewEntities();
void GetMapPosition( float * returnvec );
void GetMapPosition(float* returnvec);
void DrawOverviewLayer();
void LoadMapSprites();
bool ParseOverviewFile();
bool IsActivePlayer(cl_entity_t * ent);
bool IsActivePlayer(cl_entity_t* ent);
void SetModes(int iMainMode, int iInsetMode);
void HandleButtonsDown(int ButtonPressed);
void HandleButtonsUp(int ButtonPressed);
void FindNextPlayer( bool bReverse );
void FindPlayer(const char *name);
void DirectorMessage( int iSize, void *pbuf );
void FindNextPlayer(bool bReverse);
void FindPlayer(const char* name);
void DirectorMessage(int iSize, void* pbuf);
void SetSpectatorStartPosition();
bool Init() override;
bool VidInit() override;
bool Draw(float flTime) override;
void AddWaypoint( float time, Vector pos, Vector angle, float fov, int flags );
void SetCameraView(Vector pos, Vector angle, float fov);
float GetFOV();
bool GetDirectorCamera(Vector&position, Vector&angle);
void SetWayInterpolation(cameraWayPoint_t * prev, cameraWayPoint_t * start, cameraWayPoint_t * end, cameraWayPoint_t * next);
void AddWaypoint(float time, Vector pos, Vector angle, float fov, int flags);
void SetCameraView(Vector pos, Vector angle, float fov);
float GetFOV();
bool GetDirectorCamera(Vector& position, Vector& angle);
void SetWayInterpolation(cameraWayPoint_t* prev, cameraWayPoint_t* start, cameraWayPoint_t* end, cameraWayPoint_t* next);
int m_iDrawCycle;
client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES];
char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128];
int m_lastHudMessage;
overviewInfo_t m_OverviewData;
overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES];
int m_iObserverFlags;
int m_iSpectatorNumber;
float m_mapZoom; // zoom the user currently uses
Vector m_mapOrigin; // origin where user rotates around
cvar_t * m_drawnames;
cvar_t * m_drawcone;
cvar_t * m_drawstatus;
cvar_t * m_autoDirector;
cvar_t * m_pip;
bool m_chatEnabled;
bool m_IsInterpolating;
int m_ChaseEntity; // if != 0, follow this entity with viewangles
int m_WayPoint; // current waypoint 1
int m_NumWayPoints; // current number of waypoints
Vector m_cameraOrigin; // a help camera
Vector m_cameraAngles; // and it's angles
CInterpolation m_WayInterpolation;
char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128];
int m_lastHudMessage;
overviewInfo_t m_OverviewData;
overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES];
int m_iObserverFlags;
int m_iSpectatorNumber;
float m_mapZoom; // zoom the user currently uses
Vector m_mapOrigin; // origin where user rotates around
cvar_t* m_drawnames;
cvar_t* m_drawcone;
cvar_t* m_drawstatus;
cvar_t* m_autoDirector;
cvar_t* m_pip;
bool m_chatEnabled;
bool m_IsInterpolating;
int m_ChaseEntity; // if != 0, follow this entity with viewangles
int m_WayPoint; // current waypoint 1
int m_NumWayPoints; // current number of waypoints
Vector m_cameraOrigin; // a help camera
Vector m_cameraAngles; // and it's angles
CInterpolation m_WayInterpolation;
private:
Vector m_vPlayerPos[MAX_PLAYERS];
HSPRITE m_hsprPlayerBlue;
HSPRITE m_hsprPlayerRed;
HSPRITE m_hsprPlayer;
HSPRITE m_hsprCamera;
HSPRITE m_hsprPlayerDead;
HSPRITE m_hsprViewcone;
HSPRITE m_hsprUnkownMap;
HSPRITE m_hsprBeam;
HSPRITE m_hCrosshair;
Vector m_vPlayerPos[MAX_PLAYERS];
HSPRITE m_hsprPlayerBlue;
HSPRITE m_hsprPlayerRed;
HSPRITE m_hsprPlayer;
HSPRITE m_hsprCamera;
HSPRITE m_hsprPlayerDead;
HSPRITE m_hsprViewcone;
HSPRITE m_hsprUnkownMap;
HSPRITE m_hsprBeam;
HSPRITE m_hCrosshair;
Rect m_crosshairRect;
Rect m_crosshairRect;
struct model_s * m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame
float m_flNextObserverInput;
float m_FOV;
float m_zoomDelta;
float m_moveDelta;
int m_lastPrimaryObject;
int m_lastSecondaryObject;
struct model_s* m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame
float m_flNextObserverInput;
float m_FOV;
float m_zoomDelta;
float m_moveDelta;
int m_lastPrimaryObject;
int m_lastSecondaryObject;
cameraWayPoint_t m_CamPath[MAX_CAM_WAYPOINTS];
cameraWayPoint_t m_CamPath[MAX_CAM_WAYPOINTS];
};

View file

@ -21,19 +21,19 @@
#include <stdlib.h>
#include <memory.h>
int CL_ButtonBits( bool );
void CL_ResetButtonBits( int bits );
int CL_ButtonBits(bool);
void CL_ResetButtonBits(int bits);
extern float v_idlescale;
float in_fov;
extern void HUD_SetCmdBits( int bits );
extern void HUD_SetCmdBits(int bits);
bool CHud::UpdateClientData(client_data_t *cdata, float time)
bool CHud::UpdateClientData(client_data_t* cdata, float time)
{
memcpy(m_vecOrigin, cdata->origin, sizeof(Vector));
memcpy(m_vecAngles, cdata->viewangles, sizeof(Vector));
m_iKeyBits = CL_ButtonBits( false );
m_iKeyBits = CL_ButtonBits(false);
m_iWeaponBits = cdata->iWeaponBits;
in_fov = cdata->fov;
@ -41,13 +41,11 @@ bool CHud::UpdateClientData(client_data_t *cdata, float time)
Think();
cdata->fov = m_iFOV;
v_idlescale = m_iConcussionEffect;
CL_ResetButtonBits( m_iKeyBits );
CL_ResetButtonBits(m_iKeyBits);
// return 1 if in anything in the client_data struct has been changed, 0 otherwise
return true;
}

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -18,7 +18,7 @@
#include "SDL2/SDL_mouse.h"
float CL_KeyState (kbutton_t *key);
float CL_KeyState(kbutton_t* key);
extern cl_enginefunc_t gEngfuncs;
@ -32,8 +32,8 @@ extern cl_enginefunc_t gEngfuncs;
#define MAX_ANGLE_DIFF 10.0
#define PITCH_MAX 90.0
#define PITCH_MIN 0
#define YAW_MAX 135.0
#define YAW_MIN -135.0
#define YAW_MAX 135.0
#define YAW_MIN -135.0
enum ECAM_Command
{
@ -44,19 +44,19 @@ enum ECAM_Command
//-------------------------------------------------- Global Variables
cvar_t *cam_command;
cvar_t *cam_snapto;
cvar_t *cam_idealyaw;
cvar_t *cam_idealpitch;
cvar_t *cam_idealdist;
cvar_t *cam_contain;
cvar_t* cam_command;
cvar_t* cam_snapto;
cvar_t* cam_idealyaw;
cvar_t* cam_idealpitch;
cvar_t* cam_idealdist;
cvar_t* cam_contain;
cvar_t *c_maxpitch;
cvar_t *c_minpitch;
cvar_t *c_maxyaw;
cvar_t *c_minyaw;
cvar_t *c_maxdistance;
cvar_t *c_mindistance;
cvar_t* c_maxpitch;
cvar_t* c_minpitch;
cvar_t* c_maxyaw;
cvar_t* c_minyaw;
cvar_t* c_maxdistance;
cvar_t* c_mindistance;
// pitch, yaw, dist
Vector cam_ofs;
@ -65,11 +65,11 @@ Vector cam_ofs;
// In third person
bool cam_thirdperson;
bool cam_mousemove; //true if we are moving the cam with the mouse, False if not
bool iMouseInUse=false;
bool iMouseInUse = false;
bool cam_distancemove;
extern int mouse_x, mouse_y; //used to determine what the current x and y values are
extern int mouse_x, mouse_y; //used to determine what the current x and y values are
int cam_old_mouse_x, cam_old_mouse_y; //holds the last ticks mouse movement
Point cam_mouse;
Point cam_mouse;
//-------------------------------------------------- Local Variables
static kbutton_t cam_pitchup, cam_pitchdown, cam_yawleft, cam_yawright;
@ -82,41 +82,41 @@ void CAM_ToFirstPerson();
void CAM_StartDistance();
void CAM_EndDistance();
void SDL_GetCursorPos( Point *p )
void SDL_GetCursorPos(Point* p)
{
gEngfuncs.GetMousePosition( &p->x, &p->y );
// SDL_GetMouseState( &p->x, &p->y );
gEngfuncs.GetMousePosition(&p->x, &p->y);
// SDL_GetMouseState( &p->x, &p->y );
}
void SDL_SetCursorPos( const int x, const int y )
void SDL_SetCursorPos(const int x, const int y)
{
}
//-------------------------------------------------- Local Functions
float MoveToward( float cur, float goal, float maxspeed )
float MoveToward(float cur, float goal, float maxspeed)
{
if( cur != goal )
if (cur != goal)
{
if( fabs( cur - goal ) > 180.0 )
if (fabs(cur - goal) > 180.0)
{
if( cur < goal )
if (cur < goal)
cur += 360.0;
else
cur -= 360.0;
}
if( cur < goal )
if (cur < goal)
{
if( cur < goal - 1.0 )
cur += ( goal - cur ) / 4.0;
if (cur < goal - 1.0)
cur += (goal - cur) / 4.0;
else
cur = goal;
}
else
{
if( cur > goal + 1.0 )
cur -= ( cur - goal ) / 4.0;
if (cur > goal + 1.0)
cur -= (cur - goal) / 4.0;
else
cur = goal;
}
@ -124,9 +124,9 @@ float MoveToward( float cur, float goal, float maxspeed )
// bring cur back into range
if( cur < 0 )
if (cur < 0)
cur += 360.0;
else if( cur >= 360 )
else if (cur >= 360)
cur -= 360;
return cur;
@ -137,25 +137,25 @@ float MoveToward( float cur, float goal, float maxspeed )
typedef struct
{
Vector boxmins, boxmaxs;// enclose the test object along entire move
float *mins, *maxs; // size of the moving object
Vector mins2, maxs2; // size when clipping against mosnters
float *start, *end;
trace_t trace;
int type;
edict_t *passedict;
qboolean monsterclip;
Vector boxmins, boxmaxs; // enclose the test object along entire move
float *mins, *maxs; // size of the moving object
Vector mins2, maxs2; // size when clipping against mosnters
float *start, *end;
trace_t trace;
int type;
edict_t* passedict;
qboolean monsterclip;
} moveclip_t;
extern trace_t SV_ClipMoveToEntity (edict_t *ent, Vector start, Vector mins, Vector maxs, Vector end);
extern trace_t SV_ClipMoveToEntity(edict_t* ent, Vector start, Vector mins, Vector maxs, Vector end);
void DLLEXPORT CAM_Think()
{
// RecClCamThink();
// RecClCamThink();
Vector origin;
Vector ext, pnt, camForward, camRight, camUp;
moveclip_t clip;
moveclip_t clip;
float dist;
Vector camAngles;
float flSensitivity;
@ -164,193 +164,190 @@ void DLLEXPORT CAM_Think()
#endif
Vector viewangles;
switch( (int) cam_command->value )
switch ((int)cam_command->value)
{
case CAM_COMMAND_TOTHIRDPERSON:
CAM_ToThirdPerson();
break;
case CAM_COMMAND_TOTHIRDPERSON:
CAM_ToThirdPerson();
break;
case CAM_COMMAND_TOFIRSTPERSON:
CAM_ToFirstPerson();
break;
case CAM_COMMAND_TOFIRSTPERSON:
CAM_ToFirstPerson();
break;
case CAM_COMMAND_NONE:
default:
break;
case CAM_COMMAND_NONE:
default:
break;
}
if( !cam_thirdperson )
if (!cam_thirdperson)
return;
#ifdef LATER
if ( cam_contain->value )
if (cam_contain->value)
{
gEngfuncs.GetClientOrigin( origin );
gEngfuncs.GetClientOrigin(origin);
ext[0] = ext[1] = ext[2] = 0.0;
}
#endif
camAngles[ PITCH ] = cam_idealpitch->value;
camAngles[ YAW ] = cam_idealyaw->value;
camAngles[PITCH] = cam_idealpitch->value;
camAngles[YAW] = cam_idealyaw->value;
dist = cam_idealdist->value;
//
//movement of the camera with the mouse
//
if (cam_mousemove)
{
//get windows cursor position
SDL_GetCursorPos (&cam_mouse);
//get windows cursor position
SDL_GetCursorPos(&cam_mouse);
//check for X delta values and adjust accordingly
//eventually adjust YAW based on amount of movement
//don't do any movement of the cam using YAW/PITCH if we are zooming in/out the camera
if (!cam_distancemove)
{
//keep the camera within certain limits around the player (ie avoid certain bad viewing angles)
if (cam_mouse.x>gEngfuncs.GetWindowCenterX())
//don't do any movement of the cam using YAW/PITCH if we are zooming in/out the camera
if (!cam_distancemove)
{
//if ((camAngles[YAW]>=225.0)||(camAngles[YAW]<135.0))
if (camAngles[YAW]<c_maxyaw->value)
{
camAngles[ YAW ] += (CAM_ANGLE_MOVE)*((cam_mouse.x-gEngfuncs.GetWindowCenterX())/2);
}
if (camAngles[YAW]>c_maxyaw->value)
{
camAngles[YAW]=c_maxyaw->value;
}
}
else if (cam_mouse.x<gEngfuncs.GetWindowCenterX())
{
//if ((camAngles[YAW]<=135.0)||(camAngles[YAW]>225.0))
if (camAngles[YAW]>c_minyaw->value)
{
camAngles[ YAW ] -= (CAM_ANGLE_MOVE)* ((gEngfuncs.GetWindowCenterX()-cam_mouse.x)/2);
}
if (camAngles[YAW]<c_minyaw->value)
{
camAngles[YAW]=c_minyaw->value;
}
}
//check for y delta values and adjust accordingly
//eventually adjust PITCH based on amount of movement
//also make sure camera is within bounds
if (cam_mouse.y>gEngfuncs.GetWindowCenterY())
{
if(camAngles[PITCH]<c_maxpitch->value)
//keep the camera within certain limits around the player (ie avoid certain bad viewing angles)
if (cam_mouse.x > gEngfuncs.GetWindowCenterX())
{
camAngles[PITCH] +=(CAM_ANGLE_MOVE)* ((cam_mouse.y-gEngfuncs.GetWindowCenterY())/2);
}
if (camAngles[PITCH]>c_maxpitch->value)
{
camAngles[PITCH]=c_maxpitch->value;
}
}
else if (cam_mouse.y<gEngfuncs.GetWindowCenterY())
{
if (camAngles[PITCH]>c_minpitch->value)
{
camAngles[PITCH] -= (CAM_ANGLE_MOVE)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2);
}
if (camAngles[PITCH]<c_minpitch->value)
{
camAngles[PITCH]=c_minpitch->value;
}
}
//if ((camAngles[YAW]>=225.0)||(camAngles[YAW]<135.0))
if (camAngles[YAW] < c_maxyaw->value)
{
camAngles[YAW] += (CAM_ANGLE_MOVE) * ((cam_mouse.x - gEngfuncs.GetWindowCenterX()) / 2);
}
if (camAngles[YAW] > c_maxyaw->value)
{
//set old mouse coordinates to current mouse coordinates
//since we are done with the mouse
camAngles[YAW] = c_maxyaw->value;
}
}
else if (cam_mouse.x < gEngfuncs.GetWindowCenterX())
{
//if ((camAngles[YAW]<=135.0)||(camAngles[YAW]>225.0))
if (camAngles[YAW] > c_minyaw->value)
{
camAngles[YAW] -= (CAM_ANGLE_MOVE) * ((gEngfuncs.GetWindowCenterX() - cam_mouse.x) / 2);
}
if (camAngles[YAW] < c_minyaw->value)
{
camAngles[YAW] = c_minyaw->value;
}
}
if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
{
cam_old_mouse_x=cam_mouse.x*flSensitivity;
cam_old_mouse_y=cam_mouse.y*flSensitivity;
//check for y delta values and adjust accordingly
//eventually adjust PITCH based on amount of movement
//also make sure camera is within bounds
if (cam_mouse.y > gEngfuncs.GetWindowCenterY())
{
if (camAngles[PITCH] < c_maxpitch->value)
{
camAngles[PITCH] += (CAM_ANGLE_MOVE) * ((cam_mouse.y - gEngfuncs.GetWindowCenterY()) / 2);
}
if (camAngles[PITCH] > c_maxpitch->value)
{
camAngles[PITCH] = c_maxpitch->value;
}
}
else if (cam_mouse.y < gEngfuncs.GetWindowCenterY())
{
if (camAngles[PITCH] > c_minpitch->value)
{
camAngles[PITCH] -= (CAM_ANGLE_MOVE) * ((gEngfuncs.GetWindowCenterY() - cam_mouse.y) / 2);
}
if (camAngles[PITCH] < c_minpitch->value)
{
camAngles[PITCH] = c_minpitch->value;
}
}
//set old mouse coordinates to current mouse coordinates
//since we are done with the mouse
if ((flSensitivity = gHUD.GetSensitivity()) != 0)
{
cam_old_mouse_x = cam_mouse.x * flSensitivity;
cam_old_mouse_y = cam_mouse.y * flSensitivity;
}
else
{
cam_old_mouse_x = cam_mouse.x;
cam_old_mouse_y = cam_mouse.y;
}
SDL_SetCursorPos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
}
else
{
cam_old_mouse_x=cam_mouse.x;
cam_old_mouse_y=cam_mouse.y;
}
SDL_SetCursorPos (gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
}
}
//Nathan code here
if( 0 != CL_KeyState( &cam_pitchup ) )
camAngles[ PITCH ] += CAM_ANGLE_DELTA;
else if(0 != CL_KeyState( &cam_pitchdown ) )
camAngles[ PITCH ] -= CAM_ANGLE_DELTA;
if (0 != CL_KeyState(&cam_pitchup))
camAngles[PITCH] += CAM_ANGLE_DELTA;
else if (0 != CL_KeyState(&cam_pitchdown))
camAngles[PITCH] -= CAM_ANGLE_DELTA;
if(0 != CL_KeyState( &cam_yawleft ) )
camAngles[ YAW ] -= CAM_ANGLE_DELTA;
else if(0 != CL_KeyState( &cam_yawright ) )
camAngles[ YAW ] += CAM_ANGLE_DELTA;
if (0 != CL_KeyState(&cam_yawleft))
camAngles[YAW] -= CAM_ANGLE_DELTA;
else if (0 != CL_KeyState(&cam_yawright))
camAngles[YAW] += CAM_ANGLE_DELTA;
if(0 != CL_KeyState( &cam_in ) )
if (0 != CL_KeyState(&cam_in))
{
dist -= CAM_DIST_DELTA;
if( dist < CAM_MIN_DIST )
if (dist < CAM_MIN_DIST)
{
// If we go back into first person, reset the angle
camAngles[ PITCH ] = 0;
camAngles[ YAW ] = 0;
camAngles[PITCH] = 0;
camAngles[YAW] = 0;
dist = CAM_MIN_DIST;
}
}
else if(0 != CL_KeyState( &cam_out ) )
else if (0 != CL_KeyState(&cam_out))
dist += CAM_DIST_DELTA;
if (cam_distancemove)
{
if (cam_mouse.y>gEngfuncs.GetWindowCenterY())
if (cam_mouse.y > gEngfuncs.GetWindowCenterY())
{
if(dist<c_maxdistance->value)
if (dist < c_maxdistance->value)
{
dist +=CAM_DIST_DELTA * ((cam_mouse.y-gEngfuncs.GetWindowCenterY())/2);
dist += CAM_DIST_DELTA * ((cam_mouse.y - gEngfuncs.GetWindowCenterY()) / 2);
}
if (dist>c_maxdistance->value)
if (dist > c_maxdistance->value)
{
dist=c_maxdistance->value;
dist = c_maxdistance->value;
}
}
else if (cam_mouse.y<gEngfuncs.GetWindowCenterY())
else if (cam_mouse.y < gEngfuncs.GetWindowCenterY())
{
if (dist>c_mindistance->value)
if (dist > c_mindistance->value)
{
dist -= (CAM_DIST_DELTA)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2);
dist -= (CAM_DIST_DELTA) * ((gEngfuncs.GetWindowCenterY() - cam_mouse.y) / 2);
}
if (dist<c_mindistance->value)
if (dist < c_mindistance->value)
{
dist=c_mindistance->value;
dist = c_mindistance->value;
}
}
//set old mouse coordinates to current mouse coordinates
//since we are done with the mouse
cam_old_mouse_x=cam_mouse.x*gHUD.GetSensitivity();
cam_old_mouse_y=cam_mouse.y*gHUD.GetSensitivity();
SDL_SetCursorPos (gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
cam_old_mouse_x = cam_mouse.x * gHUD.GetSensitivity();
cam_old_mouse_y = cam_mouse.y * gHUD.GetSensitivity();
SDL_SetCursorPos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
}
#ifdef LATER
if( cam_contain->value )
if (cam_contain->value)
{
// check new ideal
VectorCopy( origin, pnt );
AngleVectors( camAngles, camForward, camRight, camUp );
for (i=0 ; i<3 ; i++)
pnt[i] += -dist*camForward[i];
VectorCopy(origin, pnt);
AngleVectors(camAngles, camForward, camRight, camUp);
for (i = 0; i < 3; i++)
pnt[i] += -dist * camForward[i];
// check line from r_refdef.vieworg to pnt
memset ( &clip, 0, sizeof ( moveclip_t ) );
clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt );
if( clip.trace.fraction == 1.0 )
memset(&clip, 0, sizeof(moveclip_t));
clip.trace = SV_ClipMoveToEntity(sv.edicts, r_refdef.vieworg, ext, ext, pnt);
if (clip.trace.fraction == 1.0)
{
// update ideal
cam_idealpitch->value = camAngles[ PITCH ];
cam_idealyaw->value = camAngles[ YAW ];
cam_idealpitch->value = camAngles[PITCH];
cam_idealyaw->value = camAngles[YAW];
cam_idealdist->value = dist;
}
}
@ -358,156 +355,156 @@ void DLLEXPORT CAM_Think()
#endif
{
// update ideal
cam_idealpitch->value = camAngles[ PITCH ];
cam_idealyaw->value = camAngles[ YAW ];
cam_idealpitch->value = camAngles[PITCH];
cam_idealyaw->value = camAngles[YAW];
cam_idealdist->value = dist;
}
// Move towards ideal
VectorCopy( cam_ofs, camAngles );
VectorCopy(cam_ofs, camAngles);
gEngfuncs.GetViewAngles( (float *)viewangles );
gEngfuncs.GetViewAngles((float*)viewangles);
if(0 != cam_snapto->value )
if (0 != cam_snapto->value)
{
camAngles[ YAW ] = cam_idealyaw->value + viewangles[ YAW ];
camAngles[ PITCH ] = cam_idealpitch->value + viewangles[ PITCH ];
camAngles[ 2 ] = cam_idealdist->value;
camAngles[YAW] = cam_idealyaw->value + viewangles[YAW];
camAngles[PITCH] = cam_idealpitch->value + viewangles[PITCH];
camAngles[2] = cam_idealdist->value;
}
else
{
if( camAngles[ YAW ] - viewangles[ YAW ] != cam_idealyaw->value )
camAngles[ YAW ] = MoveToward( camAngles[ YAW ], cam_idealyaw->value + viewangles[ YAW ], CAM_ANGLE_SPEED );
if (camAngles[YAW] - viewangles[YAW] != cam_idealyaw->value)
camAngles[YAW] = MoveToward(camAngles[YAW], cam_idealyaw->value + viewangles[YAW], CAM_ANGLE_SPEED);
if( camAngles[ PITCH ] - viewangles[ PITCH ] != cam_idealpitch->value )
camAngles[ PITCH ] = MoveToward( camAngles[ PITCH ], cam_idealpitch->value + viewangles[ PITCH ], CAM_ANGLE_SPEED );
if (camAngles[PITCH] - viewangles[PITCH] != cam_idealpitch->value)
camAngles[PITCH] = MoveToward(camAngles[PITCH], cam_idealpitch->value + viewangles[PITCH], CAM_ANGLE_SPEED);
if( fabs( camAngles[ 2 ] - cam_idealdist->value ) < 2.0 )
camAngles[ 2 ] = cam_idealdist->value;
if (fabs(camAngles[2] - cam_idealdist->value) < 2.0)
camAngles[2] = cam_idealdist->value;
else
camAngles[ 2 ] += ( cam_idealdist->value - camAngles[ 2 ] ) / 4.0;
camAngles[2] += (cam_idealdist->value - camAngles[2]) / 4.0;
}
#ifdef LATER
if( cam_contain->value )
if (cam_contain->value)
{
// Test new position
dist = camAngles[ ROLL ];
camAngles[ ROLL ] = 0;
dist = camAngles[ROLL];
camAngles[ROLL] = 0;
VectorCopy( origin, pnt );
AngleVectors( camAngles, camForward, camRight, camUp );
for (i=0 ; i<3 ; i++)
pnt[i] += -dist*camForward[i];
VectorCopy(origin, pnt);
AngleVectors(camAngles, camForward, camRight, camUp);
for (i = 0; i < 3; i++)
pnt[i] += -dist * camForward[i];
// check line from r_refdef.vieworg to pnt
memset ( &clip, 0, sizeof ( moveclip_t ) );
memset(&clip, 0, sizeof(moveclip_t));
ext[0] = ext[1] = ext[2] = 0.0;
clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt );
if( clip.trace.fraction != 1.0 )
clip.trace = SV_ClipMoveToEntity(sv.edicts, r_refdef.vieworg, ext, ext, pnt);
if (clip.trace.fraction != 1.0)
return;
}
#endif
cam_ofs[ 0 ] = camAngles[ 0 ];
cam_ofs[ 1 ] = camAngles[ 1 ];
cam_ofs[ 2 ] = dist;
cam_ofs[0] = camAngles[0];
cam_ofs[1] = camAngles[1];
cam_ofs[2] = dist;
}
extern void KeyDown (kbutton_t *b); // HACK
extern void KeyUp (kbutton_t *b); // HACK
extern void KeyDown(kbutton_t* b); // HACK
extern void KeyUp(kbutton_t* b); // HACK
void CAM_PitchUpDown() { KeyDown( &cam_pitchup ); }
void CAM_PitchUpUp() { KeyUp( &cam_pitchup ); }
void CAM_PitchDownDown() { KeyDown( &cam_pitchdown ); }
void CAM_PitchDownUp() { KeyUp( &cam_pitchdown ); }
void CAM_YawLeftDown() { KeyDown( &cam_yawleft ); }
void CAM_YawLeftUp() { KeyUp( &cam_yawleft ); }
void CAM_YawRightDown() { KeyDown( &cam_yawright ); }
void CAM_YawRightUp() { KeyUp( &cam_yawright ); }
void CAM_InDown() { KeyDown( &cam_in ); }
void CAM_InUp() { KeyUp( &cam_in ); }
void CAM_OutDown() { KeyDown( &cam_out ); }
void CAM_OutUp() { KeyUp( &cam_out ); }
void CAM_PitchUpDown() { KeyDown(&cam_pitchup); }
void CAM_PitchUpUp() { KeyUp(&cam_pitchup); }
void CAM_PitchDownDown() { KeyDown(&cam_pitchdown); }
void CAM_PitchDownUp() { KeyUp(&cam_pitchdown); }
void CAM_YawLeftDown() { KeyDown(&cam_yawleft); }
void CAM_YawLeftUp() { KeyUp(&cam_yawleft); }
void CAM_YawRightDown() { KeyDown(&cam_yawright); }
void CAM_YawRightUp() { KeyUp(&cam_yawright); }
void CAM_InDown() { KeyDown(&cam_in); }
void CAM_InUp() { KeyUp(&cam_in); }
void CAM_OutDown() { KeyDown(&cam_out); }
void CAM_OutUp() { KeyUp(&cam_out); }
void CAM_ToThirdPerson()
{
{
Vector viewangles;
#if !defined( _DEBUG )
if ( gEngfuncs.GetMaxClients() > 1 )
#if !defined(_DEBUG)
if (gEngfuncs.GetMaxClients() > 1)
{
// no thirdperson in multiplayer.
return;
}
#endif
gEngfuncs.GetViewAngles( (float *)viewangles );
gEngfuncs.GetViewAngles((float*)viewangles);
if( !cam_thirdperson )
if (!cam_thirdperson)
{
cam_thirdperson = true;
cam_ofs[ YAW ] = viewangles[ YAW ];
cam_ofs[ PITCH ] = viewangles[ PITCH ];
cam_ofs[ 2 ] = CAM_MIN_DIST;
cam_thirdperson = true;
cam_ofs[YAW] = viewangles[YAW];
cam_ofs[PITCH] = viewangles[PITCH];
cam_ofs[2] = CAM_MIN_DIST;
}
gEngfuncs.Cvar_SetValue( "cam_command", 0 );
gEngfuncs.Cvar_SetValue("cam_command", 0);
}
void CAM_ToFirstPerson()
{
void CAM_ToFirstPerson()
{
cam_thirdperson = false;
gEngfuncs.Cvar_SetValue( "cam_command", 0 );
gEngfuncs.Cvar_SetValue("cam_command", 0);
}
void CAM_ToggleSnapto()
{
{
cam_snapto->value = 0 != cam_snapto->value ? 0 : 1;
}
void CAM_Init()
{
gEngfuncs.pfnAddCommand( "+campitchup", CAM_PitchUpDown );
gEngfuncs.pfnAddCommand( "-campitchup", CAM_PitchUpUp );
gEngfuncs.pfnAddCommand( "+campitchdown", CAM_PitchDownDown );
gEngfuncs.pfnAddCommand( "-campitchdown", CAM_PitchDownUp );
gEngfuncs.pfnAddCommand( "+camyawleft", CAM_YawLeftDown );
gEngfuncs.pfnAddCommand( "-camyawleft", CAM_YawLeftUp );
gEngfuncs.pfnAddCommand( "+camyawright", CAM_YawRightDown );
gEngfuncs.pfnAddCommand( "-camyawright", CAM_YawRightUp );
gEngfuncs.pfnAddCommand( "+camin", CAM_InDown );
gEngfuncs.pfnAddCommand( "-camin", CAM_InUp );
gEngfuncs.pfnAddCommand( "+camout", CAM_OutDown );
gEngfuncs.pfnAddCommand( "-camout", CAM_OutUp );
gEngfuncs.pfnAddCommand( "thirdperson", CAM_ToThirdPerson );
gEngfuncs.pfnAddCommand( "firstperson", CAM_ToFirstPerson );
gEngfuncs.pfnAddCommand( "+cammousemove",CAM_StartMouseMove);
gEngfuncs.pfnAddCommand( "-cammousemove",CAM_EndMouseMove);
gEngfuncs.pfnAddCommand( "+camdistance", CAM_StartDistance );
gEngfuncs.pfnAddCommand( "-camdistance", CAM_EndDistance );
gEngfuncs.pfnAddCommand( "snapto", CAM_ToggleSnapto );
gEngfuncs.pfnAddCommand("+campitchup", CAM_PitchUpDown);
gEngfuncs.pfnAddCommand("-campitchup", CAM_PitchUpUp);
gEngfuncs.pfnAddCommand("+campitchdown", CAM_PitchDownDown);
gEngfuncs.pfnAddCommand("-campitchdown", CAM_PitchDownUp);
gEngfuncs.pfnAddCommand("+camyawleft", CAM_YawLeftDown);
gEngfuncs.pfnAddCommand("-camyawleft", CAM_YawLeftUp);
gEngfuncs.pfnAddCommand("+camyawright", CAM_YawRightDown);
gEngfuncs.pfnAddCommand("-camyawright", CAM_YawRightUp);
gEngfuncs.pfnAddCommand("+camin", CAM_InDown);
gEngfuncs.pfnAddCommand("-camin", CAM_InUp);
gEngfuncs.pfnAddCommand("+camout", CAM_OutDown);
gEngfuncs.pfnAddCommand("-camout", CAM_OutUp);
gEngfuncs.pfnAddCommand("thirdperson", CAM_ToThirdPerson);
gEngfuncs.pfnAddCommand("firstperson", CAM_ToFirstPerson);
gEngfuncs.pfnAddCommand("+cammousemove", CAM_StartMouseMove);
gEngfuncs.pfnAddCommand("-cammousemove", CAM_EndMouseMove);
gEngfuncs.pfnAddCommand("+camdistance", CAM_StartDistance);
gEngfuncs.pfnAddCommand("-camdistance", CAM_EndDistance);
gEngfuncs.pfnAddCommand("snapto", CAM_ToggleSnapto);
cam_command = gEngfuncs.pfnRegisterVariable ( "cam_command", "0", 0 ); // tells camera to go to thirdperson
cam_snapto = gEngfuncs.pfnRegisterVariable ( "cam_snapto", "0", 0 ); // snap to thirdperson view
cam_idealyaw = gEngfuncs.pfnRegisterVariable ( "cam_idealyaw", "90", 0 ); // thirdperson yaw
cam_idealpitch = gEngfuncs.pfnRegisterVariable ( "cam_idealpitch", "0", 0 ); // thirperson pitch
cam_idealdist = gEngfuncs.pfnRegisterVariable ( "cam_idealdist", "64", 0 ); // thirdperson distance
cam_contain = gEngfuncs.pfnRegisterVariable ( "cam_contain", "0", 0 ); // contain camera to world
cam_command = gEngfuncs.pfnRegisterVariable("cam_command", "0", 0); // tells camera to go to thirdperson
cam_snapto = gEngfuncs.pfnRegisterVariable("cam_snapto", "0", 0); // snap to thirdperson view
cam_idealyaw = gEngfuncs.pfnRegisterVariable("cam_idealyaw", "90", 0); // thirdperson yaw
cam_idealpitch = gEngfuncs.pfnRegisterVariable("cam_idealpitch", "0", 0); // thirperson pitch
cam_idealdist = gEngfuncs.pfnRegisterVariable("cam_idealdist", "64", 0); // thirdperson distance
cam_contain = gEngfuncs.pfnRegisterVariable("cam_contain", "0", 0); // contain camera to world
c_maxpitch = gEngfuncs.pfnRegisterVariable ( "c_maxpitch", "90.0", 0 );
c_minpitch = gEngfuncs.pfnRegisterVariable ( "c_minpitch", "0.0", 0 );
c_maxyaw = gEngfuncs.pfnRegisterVariable ( "c_maxyaw", "135.0", 0 );
c_minyaw = gEngfuncs.pfnRegisterVariable ( "c_minyaw", "-135.0", 0 );
c_maxdistance = gEngfuncs.pfnRegisterVariable ( "c_maxdistance", "200.0", 0 );
c_mindistance = gEngfuncs.pfnRegisterVariable ( "c_mindistance", "30.0", 0 );
c_maxpitch = gEngfuncs.pfnRegisterVariable("c_maxpitch", "90.0", 0);
c_minpitch = gEngfuncs.pfnRegisterVariable("c_minpitch", "0.0", 0);
c_maxyaw = gEngfuncs.pfnRegisterVariable("c_maxyaw", "135.0", 0);
c_minyaw = gEngfuncs.pfnRegisterVariable("c_minyaw", "-135.0", 0);
c_maxdistance = gEngfuncs.pfnRegisterVariable("c_maxdistance", "200.0", 0);
c_mindistance = gEngfuncs.pfnRegisterVariable("c_mindistance", "30.0", 0);
}
void CAM_ClearStates()
{
Vector viewangles;
gEngfuncs.GetViewAngles( (float *)viewangles );
gEngfuncs.GetViewAngles((float*)viewangles);
cam_pitchup.state = 0;
cam_pitchdown.state = 0;
@ -518,24 +515,24 @@ void CAM_ClearStates()
cam_thirdperson = false;
cam_command->value = 0;
cam_mousemove=false;
cam_mousemove = false;
cam_snapto->value = 0;
cam_distancemove = false;
cam_ofs[ 0 ] = 0.0;
cam_ofs[ 1 ] = 0.0;
cam_ofs[ 2 ] = CAM_MIN_DIST;
cam_ofs[0] = 0.0;
cam_ofs[1] = 0.0;
cam_ofs[2] = CAM_MIN_DIST;
cam_idealpitch->value = viewangles[ PITCH ];
cam_idealyaw->value = viewangles[ YAW ];
cam_idealpitch->value = viewangles[PITCH];
cam_idealyaw->value = viewangles[YAW];
cam_idealdist->value = CAM_MIN_DIST;
}
void CAM_StartMouseMove()
{
float flSensitivity;
//only move the cam with mouse if we are in third person.
if (cam_thirdperson)
{
@ -543,27 +540,27 @@ void CAM_StartMouseMove()
//variables for mouse camera movement
if (!cam_mousemove)
{
cam_mousemove=true;
iMouseInUse=true;
SDL_GetCursorPos (&cam_mouse);
cam_mousemove = true;
iMouseInUse = true;
SDL_GetCursorPos(&cam_mouse);
if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
if ((flSensitivity = gHUD.GetSensitivity()) != 0)
{
cam_old_mouse_x=cam_mouse.x*flSensitivity;
cam_old_mouse_y=cam_mouse.y*flSensitivity;
cam_old_mouse_x = cam_mouse.x * flSensitivity;
cam_old_mouse_y = cam_mouse.y * flSensitivity;
}
else
{
cam_old_mouse_x=cam_mouse.x;
cam_old_mouse_y=cam_mouse.y;
cam_old_mouse_x = cam_mouse.x;
cam_old_mouse_y = cam_mouse.y;
}
}
}
//we are not in 3rd person view..therefore do not allow camera movement
else
{
cam_mousemove=false;
iMouseInUse=false;
{
cam_mousemove = false;
iMouseInUse = false;
}
}
@ -571,13 +568,13 @@ void CAM_StartMouseMove()
//tell the engine that mouse camera movement is off
void CAM_EndMouseMove()
{
cam_mousemove=false;
iMouseInUse=false;
cam_mousemove = false;
iMouseInUse = false;
}
//----------------------------------------------------------
//routines to start the process of moving the cam in or out
//routines to start the process of moving the cam in or out
//using the mouse
//----------------------------------------------------------
void CAM_StartDistance()
@ -585,24 +582,24 @@ void CAM_StartDistance()
//only move the cam with mouse if we are in third person.
if (cam_thirdperson)
{
//set appropriate flags and initialize the old mouse position
//variables for mouse camera movement
if (!cam_distancemove)
{
cam_distancemove=true;
cam_mousemove=true;
iMouseInUse=true;
SDL_GetCursorPos (&cam_mouse);
cam_old_mouse_x=cam_mouse.x*gHUD.GetSensitivity();
cam_old_mouse_y=cam_mouse.y*gHUD.GetSensitivity();
}
//set appropriate flags and initialize the old mouse position
//variables for mouse camera movement
if (!cam_distancemove)
{
cam_distancemove = true;
cam_mousemove = true;
iMouseInUse = true;
SDL_GetCursorPos(&cam_mouse);
cam_old_mouse_x = cam_mouse.x * gHUD.GetSensitivity();
cam_old_mouse_y = cam_mouse.y * gHUD.GetSensitivity();
}
}
//we are not in 3rd person view..therefore do not allow camera movement
else
{
cam_distancemove=false;
cam_mousemove=false;
iMouseInUse=false;
{
cam_distancemove = false;
cam_mousemove = false;
iMouseInUse = false;
}
}
@ -610,21 +607,21 @@ void CAM_StartDistance()
//tell the engine that mouse camera movement is off
void CAM_EndDistance()
{
cam_distancemove=false;
cam_mousemove=false;
iMouseInUse=false;
cam_distancemove = false;
cam_mousemove = false;
iMouseInUse = false;
}
int DLLEXPORT CL_IsThirdPerson()
{
// RecClCL_IsThirdPerson();
// RecClCL_IsThirdPerson();
return static_cast<int>(cam_thirdperson || (0 != g_iUser1 && (g_iUser2 == gEngfuncs.GetLocalPlayer()->index) ));
return static_cast<int>(cam_thirdperson || (0 != g_iUser1 && (g_iUser2 == gEngfuncs.GetLocalPlayer()->index)));
}
void DLLEXPORT CL_CameraOffset( float *ofs )
void DLLEXPORT CL_CameraOffset(float* ofs)
{
// RecClCL_GetCameraOffsets(ofs);
// RecClCL_GetCameraOffsets(ofs);
VectorCopy( cam_ofs, ofs );
VectorCopy(cam_ofs, ofs);
}

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -8,8 +8,8 @@
#pragma once
// up / down
#define PITCH 0
#define PITCH 0
// left / right
#define YAW 1
#define YAW 1
// fall over
#define ROLL 2
#define ROLL 2

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -18,53 +18,53 @@
#include "interpolation.h"
// = determinant of matrix a,b,c
#define Determinant(a,b,c) ( (a)[2] * ( (b)[0]*(c)[1] - (b)[1]*(c)[0] ) + \
(a)[1] * ( (b)[2]*(c)[0] - (b)[0]*(c)[2] ) + \
(a)[0] * ( (b)[1]*(c)[2] - (b)[2]*(c)[1] ) )
#define Determinant(a, b, c) ((a)[2] * ((b)[0] * (c)[1] - (b)[1] * (c)[0]) + \
(a)[1] * ((b)[2] * (c)[0] - (b)[0] * (c)[2]) + \
(a)[0] * ((b)[1] * (c)[2] - (b)[2] * (c)[1]))
// slove 3 vector linear system of equations v0 = x*v1 + y*v2 + z*v3 (if possible)
bool SolveLSE (Vector v0, Vector v1, Vector v2, Vector v3, float * x, float * y, float * z)
bool SolveLSE(Vector v0, Vector v1, Vector v2, Vector v3, float* x, float* y, float* z)
{
float d = Determinant(v1,v2,v3);
float d = Determinant(v1, v2, v3);
if (d==0.0f)
if (d == 0.0f)
return false;
if ( x )
*x = Determinant(v0,v2,v3) / d;
if (x)
*x = Determinant(v0, v2, v3) / d;
if ( y )
*y= Determinant(v1,v0,v3) / d;
if (y)
*y = Determinant(v1, v0, v3) / d;
if (z)
*z = Determinant(v1, v2, v0) / d;
if ( z )
*z= Determinant(v1,v2,v0) / d;
return true;
}
// p = closest point between vector lines a1+x*m1 and a2+x*m2
bool GetPointBetweenLines(Vector& p, Vector a1, Vector m1, Vector a2, Vector m2 )
bool GetPointBetweenLines(Vector& p, Vector a1, Vector m1, Vector a2, Vector m2)
{
float x,z;
float x, z;
Vector t1 = CrossProduct(m1, m2);
Vector t2 = a2 - a1;
if ( !SolveLSE( t2, m1, t1, m2, &x , NULL, &z ) )
if (!SolveLSE(t2, m1, t1, m2, &x, NULL, &z))
return false;
t1 = a1 + x*m1;
t2 = a2 + (-z)*m2;
t1 = a1 + x * m1;
t2 = a2 + (-z) * m2;
p = ( t1 + t2 ) / 2.0f;
p = (t1 + t2) / 2.0f;
return true;
}
// Bernstein Poynom B(u) with n = 2, i = 0
#define BernsteinPolynom20(u) ((1.0f-u)*(1.0f-u))
#define BernsteinPolynom21(u) (2.0f*u*(1.0f-u))
#define BernsteinPolynom22(u) (u*u)
#define BernsteinPolynom20(u) ((1.0f - u) * (1.0f - u))
#define BernsteinPolynom21(u) (2.0f * u * (1.0f - u))
#define BernsteinPolynom22(u) (u * u)
CInterpolation::CInterpolation()
{
@ -75,12 +75,12 @@ CInterpolation::~CInterpolation()
m_SmoothStart = m_SmoothEnd = false;
}
void CInterpolation::SetViewAngles(Vector start, Vector end )
void CInterpolation::SetViewAngles(Vector start, Vector end)
{
m_StartAngle = start;
m_EndAngle = end;
NormalizeAngles( m_StartAngle );
NormalizeAngles( m_EndAngle );
m_EndAngle = end;
NormalizeAngles(m_StartAngle);
NormalizeAngles(m_EndAngle);
}
void CInterpolation::SetFOVs(float start, float end)
@ -93,37 +93,36 @@ void CInterpolation::SetWaypoints(Vector* prev, Vector start, Vector end, Vector
{
m_StartPoint = start;
m_EndPoint = end;
Vector a,b,c,d;
if ( !prev && !next )
Vector a, b, c, d;
if (!prev && !next)
{
// no direction given, straight linear interpolation
m_Center = (m_StartPoint + m_EndPoint) / 2.0f;
}
else if ( !prev )
else if (!prev)
{
a = start - end;
float dist = a.Length() / 2.0f;
a = start - end;
float dist = a.Length() / 2.0f;
a = a.Normalize();
b = *next - end;
b = b.Normalize();
c = a - b;
c = c.Normalize();
m_Center = end + c*dist;
m_Center = end + c * dist;
}
else if ( !next )
else if (!next)
{
a = *prev - start;
a = a.Normalize();
b = end - start;
a = a.Normalize();
b = end - start;
float dist = b.Length() / 2.0f;
b = b.Normalize();
c = b - a;
c = c.Normalize();
m_Center = start + c*dist;
m_Center = start + c * dist;
}
else
{
@ -140,44 +139,44 @@ void CInterpolation::SetWaypoints(Vector* prev, Vector start, Vector end, Vector
b = b.Normalize();
d = a - b;
GetPointBetweenLines( m_Center, start, c, end, d);
GetPointBetweenLines(m_Center, start, c, end, d);
}
}
void CInterpolation::Interpolate( float t, Vector& point, Vector& angle, float * fov)
void CInterpolation::Interpolate(float t, Vector& point, Vector& angle, float* fov)
{
if ( m_SmoothStart && m_SmoothEnd )
if (m_SmoothStart && m_SmoothEnd)
{
t = (1.0f-t)*(t*t)+t*(1.0f-((t-1.0f)*(t-1.0f)));
t = (1.0f - t) * (t * t) + t * (1.0f - ((t - 1.0f) * (t - 1.0f)));
}
else if ( m_SmoothStart )
else if (m_SmoothStart)
{
t = t*t;
t = t * t;
}
else if ( m_SmoothEnd )
else if (m_SmoothEnd)
{
t = t - 1.0f;
t = -(t*t)+1;
t = -(t * t) + 1;
}
if ( point )
if (point)
{
BezierInterpolatePoint(t, point);
}
if ( angle )
if (angle)
{
InterpolateAngle(t, angle);
}
if ( fov )
if (fov)
{
*fov = m_StartFov + (t * (m_EndFov-m_StartFov));
*fov = m_StartFov + (t * (m_EndFov - m_StartFov));
}
}
void CInterpolation::BezierInterpolatePoint( float t, Vector& point )
void CInterpolation::BezierInterpolatePoint(float t, Vector& point)
{
point = m_StartPoint * BernsteinPolynom20(t);
point = point + m_Center * BernsteinPolynom21(t);
@ -188,35 +187,31 @@ void CInterpolation::SetSmoothing(bool start, bool end)
{
m_SmoothStart = start;
m_SmoothEnd = end;
}
void CInterpolation::InterpolateAngle( float t, Vector& angle )
void CInterpolation::InterpolateAngle(float t, Vector& angle)
{
int i;
float ang1, ang2;
float d;
for ( i = 0 ; i < 3 ; i++ )
for (i = 0; i < 3; i++)
{
ang1 = m_StartAngle[i];
ang2 = m_EndAngle[i];
d = ang2 - ang1;
if ( d > 180 )
if (d > 180)
{
d -= 360;
}
else if ( d < -180 )
{
else if (d < -180)
{
d += 360;
}
angle[i] = ang1 + d * t;
}
NormalizeAngles( angle );
NormalizeAngles(angle);
}

View file

@ -16,34 +16,32 @@
#pragma once
// interpolation class
class CInterpolation
class CInterpolation
{
public:
CInterpolation();
virtual ~CInterpolation();
void SetWaypoints(Vector* prev, Vector start, Vector end, Vector* next);
void SetViewAngles(Vector start, Vector end );
void SetViewAngles(Vector start, Vector end);
void SetFOVs(float start, float end);
void SetSmoothing(bool start, bool end);
// get interpolated point 0 =< t =< 1, 0 = start, 1 = end
void Interpolate(float t, Vector& point, Vector& angle, float * fov);
void Interpolate(float t, Vector& point, Vector& angle, float* fov);
protected:
void BezierInterpolatePoint(float t, Vector& point);
void InterpolateAngle(float t, Vector& angle);
void BezierInterpolatePoint( float t, Vector& point );
void InterpolateAngle( float t, Vector& angle );
Vector m_StartPoint;
Vector m_EndPoint;
Vector m_StartAngle;
Vector m_EndAngle;
Vector m_Center;
float m_StartFov;
float m_EndFov;
Vector m_StartPoint;
Vector m_EndPoint;
Vector m_StartAngle;
Vector m_EndAngle;
Vector m_Center;
float m_StartFov;
float m_EndFov;
bool m_SmoothStart;
bool m_SmoothEnd;
bool m_SmoothStart;
bool m_SmoothEnd;
};

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -9,6 +9,6 @@
typedef struct kbutton_s
{
int down[2]; // key nums holding it down
int state; // low bit is down state
int down[2]; // key nums holding it down
int state; // low bit is down state
} kbutton_t;

View file

@ -26,39 +26,39 @@
#include "vgui_TeamFortressViewport.h"
#define MAX_MENU_STRING 512
#define MAX_MENU_STRING 512
char g_szMenuString[MAX_MENU_STRING];
char g_szPrelocalisedMenuString[MAX_MENU_STRING];
bool KB_ConvertString( char *in, char **ppout );
bool KB_ConvertString(char* in, char** ppout);
DECLARE_MESSAGE( m_Menu, ShowMenu );
DECLARE_MESSAGE(m_Menu, ShowMenu);
bool CHudMenu :: Init()
bool CHudMenu ::Init()
{
gHUD.AddHudElem( this );
gHUD.AddHudElem(this);
HOOK_MESSAGE( ShowMenu );
HOOK_MESSAGE(ShowMenu);
InitHUDData();
return true;
}
void CHudMenu :: InitHUDData()
void CHudMenu ::InitHUDData()
{
m_fMenuDisplayed = false;
m_bitsValidSlots = 0;
Reset();
}
void CHudMenu :: Reset()
void CHudMenu ::Reset()
{
g_szPrelocalisedMenuString[0] = 0;
m_fWaitingForMore = false;
}
bool CHudMenu :: VidInit()
bool CHudMenu ::VidInit()
{
return true;
}
@ -81,14 +81,14 @@ bool CHudMenu :: VidInit()
static int menu_r, menu_g, menu_b, menu_x;
static bool menu_ralign;
static inline const char* ParseEscapeToken( const char* token )
static inline const char* ParseEscapeToken(const char* token)
{
if ( *token != '\\' )
if (*token != '\\')
return token;
token++;
switch ( *token )
switch (*token)
{
case '\0':
return token;
@ -118,7 +118,7 @@ static inline const char* ParseEscapeToken( const char* token )
break;
case 'R':
menu_x = ScreenWidth/2;
menu_x = ScreenWidth / 2;
menu_ralign = true;
break;
}
@ -127,13 +127,13 @@ static inline const char* ParseEscapeToken( const char* token )
}
bool CHudMenu :: Draw( float flTime )
bool CHudMenu ::Draw(float flTime)
{
// check for if menu is set to disappear
if ( m_flShutoffTime > 0 )
if (m_flShutoffTime > 0)
{
if ( m_flShutoffTime <= gHUD.m_flTime )
{ // times up, shutoff
if (m_flShutoffTime <= gHUD.m_flTime)
{ // times up, shutoff
m_fMenuDisplayed = false;
m_iFlags &= ~HUD_ACTIVE;
return true;
@ -141,7 +141,7 @@ bool CHudMenu :: Draw( float flTime )
}
// don't draw the menu if the scoreboard is being shown
if ( gViewPort && gViewPort->IsScoreBoardVisible() )
if (gViewPort && gViewPort->IsScoreBoardVisible())
return true;
// draw the menu, along the left-hand side of the screen
@ -149,72 +149,72 @@ bool CHudMenu :: Draw( float flTime )
// count the number of newlines
int nlc = 0;
int i;
for ( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
for (i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++)
{
if ( g_szMenuString[i] == '\n' )
if (g_szMenuString[i] == '\n')
nlc++;
}
// center it
int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text
int y = (ScreenHeight / 2) - ((nlc / 2) * 12) - 40; // make sure it is above the say text
menu_r = 255;
menu_g = 255;
menu_b = 255;
menu_x = 20;
menu_ralign = false;
menu_r = 255;
menu_g = 255;
menu_b = 255;
menu_x = 20;
menu_ralign = false;
const char* sptr = g_szMenuString;
while ( *sptr != '\0' )
while (*sptr != '\0')
{
if ( *sptr == '\\' )
if (*sptr == '\\')
{
sptr = ParseEscapeToken( sptr );
sptr = ParseEscapeToken(sptr);
}
else if ( *sptr == '\n' )
else if (*sptr == '\n')
{
menu_ralign = false;
menu_x = 20;
y += (12);
menu_ralign = false;
menu_x = 20;
y += (12);
sptr++;
}
else
{
char menubuf[ 80 ];
const char *ptr = sptr;
while ( *sptr != '\0' && *sptr != '\n' && *sptr != '\\')
char menubuf[80];
const char* ptr = sptr;
while (*sptr != '\0' && *sptr != '\n' && *sptr != '\\')
{
sptr++;
}
strncpy( menubuf, ptr, V_min( ( sptr - ptr), (int)sizeof( menubuf ) ));
menubuf[ V_min( ( sptr - ptr), (int)(sizeof( menubuf )-1) ) ] = '\0';
if ( menu_ralign )
{
strncpy(menubuf, ptr, V_min((sptr - ptr), (int)sizeof(menubuf)));
menubuf[V_min((sptr - ptr), (int)(sizeof(menubuf) - 1))] = '\0';
if (menu_ralign)
{
// IMPORTANT: Right-to-left rendered text does not parse escape tokens!
menu_x = gHUD.DrawHudStringReverse( menu_x, y, 0, menubuf, menu_r, menu_g, menu_b );
menu_x = gHUD.DrawHudStringReverse(menu_x, y, 0, menubuf, menu_r, menu_g, menu_b);
}
else
{
menu_x = gHUD.DrawHudString( menu_x, y, 320, menubuf, menu_r, menu_g, menu_b );
menu_x = gHUD.DrawHudString(menu_x, y, 320, menubuf, menu_r, menu_g, menu_b);
}
}
}
return true;
}
// selects an item from the menu
void CHudMenu :: SelectMenuItem( int menu_item )
void CHudMenu ::SelectMenuItem(int menu_item)
{
// if menu_item is in a valid slot, send a menuselect command to the server
if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) != 0 )
if ((menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item - 1))) != 0)
{
char szbuf[32];
sprintf( szbuf, "menuselect %d\n", menu_item );
EngineClientCmd( szbuf );
sprintf(szbuf, "menuselect %d\n", menu_item);
EngineClientCmd(szbuf);
// remove the menu
m_fMenuDisplayed = false;
@ -230,42 +230,42 @@ void CHudMenu :: SelectMenuItem( int menu_item )
// byte : a boolean, true if there is more string yet to be received before displaying the menu, false if it's the last string
// string: menu string to display
// if this message is never received, then scores will simply be the combined totals of the players.
bool CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
bool CHudMenu ::MsgFunc_ShowMenu(const char* pszName, int iSize, void* pbuf)
{
char *temp = NULL;
char* temp = NULL;
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
m_bitsValidSlots = READ_SHORT();
int DisplayTime = READ_CHAR();
bool NeedMore = READ_BYTE() != 0;
if ( DisplayTime > 0 )
if (DisplayTime > 0)
m_flShutoffTime = DisplayTime + gHUD.m_flTime;
else
m_flShutoffTime = -1;
if ( 0 != m_bitsValidSlots )
if (0 != m_bitsValidSlots)
{
if ( !m_fWaitingForMore ) // this is the start of a new menu
if (!m_fWaitingForMore) // this is the start of a new menu
{
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
strncpy(g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING);
}
else
{ // append to the current menu string
strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) );
{ // append to the current menu string
strncat(g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString));
}
g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not)
g_szPrelocalisedMenuString[MAX_MENU_STRING - 1] = 0; // ensure null termination (strncat/strncpy does not)
if ( !NeedMore )
{ // we have the whole string, so we can localise it now
strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) );
if (!NeedMore)
{ // we have the whole string, so we can localise it now
strcpy(g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString(g_szPrelocalisedMenuString));
// Swap in characters
if ( KB_ConvertString( g_szMenuString, &temp ) )
if (KB_ConvertString(g_szMenuString, &temp))
{
strcpy( g_szMenuString, temp );
free( temp );
strcpy(g_szMenuString, temp);
free(temp);
}
}

View file

@ -24,18 +24,18 @@
#include <stdio.h>
#include "parsemsg.h"
DECLARE_MESSAGE( m_Message, HudText )
DECLARE_MESSAGE( m_Message, GameTitle )
DECLARE_MESSAGE(m_Message, HudText)
DECLARE_MESSAGE(m_Message, GameTitle)
// 1 Global client_textmessage_t for custom messages that aren't in the titles.txt
client_textmessage_t g_pCustomMessage;
const char *g_pCustomName = "Custom";
client_textmessage_t g_pCustomMessage;
const char* g_pCustomName = "Custom";
char g_pCustomText[1024];
bool CHudMessage::Init()
{
HOOK_MESSAGE( HudText );
HOOK_MESSAGE( GameTitle );
HOOK_MESSAGE(HudText);
HOOK_MESSAGE(GameTitle);
gHUD.AddHudElem(this);
@ -46,8 +46,8 @@ bool CHudMessage::Init()
bool CHudMessage::VidInit()
{
m_HUD_title_half = gHUD.GetSpriteIndex( "title_half" );
m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" );
m_HUD_title_half = gHUD.GetSpriteIndex("title_half");
m_HUD_title_life = gHUD.GetSpriteIndex("title_life");
return true;
};
@ -55,29 +55,29 @@ bool CHudMessage::VidInit()
void CHudMessage::Reset()
{
memset( m_pMessages, 0, sizeof( m_pMessages[0] ) * maxHUDMessages );
memset( m_startTime, 0, sizeof( m_startTime[0] ) * maxHUDMessages );
memset(m_pMessages, 0, sizeof(m_pMessages[0]) * maxHUDMessages);
memset(m_startTime, 0, sizeof(m_startTime[0]) * maxHUDMessages);
m_gameTitleTime = 0;
m_pGameTitle = NULL;
}
float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float localTime )
float CHudMessage::FadeBlend(float fadein, float fadeout, float hold, float localTime)
{
float fadeTime = fadein + hold;
float fadeBlend;
if ( localTime < 0 )
if (localTime < 0)
return 0;
if ( localTime < fadein )
if (localTime < fadein)
{
fadeBlend = 1 - ((fadein - localTime) / fadein);
}
else if ( localTime > fadeTime )
else if (localTime > fadeTime)
{
if ( fadeout > 0 )
if (fadeout > 0)
fadeBlend = 1 - ((localTime - fadeTime) / fadeout);
else
fadeBlend = 0;
@ -89,49 +89,49 @@ float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float loc
}
int CHudMessage::XPosition( float x, int width, int totalWidth )
int CHudMessage::XPosition(float x, int width, int totalWidth)
{
int xPos;
if ( x == -1 )
if (x == -1)
{
xPos = (ScreenWidth - width) / 2;
}
else
{
if ( x < 0 )
xPos = (1.0 + x) * ScreenWidth - totalWidth; // Alight right
if (x < 0)
xPos = (1.0 + x) * ScreenWidth - totalWidth; // Alight right
else
xPos = x * ScreenWidth;
}
if ( xPos + width > ScreenWidth )
if (xPos + width > ScreenWidth)
xPos = ScreenWidth - width;
else if ( xPos < 0 )
else if (xPos < 0)
xPos = 0;
return xPos;
}
int CHudMessage::YPosition( float y, int height )
int CHudMessage::YPosition(float y, int height)
{
int yPos;
if ( y == -1 ) // Centered?
if (y == -1) // Centered?
yPos = (ScreenHeight - height) * 0.5;
else
{
// Alight bottom?
if ( y < 0 )
yPos = (1.0 + y) * ScreenHeight - height; // Alight bottom
else // align top
if (y < 0)
yPos = (1.0 + y) * ScreenHeight - height; // Alight bottom
else // align top
yPos = y * ScreenHeight;
}
if ( yPos + height > ScreenHeight )
if (yPos + height > ScreenHeight)
yPos = ScreenHeight - height;
else if ( yPos < 0 )
else if (yPos < 0)
yPos = 0;
return yPos;
@ -146,10 +146,10 @@ void CHudMessage::MessageScanNextChar()
srcRed = m_parms.pMessage->r1;
srcGreen = m_parms.pMessage->g1;
srcBlue = m_parms.pMessage->b1;
blend = 0; // Pure source
blend = 0; // Pure source
destRed = destGreen = destBlue = 0;
switch( m_parms.pMessage->effect )
switch (m_parms.pMessage->effect)
{
// Fade-in / Fade-out
case 0:
@ -159,81 +159,81 @@ void CHudMessage::MessageScanNextChar()
case 2:
m_parms.charTime += m_parms.pMessage->fadein;
if ( m_parms.charTime > m_parms.time )
if (m_parms.charTime > m_parms.time)
{
srcRed = srcGreen = srcBlue = 0;
blend = 0; // pure source
blend = 0; // pure source
}
else
{
float deltaTime = m_parms.time - m_parms.charTime;
if ( m_parms.time > m_parms.fadeTime )
if (m_parms.time > m_parms.fadeTime)
{
blend = m_parms.fadeBlend;
}
else if ( deltaTime > m_parms.pMessage->fxtime )
blend = 0; // pure dest
else if (deltaTime > m_parms.pMessage->fxtime)
blend = 0; // pure dest
else
{
destRed = m_parms.pMessage->r2;
destGreen = m_parms.pMessage->g2;
destBlue = m_parms.pMessage->b2;
blend = 255 - (deltaTime * (1.0/m_parms.pMessage->fxtime) * 255.0 + 0.5);
blend = 255 - (deltaTime * (1.0 / m_parms.pMessage->fxtime) * 255.0 + 0.5);
}
}
break;
}
if ( blend > 255 )
if (blend > 255)
blend = 255;
else if ( blend < 0 )
else if (blend < 0)
blend = 0;
m_parms.r = ((srcRed * (255-blend)) + (destRed * blend)) >> 8;
m_parms.g = ((srcGreen * (255-blend)) + (destGreen * blend)) >> 8;
m_parms.b = ((srcBlue * (255-blend)) + (destBlue * blend)) >> 8;
m_parms.r = ((srcRed * (255 - blend)) + (destRed * blend)) >> 8;
m_parms.g = ((srcGreen * (255 - blend)) + (destGreen * blend)) >> 8;
m_parms.b = ((srcBlue * (255 - blend)) + (destBlue * blend)) >> 8;
if ( m_parms.pMessage->effect == 1 && m_parms.charTime != 0 )
if (m_parms.pMessage->effect == 1 && m_parms.charTime != 0)
{
if ( m_parms.x >= 0 && m_parms.y >= 0 && (m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ]) <= ScreenWidth )
TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2 );
if (m_parms.x >= 0 && m_parms.y >= 0 && (m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text]) <= ScreenWidth)
TextMessageDrawChar(m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2);
}
}
void CHudMessage::MessageScanStart()
{
switch( m_parms.pMessage->effect )
switch (m_parms.pMessage->effect)
{
// Fade-in / out with flicker
case 1:
case 0:
m_parms.fadeTime = m_parms.pMessage->fadein + m_parms.pMessage->holdtime;
if ( m_parms.time < m_parms.pMessage->fadein )
if (m_parms.time < m_parms.pMessage->fadein)
{
m_parms.fadeBlend = ((m_parms.pMessage->fadein - m_parms.time) * (1.0/m_parms.pMessage->fadein) * 255);
m_parms.fadeBlend = ((m_parms.pMessage->fadein - m_parms.time) * (1.0 / m_parms.pMessage->fadein) * 255);
}
else if ( m_parms.time > m_parms.fadeTime )
else if (m_parms.time > m_parms.fadeTime)
{
if ( m_parms.pMessage->fadeout > 0 )
if (m_parms.pMessage->fadeout > 0)
m_parms.fadeBlend = (((m_parms.time - m_parms.fadeTime) / m_parms.pMessage->fadeout) * 255);
else
m_parms.fadeBlend = 255; // Pure dest (off)
}
else
m_parms.fadeBlend = 0; // Pure source (on)
m_parms.fadeBlend = 0; // Pure source (on)
m_parms.charTime = 0;
if ( m_parms.pMessage->effect == 1 && (rand()%100) < 10 )
if (m_parms.pMessage->effect == 1 && (rand() % 100) < 10)
m_parms.charTime = 1;
break;
case 2:
m_parms.fadeTime = (m_parms.pMessage->fadein * m_parms.length) + m_parms.pMessage->holdtime;
if ( m_parms.time > m_parms.fadeTime && m_parms.pMessage->fadeout > 0 )
if (m_parms.time > m_parms.fadeTime && m_parms.pMessage->fadeout > 0)
m_parms.fadeBlend = (((m_parms.time - m_parms.fadeTime) / m_parms.pMessage->fadeout) * 255);
else
m_parms.fadeBlend = 0;
@ -242,10 +242,10 @@ void CHudMessage::MessageScanStart()
}
void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
void CHudMessage::MessageDrawScan(client_textmessage_t* pMessage, float time)
{
int i, j, length, width;
const char *pText;
const char* pText;
unsigned char line[80];
pText = pMessage->pMessage;
@ -256,12 +256,12 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
length = 0;
width = 0;
m_parms.totalWidth = 0;
while ( '\0' != *pText)
while ('\0' != *pText)
{
if ( *pText == '\n' )
if (*pText == '\n')
{
m_parms.lines++;
if ( width > m_parms.totalWidth )
if (width > m_parms.totalWidth)
m_parms.totalWidth = width;
width = 0;
}
@ -274,18 +274,18 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
m_parms.totalHeight = (m_parms.lines * gHUD.m_scrinfo.iCharHeight);
m_parms.y = YPosition( pMessage->y, m_parms.totalHeight );
m_parms.y = YPosition(pMessage->y, m_parms.totalHeight);
pText = pMessage->pMessage;
m_parms.charTime = 0;
MessageScanStart();
for ( i = 0; i < m_parms.lines; i++ )
for (i = 0; i < m_parms.lines; i++)
{
m_parms.lineLength = 0;
m_parms.width = 0;
while ( '\0' != *pText && *pText != '\n')
while ('\0' != *pText && *pText != '\n')
{
unsigned char c = *pText;
line[m_parms.lineLength] = c;
@ -293,19 +293,19 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
m_parms.lineLength++;
pText++;
}
pText++; // Skip LF
pText++; // Skip LF
line[m_parms.lineLength] = 0;
m_parms.x = XPosition( pMessage->x, m_parms.width, m_parms.totalWidth );
m_parms.x = XPosition(pMessage->x, m_parms.width, m_parms.totalWidth);
for ( j = 0; j < m_parms.lineLength; j++ )
for (j = 0; j < m_parms.lineLength; j++)
{
m_parms.text = line[j];
int next = m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ];
int next = m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text];
MessageScanNextChar();
if ( m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth )
TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b );
if (m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth)
TextMessageDrawChar(m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b);
m_parms.x = next;
}
@ -314,79 +314,79 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
}
bool CHudMessage::Draw( float fTime )
bool CHudMessage::Draw(float fTime)
{
int i, drawn;
client_textmessage_t *pMessage;
client_textmessage_t* pMessage;
float endTime;
drawn = 0;
if ( m_gameTitleTime > 0 )
if (m_gameTitleTime > 0)
{
float localTime = gHUD.m_flTime - m_gameTitleTime;
float brightness;
// Maybe timer isn't set yet
if ( m_gameTitleTime > gHUD.m_flTime )
if (m_gameTitleTime > gHUD.m_flTime)
m_gameTitleTime = gHUD.m_flTime;
if ( localTime > (m_pGameTitle->fadein + m_pGameTitle->holdtime + m_pGameTitle->fadeout) )
if (localTime > (m_pGameTitle->fadein + m_pGameTitle->holdtime + m_pGameTitle->fadeout))
m_gameTitleTime = 0;
else
{
brightness = FadeBlend( m_pGameTitle->fadein, m_pGameTitle->fadeout, m_pGameTitle->holdtime, localTime );
brightness = FadeBlend(m_pGameTitle->fadein, m_pGameTitle->fadeout, m_pGameTitle->holdtime, localTime);
int halfWidth = gHUD.GetSpriteRect(m_HUD_title_half).right - gHUD.GetSpriteRect(m_HUD_title_half).left;
int fullWidth = halfWidth + gHUD.GetSpriteRect(m_HUD_title_life).right - gHUD.GetSpriteRect(m_HUD_title_life).left;
int fullHeight = gHUD.GetSpriteRect(m_HUD_title_half).bottom - gHUD.GetSpriteRect(m_HUD_title_half).top;
int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth );
int y = YPosition( m_pGameTitle->y, fullHeight );
int x = XPosition(m_pGameTitle->x, fullWidth, fullWidth);
int y = YPosition(m_pGameTitle->y, fullHeight);
SPR_Set( gHUD.GetSprite(m_HUD_title_half), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_title_half) );
SPR_Set(gHUD.GetSprite(m_HUD_title_half), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1);
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_title_half));
SPR_Set( gHUD.GetSprite(m_HUD_title_life), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect(m_HUD_title_life) );
SPR_Set(gHUD.GetSprite(m_HUD_title_life), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1);
SPR_DrawAdditive(0, x + halfWidth, y, &gHUD.GetSpriteRect(m_HUD_title_life));
drawn = 1;
}
}
// Fixup level transitions
for ( i = 0; i < maxHUDMessages; i++ )
for (i = 0; i < maxHUDMessages; i++)
{
// Assume m_parms.time contains last time
if ( m_pMessages[i] )
if (m_pMessages[i])
{
pMessage = m_pMessages[i];
if ( m_startTime[i] > gHUD.m_flTime )
m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2; // Server takes 0.2 seconds to spawn, adjust for this
if (m_startTime[i] > gHUD.m_flTime)
m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2; // Server takes 0.2 seconds to spawn, adjust for this
}
}
for ( i = 0; i < maxHUDMessages; i++ )
for (i = 0; i < maxHUDMessages; i++)
{
if ( m_pMessages[i] )
if (m_pMessages[i])
{
pMessage = m_pMessages[i];
// This is when the message is over
switch( pMessage->effect )
switch (pMessage->effect)
{
case 0:
case 1:
endTime = m_startTime[i] + pMessage->fadein + pMessage->fadeout + pMessage->holdtime;
break;
// Fade in is per character in scanning messages
case 2:
endTime = m_startTime[i] + (pMessage->fadein * strlen( pMessage->pMessage )) + pMessage->fadeout + pMessage->holdtime;
endTime = m_startTime[i] + (pMessage->fadein * strlen(pMessage->pMessage)) + pMessage->fadeout + pMessage->holdtime;
break;
}
if ( fTime <= endTime )
if (fTime <= endTime)
{
float messageTime = fTime - m_startTime[i];
@ -394,7 +394,7 @@ bool CHudMessage::Draw( float fTime )
// effect 0 is fade in/fade out
// effect 1 is flickery credits
// effect 2 is write out (training room)
MessageDrawScan( pMessage, messageTime );
MessageDrawScan(pMessage, messageTime);
drawn++;
}
@ -409,29 +409,29 @@ bool CHudMessage::Draw( float fTime )
// Remember the time -- to fix up level transitions
m_parms.time = gHUD.m_flTime;
// Don't call until we get another message
if ( 0 == drawn )
if (0 == drawn)
m_iFlags &= ~HUD_ACTIVE;
return true;
}
void CHudMessage::MessageAdd( const char *pName, float time )
void CHudMessage::MessageAdd(const char* pName, float time)
{
int i,j;
client_textmessage_t *tempMessage;
int i, j;
client_textmessage_t* tempMessage;
for ( i = 0; i < maxHUDMessages; i++ )
for (i = 0; i < maxHUDMessages; i++)
{
if ( !m_pMessages[i] )
if (!m_pMessages[i])
{
// Trim off a leading # if it's there
if ( pName[0] == '#' )
tempMessage = TextMessageGet( pName+1 );
if (pName[0] == '#')
tempMessage = TextMessageGet(pName + 1);
else
tempMessage = TextMessageGet( pName );
tempMessage = TextMessageGet(pName);
// If we couldnt find it in the titles.txt, just create it
if ( !tempMessage )
if (!tempMessage)
{
g_pCustomMessage.effect = 2;
g_pCustomMessage.r1 = g_pCustomMessage.g1 = g_pCustomMessage.b1 = g_pCustomMessage.a1 = 100;
@ -439,33 +439,33 @@ void CHudMessage::MessageAdd( const char *pName, float time )
g_pCustomMessage.g2 = 110;
g_pCustomMessage.b2 = 0;
g_pCustomMessage.a2 = 0;
g_pCustomMessage.x = -1; // Centered
g_pCustomMessage.x = -1; // Centered
g_pCustomMessage.y = 0.7;
g_pCustomMessage.fadein = 0.01;
g_pCustomMessage.fadeout = 1.5;
g_pCustomMessage.fxtime = 0.25;
g_pCustomMessage.holdtime = 5;
g_pCustomMessage.pName = g_pCustomName;
strcpy( g_pCustomText, pName );
strcpy(g_pCustomText, pName);
g_pCustomMessage.pMessage = g_pCustomText;
tempMessage = &g_pCustomMessage;
}
for ( j = 0; j < maxHUDMessages; j++ )
for (j = 0; j < maxHUDMessages; j++)
{
if ( m_pMessages[j] )
if (m_pMessages[j])
{
// is this message already in the list
if ( 0 == strcmp( tempMessage->pMessage, m_pMessages[j]->pMessage ) )
if (0 == strcmp(tempMessage->pMessage, m_pMessages[j]->pMessage))
{
return;
}
// get rid of any other messages in same location (only one displays at a time)
if ( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001 )
if (fabs(tempMessage->y - m_pMessages[j]->y) < 0.0001)
{
if ( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001 )
if (fabs(tempMessage->x - m_pMessages[j]->x) < 0.0001)
{
m_pMessages[j] = NULL;
}
@ -481,55 +481,54 @@ void CHudMessage::MessageAdd( const char *pName, float time )
}
bool CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf )
bool CHudMessage::MsgFunc_HudText(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
char *pString = READ_STRING();
char* pString = READ_STRING();
MessageAdd( pString, gHUD.m_flTime );
MessageAdd(pString, gHUD.m_flTime);
// Remember the time -- to fix up level transitions
m_parms.time = gHUD.m_flTime;
// Turn on drawing
if ( (m_iFlags & HUD_ACTIVE) == 0)
if ((m_iFlags & HUD_ACTIVE) == 0)
m_iFlags |= HUD_ACTIVE;
return true;
}
bool CHudMessage::MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf )
bool CHudMessage::MsgFunc_GameTitle(const char* pszName, int iSize, void* pbuf)
{
m_pGameTitle = TextMessageGet( "GAMETITLE" );
if ( m_pGameTitle != NULL )
m_pGameTitle = TextMessageGet("GAMETITLE");
if (m_pGameTitle != NULL)
{
m_gameTitleTime = gHUD.m_flTime;
// Turn on drawing
if ( (m_iFlags & HUD_ACTIVE) == 0)
if ((m_iFlags & HUD_ACTIVE) == 0)
m_iFlags |= HUD_ACTIVE;
}
return true;
}
void CHudMessage::MessageAdd(client_textmessage_t * newMessage )
void CHudMessage::MessageAdd(client_textmessage_t* newMessage)
{
m_parms.time = gHUD.m_flTime;
// Turn on drawing
if ( (m_iFlags & HUD_ACTIVE) == 0)
if ((m_iFlags & HUD_ACTIVE) == 0)
m_iFlags |= HUD_ACTIVE;
for ( int i = 0; i < maxHUDMessages; i++ )
for (int i = 0; i < maxHUDMessages; i++)
{
if ( !m_pMessages[i] )
if (!m_pMessages[i])
{
m_pMessages[i] = newMessage;
m_startTime[i] = gHUD.m_flTime;
return;
}
}
}

View file

@ -28,36 +28,36 @@
#include "vgui_TeamFortressViewport.h"
extern float *GetClientColor( int clientIndex );
extern float* GetClientColor(int clientIndex);
#define MAX_LINES 5
#define MAX_CHARS_PER_LINE 256 /* it can be less than this, depending on char size */
#define MAX_LINES 5
#define MAX_CHARS_PER_LINE 256 /* it can be less than this, depending on char size */
// allow 20 pixels on either side of the text
#define MAX_LINE_WIDTH ( ScreenWidth - 40 )
#define LINE_START 10
#define MAX_LINE_WIDTH (ScreenWidth - 40)
#define LINE_START 10
static float SCROLL_SPEED = 5;
static char g_szLineBuffer[ MAX_LINES + 1 ][ MAX_CHARS_PER_LINE ];
static float *g_pflNameColors[ MAX_LINES + 1 ];
static int g_iNameLengths[ MAX_LINES + 1 ];
static float flScrollTime = 0; // the time at which the lines next scroll up
static char g_szLineBuffer[MAX_LINES + 1][MAX_CHARS_PER_LINE];
static float* g_pflNameColors[MAX_LINES + 1];
static int g_iNameLengths[MAX_LINES + 1];
static float flScrollTime = 0; // the time at which the lines next scroll up
static int Y_START = 0;
static int line_height = 0;
DECLARE_MESSAGE( m_SayText, SayText );
DECLARE_MESSAGE(m_SayText, SayText);
bool CHudSayText :: Init()
bool CHudSayText ::Init()
{
gHUD.AddHudElem( this );
gHUD.AddHudElem(this);
HOOK_MESSAGE( SayText );
HOOK_MESSAGE(SayText);
InitHUDData();
m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext", "1", 0 );
m_HUD_saytext_time = gEngfuncs.pfnRegisterVariable( "hud_saytext_time", "5", 0 );
m_HUD_saytext = gEngfuncs.pfnRegisterVariable("hud_saytext", "1", 0);
m_HUD_saytext_time = gEngfuncs.pfnRegisterVariable("hud_saytext_time", "5", 0);
m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission
@ -65,14 +65,14 @@ bool CHudSayText :: Init()
}
void CHudSayText :: InitHUDData()
void CHudSayText ::InitHUDData()
{
memset( g_szLineBuffer, 0, sizeof g_szLineBuffer );
memset( g_pflNameColors, 0, sizeof g_pflNameColors );
memset( g_iNameLengths, 0, sizeof g_iNameLengths );
memset(g_szLineBuffer, 0, sizeof g_szLineBuffer);
memset(g_pflNameColors, 0, sizeof g_pflNameColors);
memset(g_iNameLengths, 0, sizeof g_iNameLengths);
}
bool CHudSayText :: VidInit()
bool CHudSayText ::VidInit()
{
return true;
}
@ -80,14 +80,14 @@ bool CHudSayText :: VidInit()
int ScrollTextUp()
{
ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer
ConsolePrint(g_szLineBuffer[0]); // move the first line into the console buffer
g_szLineBuffer[MAX_LINES][0] = 0;
memmove( g_szLineBuffer[0], g_szLineBuffer[1], sizeof(g_szLineBuffer) - sizeof(g_szLineBuffer[0]) ); // overwrite the first line
memmove( &g_pflNameColors[0], &g_pflNameColors[1], sizeof(g_pflNameColors) - sizeof(g_pflNameColors[0]) );
memmove( &g_iNameLengths[0], &g_iNameLengths[1], sizeof(g_iNameLengths) - sizeof(g_iNameLengths[0]) );
g_szLineBuffer[MAX_LINES-1][0] = 0;
memmove(g_szLineBuffer[0], g_szLineBuffer[1], sizeof(g_szLineBuffer) - sizeof(g_szLineBuffer[0])); // overwrite the first line
memmove(&g_pflNameColors[0], &g_pflNameColors[1], sizeof(g_pflNameColors) - sizeof(g_pflNameColors[0]));
memmove(&g_iNameLengths[0], &g_iNameLengths[1], sizeof(g_iNameLengths) - sizeof(g_iNameLengths[0]));
g_szLineBuffer[MAX_LINES - 1][0] = 0;
if ( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines
if (g_szLineBuffer[0][0] == ' ') // also scroll up following lines
{
g_szLineBuffer[0][0] = 2;
return 1 + ScrollTextUp();
@ -96,22 +96,22 @@ int ScrollTextUp()
return 1;
}
bool CHudSayText :: Draw( float flTime )
bool CHudSayText ::Draw(float flTime)
{
int y = Y_START;
if ( ( gViewPort && !gViewPort->AllowedToPrintText()) || 0 == m_HUD_saytext->value )
if ((gViewPort && !gViewPort->AllowedToPrintText()) || 0 == m_HUD_saytext->value)
return true;
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = V_min( flScrollTime, flTime + m_HUD_saytext_time->value );
flScrollTime = V_min(flScrollTime, flTime + m_HUD_saytext_time->value);
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = V_min( flScrollTime, flTime + m_HUD_saytext_time->value );
flScrollTime = V_min(flScrollTime, flTime + m_HUD_saytext_time->value);
if ( flScrollTime <= flTime )
if (flScrollTime <= flTime)
{
if ( '\0' != *g_szLineBuffer[0])
if ('\0' != *g_szLineBuffer[0])
{
flScrollTime = flTime + m_HUD_saytext_time->value;
// push the console up
@ -123,37 +123,37 @@ bool CHudSayText :: Draw( float flTime )
}
}
for ( int i = 0; i < MAX_LINES; i++ )
for (int i = 0; i < MAX_LINES; i++)
{
if ( '\0' != *g_szLineBuffer[i])
if ('\0' != *g_szLineBuffer[i])
{
if ( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] )
if (*g_szLineBuffer[i] == 2 && g_pflNameColors[i])
{
// it's a saytext string
char *buf = static_cast<char *>( _alloca( strlen( g_szLineBuffer[i] ) ) );
if ( buf )
char* buf = static_cast<char*>(_alloca(strlen(g_szLineBuffer[i])));
if (buf)
{
//char buf[MAX_PLAYER_NAME_LENGTH+32];
// draw the first x characters in the player color
strncpy( buf, g_szLineBuffer[i], V_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) );
buf[ V_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31) ] = 0;
gEngfuncs.pfnDrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
int x = DrawConsoleString( LINE_START, y, buf + 1 ); // don't draw the control code at the start
strncpy( buf, g_szLineBuffer[i] + g_iNameLengths[i], strlen( g_szLineBuffer[i] ));
buf[ strlen( g_szLineBuffer[i] + g_iNameLengths[i] ) - 1 ] = '\0';
strncpy(buf, g_szLineBuffer[i], V_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 32));
buf[V_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31)] = 0;
gEngfuncs.pfnDrawSetTextColor(g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2]);
int x = DrawConsoleString(LINE_START, y, buf + 1); // don't draw the control code at the start
strncpy(buf, g_szLineBuffer[i] + g_iNameLengths[i], strlen(g_szLineBuffer[i]));
buf[strlen(g_szLineBuffer[i] + g_iNameLengths[i]) - 1] = '\0';
// color is reset after each string draw
DrawConsoleString( x, y, buf );
DrawConsoleString(x, y, buf);
}
else
{
assert( "Not able to alloca chat buffer!\n");
assert("Not able to alloca chat buffer!\n");
}
}
else
{
// normal draw
DrawConsoleString( LINE_START, y, g_szLineBuffer[i] );
DrawConsoleString(LINE_START, y, g_szLineBuffer[i]);
}
}
@ -163,33 +163,33 @@ bool CHudSayText :: Draw( float flTime )
return true;
}
bool CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
bool CHudSayText ::MsgFunc_SayText(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int client_index = READ_BYTE(); // the client who spoke the message
SayTextPrint(READ_STRING(), iSize - 1, client_index);
int client_index = READ_BYTE(); // the client who spoke the message
SayTextPrint( READ_STRING(), iSize - 1, client_index );
return true;
}
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
void CHudSayText ::SayTextPrint(const char* pszBuf, int iBufSize, int clientIndex)
{
if ( gViewPort && gViewPort->AllowedToPrintText() == false )
if (gViewPort && gViewPort->AllowedToPrintText() == false)
{
// Print it straight to the console
ConsolePrint( pszBuf );
ConsolePrint(pszBuf);
return;
}
int i;
// find an empty string slot
for ( i = 0; i < MAX_LINES; i++ )
for (i = 0; i < MAX_LINES; i++)
{
if ( '\0' == *g_szLineBuffer[i])
if ('\0' == *g_szLineBuffer[i])
break;
}
if ( i == MAX_LINES )
if (i == MAX_LINES)
{
// force scroll buffer up
ScrollTextUp();
@ -200,125 +200,124 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn
g_pflNameColors[i] = NULL;
// if it's a say message, search for the players name in the string
if ( *pszBuf == 2 && clientIndex > 0 )
if (*pszBuf == 2 && clientIndex > 0)
{
gEngfuncs.pfnGetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] );
const char *pName = g_PlayerInfoList[clientIndex].name;
gEngfuncs.pfnGetPlayerInfo(clientIndex, &g_PlayerInfoList[clientIndex]);
const char* pName = g_PlayerInfoList[clientIndex].name;
if ( pName )
if (pName)
{
const char *nameInString = strstr( pszBuf, pName );
const char* nameInString = strstr(pszBuf, pName);
if ( nameInString )
if (nameInString)
{
g_iNameLengths[i] = strlen( pName ) + (nameInString - pszBuf);
g_pflNameColors[i] = GetClientColor( clientIndex );
g_iNameLengths[i] = strlen(pName) + (nameInString - pszBuf);
g_pflNameColors[i] = GetClientColor(clientIndex);
}
}
}
strncpy( g_szLineBuffer[i], pszBuf, MAX_CHARS_PER_LINE );
strncpy(g_szLineBuffer[i], pszBuf, MAX_CHARS_PER_LINE);
// make sure the text fits in one line
EnsureTextFitsInOneLineAndWrapIfHaveTo( i );
EnsureTextFitsInOneLineAndWrapIfHaveTo(i);
// Set scroll time
if ( i == 0 )
if (i == 0)
{
flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value;
}
m_iFlags |= HUD_ACTIVE;
PlaySound( "misc/talk.wav", 1 );
PlaySound("misc/talk.wav", 1);
Y_START = ScreenHeight - 60 - ( line_height * (MAX_LINES+2) );
Y_START = ScreenHeight - 60 - (line_height * (MAX_LINES + 2));
}
void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
void CHudSayText ::EnsureTextFitsInOneLineAndWrapIfHaveTo(int line)
{
int line_width = 0;
GetConsoleStringSize( g_szLineBuffer[line], &line_width, &line_height );
GetConsoleStringSize(g_szLineBuffer[line], &line_width, &line_height);
if ( (line_width + LINE_START) > MAX_LINE_WIDTH )
if ((line_width + LINE_START) > MAX_LINE_WIDTH)
{ // string is too long to fit on line
// scan the string until we find what word is too long, and wrap the end of the sentence after the word
int length = LINE_START;
int tmp_len = 0;
char *last_break = NULL;
for ( char *x = g_szLineBuffer[line]; *x != 0; x++ )
char* last_break = NULL;
for (char* x = g_szLineBuffer[line]; *x != 0; x++)
{
// check for a color change, if so skip past it
if ( x[0] == '/' && x[1] == '(' )
if (x[0] == '/' && x[1] == '(')
{
x += 2;
// skip forward until past mode specifier
while ( *x != 0 && *x != ')' )
while (*x != 0 && *x != ')')
x++;
if ( *x != 0 )
if (*x != 0)
x++;
if ( *x == 0 )
if (*x == 0)
break;
}
char buf[2];
buf[1] = 0;
if ( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character
if (*x == ' ' && x != g_szLineBuffer[line]) // store each line break, except for the very first character
last_break = x;
buf[0] = *x; // get the length of the current character
GetConsoleStringSize( buf, &tmp_len, &line_height );
buf[0] = *x; // get the length of the current character
GetConsoleStringSize(buf, &tmp_len, &line_height);
length += tmp_len;
if ( length > MAX_LINE_WIDTH )
{ // needs to be broken up
if ( !last_break )
last_break = x-1;
if (length > MAX_LINE_WIDTH)
{ // needs to be broken up
if (!last_break)
last_break = x - 1;
x = last_break;
// find an empty string slot
int j;
do
do
{
for ( j = 0; j < MAX_LINES; j++ )
for (j = 0; j < MAX_LINES; j++)
{
if ( '\0' == *g_szLineBuffer[j])
if ('\0' == *g_szLineBuffer[j])
break;
}
if ( j == MAX_LINES )
if (j == MAX_LINES)
{
// need to make more room to display text, scroll stuff up then fix the pointers
int linesmoved = ScrollTextUp();
line -= linesmoved;
last_break = last_break - (sizeof(g_szLineBuffer[0]) * linesmoved);
}
}
while ( j == MAX_LINES );
} while (j == MAX_LINES);
// copy remaining string into next buffer, making sure it starts with a space character
if ( (char)*last_break == (char)' ' )
if ((char)*last_break == (char)' ')
{
int linelen = strlen(g_szLineBuffer[j]);
int remaininglen = strlen(last_break);
if ( (linelen - remaininglen) <= MAX_CHARS_PER_LINE )
strcat( g_szLineBuffer[j], last_break );
if ((linelen - remaininglen) <= MAX_CHARS_PER_LINE)
strcat(g_szLineBuffer[j], last_break);
}
else
{
if ( (strlen(g_szLineBuffer[j]) - strlen(last_break) - 2) < MAX_CHARS_PER_LINE )
if ((strlen(g_szLineBuffer[j]) - strlen(last_break) - 2) < MAX_CHARS_PER_LINE)
{
strcat( g_szLineBuffer[j], " " );
strcat( g_szLineBuffer[j], last_break );
strcat(g_szLineBuffer[j], " ");
strcat(g_szLineBuffer[j], last_break);
}
}
*last_break = 0; // cut off the last string
EnsureTextFitsInOneLineAndWrapIfHaveTo( j );
EnsureTextFitsInOneLineAndWrapIfHaveTo(j);
break;
}
}

View file

@ -25,13 +25,13 @@
#include "parsemsg.h"
#include "event_api.h"
DECLARE_MESSAGE( m_StatusIcons, StatusIcon );
DECLARE_MESSAGE(m_StatusIcons, StatusIcon);
bool CHudStatusIcons::Init()
{
HOOK_MESSAGE( StatusIcon );
HOOK_MESSAGE(StatusIcon);
gHUD.AddHudElem( this );
gHUD.AddHudElem(this);
Reset();
@ -46,31 +46,31 @@ bool CHudStatusIcons::VidInit()
void CHudStatusIcons::Reset()
{
memset( m_IconList, 0, sizeof m_IconList );
memset(m_IconList, 0, sizeof m_IconList);
m_iFlags &= ~HUD_ACTIVE;
}
// Draw status icons along the left-hand side of the screen
bool CHudStatusIcons::Draw( float flTime )
bool CHudStatusIcons::Draw(float flTime)
{
if (0 != gEngfuncs.IsSpectateOnly())
return true;
// find starting position to draw from, along right-hand side of screen
int x = 5;
int y = ScreenHeight / 2;
// loop through icon list, and draw any valid icons drawing up from the middle of screen
for ( int i = 0; i < MAX_ICONSPRITES; i++ )
for (int i = 0; i < MAX_ICONSPRITES; i++)
{
if ( 0 != m_IconList[i].spr )
if (0 != m_IconList[i].spr)
{
y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5;
SPR_Set( m_IconList[i].spr, m_IconList[i].r, m_IconList[i].g, m_IconList[i].b );
SPR_DrawAdditive( 0, x, y, &m_IconList[i].rc );
y -= (m_IconList[i].rc.bottom - m_IconList[i].rc.top) + 5;
SPR_Set(m_IconList[i].spr, m_IconList[i].r, m_IconList[i].g, m_IconList[i].b);
SPR_DrawAdditive(0, x, y, &m_IconList[i].rc);
}
}
return true;
}
@ -81,82 +81,82 @@ bool CHudStatusIcons::Draw( float flTime )
// byte : red
// byte : green
// byte : blue
bool CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *pbuf )
bool CHudStatusIcons::MsgFunc_StatusIcon(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
bool ShouldEnable = READ_BYTE() != 0;
char *pszIconName = READ_STRING();
if ( ShouldEnable )
char* pszIconName = READ_STRING();
if (ShouldEnable)
{
int r = READ_BYTE();
int g = READ_BYTE();
int b = READ_BYTE();
EnableIcon( pszIconName, r, g, b );
EnableIcon(pszIconName, r, g, b);
m_iFlags |= HUD_ACTIVE;
}
else
{
DisableIcon( pszIconName );
DisableIcon(pszIconName);
}
return true;
}
// add the icon to the icon list, and set it's drawing color
void CHudStatusIcons::EnableIcon( const char *pszIconName, unsigned char red, unsigned char green, unsigned char blue )
void CHudStatusIcons::EnableIcon(const char* pszIconName, unsigned char red, unsigned char green, unsigned char blue)
{
int i;
// check to see if the sprite is in the current list
for ( i = 0; i < MAX_ICONSPRITES; i++ )
for (i = 0; i < MAX_ICONSPRITES; i++)
{
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
if (!stricmp(m_IconList[i].szSpriteName, pszIconName))
break;
}
if ( i == MAX_ICONSPRITES )
if (i == MAX_ICONSPRITES)
{
// icon not in list, so find an empty slot to add to
for ( i = 0; i < MAX_ICONSPRITES; i++ )
for (i = 0; i < MAX_ICONSPRITES; i++)
{
if ( 0 == m_IconList[i].spr )
if (0 == m_IconList[i].spr)
break;
}
}
// if we've run out of space in the list, overwrite the first icon
if ( i == MAX_ICONSPRITES )
if (i == MAX_ICONSPRITES)
{
i = 0;
}
// Load the sprite and add it to the list
// the sprite must be listed in hud.txt
int spr_index = gHUD.GetSpriteIndex( pszIconName );
m_IconList[i].spr = gHUD.GetSprite( spr_index );
m_IconList[i].rc = gHUD.GetSpriteRect( spr_index );
int spr_index = gHUD.GetSpriteIndex(pszIconName);
m_IconList[i].spr = gHUD.GetSprite(spr_index);
m_IconList[i].rc = gHUD.GetSpriteRect(spr_index);
m_IconList[i].r = red;
m_IconList[i].g = green;
m_IconList[i].b = blue;
strcpy( m_IconList[i].szSpriteName, pszIconName );
strcpy(m_IconList[i].szSpriteName, pszIconName);
// Hack: Play Timer sound when a grenade icon is played (in 0.8 seconds)
if ( strstr(m_IconList[i].szSpriteName, "grenade") )
if (strstr(m_IconList[i].szSpriteName, "grenade"))
{
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer();
gEngfuncs.pEventAPI->EV_PlaySound( pthisplayer->index, pthisplayer->origin, CHAN_STATIC, "weapons/timer.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
cl_entity_t* pthisplayer = gEngfuncs.GetLocalPlayer();
gEngfuncs.pEventAPI->EV_PlaySound(pthisplayer->index, pthisplayer->origin, CHAN_STATIC, "weapons/timer.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
}
}
void CHudStatusIcons::DisableIcon( const char *pszIconName )
void CHudStatusIcons::DisableIcon(const char* pszIconName)
{
// find the sprite is in the current list
for ( int i = 0; i < MAX_ICONSPRITES; i++ )
for (int i = 0; i < MAX_ICONSPRITES; i++)
{
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
if (!stricmp(m_IconList[i].szSpriteName, pszIconName))
{
// clear the item from the list
memset( &m_IconList[i], 0, sizeof(icon_sprite_t) );
memset(&m_IconList[i], 0, sizeof(icon_sprite_t));
return;
}
}

View file

@ -26,92 +26,92 @@
#include <string.h>
#include <stdio.h>
DECLARE_MESSAGE( m_StatusBar, StatusText );
DECLARE_MESSAGE( m_StatusBar, StatusValue );
DECLARE_MESSAGE(m_StatusBar, StatusText);
DECLARE_MESSAGE(m_StatusBar, StatusValue);
#ifdef _TFC
#define STATUSBAR_ID_LINE 2
#define STATUSBAR_ID_LINE 2
#else
#define STATUSBAR_ID_LINE 1
#define STATUSBAR_ID_LINE 1
#endif
float *GetClientColor( int clientIndex );
float* GetClientColor(int clientIndex);
extern float g_ColorYellow[3];
bool CHudStatusBar :: Init()
bool CHudStatusBar ::Init()
{
gHUD.AddHudElem( this );
gHUD.AddHudElem(this);
HOOK_MESSAGE( StatusText );
HOOK_MESSAGE( StatusValue );
HOOK_MESSAGE(StatusText);
HOOK_MESSAGE(StatusValue);
Reset();
CVAR_CREATE( "hud_centerid", "0", FCVAR_ARCHIVE );
CVAR_CREATE("hud_centerid", "0", FCVAR_ARCHIVE);
return true;
}
bool CHudStatusBar :: VidInit()
bool CHudStatusBar ::VidInit()
{
// Load sprites here
return true;
}
void CHudStatusBar :: Reset()
void CHudStatusBar ::Reset()
{
int i = 0;
m_iFlags &= ~HUD_ACTIVE; // start out inactive
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ )
m_iFlags &= ~HUD_ACTIVE; // start out inactive
for (i = 0; i < MAX_STATUSBAR_LINES; i++)
m_szStatusText[i][0] = 0;
memset( m_iStatusValues, 0, sizeof m_iStatusValues );
memset(m_iStatusValues, 0, sizeof m_iStatusValues);
m_iStatusValues[0] = 1; // 0 is the special index, which always returns true
m_iStatusValues[0] = 1; // 0 is the special index, which always returns true
// reset our colors for the status bar lines (yellow is default)
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ )
for (i = 0; i < MAX_STATUSBAR_LINES; i++)
m_pflNameColors[i] = g_ColorYellow;
}
void CHudStatusBar :: ParseStatusString( int line_num )
void CHudStatusBar ::ParseStatusString(int line_num)
{
// localise string first
char szBuffer[MAX_STATUSTEXT_LENGTH];
memset( szBuffer, 0, sizeof szBuffer );
gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH );
memset(szBuffer, 0, sizeof szBuffer);
gHUD.m_TextMessage.LocaliseTextString(m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH);
// parse m_szStatusText & m_iStatusValues into m_szStatusBar
memset( m_szStatusBar[line_num], 0, MAX_STATUSTEXT_LENGTH );
char *src = szBuffer;
char *dst = m_szStatusBar[line_num];
memset(m_szStatusBar[line_num], 0, MAX_STATUSTEXT_LENGTH);
char* src = szBuffer;
char* dst = m_szStatusBar[line_num];
char *src_start = src, *dst_start = dst;
while ( *src != 0 )
while (*src != 0)
{
while ( *src == '\n' )
src++; // skip over any newlines
while (*src == '\n')
src++; // skip over any newlines
if ( ((src - src_start) >= MAX_STATUSTEXT_LENGTH) || ((dst - dst_start) >= MAX_STATUSTEXT_LENGTH) )
if (((src - src_start) >= MAX_STATUSTEXT_LENGTH) || ((dst - dst_start) >= MAX_STATUSTEXT_LENGTH))
break;
int index = atoi( src );
int index = atoi(src);
// should we draw this line?
if ( (index >= 0 && index < MAX_STATUSBAR_VALUES) && (m_iStatusValues[index] != 0) )
{ // parse this line and append result to the status bar
while ( *src >= '0' && *src <= '9' )
if ((index >= 0 && index < MAX_STATUSBAR_VALUES) && (m_iStatusValues[index] != 0))
{ // parse this line and append result to the status bar
while (*src >= '0' && *src <= '9')
src++;
if ( *src == '\n' || *src == 0 )
if (*src == '\n' || *src == 0)
continue; // no more left in this text line
// copy the text, char by char, until we hit a % or a \n
while ( *src != '\n' && *src != 0 )
while (*src != '\n' && *src != 0)
{
if ( *src != '%' )
{ // just copy the character
if (*src != '%')
{ // just copy the character
*dst = *src;
dst++, src++;
}
@ -121,7 +121,7 @@ void CHudStatusBar :: ParseStatusString( int line_num )
char valtype = *(++src); // move over %
// if it's a %, draw a % sign
if ( valtype == '%' )
if (valtype == '%')
{
*dst = valtype;
dst++, src++;
@ -129,39 +129,39 @@ void CHudStatusBar :: ParseStatusString( int line_num )
}
// move over descriptor, then get and move over the index
index = atoi( ++src );
while ( *src >= '0' && *src <= '9' )
index = atoi(++src);
while (*src >= '0' && *src <= '9')
src++;
if ( index >= 0 && index < MAX_STATUSBAR_VALUES )
if (index >= 0 && index < MAX_STATUSBAR_VALUES)
{
int indexval = m_iStatusValues[index];
// get the string to substitute in place of the %XX
char szRepString[MAX_PLAYER_NAME_LENGTH];
switch ( valtype )
switch (valtype)
{
case 'p': // player name
gEngfuncs.pfnGetPlayerInfo( indexval, &g_PlayerInfoList[indexval] );
if ( g_PlayerInfoList[indexval].name != NULL )
case 'p': // player name
gEngfuncs.pfnGetPlayerInfo(indexval, &g_PlayerInfoList[indexval]);
if (g_PlayerInfoList[indexval].name != NULL)
{
strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH );
m_pflNameColors[line_num] = GetClientColor( indexval );
strncpy(szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH);
m_pflNameColors[line_num] = GetClientColor(indexval);
}
else
{
strcpy( szRepString, "******" );
strcpy(szRepString, "******");
}
break;
case 'i': // number
sprintf( szRepString, "%d", indexval );
case 'i': // number
sprintf(szRepString, "%d", indexval);
break;
default:
szRepString[0] = 0;
}
for ( char *cp = szRepString; *cp != 0 && ((dst - dst_start) < MAX_STATUSTEXT_LENGTH); cp++, dst++ )
for (char* cp = szRepString; *cp != 0 && ((dst - dst_start) < MAX_STATUSTEXT_LENGTH); cp++, dst++)
*dst = *cp;
}
}
@ -170,46 +170,46 @@ void CHudStatusBar :: ParseStatusString( int line_num )
else
{
// skip to next line of text
while ( *src != 0 && *src != '\n' )
while (*src != 0 && *src != '\n')
src++;
}
}
}
bool CHudStatusBar :: Draw( float fTime )
bool CHudStatusBar ::Draw(float fTime)
{
if ( m_bReparseString )
if (m_bReparseString)
{
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
for (int i = 0; i < MAX_STATUSBAR_LINES; i++)
{
m_pflNameColors[i] = g_ColorYellow;
ParseStatusString( i );
ParseStatusString(i);
}
m_bReparseString = false;
}
int Y_START = ScreenHeight - 52;
// Draw the status bar lines
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
for (int i = 0; i < MAX_STATUSBAR_LINES; i++)
{
int TextHeight, TextWidth;
GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );
GetConsoleStringSize(m_szStatusBar[i], &TextWidth, &TextHeight);
int x = 8;
int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen
int y = Y_START - (4 + TextHeight * i); // draw along bottom of screen
// let user set status ID bar centering
if ( (i == STATUSBAR_ID_LINE) && 0 != CVAR_GET_FLOAT("hud_centerid") )
if ((i == STATUSBAR_ID_LINE) && 0 != CVAR_GET_FLOAT("hud_centerid"))
{
x = V_max( 0, V_max(2, (ScreenWidth - TextWidth)) / 2 );
y = (ScreenHeight / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid"));
x = V_max(0, V_max(2, (ScreenWidth - TextWidth)) / 2);
y = (ScreenHeight / 2) + (TextHeight * CVAR_GET_FLOAT("hud_centerid"));
}
if ( m_pflNameColors[i] )
gEngfuncs.pfnDrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
if (m_pflNameColors[i])
gEngfuncs.pfnDrawSetTextColor(m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2]);
DrawConsoleString( x, y, m_szStatusBar[i] );
DrawConsoleString(x, y, m_szStatusBar[i]);
}
return true;
@ -217,7 +217,7 @@ bool CHudStatusBar :: Draw( float fTime )
// Message handler for StatusText message
// accepts two values:
// byte: line number of status bar text
// byte: line number of status bar text
// string: status bar text
// this string describes how the status bar should be drawn
// a semi-regular expression:
@ -227,17 +227,17 @@ bool CHudStatusBar :: Draw( float fTime )
// if StatusValue[slotnum] != 0, the following string is drawn, upto the next newline - otherwise the text is skipped upto next newline
// %pX, where X is an integer, will substitute a player name here, getting the player index from StatusValue[X]
// %iX, where X is an integer, will substitute a number here, getting the number from StatusValue[X]
bool CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf )
bool CHudStatusBar ::MsgFunc_StatusText(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int line = READ_BYTE();
if ( line < 0 || line > MAX_STATUSBAR_LINES )
if (line < 0 || line > MAX_STATUSBAR_LINES)
return true;
strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH );
m_szStatusText[line][MAX_STATUSTEXT_LENGTH-1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long)
strncpy(m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH);
m_szStatusText[line][MAX_STATUSTEXT_LENGTH - 1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long)
m_iFlags |= HUD_ACTIVE;
m_bReparseString = true;
@ -249,17 +249,17 @@ bool CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *
// accepts two values:
// byte: index into the status value array
// short: value to store
bool CHudStatusBar :: MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf )
bool CHudStatusBar ::MsgFunc_StatusValue(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int index = READ_BYTE();
if ( index < 1 || index > MAX_STATUSBAR_VALUES )
if (index < 1 || index > MAX_STATUSBAR_VALUES)
return true; // index out of range
m_iStatusValues[index] = READ_SHORT();
m_bReparseString = true;
return true;
}

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -20,10 +20,10 @@ AngleQuaternion
====================
*/
void AngleQuaternion( float *angles, vec4_t quaternion )
void AngleQuaternion(float* angles, vec4_t quaternion)
{
float angle;
float sr, sp, sy, cr, cp, cy;
float angle;
float sr, sp, sy, cr, cp, cy;
// FIXME: rescale the inputs to 1/2 angle
angle = angles[2] * 0.5;
@ -36,10 +36,10 @@ void AngleQuaternion( float *angles, vec4_t quaternion )
sr = sin(angle);
cr = cos(angle);
quaternion[0] = sr*cp*cy-cr*sp*sy; // X
quaternion[1] = cr*sp*cy+sr*cp*sy; // Y
quaternion[2] = cr*cp*sy-sr*sp*cy; // Z
quaternion[3] = cr*cp*cy+sr*sp*sy; // W
quaternion[0] = sr * cp * cy - cr * sp * sy; // X
quaternion[1] = cr * sp * cy + sr * cp * sy; // Y
quaternion[2] = cr * cp * sy - sr * sp * cy; // Z
quaternion[3] = cr * cp * cy + sr * sp * sy; // W
}
/*
@ -48,10 +48,10 @@ QuaternionSlerp
====================
*/
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
void QuaternionSlerp(vec4_t p, vec4_t q, float t, vec4_t qt)
{
int i;
float omega, cosom, sinom, sclp, sclq;
float omega, cosom, sinom, sclp, sclq;
// decide if one of the quaternions is backwards
float a = 0;
@ -59,8 +59,8 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
for (i = 0; i < 4; i++)
{
a += (p[i]-q[i])*(p[i]-q[i]);
b += (p[i]+q[i])*(p[i]+q[i]);
a += (p[i] - q[i]) * (p[i] - q[i]);
b += (p[i] + q[i]) * (p[i] + q[i]);
}
if (a > b)
{
@ -70,23 +70,24 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
}
}
cosom = p[0]*q[0] + p[1]*q[1] + p[2]*q[2] + p[3]*q[3];
cosom = p[0] * q[0] + p[1] * q[1] + p[2] * q[2] + p[3] * q[3];
if ((1.0 + cosom) > 0.000001)
{
if ((1.0 - cosom) > 0.000001)
{
omega = acos( cosom );
sinom = sin( omega );
sclp = sin( (1.0 - t)*omega) / sinom;
sclq = sin( t*omega ) / sinom;
omega = acos(cosom);
sinom = sin(omega);
sclp = sin((1.0 - t) * omega) / sinom;
sclq = sin(t * omega) / sinom;
}
else
{
sclp = 1.0 - t;
sclq = t;
}
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
qt[i] = sclp * p[i] + sclq * q[i];
}
}
@ -96,8 +97,8 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
qt[1] = q[0];
qt[2] = -q[3];
qt[3] = q[2];
sclp = sin( (1.0 - t) * (0.5 * M_PI));
sclq = sin( t * (0.5 * M_PI));
sclp = sin((1.0 - t) * (0.5 * M_PI));
sclq = sin(t * (0.5 * M_PI));
for (i = 0; i < 3; i++)
{
qt[i] = sclp * p[i] + sclq * qt[i];
@ -111,7 +112,7 @@ QuaternionMatrix
====================
*/
void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] )
void QuaternionMatrix(vec4_t quaternion, float (*matrix)[4])
{
matrix[0][0] = 1.0 - 2.0 * quaternion[1] * quaternion[1] - 2.0 * quaternion[2] * quaternion[2];
matrix[1][0] = 2.0 * quaternion[0] * quaternion[1] + 2.0 * quaternion[3] * quaternion[2];
@ -132,7 +133,7 @@ MatrixCopy
====================
*/
void MatrixCopy( float in[3][4], float out[3][4] )
void MatrixCopy(float in[3][4], float out[3][4])
{
memcpy( out, in, sizeof( float ) * 3 * 4 );
memcpy(out, in, sizeof(float) * 3 * 4);
}

View file

@ -28,13 +28,13 @@
#include "vgui_TeamFortressViewport.h"
DECLARE_MESSAGE( m_TextMessage, TextMsg );
DECLARE_MESSAGE(m_TextMessage, TextMsg);
bool CHudTextMessage::Init()
{
HOOK_MESSAGE( TextMsg );
HOOK_MESSAGE(TextMsg);
gHUD.AddHudElem( this );
gHUD.AddHudElem(this);
Reset();
@ -44,25 +44,25 @@ bool CHudTextMessage::Init()
// Searches through the string for any msg names (indicated by a '#')
// any found are looked up in titles.txt and the new message substituted
// the new value is pushed into dst_buffer
char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size )
char* CHudTextMessage::LocaliseTextString(const char* msg, char* dst_buffer, int buffer_size)
{
char *dst = dst_buffer;
for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- )
char* dst = dst_buffer;
for (char* src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size--)
{
if ( *src == '#' )
if (*src == '#')
{
// cut msg name out of string
static char word_buf[255];
char *wdst = word_buf, *word_start = src;
for ( ++src ; (*src >= 'A' && *src <= 'z') || (*src >= '0' && *src <= '9'); wdst++, src++ )
for (++src; (*src >= 'A' && *src <= 'z') || (*src >= '0' && *src <= '9'); wdst++, src++)
{
*wdst = *src;
}
*wdst = 0;
// lookup msg name in titles.txt
client_textmessage_t *clmsg = TextMessageGet( word_buf );
if ( !clmsg || !(clmsg->pMessage) )
client_textmessage_t* clmsg = TextMessageGet(word_buf);
if (!clmsg || !(clmsg->pMessage))
{
src = word_start;
*dst = *src;
@ -71,7 +71,7 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in
}
// copy string into message over the msg name
for ( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ )
for (char* wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++)
{
*dst = *wsrc;
}
@ -85,62 +85,62 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in
}
}
dst_buffer[buffer_size-1] = 0; // ensure null termination
dst_buffer[buffer_size - 1] = 0; // ensure null termination
return dst_buffer;
}
// As above, but with a local static buffer
char *CHudTextMessage::BufferedLocaliseTextString( const char *msg )
char* CHudTextMessage::BufferedLocaliseTextString(const char* msg)
{
static char dst_buffer[1024];
LocaliseTextString( msg, dst_buffer, 1024 );
LocaliseTextString(msg, dst_buffer, 1024);
return dst_buffer;
}
// Simplified version of LocaliseTextString; assumes string is only one word
const char *CHudTextMessage::LookupString( const char *msg, int *msg_dest )
const char* CHudTextMessage::LookupString(const char* msg, int* msg_dest)
{
if ( !msg )
if (!msg)
return "";
// '#' character indicates this is a reference to a string in titles.txt, and not the string itself
if ( msg[0] == '#' )
if (msg[0] == '#')
{
// this is a message name, so look up the real message
client_textmessage_t *clmsg = TextMessageGet( msg+1 );
client_textmessage_t* clmsg = TextMessageGet(msg + 1);
if ( !clmsg || !(clmsg->pMessage) )
if (!clmsg || !(clmsg->pMessage))
return msg; // lookup failed, so return the original string
if ( msg_dest )
if (msg_dest)
{
// check to see if titles.txt info overrides msg destination
// if clmsg->effect is less than 0, then clmsg->effect holds -1 * message_destination
if ( clmsg->effect < 0 ) //
if (clmsg->effect < 0) //
*msg_dest = -clmsg->effect;
}
return clmsg->pMessage;
}
else
{ // nothing special about this message, so just return the same string
{ // nothing special about this message, so just return the same string
return msg;
}
}
void StripEndNewlineFromString( char *str )
void StripEndNewlineFromString(char* str)
{
int s = strlen( str ) - 1;
if ( str[s] == '\n' || str[s] == '\r' )
int s = strlen(str) - 1;
if (str[s] == '\n' || str[s] == '\r')
str[s] = 0;
}
// converts all '\r' characters to '\n', so that the engine can deal with the properly
// returns a pointer to str
char* ConvertCRtoNL( char *str )
char* ConvertCRtoNL(char* str)
{
for ( char *ch = str; *ch != 0; ch++ )
if ( *ch == '\r' )
for (char* ch = str; *ch != 0; ch++)
if (*ch == '\r')
*ch = '\n';
return str;
}
@ -157,56 +157,56 @@ char* ConvertCRtoNL( char *str )
// string: message parameter 4
// any string that starts with the character '#' is a message name, and is used to look up the real message in titles.txt
// the next (optional) one to four strings are parameters for that string (which can also be message names if they begin with '#')
bool CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf )
bool CHudTextMessage::MsgFunc_TextMsg(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
int msg_dest = READ_BYTE();
#define MSG_BUF_SIZE 128
static char szBuf[6][MSG_BUF_SIZE];
const char *msg_text = LookupString( READ_STRING(), &msg_dest );
msg_text = safe_strcpy( szBuf[0], msg_text , MSG_BUF_SIZE);
const char* msg_text = LookupString(READ_STRING(), &msg_dest);
msg_text = safe_strcpy(szBuf[0], msg_text, MSG_BUF_SIZE);
// keep reading strings and using C format strings for subsituting the strings into the localised text string
const char *tempsstr1 = LookupString( READ_STRING() );
char* sstr1 = safe_strcpy( szBuf[1], tempsstr1 , MSG_BUF_SIZE);
StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines
const char * tempsstr2 = LookupString( READ_STRING() );
char* sstr2 = safe_strcpy( szBuf[2], tempsstr2 , MSG_BUF_SIZE);
StripEndNewlineFromString( sstr2 );
const char * tempsstr3 = LookupString( READ_STRING() );
char* sstr3 = safe_strcpy( szBuf[3], tempsstr3 , MSG_BUF_SIZE);
StripEndNewlineFromString( sstr3 );
const char * tempsstr4 = LookupString( READ_STRING() );
char* sstr4 = safe_strcpy( szBuf[4], tempsstr4 , MSG_BUF_SIZE);
StripEndNewlineFromString( sstr4 );
char *psz = szBuf[5];
const char* tempsstr1 = LookupString(READ_STRING());
char* sstr1 = safe_strcpy(szBuf[1], tempsstr1, MSG_BUF_SIZE);
StripEndNewlineFromString(sstr1); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines
const char* tempsstr2 = LookupString(READ_STRING());
char* sstr2 = safe_strcpy(szBuf[2], tempsstr2, MSG_BUF_SIZE);
StripEndNewlineFromString(sstr2);
const char* tempsstr3 = LookupString(READ_STRING());
char* sstr3 = safe_strcpy(szBuf[3], tempsstr3, MSG_BUF_SIZE);
StripEndNewlineFromString(sstr3);
const char* tempsstr4 = LookupString(READ_STRING());
char* sstr4 = safe_strcpy(szBuf[4], tempsstr4, MSG_BUF_SIZE);
StripEndNewlineFromString(sstr4);
char* psz = szBuf[5];
if ( gViewPort && !gViewPort->AllowedToPrintText() )
if (gViewPort && !gViewPort->AllowedToPrintText())
return true;
switch ( msg_dest )
switch (msg_dest)
{
case HUD_PRINTCENTER:
safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
CenterPrint( ConvertCRtoNL( psz ) );
safe_sprintf(psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4);
CenterPrint(ConvertCRtoNL(psz));
break;
case HUD_PRINTNOTIFY:
psz[0] = 1; // mark this message to go into the notify buffer
safe_sprintf( psz+1, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) );
psz[0] = 1; // mark this message to go into the notify buffer
safe_sprintf(psz + 1, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4);
ConsolePrint(ConvertCRtoNL(psz));
break;
case HUD_PRINTTALK:
safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 );
safe_sprintf(psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4);
gHUD.m_SayText.SayTextPrint(ConvertCRtoNL(psz), 128);
break;
case HUD_PRINTCONSOLE:
safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) );
safe_sprintf(psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4);
ConsolePrint(ConvertCRtoNL(psz));
break;
}

View file

@ -24,12 +24,12 @@
#include <stdio.h>
#include "parsemsg.h"
DECLARE_MESSAGE(m_Train, Train )
DECLARE_MESSAGE(m_Train, Train)
bool CHudTrain::Init()
{
HOOK_MESSAGE( Train );
HOOK_MESSAGE(Train);
m_iPos = 0;
m_iFlags = 0;
@ -47,31 +47,30 @@ bool CHudTrain::VidInit()
bool CHudTrain::Draw(float fTime)
{
if ( 0 == m_hSprite )
if (0 == m_hSprite)
m_hSprite = LoadSprite("sprites/%d_train.spr");
if (0 != m_iPos)
{
int r, g, b, x, y;
UnpackRGB(r,g,b, RGB_YELLOWISH);
SPR_Set(m_hSprite, r, g, b );
UnpackRGB(r, g, b, RGB_YELLOWISH);
SPR_Set(m_hSprite, r, g, b);
// This should show up to the right and part way up the armor number
y = ScreenHeight - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight;
x = ScreenWidth/3 + SPR_Width(m_hSprite,0)/4;
SPR_DrawAdditive( m_iPos - 1, x, y, NULL);
y = ScreenHeight - SPR_Height(m_hSprite, 0) - gHUD.m_iFontHeight;
x = ScreenWidth / 3 + SPR_Width(m_hSprite, 0) / 4;
SPR_DrawAdditive(m_iPos - 1, x, y, NULL);
}
return true;
}
bool CHudTrain::MsgFunc_Train(const char *pszName, int iSize, void *pbuf)
bool CHudTrain::MsgFunc_Train(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
// update Train data
m_iPos = READ_BYTE();

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -20,7 +20,7 @@
#include "particleman.h"
#include "tri.h"
extern IParticleMan *g_pParticleMan;
extern IParticleMan* g_pParticleMan;
/*
=================
@ -31,12 +31,12 @@ Non-transparent triangles-- add them here
*/
void DLLEXPORT HUD_DrawNormalTriangles()
{
// RecClDrawNormalTriangles();
// RecClDrawNormalTriangles();
gHUD.m_Spectator.DrawOverview();
}
#if defined( _TFC )
#if defined(_TFC)
void RunEventList();
#endif
@ -49,12 +49,12 @@ Render any triangles with transparent rendermode needs here
*/
void DLLEXPORT HUD_DrawTransparentTriangles()
{
// RecClDrawTransparentTriangles();
// RecClDrawTransparentTriangles();
#if defined( _TFC )
#if defined(_TFC)
RunEventList();
#endif
if ( g_pParticleMan )
g_pParticleMan->Update();
if (g_pParticleMan)
g_pParticleMan->Update();
}

View file

@ -2,4 +2,4 @@
#include "particleman.h"
extern IParticleMan *g_pParticleMan;
extern IParticleMan* g_pParticleMan;

View file

@ -25,10 +25,10 @@
#include "cl_util.h"
#include <string.h>
HSPRITE LoadSprite(const char *pszName)
HSPRITE LoadSprite(const char* pszName)
{
int i;
char sz[256];
char sz[256];
if (ScreenWidth < 640)
i = 320;
@ -39,4 +39,3 @@ HSPRITE LoadSprite(const char *pszName)
return SPR_Load(sz);
}

View file

@ -5,7 +5,7 @@
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose: TFC Class Menu
// Purpose: TFC Class Menu
//
// $Workfile: $
// $Date: $
@ -34,219 +34,218 @@
#include "vgui_TeamFortressViewport.h"
// Class Menu Dimensions
#define CLASSMENU_TITLE_X XRES(40)
#define CLASSMENU_TITLE_Y YRES(32)
#define CLASSMENU_TOPLEFT_BUTTON_X XRES(40)
#define CLASSMENU_TOPLEFT_BUTTON_Y YRES(80)
#define CLASSMENU_BUTTON_SIZE_X XRES(124)
#define CLASSMENU_BUTTON_SIZE_Y YRES(24)
#define CLASSMENU_BUTTON_SPACER_Y YRES(8)
#define CLASSMENU_WINDOW_X XRES(176)
#define CLASSMENU_WINDOW_Y YRES(80)
#define CLASSMENU_WINDOW_SIZE_X XRES(424)
#define CLASSMENU_WINDOW_SIZE_Y YRES(312)
#define CLASSMENU_WINDOW_TEXT_X XRES(150)
#define CLASSMENU_WINDOW_TEXT_Y YRES(80)
#define CLASSMENU_WINDOW_NAME_X XRES(150)
#define CLASSMENU_WINDOW_NAME_Y YRES(8)
#define CLASSMENU_WINDOW_PLAYERS_Y YRES(42)
#define CLASSMENU_TITLE_X XRES(40)
#define CLASSMENU_TITLE_Y YRES(32)
#define CLASSMENU_TOPLEFT_BUTTON_X XRES(40)
#define CLASSMENU_TOPLEFT_BUTTON_Y YRES(80)
#define CLASSMENU_BUTTON_SIZE_X XRES(124)
#define CLASSMENU_BUTTON_SIZE_Y YRES(24)
#define CLASSMENU_BUTTON_SPACER_Y YRES(8)
#define CLASSMENU_WINDOW_X XRES(176)
#define CLASSMENU_WINDOW_Y YRES(80)
#define CLASSMENU_WINDOW_SIZE_X XRES(424)
#define CLASSMENU_WINDOW_SIZE_Y YRES(312)
#define CLASSMENU_WINDOW_TEXT_X XRES(150)
#define CLASSMENU_WINDOW_TEXT_Y YRES(80)
#define CLASSMENU_WINDOW_NAME_X XRES(150)
#define CLASSMENU_WINDOW_NAME_Y YRES(8)
#define CLASSMENU_WINDOW_PLAYERS_Y YRES(42)
// Creation
CClassMenuPanel::CClassMenuPanel(int iTrans, bool iRemoveMe, int x,int y,int wide,int tall) : CMenuPanel(iTrans, iRemoveMe, x,y,wide,tall)
CClassMenuPanel::CClassMenuPanel(int iTrans, bool iRemoveMe, int x, int y, int wide, int tall) : CMenuPanel(iTrans, iRemoveMe, x, y, wide, tall)
{
// don't show class graphics at below 640x480 resolution
bool bShowClassGraphic = true;
if ( ScreenWidth < 640 )
if (ScreenWidth < 640)
{
bShowClassGraphic = false;
}
memset( m_pClassImages, 0, sizeof(m_pClassImages) );
memset(m_pClassImages, 0, sizeof(m_pClassImages));
// Get the scheme used for the Titles
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
CSchemeManager* pSchemes = gViewPort->GetSchemeManager();
// schemes
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
SchemeHandle_t hClassWindowText = pSchemes->getSchemeHandle( "Briefing Text" );
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Title Font");
SchemeHandle_t hClassWindowText = pSchemes->getSchemeHandle("Briefing Text");
// color schemes
int r, g, b, a;
// Create the title
Label *pLabel = new Label( "", CLASSMENU_TITLE_X, CLASSMENU_TITLE_Y );
pLabel->setParent( this );
pLabel->setFont( pSchemes->getFont(hTitleScheme) );
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
pLabel->setFgColor( r, g, b, a );
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
pLabel->setBgColor( r, g, b, a );
pLabel->setContentAlignment( vgui::Label::a_west );
Label* pLabel = new Label("", CLASSMENU_TITLE_X, CLASSMENU_TITLE_Y);
pLabel->setParent(this);
pLabel->setFont(pSchemes->getFont(hTitleScheme));
pSchemes->getFgColor(hTitleScheme, r, g, b, a);
pLabel->setFgColor(r, g, b, a);
pSchemes->getBgColor(hTitleScheme, r, g, b, a);
pLabel->setBgColor(r, g, b, a);
pLabel->setContentAlignment(vgui::Label::a_west);
pLabel->setText(gHUD.m_TextMessage.BufferedLocaliseTextString("#Title_SelectYourClass"));
// Create the Scroll panel
m_pScrollPanel = new CTFScrollPanel( CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y );
m_pScrollPanel = new CTFScrollPanel(CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y);
m_pScrollPanel->setParent(this);
//force the scrollbars on, so after the validate clientClip will be smaller
m_pScrollPanel->setScrollBarAutoVisible(false, false);
m_pScrollPanel->setScrollBarVisible(true, true);
m_pScrollPanel->setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0) ) );
m_pScrollPanel->setBorder(new LineBorder(Color(255 * 0.7, 170 * 0.7, 0, 0)));
m_pScrollPanel->validate();
int clientWide=m_pScrollPanel->getClient()->getWide();
int clientWide = m_pScrollPanel->getClient()->getWide();
//turn scrollpanel back into auto show scrollbar mode and validate
m_pScrollPanel->setScrollBarAutoVisible(false,true);
m_pScrollPanel->setScrollBarVisible(false,false);
m_pScrollPanel->setScrollBarAutoVisible(false, true);
m_pScrollPanel->setScrollBarVisible(false, false);
m_pScrollPanel->validate();
// Create the Class buttons
#ifdef _TFC
for (int i = 0; i <= PC_RANDOM; i++)
{
char sz[256];
int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y + ( (CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y) * i );
char sz[256];
int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y + ((CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y) * i);
ActionSignal *pASignal = new CMenuHandler_StringCommandClassSelect( sTFClassSelection[i], true );
ActionSignal* pASignal = new CMenuHandler_StringCommandClassSelect(sTFClassSelection[i], true);
// Class button
sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[i] ) );
m_pButtons[i] = new ClassButton( i, sz, CLASSMENU_TOPLEFT_BUTTON_X, iYPos, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y, true);
sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(sLocalisedClasses[i]));
m_pButtons[i] = new ClassButton(i, sz, CLASSMENU_TOPLEFT_BUTTON_X, iYPos, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y, true);
// RandomPC uses '0'
if ( i >= 1 && i <= 9 )
if (i >= 1 && i <= 9)
{
sprintf(sz,"%d",i);
sprintf(sz, "%d", i);
}
else
{
sprintf(sz,"0");
sprintf(sz, "0");
}
m_pButtons[i]->setBoundKey( sz[0] );
m_pButtons[i]->setContentAlignment( vgui::Label::a_west );
m_pButtons[i]->addActionSignal( pASignal );
m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver(this, i) );
m_pButtons[i]->setParent( this );
m_pButtons[i]->setBoundKey(sz[0]);
m_pButtons[i]->setContentAlignment(vgui::Label::a_west);
m_pButtons[i]->addActionSignal(pASignal);
m_pButtons[i]->addInputSignal(new CHandler_MenuButtonOver(this, i));
m_pButtons[i]->setParent(this);
// Create the Class Info Window
//m_pClassInfoPanel[i] = new CTransparentPanel( 255, CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y );
m_pClassInfoPanel[i] = new CTransparentPanel( 255, 0, 0, clientWide, CLASSMENU_WINDOW_SIZE_Y );
m_pClassInfoPanel[i]->setParent( m_pScrollPanel->getClient() );
m_pClassInfoPanel[i] = new CTransparentPanel(255, 0, 0, clientWide, CLASSMENU_WINDOW_SIZE_Y);
m_pClassInfoPanel[i]->setParent(m_pScrollPanel->getClient());
//m_pClassInfoPanel[i]->setVisible( false );
// don't show class pic in lower resolutions
int textOffs = XRES(8);
if ( bShowClassGraphic )
if (bShowClassGraphic)
{
textOffs = CLASSMENU_WINDOW_NAME_X;
}
// Create the Class Name Label
sprintf(sz, "#Title_%s", sTFClassSelection[i]);
char* localName=CHudTextMessage::BufferedLocaliseTextString( sz );
Label *pNameLabel = new Label( "", textOffs, CLASSMENU_WINDOW_NAME_Y );
pNameLabel->setFont( pSchemes->getFont(hTitleScheme) );
pNameLabel->setParent( m_pClassInfoPanel[i] );
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
pNameLabel->setFgColor( r, g, b, a );
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
pNameLabel->setBgColor( r, g, b, a );
pNameLabel->setContentAlignment( vgui::Label::a_west );
char* localName = CHudTextMessage::BufferedLocaliseTextString(sz);
Label* pNameLabel = new Label("", textOffs, CLASSMENU_WINDOW_NAME_Y);
pNameLabel->setFont(pSchemes->getFont(hTitleScheme));
pNameLabel->setParent(m_pClassInfoPanel[i]);
pSchemes->getFgColor(hTitleScheme, r, g, b, a);
pNameLabel->setFgColor(r, g, b, a);
pSchemes->getBgColor(hTitleScheme, r, g, b, a);
pNameLabel->setBgColor(r, g, b, a);
pNameLabel->setContentAlignment(vgui::Label::a_west);
//pNameLabel->setBorder(new LineBorder());
pNameLabel->setText( "%s", localName);
pNameLabel->setText("%s", localName);
// Create the Class Image
if ( bShowClassGraphic )
if (bShowClassGraphic)
{
for ( int team = 0; team < 2; team++ )
for (int team = 0; team < 2; team++)
{
if ( team == 1 )
if (team == 1)
{
sprintf( sz, "%sred", sTFClassSelection[i] );
sprintf(sz, "%sred", sTFClassSelection[i]);
}
else
{
sprintf( sz, "%sblue", sTFClassSelection[i] );
sprintf(sz, "%sblue", sTFClassSelection[i]);
}
m_pClassImages[team][i] = new CImageLabel( sz, 0, 0, CLASSMENU_WINDOW_TEXT_X, CLASSMENU_WINDOW_TEXT_Y );
m_pClassImages[team][i] = new CImageLabel(sz, 0, 0, CLASSMENU_WINDOW_TEXT_X, CLASSMENU_WINDOW_TEXT_Y);
CImageLabel *pLabel = m_pClassImages[team][i];
pLabel->setParent( m_pClassInfoPanel[i] );
CImageLabel* pLabel = m_pClassImages[team][i];
pLabel->setParent(m_pClassInfoPanel[i]);
//pLabel->setBorder(new LineBorder());
if ( team != 1 )
if (team != 1)
{
pLabel->setVisible( false );
pLabel->setVisible(false);
}
// Reposition it based upon it's size
int xOut, yOut;
pNameLabel->getTextSize( xOut, yOut );
pLabel->setPos( (CLASSMENU_WINDOW_TEXT_X - pLabel->getWide()) / 2, yOut /2 );
pNameLabel->getTextSize(xOut, yOut);
pLabel->setPos((CLASSMENU_WINDOW_TEXT_X - pLabel->getWide()) / 2, yOut / 2);
}
}
// Create the Player count string
gHUD.m_TextMessage.LocaliseTextString( "#Title_CurrentlyOnYourTeam", m_sPlayersOnTeamString, STRLENMAX_PLAYERSONTEAM );
m_pPlayers[i] = new Label( "", textOffs, CLASSMENU_WINDOW_PLAYERS_Y );
m_pPlayers[i]->setParent( m_pClassInfoPanel[i] );
m_pPlayers[i]->setBgColor( 0, 0, 0, 255 );
m_pPlayers[i]->setContentAlignment( vgui::Label::a_west );
m_pPlayers[i]->setFont( pSchemes->getFont(hClassWindowText) );
gHUD.m_TextMessage.LocaliseTextString("#Title_CurrentlyOnYourTeam", m_sPlayersOnTeamString, STRLENMAX_PLAYERSONTEAM);
m_pPlayers[i] = new Label("", textOffs, CLASSMENU_WINDOW_PLAYERS_Y);
m_pPlayers[i]->setParent(m_pClassInfoPanel[i]);
m_pPlayers[i]->setBgColor(0, 0, 0, 255);
m_pPlayers[i]->setContentAlignment(vgui::Label::a_west);
m_pPlayers[i]->setFont(pSchemes->getFont(hClassWindowText));
// Open up the Class Briefing File
sprintf(sz, "classes/short_%s.txt", sTFClassSelection[i]);
char *cText = "Class Description not available.";
char *pfile = (char *)gEngfuncs.COM_LoadFile( sz, 5, NULL );
char* cText = "Class Description not available.";
char* pfile = (char*)gEngfuncs.COM_LoadFile(sz, 5, NULL);
if (pfile)
{
cText = pfile;
}
// Create the Text info window
TextPanel *pTextWindow = new TextPanel(cText, textOffs, CLASSMENU_WINDOW_TEXT_Y, (CLASSMENU_WINDOW_SIZE_X - textOffs)-5, CLASSMENU_WINDOW_SIZE_Y - CLASSMENU_WINDOW_TEXT_Y);
pTextWindow->setParent( m_pClassInfoPanel[i] );
pTextWindow->setFont( pSchemes->getFont(hClassWindowText) );
pSchemes->getFgColor( hClassWindowText, r, g, b, a );
pTextWindow->setFgColor( r, g, b, a );
pSchemes->getBgColor( hClassWindowText, r, g, b, a );
pTextWindow->setBgColor( r, g, b, a );
TextPanel* pTextWindow = new TextPanel(cText, textOffs, CLASSMENU_WINDOW_TEXT_Y, (CLASSMENU_WINDOW_SIZE_X - textOffs) - 5, CLASSMENU_WINDOW_SIZE_Y - CLASSMENU_WINDOW_TEXT_Y);
pTextWindow->setParent(m_pClassInfoPanel[i]);
pTextWindow->setFont(pSchemes->getFont(hClassWindowText));
pSchemes->getFgColor(hClassWindowText, r, g, b, a);
pTextWindow->setFgColor(r, g, b, a);
pSchemes->getBgColor(hClassWindowText, r, g, b, a);
pTextWindow->setBgColor(r, g, b, a);
// Resize the Info panel to fit it all
int wide,tall;
pTextWindow->getTextImage()->getTextSizeWrapped( wide,tall);
pTextWindow->setSize(wide,tall);
int wide, tall;
pTextWindow->getTextImage()->getTextSizeWrapped(wide, tall);
pTextWindow->setSize(wide, tall);
int xx,yy;
pTextWindow->getPos(xx,yy);
int maxX=xx+wide;
int maxY=yy+tall;
int xx, yy;
pTextWindow->getPos(xx, yy);
int maxX = xx + wide;
int maxY = yy + tall;
//check to see if the image goes lower than the text
//just use the red teams [0] images
if(m_pClassImages[0][i]!=null)
if (m_pClassImages[0][i] != null)
{
m_pClassImages[0][i]->getPos(xx,yy);
if((yy+m_pClassImages[0][i]->getTall())>maxY)
m_pClassImages[0][i]->getPos(xx, yy);
if ((yy + m_pClassImages[0][i]->getTall()) > maxY)
{
maxY=yy+m_pClassImages[0][i]->getTall();
maxY = yy + m_pClassImages[0][i]->getTall();
}
}
m_pClassInfoPanel[i]->setSize( maxX , maxY );
if (pfile) gEngfuncs.COM_FreeFile( pfile );
m_pClassInfoPanel[i]->setSize(maxX, maxY);
if (pfile)
gEngfuncs.COM_FreeFile(pfile);
//m_pClassInfoPanel[i]->setBorder(new LineBorder());
}
#endif
// Create the Cancel button
m_pCancelButton = new CommandButton( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Menu_Cancel" ), CLASSMENU_TOPLEFT_BUTTON_X, 0, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y);
m_pCancelButton->setParent( this );
m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow(HIDE_TEXTWINDOW) );
m_pCancelButton = new CommandButton(gHUD.m_TextMessage.BufferedLocaliseTextString("#Menu_Cancel"), CLASSMENU_TOPLEFT_BUTTON_X, 0, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y);
m_pCancelButton->setParent(this);
m_pCancelButton->addActionSignal(new CMenuHandler_TextWindow(HIDE_TEXTWINDOW));
m_iCurrentInfo = 0;
}
@ -257,7 +256,7 @@ void CClassMenuPanel::Update()
if (0 == g_iTeamNumber)
return;
int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y;
int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y;
// Cycle through the rest of the buttons
#ifdef _TFC
@ -265,118 +264,118 @@ void CClassMenuPanel::Update()
{
bool bCivilian = (gViewPort->GetValidClasses(g_iTeamNumber) == -1);
if ( bCivilian )
if (bCivilian)
{
// If this team can only be civilians, only the civilian button's visible
if (i == 0)
{
m_pButtons[0]->setVisible( true );
SetActiveInfo( 0 );
m_pButtons[0]->setVisible(true);
SetActiveInfo(0);
iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y;
}
else
{
m_pButtons[i]->setVisible( false );
m_pButtons[i]->setVisible(false);
}
}
else
else
{
if ( m_pButtons[i]->IsNotValid() || i == 0 )
if (m_pButtons[i]->IsNotValid() || i == 0)
{
m_pButtons[i]->setVisible( false );
m_pButtons[i]->setVisible(false);
}
else
{
m_pButtons[i]->setVisible( true );
m_pButtons[i]->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos );
m_pButtons[i]->setVisible(true);
m_pButtons[i]->setPos(CLASSMENU_TOPLEFT_BUTTON_X, iYPos);
iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y;
// Start with the first option up
if (!m_iCurrentInfo)
SetActiveInfo( i );
SetActiveInfo(i);
}
}
// Now count the number of teammembers of this class
int iTotal = 0;
for ( int j = 1; j < MAX_PLAYERS; j++ )
for (int j = 1; j < MAX_PLAYERS; j++)
{
if ( g_PlayerInfoList[j].name == NULL )
if (g_PlayerInfoList[j].name == NULL)
continue; // empty player slot, skip
if ( g_PlayerExtraInfo[j].teamname[0] == 0 )
if (g_PlayerExtraInfo[j].teamname[0] == 0)
continue; // skip over players who are not in a team
if ( g_PlayerInfoList[j].thisplayer )
if (g_PlayerInfoList[j].thisplayer)
continue; // skip this player
if ( g_PlayerExtraInfo[j].teamnumber != g_iTeamNumber )
if (g_PlayerExtraInfo[j].teamnumber != g_iTeamNumber)
continue; // skip over players in other teams
// If this team is forced to be civilians, just count the number of teammates
if ( g_PlayerExtraInfo[j].playerclass != i && !bCivilian )
if (g_PlayerExtraInfo[j].playerclass != i && !bCivilian)
continue;
iTotal++;
}
char sz[256];
char sz[256];
sprintf(sz, m_sPlayersOnTeamString, iTotal);
m_pPlayers[i]->setText( "%s", sz );
m_pPlayers[i]->setText("%s", sz);
// Set the text color to the teamcolor
m_pPlayers[i]->setFgColor( iTeamColors[g_iTeamNumber % iNumberOfTeamColors][0],
iTeamColors[g_iTeamNumber % iNumberOfTeamColors][1],
iTeamColors[g_iTeamNumber % iNumberOfTeamColors][2],
0 );
m_pPlayers[i]->setFgColor(iTeamColors[g_iTeamNumber % iNumberOfTeamColors][0],
iTeamColors[g_iTeamNumber % iNumberOfTeamColors][1],
iTeamColors[g_iTeamNumber % iNumberOfTeamColors][2],
0);
// set the graphic to be the team pick
for ( int team = 0; team < MAX_TEAMS; team++ )
for (int team = 0; team < MAX_TEAMS; team++)
{
// unset all the other images
if ( m_pClassImages[team][i] )
if (m_pClassImages[team][i])
{
m_pClassImages[team][i]->setVisible( false );
m_pClassImages[team][i]->setVisible(false);
}
// set the current team image
if ( m_pClassImages[g_iTeamNumber-1][i] != NULL )
if (m_pClassImages[g_iTeamNumber - 1][i] != NULL)
{
m_pClassImages[g_iTeamNumber-1][i]->setVisible( true );
m_pClassImages[g_iTeamNumber - 1][i]->setVisible(true);
}
else if ( m_pClassImages[0][i] )
else if (m_pClassImages[0][i])
{
m_pClassImages[0][i]->setVisible( true );
m_pClassImages[0][i]->setVisible(true);
}
}
}
#endif
// If the player already has a class, make the cancel button visible
if ( 0 != g_iPlayerClass )
if (0 != g_iPlayerClass)
{
m_pCancelButton->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos );
m_pCancelButton->setVisible( true );
m_pCancelButton->setPos(CLASSMENU_TOPLEFT_BUTTON_X, iYPos);
m_pCancelButton->setVisible(true);
}
else
{
m_pCancelButton->setVisible( false );
m_pCancelButton->setVisible(false);
}
}
//======================================
// Key inputs for the Class Menu
bool CClassMenuPanel::SlotInput( int iSlot )
bool CClassMenuPanel::SlotInput(int iSlot)
{
if ( (iSlot < 0) || (iSlot > 9) )
if ((iSlot < 0) || (iSlot > 9))
return false;
if ( !m_pButtons[ iSlot ] )
if (!m_pButtons[iSlot])
return false;
// Is the button pushable? (0 is special case)
if (iSlot == 0)
{
// Selects Civilian and RandomPC
if ( gViewPort->GetValidClasses(g_iTeamNumber) == -1 )
if (gViewPort->GetValidClasses(g_iTeamNumber) == -1)
{
m_pButtons[ 0 ]->fireActionSignal();
m_pButtons[0]->fireActionSignal();
return true;
}
@ -384,9 +383,9 @@ bool CClassMenuPanel::SlotInput( int iSlot )
iSlot = 10;
}
if ( !(m_pButtons[ iSlot ]->IsNotValid()) )
if (!(m_pButtons[iSlot]->IsNotValid()))
{
m_pButtons[ iSlot ]->fireActionSignal();
m_pButtons[iSlot]->fireActionSignal();
return true;
}
@ -406,31 +405,30 @@ void CClassMenuPanel::Open()
//-----------------------------------------------------------------------------
void CClassMenuPanel::Initialize()
{
setVisible( false );
m_pScrollPanel->setScrollValue( 0, 0 );
setVisible(false);
m_pScrollPanel->setScrollValue(0, 0);
}
//======================================
// Mouse is over a class button, bring up the class info
void CClassMenuPanel::SetActiveInfo( int iInput )
void CClassMenuPanel::SetActiveInfo(int iInput)
{
// Remove all the Info panels and bring up the specified one
#ifdef _TFC
for (int i = 0; i <= PC_RANDOM; i++)
{
m_pButtons[i]->setArmed( false );
m_pClassInfoPanel[i]->setVisible( false );
m_pButtons[i]->setArmed(false);
m_pClassInfoPanel[i]->setVisible(false);
}
if ( iInput > PC_RANDOM || iInput < 0 )
if (iInput > PC_RANDOM || iInput < 0)
#endif
iInput = 0;
m_pButtons[iInput]->setArmed( true );
m_pClassInfoPanel[iInput]->setVisible( true );
m_pButtons[iInput]->setArmed(true);
m_pClassInfoPanel[iInput]->setVisible(true);
m_iCurrentInfo = iInput;
m_pScrollPanel->setScrollValue(0,0);
m_pScrollPanel->setScrollValue(0, 0);
m_pScrollPanel->validate();
}

View file

@ -34,20 +34,20 @@
#include "vgui_loadtga.h"
// Arrow filenames
const char *sArrowFilenames[] =
{
"arrowup",
"arrowdn",
"arrowlt",
"arrowrt",
const char* sArrowFilenames[] =
{
"arrowup",
"arrowdn",
"arrowlt",
"arrowrt",
};
// Get the name of TGA file, without a gamedir
char *GetTGANameForRes(const char *pszName)
char* GetTGANameForRes(const char* pszName)
{
int i;
char sz[256];
static char gd[256];
char sz[256];
static char gd[256];
if (ScreenWidth < 640)
i = 320;
else
@ -60,9 +60,9 @@ char *GetTGANameForRes(const char *pszName)
//-----------------------------------------------------------------------------
// Purpose: Loads a .tga file and returns a pointer to the VGUI tga object
//-----------------------------------------------------------------------------
BitmapTGA *LoadTGAForRes( const char* pImageName )
BitmapTGA* LoadTGAForRes(const char* pImageName)
{
BitmapTGA *pTGA;
BitmapTGA* pTGA;
char sz[256];
sprintf(sz, "%%d_%s", pImageName);
@ -73,31 +73,31 @@ BitmapTGA *LoadTGAForRes( const char* pImageName )
//===========================================================
// All TFC Hud buttons are derived from this one.
CommandButton::CommandButton( const char* text,int x,int y,int wide,int tall, bool bNoHighlight) : Button("",x,y,wide,tall)
CommandButton::CommandButton(const char* text, int x, int y, int wide, int tall, bool bNoHighlight) : Button("", x, y, wide, tall)
{
m_iPlayerClass = 0;
m_bNoHighlight = bNoHighlight;
m_bFlat = false;
Init();
setText( text );
setText(text);
}
CommandButton::CommandButton( int iPlayerClass, const char* text,int x,int y,int wide,int tall, bool bFlat) : Button("",x,y,wide,tall)
CommandButton::CommandButton(int iPlayerClass, const char* text, int x, int y, int wide, int tall, bool bFlat) : Button("", x, y, wide, tall)
{
m_iPlayerClass = iPlayerClass;
m_bNoHighlight = false;
m_bFlat = bFlat;
Init();
setText( text );
setText(text);
}
CommandButton::CommandButton(const char *text, int x, int y, int wide, int tall, bool bNoHighlight, bool bFlat) : Button("",x,y,wide,tall)
CommandButton::CommandButton(const char* text, int x, int y, int wide, int tall, bool bNoHighlight, bool bFlat) : Button("", x, y, wide, tall)
{
m_iPlayerClass = 0;
m_bFlat = bFlat;
m_bNoHighlight = bNoHighlight;
Init();
setText( text );
setText(text);
}
void CommandButton::Init()
@ -110,11 +110,11 @@ void CommandButton::Init()
setFgColor(Scheme::sc_primary1);
// left align
setContentAlignment( vgui::Label::a_west );
setContentAlignment(vgui::Label::a_west);
// Add the Highlight signal
if (!m_bNoHighlight)
addInputSignal( new CHandler_CommandButtonHighlight(this) );
addInputSignal(new CHandler_CommandButtonHighlight(this));
// not bound to any button yet
m_cBoundKey = 0;
@ -128,37 +128,37 @@ void CommandButton::RecalculateText()
{
char szBuf[128];
if ( m_cBoundKey != 0 )
if (m_cBoundKey != 0)
{
if ( m_cBoundKey == (char)255 )
if (m_cBoundKey == (char)255)
{
strcpy( szBuf, m_sMainText );
strcpy(szBuf, m_sMainText);
}
else
{
sprintf( szBuf, " %c %s", m_cBoundKey, m_sMainText );
sprintf(szBuf, " %c %s", m_cBoundKey, m_sMainText);
}
szBuf[MAX_BUTTON_SIZE-1] = 0;
szBuf[MAX_BUTTON_SIZE - 1] = 0;
}
else
{
// just draw a space if no key bound
sprintf( szBuf, " %s", m_sMainText );
szBuf[MAX_BUTTON_SIZE-1] = 0;
sprintf(szBuf, " %s", m_sMainText);
szBuf[MAX_BUTTON_SIZE - 1] = 0;
}
Button::setText( szBuf );
Button::setText(szBuf);
}
void CommandButton::setText( const char *text )
void CommandButton::setText(const char* text)
{
strncpy( m_sMainText, text, MAX_BUTTON_SIZE );
m_sMainText[MAX_BUTTON_SIZE-1] = 0;
strncpy(m_sMainText, text, MAX_BUTTON_SIZE);
m_sMainText[MAX_BUTTON_SIZE - 1] = 0;
RecalculateText();
}
void CommandButton::setBoundKey( char boundKey )
void CommandButton::setBoundKey(char boundKey)
{
m_cBoundKey = boundKey;
RecalculateText();
@ -169,67 +169,67 @@ char CommandButton::getBoundKey()
return m_cBoundKey;
}
void CommandButton::AddSubMenu( CCommandMenu *pNewMenu )
void CommandButton::AddSubMenu(CCommandMenu* pNewMenu)
{
m_pSubMenu = pNewMenu;
// Prevent this button from being pushed
setMouseClickEnabled( MOUSE_LEFT, false );
setMouseClickEnabled(MOUSE_LEFT, false);
}
void CommandButton::UpdateSubMenus( int iAdjustment )
void CommandButton::UpdateSubMenus(int iAdjustment)
{
if ( m_pSubMenu )
m_pSubMenu->RecalculatePositions( iAdjustment );
if (m_pSubMenu)
m_pSubMenu->RecalculatePositions(iAdjustment);
}
void CommandButton::paint()
{
// Make the sub label paint the same as the button
if ( m_pSubLabel )
if (m_pSubLabel)
{
if ( isSelected() )
if (isSelected())
m_pSubLabel->PushDown();
else
m_pSubLabel->PushUp();
}
// draw armed button text in white
if ( isArmed() )
if (isArmed())
{
setFgColor( Scheme::sc_secondary2 );
setFgColor(Scheme::sc_secondary2);
}
else
{
setFgColor( Scheme::sc_primary1 );
setFgColor(Scheme::sc_primary1);
}
Button::paint();
}
void CommandButton::paintBackground()
{
if ( m_bFlat )
if (m_bFlat)
{
if ( isArmed() )
if (isArmed())
{
// Orange Border
drawSetColor( Scheme::sc_secondary1 );
drawOutlinedRect(0,0,_size[0],_size[1]);
drawSetColor(Scheme::sc_secondary1);
drawOutlinedRect(0, 0, _size[0], _size[1]);
}
}
else
{
if ( isArmed() )
if (isArmed())
{
// Orange highlight background
drawSetColor( Scheme::sc_primary2 );
drawFilledRect(0,0,_size[0],_size[1]);
drawSetColor(Scheme::sc_primary2);
drawFilledRect(0, 0, _size[0], _size[1]);
}
// Orange Border
drawSetColor( Scheme::sc_secondary1 );
drawOutlinedRect(0,0,_size[0],_size[1]);
drawSetColor(Scheme::sc_secondary1);
drawOutlinedRect(0, 0, _size[0], _size[1]);
}
}
@ -239,36 +239,36 @@ void CommandButton::paintBackground()
void CommandButton::cursorEntered()
{
// unarm all the other buttons in this menu
CCommandMenu *containingMenu = getParentMenu();
if ( containingMenu )
CCommandMenu* containingMenu = getParentMenu();
if (containingMenu)
{
containingMenu->ClearButtonsOfArmedState();
// make all our higher buttons armed
CCommandMenu *pCParent = containingMenu->GetParentMenu();
if ( pCParent )
CCommandMenu* pCParent = containingMenu->GetParentMenu();
if (pCParent)
{
CommandButton *pParentButton = pCParent->FindButtonWithSubmenu( containingMenu );
CommandButton* pParentButton = pCParent->FindButtonWithSubmenu(containingMenu);
pParentButton->cursorEntered();
}
}
// arm ourselves
setArmed( true );
setArmed(true);
}
//-----------------------------------------------------------------------------
// Purpose:
// Purpose:
//-----------------------------------------------------------------------------
void CommandButton::cursorExited()
{
// only clear ourselves if we have do not have a containing menu
// only stay armed if we have a sub menu
// the buttons only unarm themselves when another button is armed instead
if ( !getParentMenu() || !GetSubMenu() )
if (!getParentMenu() || !GetSubMenu())
{
setArmed( false );
setArmed(false);
}
}
@ -276,16 +276,16 @@ void CommandButton::cursorExited()
// Purpose: Returns the command menu that the button is part of, if any
// Output : CCommandMenu *
//-----------------------------------------------------------------------------
CCommandMenu *CommandButton::getParentMenu()
{
return m_pParentMenu;
CCommandMenu* CommandButton::getParentMenu()
{
return m_pParentMenu;
}
//-----------------------------------------------------------------------------
// Purpose: Sets the menu that contains this button
// Input : *pParentMenu -
// Input : *pParentMenu -
//-----------------------------------------------------------------------------
void CommandButton::setParentMenu( CCommandMenu *pParentMenu )
void CommandButton::setParentMenu(CCommandMenu* pParentMenu)
{
m_pParentMenu = pParentMenu;
}
@ -295,7 +295,7 @@ void CommandButton::setParentMenu( CCommandMenu *pParentMenu )
bool ClassButton::IsNotValid()
{
// If this is the main ChangeClass button, remove it if the player's only able to be civilians
if ( m_iPlayerClass == -1 )
if (m_iPlayerClass == -1)
{
if (gViewPort->GetValidClasses(g_iTeamNumber) == -1)
return true;
@ -305,20 +305,20 @@ bool ClassButton::IsNotValid()
// Is it an illegal class?
#ifdef _TFC
if ((gViewPort->GetValidClasses(0) & sTFValidClassInts[ m_iPlayerClass ]) || (gViewPort->GetValidClasses(g_iTeamNumber) & sTFValidClassInts[ m_iPlayerClass ]))
if ((gViewPort->GetValidClasses(0) & sTFValidClassInts[m_iPlayerClass]) || (gViewPort->GetValidClasses(g_iTeamNumber) & sTFValidClassInts[m_iPlayerClass]))
return true;
#endif
// Only check current class if they've got autokill on
bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0;
if ( bAutoKill )
{
bool bAutoKill = CVAR_GET_FLOAT("hud_classautokill") != 0;
if (bAutoKill)
{
// Is it the player's current class?
if (
if (
#ifdef _TFC
(gViewPort->IsRandomPC() && m_iPlayerClass == PC_RANDOM) ||
(gViewPort->IsRandomPC() && m_iPlayerClass == PC_RANDOM) ||
#endif
(!gViewPort->IsRandomPC() && (m_iPlayerClass == g_iPlayerClass)) )
(!gViewPort->IsRandomPC() && (m_iPlayerClass == g_iPlayerClass)))
return true;
}
@ -327,28 +327,28 @@ bool ClassButton::IsNotValid()
//===========================================================
// Button with Class image beneath it
CImageLabel::CImageLabel( const char* pImageName,int x,int y ) : Label( "", x,y )
CImageLabel::CImageLabel(const char* pImageName, int x, int y) : Label("", x, y)
{
setContentFitted(true);
m_pTGA = LoadTGAForRes(pImageName);
setImage( m_pTGA );
setImage(m_pTGA);
}
CImageLabel::CImageLabel( const char* pImageName,int x,int y,int wide,int tall ) : Label( "", x,y,wide,tall )
CImageLabel::CImageLabel(const char* pImageName, int x, int y, int wide, int tall) : Label("", x, y, wide, tall)
{
setContentFitted(true);
m_pTGA = LoadTGAForRes(pImageName);
setImage( m_pTGA );
setImage(m_pTGA);
}
//===========================================================
// Image size
int CImageLabel::getImageWide()
{
if( m_pTGA )
if (m_pTGA)
{
int iXSize, iYSize;
m_pTGA->getSize( iXSize, iYSize );
m_pTGA->getSize(iXSize, iYSize);
return iXSize;
}
else
@ -359,10 +359,10 @@ int CImageLabel::getImageWide()
int CImageLabel::getImageTall()
{
if( m_pTGA )
if (m_pTGA)
{
int iXSize, iYSize;
m_pTGA->getSize( iXSize, iYSize );
m_pTGA->getSize(iXSize, iYSize);
return iYSize;
}
else
@ -371,35 +371,35 @@ int CImageLabel::getImageTall()
}
}
void CImageLabel::LoadImage(const char * pImageName)
void CImageLabel::LoadImage(const char* pImageName)
{
if ( m_pTGA )
if (m_pTGA)
delete m_pTGA;
// Load the Image
m_pTGA = LoadTGAForRes(pImageName);
if ( m_pTGA == NULL )
if (m_pTGA == NULL)
{
// we didn't find a matching image file for this resolution
// try to load file resolution independent
char sz[256];
sprintf(sz, "%s/%s",gEngfuncs.pfnGetGameDirectory(), pImageName );
FileInputStream fis( sz, false );
m_pTGA = new BitmapTGA(&fis,true);
sprintf(sz, "%s/%s", gEngfuncs.pfnGetGameDirectory(), pImageName);
FileInputStream fis(sz, false);
m_pTGA = new BitmapTGA(&fis, true);
fis.close();
}
if ( m_pTGA == NULL )
return; // unable to load image
int w,t;
if (m_pTGA == NULL)
return; // unable to load image
m_pTGA->getSize( w, t );
int w, t;
setSize( XRES (w),YRES (t) );
setImage( m_pTGA );
m_pTGA->getSize(w, t);
setSize(XRES(w), YRES(t));
setImage(m_pTGA);
}
//===========================================================
@ -408,28 +408,28 @@ void CCommandMenu::paintBackground()
{
// Transparent black background
if ( m_iSpectCmdMenu )
drawSetColor( 0, 0, 0, 64 );
if (m_iSpectCmdMenu)
drawSetColor(0, 0, 0, 64);
else
drawSetColor(Scheme::sc_primary3);
drawSetColor(Scheme::sc_primary3);
drawFilledRect(0,0,_size[0],_size[1]);
drawFilledRect(0, 0, _size[0], _size[1]);
}
//=================================================================================
// CUSTOM SCROLLPANEL
//=================================================================================
CTFScrollButton::CTFScrollButton(int iArrow, const char* text,int x,int y,int wide,int tall) : CommandButton(text,x,y,wide,tall)
CTFScrollButton::CTFScrollButton(int iArrow, const char* text, int x, int y, int wide, int tall) : CommandButton(text, x, y, wide, tall)
{
// Set text color to orange
setFgColor(Scheme::sc_primary1);
// Load in the arrow
m_pTGA = LoadTGAForRes( sArrowFilenames[iArrow] );
setImage( m_pTGA );
m_pTGA = LoadTGAForRes(sArrowFilenames[iArrow]);
setImage(m_pTGA);
// Highlight signal
InputSignal *pISignal = new CHandler_CommandButtonHighlight(this);
InputSignal* pISignal = new CHandler_CommandButtonHighlight(this);
addInputSignal(pISignal);
}
@ -439,13 +439,13 @@ void CTFScrollButton::paint()
return;
// draw armed button text in white
if ( isArmed() )
if (isArmed())
{
m_pTGA->setColor( Color(255,255,255, 0) );
m_pTGA->setColor(Color(255, 255, 255, 0));
}
else
{
m_pTGA->setColor( Color(255,255,255, 128) );
m_pTGA->setColor(Color(255, 255, 255, 128));
}
m_pTGA->doPaint(this);
@ -453,7 +453,7 @@ void CTFScrollButton::paint()
void CTFScrollButton::paintBackground()
{
/*
/*
if ( isArmed() )
{
// Orange highlight background
@ -469,50 +469,50 @@ void CTFScrollButton::paintBackground()
void CTFSlider::paintBackground()
{
int wide,tall,nobx,noby;
getPaintSize(wide,tall);
getNobPos(nobx,noby);
int wide, tall, nobx, noby;
getPaintSize(wide, tall);
getNobPos(nobx, noby);
// Border
drawSetColor( Scheme::sc_secondary1 );
drawOutlinedRect( 0,0,wide,tall );
drawSetColor(Scheme::sc_secondary1);
drawOutlinedRect(0, 0, wide, tall);
if( isVertical() )
if (isVertical())
{
// Nob Fill
drawSetColor( Scheme::sc_primary2 );
drawFilledRect( 0,nobx,wide,noby );
drawSetColor(Scheme::sc_primary2);
drawFilledRect(0, nobx, wide, noby);
// Nob Outline
drawSetColor( Scheme::sc_primary1 );
drawOutlinedRect( 0,nobx,wide,noby );
drawSetColor(Scheme::sc_primary1);
drawOutlinedRect(0, nobx, wide, noby);
}
else
{
// Nob Fill
drawSetColor( Scheme::sc_primary2 );
drawFilledRect( nobx,0,noby,tall );
drawSetColor(Scheme::sc_primary2);
drawFilledRect(nobx, 0, noby, tall);
// Nob Outline
drawSetColor( Scheme::sc_primary1 );
drawOutlinedRect( nobx,0,noby,tall );
drawSetColor(Scheme::sc_primary1);
drawOutlinedRect(nobx, 0, noby, tall);
}
}
CTFScrollPanel::CTFScrollPanel(int x,int y,int wide,int tall) : ScrollPanel(x,y,wide,tall)
CTFScrollPanel::CTFScrollPanel(int x, int y, int wide, int tall) : ScrollPanel(x, y, wide, tall)
{
ScrollBar *pScrollBar = getVerticalScrollBar();
pScrollBar->setButton( new CTFScrollButton( ARROW_UP, "", 0,0,16,16 ), 0 );
pScrollBar->setButton( new CTFScrollButton( ARROW_DOWN, "", 0,0,16,16 ), 1 );
pScrollBar->setSlider( new CTFSlider(0,wide-1,wide,(tall-(wide*2))+2,true) );
ScrollBar* pScrollBar = getVerticalScrollBar();
pScrollBar->setButton(new CTFScrollButton(ARROW_UP, "", 0, 0, 16, 16), 0);
pScrollBar->setButton(new CTFScrollButton(ARROW_DOWN, "", 0, 0, 16, 16), 1);
pScrollBar->setSlider(new CTFSlider(0, wide - 1, wide, (tall - (wide * 2)) + 2, true));
pScrollBar->setPaintBorderEnabled(false);
pScrollBar->setPaintBackgroundEnabled(false);
pScrollBar->setPaintEnabled(false);
pScrollBar = getHorizontalScrollBar();
pScrollBar->setButton( new CTFScrollButton( ARROW_LEFT, "", 0,0,16,16 ), 0 );
pScrollBar->setButton( new CTFScrollButton( ARROW_RIGHT, "", 0,0,16,16 ), 1 );
pScrollBar->setSlider( new CTFSlider(tall,0,wide-(tall*2),tall,false) );
pScrollBar->setButton(new CTFScrollButton(ARROW_LEFT, "", 0, 0, 16, 16), 0);
pScrollBar->setButton(new CTFScrollButton(ARROW_RIGHT, "", 0, 0, 16, 16), 1);
pScrollBar->setSlider(new CTFSlider(tall, 0, wide - (tall * 2), tall, false));
pScrollBar->setPaintBorderEnabled(false);
pScrollBar->setPaintBackgroundEnabled(false);
pScrollBar->setPaintEnabled(false);
@ -522,25 +522,24 @@ CTFScrollPanel::CTFScrollPanel(int x,int y,int wide,int tall) : ScrollPanel(x,y,
//=================================================================================
// CUSTOM HANDLERS
//=================================================================================
void CHandler_MenuButtonOver::cursorEntered(Panel *panel)
void CHandler_MenuButtonOver::cursorEntered(Panel* panel)
{
if ( gViewPort && m_pMenuPanel )
if (gViewPort && m_pMenuPanel)
{
m_pMenuPanel->SetActiveInfo( m_iButton );
m_pMenuPanel->SetActiveInfo(m_iButton);
}
}
void CMenuHandler_StringCommandClassSelect::actionPerformed(Panel* panel)
{
CMenuHandler_StringCommand::actionPerformed( panel );
CMenuHandler_StringCommand::actionPerformed(panel);
// THIS IS NOW BEING DONE ON THE TFC SERVER TO AVOID KILLING SOMEONE THEN
// THIS IS NOW BEING DONE ON THE TFC SERVER TO AVOID KILLING SOMEONE THEN
// HAVE THE SERVER SAY "SORRY...YOU CAN'T BE THAT CLASS".
#if !defined _TFC
bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0;
if ( bAutoKill && g_iPlayerClass != 0 )
bool bAutoKill = CVAR_GET_FLOAT("hud_classautokill") != 0;
if (bAutoKill && g_iPlayerClass != 0)
gEngfuncs.pfnClientCmd("kill");
#endif
}

View file

@ -5,7 +5,7 @@
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose:
// Purpose:
//
// $Workfile: $
// $Date: $
@ -20,7 +20,7 @@
#include "VGUI_ScrollPanel.h"
#include "VGUI_TextImage.h"
#include<VGUI_StackLayout.h>
#include <VGUI_StackLayout.h>
#include "hud.h"
#include "cl_util.h"
@ -31,13 +31,13 @@
#include "vgui_int.h"
#include "vgui_TeamFortressViewport.h"
#define MOTD_TITLE_X XRES(16)
#define MOTD_TITLE_Y YRES(16)
#define MOTD_TITLE_X XRES(16)
#define MOTD_TITLE_Y YRES(16)
#define MOTD_WINDOW_X XRES(112)
#define MOTD_WINDOW_Y YRES(80)
#define MOTD_WINDOW_SIZE_X XRES(424)
#define MOTD_WINDOW_SIZE_Y YRES(312)
#define MOTD_WINDOW_X XRES(112)
#define MOTD_WINDOW_Y YRES(80)
#define MOTD_WINDOW_SIZE_X XRES(424)
#define MOTD_WINDOW_SIZE_Y YRES(312)
//-----------------------------------------------------------------------------
// Purpose: Displays the MOTD and basic server information
@ -45,81 +45,80 @@
class CMessageWindowPanel : public CMenuPanel
{
public:
CMessageWindowPanel( const char *szMOTD, const char *szTitle, bool iShadeFullScreen, bool iRemoveMe, int x, int y, int wide, int tall );
CMessageWindowPanel(const char* szMOTD, const char* szTitle, bool iShadeFullScreen, bool iRemoveMe, int x, int y, int wide, int tall);
private:
CTransparentPanel *m_pBackgroundPanel;
CTransparentPanel* m_pBackgroundPanel;
};
//-----------------------------------------------------------------------------
// Purpose: Creates a new CMessageWindowPanel
// Output : CMenuPanel - interface to the panel
//-----------------------------------------------------------------------------
CMenuPanel *CMessageWindowPanel_Create( const char *szMOTD, const char *szTitle, bool iShadeFullscreen, bool iRemoveMe, int x, int y, int wide, int tall )
CMenuPanel* CMessageWindowPanel_Create(const char* szMOTD, const char* szTitle, bool iShadeFullscreen, bool iRemoveMe, int x, int y, int wide, int tall)
{
return new CMessageWindowPanel( szMOTD, szTitle, iShadeFullscreen, iRemoveMe, x, y, wide, tall );
return new CMessageWindowPanel(szMOTD, szTitle, iShadeFullscreen, iRemoveMe, x, y, wide, tall);
}
//-----------------------------------------------------------------------------
// Purpose: Constructs a message panel
//-----------------------------------------------------------------------------
CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitle, bool iShadeFullscreen, bool iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iShadeFullscreen ? 100 : 255, iRemoveMe, x, y, wide, tall )
CMessageWindowPanel::CMessageWindowPanel(const char* szMOTD, const char* szTitle, bool iShadeFullscreen, bool iRemoveMe, int x, int y, int wide, int tall) : CMenuPanel(iShadeFullscreen ? 100 : 255, iRemoveMe, x, y, wide, tall)
{
// Get the scheme used for the Titles
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
CSchemeManager* pSchemes = gViewPort->GetSchemeManager();
// schemes
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
SchemeHandle_t hMOTDText = pSchemes->getSchemeHandle( "Briefing Text" );
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Title Font");
SchemeHandle_t hMOTDText = pSchemes->getSchemeHandle("Briefing Text");
// color schemes
int r, g, b, a;
// Create the window
m_pBackgroundPanel = new CTransparentPanel( iShadeFullscreen ? 255 : 100, MOTD_WINDOW_X, MOTD_WINDOW_Y, MOTD_WINDOW_SIZE_X, MOTD_WINDOW_SIZE_Y );
m_pBackgroundPanel->setParent( this );
m_pBackgroundPanel->setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0)) );
m_pBackgroundPanel->setVisible( true );
m_pBackgroundPanel = new CTransparentPanel(iShadeFullscreen ? 255 : 100, MOTD_WINDOW_X, MOTD_WINDOW_Y, MOTD_WINDOW_SIZE_X, MOTD_WINDOW_SIZE_Y);
m_pBackgroundPanel->setParent(this);
m_pBackgroundPanel->setBorder(new LineBorder(Color(255 * 0.7, 170 * 0.7, 0, 0)));
m_pBackgroundPanel->setVisible(true);
int iXSize,iYSize,iXPos,iYPos;
m_pBackgroundPanel->getPos( iXPos,iYPos );
m_pBackgroundPanel->getSize( iXSize,iYSize );
int iXSize, iYSize, iXPos, iYPos;
m_pBackgroundPanel->getPos(iXPos, iYPos);
m_pBackgroundPanel->getSize(iXSize, iYSize);
// Create the title
Label *pLabel = new Label( "", iXPos + MOTD_TITLE_X, iYPos + MOTD_TITLE_Y );
pLabel->setParent( this );
pLabel->setFont( pSchemes->getFont(hTitleScheme) );
pLabel->setFont( Scheme::sf_primary1 );
Label* pLabel = new Label("", iXPos + MOTD_TITLE_X, iYPos + MOTD_TITLE_Y);
pLabel->setParent(this);
pLabel->setFont(pSchemes->getFont(hTitleScheme));
pLabel->setFont(Scheme::sf_primary1);
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
pLabel->setFgColor( r, g, b, a );
pLabel->setFgColor( Scheme::sc_primary1 );
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
pLabel->setBgColor( r, g, b, a );
pLabel->setContentAlignment( vgui::Label::a_west );
pLabel->setText( "%s", szTitle);
pSchemes->getFgColor(hTitleScheme, r, g, b, a);
pLabel->setFgColor(r, g, b, a);
pLabel->setFgColor(Scheme::sc_primary1);
pSchemes->getBgColor(hTitleScheme, r, g, b, a);
pLabel->setBgColor(r, g, b, a);
pLabel->setContentAlignment(vgui::Label::a_west);
pLabel->setText("%s", szTitle);
// Create the Scroll panel
ScrollPanel *pScrollPanel = new CTFScrollPanel( iXPos + XRES(16), iYPos + MOTD_TITLE_Y*2 + YRES(16), iXSize - XRES(32), iYSize - (YRES(48) + BUTTON_SIZE_Y*2) );
ScrollPanel* pScrollPanel = new CTFScrollPanel(iXPos + XRES(16), iYPos + MOTD_TITLE_Y * 2 + YRES(16), iXSize - XRES(32), iYSize - (YRES(48) + BUTTON_SIZE_Y * 2));
pScrollPanel->setParent(this);
//force the scrollbars on so clientClip will take them in account after the validate
pScrollPanel->setScrollBarAutoVisible(false, false);
pScrollPanel->setScrollBarVisible(true, true);
pScrollPanel->validate();
// Create the text panel
TextPanel *pText = new TextPanel( "", 0,0, 64,64);
pText->setParent( pScrollPanel->getClient() );
TextPanel* pText = new TextPanel("", 0, 0, 64, 64);
pText->setParent(pScrollPanel->getClient());
// get the font and colors from the scheme
pText->setFont( pSchemes->getFont(hMOTDText) );
pSchemes->getFgColor( hMOTDText, r, g, b, a );
pText->setFgColor( r, g, b, a );
pSchemes->getBgColor( hMOTDText, r, g, b, a );
pText->setBgColor( r, g, b, a );
pText->setText( szMOTD);
pText->setFont(pSchemes->getFont(hMOTDText));
pSchemes->getFgColor(hMOTDText, r, g, b, a);
pText->setFgColor(r, g, b, a);
pSchemes->getBgColor(hMOTDText, r, g, b, a);
pText->setBgColor(r, g, b, a);
pText->setText(szMOTD);
// Get the total size of the MOTD text and resize the text panel
int iScrollSizeX, iScrollSizeY;
@ -129,10 +128,10 @@ CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitl
// You'll see a horizontal scroll bar if there is a single word that won't wrap in the
// specified width.
pText->getTextImage()->setSize(pScrollPanel->getClientClip()->getWide(), pScrollPanel->getClientClip()->getTall());
pText->getTextImage()->getTextSizeWrapped( iScrollSizeX, iScrollSizeY );
pText->getTextImage()->getTextSizeWrapped(iScrollSizeX, iScrollSizeY);
// Now resize the textpanel to fit the scrolled size
pText->setSize( iScrollSizeX , iScrollSizeY );
pText->setSize(iScrollSizeX, iScrollSizeY);
//turn the scrollbars back into automode
pScrollPanel->setScrollBarAutoVisible(true, true);
@ -140,14 +139,7 @@ CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitl
pScrollPanel->validate();
CommandButton *pButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_OK" ), iXPos + XRES(16), iYPos + iYSize - YRES(16) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y);
CommandButton* pButton = new CommandButton(CHudTextMessage::BufferedLocaliseTextString("#Menu_OK"), iXPos + XRES(16), iYPos + iYSize - YRES(16) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y);
pButton->addActionSignal(new CMenuHandler_TextWindow(HIDE_TEXTWINDOW));
pButton->setParent(this);
}

View file

@ -5,7 +5,7 @@
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose:
// Purpose:
//
// $Workfile: $
// $Date: $
@ -23,7 +23,7 @@
#include <string.h>
cvar_t *g_CV_BitmapFonts;
cvar_t* g_CV_BitmapFonts;
void Scheme_Init()
@ -39,12 +39,13 @@ void Scheme_Init()
class CSchemeManager::CScheme
{
public:
enum {
enum
{
SCHEME_NAME_LENGTH = 32,
FONT_NAME_LENGTH = 48,
FONT_FILENAME_LENGTH = 64,
};
// name
char schemeName[SCHEME_NAME_LENGTH];
@ -54,14 +55,14 @@ public:
int fontSize;
int fontWeight;
vgui::Font *font;
vgui::Font* font;
bool ownFontPointer; // true if the font is ours to delete
// scheme
byte fgColor[4];
byte bgColor[4];
byte armedFgColor[4];
byte armedBgColor[4];
byte armedBgColor[4];
byte mousedownFgColor[4];
byte mousedownBgColor[4];
byte borderColor[4];
@ -84,7 +85,7 @@ CSchemeManager::CScheme::CScheme()
CSchemeManager::CScheme::~CScheme()
{
// only delete our font pointer if we own it
if ( ownFontPointer )
if (ownFontPointer)
{
delete font;
}
@ -95,57 +96,56 @@ CSchemeManager::CScheme::~CScheme()
// !! needs to be shared out
//-----------------------------------------------------------------------------
static int g_ResArray[] =
{
320,
400,
512,
640,
800,
1024,
1152,
1280,
1600
};
{
320,
400,
512,
640,
800,
1024,
1152,
1280,
1600};
static int g_NumReses = sizeof(g_ResArray) / sizeof(int);
static byte *LoadFileByResolution( const char *filePrefix, int xRes, const char *filePostfix )
static byte* LoadFileByResolution(const char* filePrefix, int xRes, const char* filePostfix)
{
// find our resolution in the res array
int resNum = g_NumReses - 1;
while ( g_ResArray[resNum] > xRes )
while (g_ResArray[resNum] > xRes)
{
resNum--;
if ( resNum < 0 )
if (resNum < 0)
return NULL;
}
// try open the file
byte *pFile = NULL;
while ( true )
byte* pFile = NULL;
while (true)
{
// try load
char fname[256];
sprintf( fname, "%s%d%s", filePrefix, g_ResArray[resNum], filePostfix );
pFile = gEngfuncs.COM_LoadFile( fname, 5, NULL );
sprintf(fname, "%s%d%s", filePrefix, g_ResArray[resNum], filePostfix);
pFile = gEngfuncs.COM_LoadFile(fname, 5, NULL);
if ( pFile )
if (pFile)
break;
if ( resNum == 0 )
if (resNum == 0)
return NULL;
resNum--;
}
return pFile;
return pFile;
}
static void ParseRGBAFromString( byte colorArray[4], const char *colorVector )
static void ParseRGBAFromString(byte colorArray[4], const char* colorVector)
{
int r, g, b, a;
sscanf( colorVector, "%d %d %d %d", &r, &g, &b, &a );
sscanf(colorVector, "%d %d %d %d", &r, &g, &b, &a);
colorArray[0] = r;
colorArray[1] = g;
colorArray[2] = b;
@ -155,10 +155,10 @@ static void ParseRGBAFromString( byte colorArray[4], const char *colorVector )
//-----------------------------------------------------------------------------
// Purpose: initializes the scheme manager
// loading the scheme files for the current resolution
// Input : xRes -
// Input : xRes -
// yRes - dimensions of output window
//-----------------------------------------------------------------------------
CSchemeManager::CSchemeManager( int xRes, int yRes )
CSchemeManager::CSchemeManager(int xRes, int yRes)
{
// basic setup
m_pSchemeList = NULL;
@ -166,12 +166,12 @@ CSchemeManager::CSchemeManager( int xRes, int yRes )
// find the closest matching scheme file to our resolution
char token[1024];
char *pFile = (char*)LoadFileByResolution( "", xRes, "_textscheme.txt" );
char* pFile = (char*)LoadFileByResolution("", xRes, "_textscheme.txt");
m_xRes = xRes;
char *pFileStart = pFile;
byte *pFontData;
char* pFileStart = pFile;
byte* pFontData;
int fontFileLength;
char fontFilename[512];
@ -185,91 +185,91 @@ CSchemeManager::CSchemeManager( int xRes, int yRes )
const static int numTmpSchemes = 64;
static CScheme tmpSchemes[numTmpSchemes];
memset( tmpSchemes, 0, sizeof(tmpSchemes) );
memset(tmpSchemes, 0, sizeof(tmpSchemes));
int currentScheme = -1;
CScheme *pScheme = NULL;
CScheme* pScheme = NULL;
if ( !pFile )
if (!pFile)
{
gEngfuncs.Con_DPrintf( "Unable to find *_textscheme.txt\n");
gEngfuncs.Con_DPrintf("Unable to find *_textscheme.txt\n");
goto buildDefaultFont;
}
// record what has been entered so we can create defaults from the different values
bool hasFgColor, hasBgColor, hasArmedFgColor, hasArmedBgColor, hasMouseDownFgColor, hasMouseDownBgColor;
pFile = gEngfuncs.COM_ParseFile( pFile, token );
while ( strlen(token) > 0 && (currentScheme < numTmpSchemes) )
pFile = gEngfuncs.COM_ParseFile(pFile, token);
while (strlen(token) > 0 && (currentScheme < numTmpSchemes))
{
// get the paramName name
static const int tokenSize = 64;
char paramName[tokenSize], paramValue[tokenSize];
strncpy( paramName, token, tokenSize );
paramName[tokenSize-1] = 0; // ensure null termination
strncpy(paramName, token, tokenSize);
paramName[tokenSize - 1] = 0; // ensure null termination
// get the '=' character
pFile = gEngfuncs.COM_ParseFile( pFile, token );
if ( stricmp( token, "=" ) )
pFile = gEngfuncs.COM_ParseFile(pFile, token);
if (stricmp(token, "="))
{
if ( currentScheme < 0 )
if (currentScheme < 0)
{
gEngfuncs.Con_Printf( "error parsing font scheme text file at file start - expected '=', found '%s''\n", token );
gEngfuncs.Con_Printf("error parsing font scheme text file at file start - expected '=', found '%s''\n", token);
}
else
{
gEngfuncs.Con_Printf( "error parsing font scheme text file at scheme '%s' - expected '=', found '%s''\n", tmpSchemes[currentScheme].schemeName, token );
gEngfuncs.Con_Printf("error parsing font scheme text file at scheme '%s' - expected '=', found '%s''\n", tmpSchemes[currentScheme].schemeName, token);
}
break;
}
// get paramValue
pFile = gEngfuncs.COM_ParseFile( pFile, token );
strncpy( paramValue, token, tokenSize );
paramValue[tokenSize-1] = 0; // ensure null termination
pFile = gEngfuncs.COM_ParseFile(pFile, token);
strncpy(paramValue, token, tokenSize);
paramValue[tokenSize - 1] = 0; // ensure null termination
// is this a new scheme?
if ( !stricmp(paramName, "SchemeName") )
if (!stricmp(paramName, "SchemeName"))
{
// setup the defaults for the current scheme
if ( pScheme )
if (pScheme)
{
// foreground color defaults (normal -> armed -> mouse down)
if ( !hasFgColor )
if (!hasFgColor)
{
pScheme->fgColor[0] = pScheme->fgColor[1] = pScheme->fgColor[2] = pScheme->fgColor[3] = 255;
}
if ( !hasArmedFgColor )
if (!hasArmedFgColor)
{
memcpy( pScheme->armedFgColor, pScheme->fgColor, sizeof(pScheme->armedFgColor) );
memcpy(pScheme->armedFgColor, pScheme->fgColor, sizeof(pScheme->armedFgColor));
}
if ( !hasMouseDownFgColor )
if (!hasMouseDownFgColor)
{
memcpy( pScheme->mousedownFgColor, pScheme->armedFgColor, sizeof(pScheme->mousedownFgColor) );
memcpy(pScheme->mousedownFgColor, pScheme->armedFgColor, sizeof(pScheme->mousedownFgColor));
}
// background color (normal -> armed -> mouse down)
if ( !hasBgColor )
if (!hasBgColor)
{
pScheme->bgColor[0] = pScheme->bgColor[1] = pScheme->bgColor[2] = pScheme->bgColor[3] = 0;
}
if ( !hasArmedBgColor )
if (!hasArmedBgColor)
{
memcpy( pScheme->armedBgColor, pScheme->bgColor, sizeof(pScheme->armedBgColor) );
memcpy(pScheme->armedBgColor, pScheme->bgColor, sizeof(pScheme->armedBgColor));
}
if ( !hasMouseDownBgColor )
if (!hasMouseDownBgColor)
{
memcpy( pScheme->mousedownBgColor, pScheme->armedBgColor, sizeof(pScheme->mousedownBgColor) );
memcpy(pScheme->mousedownBgColor, pScheme->armedBgColor, sizeof(pScheme->mousedownBgColor));
}
// font size
if ( 0 == pScheme->fontSize )
if (0 == pScheme->fontSize)
{
pScheme->fontSize = 17;
}
if ( '\0' == pScheme->fontName[0])
if ('\0' == pScheme->fontName[0])
{
strcpy( pScheme->fontName, "Arial" );
strcpy(pScheme->fontName, "Arial");
}
}
@ -278,82 +278,82 @@ CSchemeManager::CSchemeManager( int xRes, int yRes )
pScheme = &tmpSchemes[currentScheme];
hasFgColor = hasBgColor = hasArmedFgColor = hasArmedBgColor = hasMouseDownFgColor = hasMouseDownBgColor = false;
strncpy( pScheme->schemeName, paramValue, CScheme::SCHEME_NAME_LENGTH );
pScheme->schemeName[CScheme::SCHEME_NAME_LENGTH-1] = '\0'; // ensure null termination of string
strncpy(pScheme->schemeName, paramValue, CScheme::SCHEME_NAME_LENGTH);
pScheme->schemeName[CScheme::SCHEME_NAME_LENGTH - 1] = '\0'; // ensure null termination of string
}
if ( !pScheme )
if (!pScheme)
{
gEngfuncs.Con_Printf( "font scheme text file MUST start with a 'SchemeName'\n");
gEngfuncs.Con_Printf("font scheme text file MUST start with a 'SchemeName'\n");
break;
}
// pull the data out into the scheme
if ( !stricmp(paramName, "FontName") )
if (!stricmp(paramName, "FontName"))
{
strncpy( pScheme->fontName, paramValue, CScheme::FONT_NAME_LENGTH );
pScheme->fontName[CScheme::FONT_NAME_LENGTH-1] = 0;
strncpy(pScheme->fontName, paramValue, CScheme::FONT_NAME_LENGTH);
pScheme->fontName[CScheme::FONT_NAME_LENGTH - 1] = 0;
}
else if ( !stricmp(paramName, "FontSize") )
else if (!stricmp(paramName, "FontSize"))
{
pScheme->fontSize = atoi( paramValue );
pScheme->fontSize = atoi(paramValue);
}
else if ( !stricmp(paramName, "FontWeight") )
else if (!stricmp(paramName, "FontWeight"))
{
pScheme->fontWeight = atoi( paramValue );
pScheme->fontWeight = atoi(paramValue);
}
else if ( !stricmp(paramName, "FgColor") )
else if (!stricmp(paramName, "FgColor"))
{
ParseRGBAFromString( pScheme->fgColor, paramValue );
ParseRGBAFromString(pScheme->fgColor, paramValue);
hasFgColor = true;
}
else if ( !stricmp(paramName, "BgColor") )
else if (!stricmp(paramName, "BgColor"))
{
ParseRGBAFromString( pScheme->bgColor, paramValue );
ParseRGBAFromString(pScheme->bgColor, paramValue);
hasBgColor = true;
}
else if ( !stricmp(paramName, "FgColorArmed") )
else if (!stricmp(paramName, "FgColorArmed"))
{
ParseRGBAFromString( pScheme->armedFgColor, paramValue );
ParseRGBAFromString(pScheme->armedFgColor, paramValue);
hasArmedFgColor = true;
}
else if ( !stricmp(paramName, "BgColorArmed") )
}
else if (!stricmp(paramName, "BgColorArmed"))
{
ParseRGBAFromString( pScheme->armedBgColor, paramValue );
ParseRGBAFromString(pScheme->armedBgColor, paramValue);
hasArmedBgColor = true;
}
else if ( !stricmp(paramName, "FgColorMousedown") )
else if (!stricmp(paramName, "FgColorMousedown"))
{
ParseRGBAFromString( pScheme->mousedownFgColor, paramValue );
ParseRGBAFromString(pScheme->mousedownFgColor, paramValue);
hasMouseDownFgColor = true;
}
else if ( !stricmp(paramName, "BgColorMousedown") )
else if (!stricmp(paramName, "BgColorMousedown"))
{
ParseRGBAFromString( pScheme->mousedownBgColor, paramValue );
ParseRGBAFromString(pScheme->mousedownBgColor, paramValue);
hasMouseDownBgColor = true;
}
else if ( !stricmp(paramName, "BorderColor") )
else if (!stricmp(paramName, "BorderColor"))
{
ParseRGBAFromString( pScheme->borderColor, paramValue );
ParseRGBAFromString(pScheme->borderColor, paramValue);
hasMouseDownBgColor = true;
}
// get the new token last, so we now if the loop needs to be continued or not
pFile = gEngfuncs.COM_ParseFile( pFile, token );
pFile = gEngfuncs.COM_ParseFile(pFile, token);
}
// free the file
gEngfuncs.COM_FreeFile( pFileStart );
gEngfuncs.COM_FreeFile(pFileStart);
buildDefaultFont:
// make sure we have at least 1 valid font
if ( currentScheme < 0 )
if (currentScheme < 0)
{
currentScheme = 0;
strcpy( tmpSchemes[0].schemeName, "Default Scheme" );
strcpy( tmpSchemes[0].fontName, "Arial" );
strcpy(tmpSchemes[0].schemeName, "Default Scheme");
strcpy(tmpSchemes[0].fontName, "Arial");
tmpSchemes[0].fontSize = 0;
tmpSchemes[0].fgColor[0] = tmpSchemes[0].fgColor[1] = tmpSchemes[0].fgColor[2] = tmpSchemes[0].fgColor[3] = 255;
tmpSchemes[0].armedFgColor[0] = tmpSchemes[0].armedFgColor[1] = tmpSchemes[0].armedFgColor[2] = tmpSchemes[0].armedFgColor[3] = 255;
@ -363,23 +363,21 @@ buildDefaultFont:
// we have the full list of schemes in the tmpSchemes array
// now allocate the correct sized list
m_iNumSchemes = currentScheme + 1; // 0-based index
m_pSchemeList = new CScheme[ m_iNumSchemes ];
m_pSchemeList = new CScheme[m_iNumSchemes];
// copy in the data
memcpy( m_pSchemeList, tmpSchemes, sizeof(CScheme) * m_iNumSchemes );
memcpy(m_pSchemeList, tmpSchemes, sizeof(CScheme) * m_iNumSchemes);
// create the fonts
for ( int i = 0; i < m_iNumSchemes; i++ )
for (int i = 0; i < m_iNumSchemes; i++)
{
m_pSchemeList[i].font = NULL;
// see if the current font values exist in a previously loaded font
for ( int j = 0; j < i; j++ )
for (int j = 0; j < i; j++)
{
// check if the font name, size, and weight are the same
if ( !stricmp(m_pSchemeList[i].fontName, m_pSchemeList[j].fontName)
&& m_pSchemeList[i].fontSize == m_pSchemeList[j].fontSize
&& m_pSchemeList[i].fontWeight == m_pSchemeList[j].fontWeight )
if (!stricmp(m_pSchemeList[i].fontName, m_pSchemeList[j].fontName) && m_pSchemeList[i].fontSize == m_pSchemeList[j].fontSize && m_pSchemeList[i].fontWeight == m_pSchemeList[j].fontWeight)
{
// copy the pointer, but mark i as not owning it
m_pSchemeList[i].font = m_pSchemeList[j].font;
@ -388,44 +386,44 @@ buildDefaultFont:
}
// if we haven't found the font already, load it ourselves
if ( !m_pSchemeList[i].font )
if (!m_pSchemeList[i].font)
{
fontFileLength = -1;
pFontData = NULL;
if(g_CV_BitmapFonts && 0 != g_CV_BitmapFonts->value)
if (g_CV_BitmapFonts && 0 != g_CV_BitmapFonts->value)
{
int fontRes = 640;
if ( m_xRes >= 1600 )
if (m_xRes >= 1600)
fontRes = 1600;
else if ( m_xRes >= 1280 )
else if (m_xRes >= 1280)
fontRes = 1280;
else if ( m_xRes >= 1152 )
else if (m_xRes >= 1152)
fontRes = 1152;
else if ( m_xRes >= 1024 )
else if (m_xRes >= 1024)
fontRes = 1024;
else if ( m_xRes >= 800 )
else if (m_xRes >= 800)
fontRes = 800;
sprintf(fontFilename, "gfx\\vgui\\fonts\\%d_%s.tga", fontRes, m_pSchemeList[i].schemeName);
pFontData = gEngfuncs.COM_LoadFile( fontFilename, 5, &fontFileLength );
if(!pFontData)
pFontData = gEngfuncs.COM_LoadFile(fontFilename, 5, &fontFileLength);
if (!pFontData)
gEngfuncs.Con_Printf("Missing bitmap font: %s\n", fontFilename);
}
m_pSchemeList[i].font = new vgui::Font(
m_pSchemeList[i].fontName,
m_pSchemeList[i].fontName,
pFontData,
fontFileLength,
m_pSchemeList[i].fontSize,
0,
0,
m_pSchemeList[i].fontWeight,
false,
false,
false,
m_pSchemeList[i].fontSize,
0,
0,
m_pSchemeList[i].fontWeight,
false,
false,
false,
false);
m_pSchemeList[i].ownFontPointer = true;
}
@ -444,7 +442,7 @@ buildDefaultFont:
//-----------------------------------------------------------------------------
CSchemeManager::~CSchemeManager()
{
delete [] m_pSchemeList;
delete[] m_pSchemeList;
m_iNumSchemes = 0;
}
@ -453,12 +451,12 @@ CSchemeManager::~CSchemeManager()
// Input : char *schemeName - string name of the scheme
// Output : SchemeHandle_t handle to the scheme
//-----------------------------------------------------------------------------
SchemeHandle_t CSchemeManager::getSchemeHandle( const char *schemeName )
SchemeHandle_t CSchemeManager::getSchemeHandle(const char* schemeName)
{
// iterate through the list
for ( int i = 0; i < m_iNumSchemes; i++ )
for (int i = 0; i < m_iNumSchemes; i++)
{
if ( !stricmp(schemeName, m_pSchemeList[i].schemeName) )
if (!stricmp(schemeName, m_pSchemeList[i].schemeName))
return i;
}
@ -467,12 +465,12 @@ SchemeHandle_t CSchemeManager::getSchemeHandle( const char *schemeName )
//-----------------------------------------------------------------------------
// Purpose: always returns a valid scheme handle
// Input : schemeHandle -
// Input : schemeHandle -
// Output : CScheme
//-----------------------------------------------------------------------------
CSchemeManager::CScheme *CSchemeManager::getSafeScheme( SchemeHandle_t schemeHandle )
CSchemeManager::CScheme* CSchemeManager::getSafeScheme(SchemeHandle_t schemeHandle)
{
if ( schemeHandle < m_iNumSchemes )
if (schemeHandle < m_iNumSchemes)
return m_pSchemeList + schemeHandle;
return m_pSchemeList;
@ -481,76 +479,73 @@ CSchemeManager::CScheme *CSchemeManager::getSafeScheme( SchemeHandle_t schemeHan
//-----------------------------------------------------------------------------
// Purpose: Returns the schemes pointer to a font
// Input : schemeHandle -
// Input : schemeHandle -
// Output : vgui::Font
//-----------------------------------------------------------------------------
vgui::Font *CSchemeManager::getFont( SchemeHandle_t schemeHandle )
vgui::Font* CSchemeManager::getFont(SchemeHandle_t schemeHandle)
{
return getSafeScheme( schemeHandle )->font;
return getSafeScheme(schemeHandle)->font;
}
void CSchemeManager::getFgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
void CSchemeManager::getFgColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a)
{
CScheme *pScheme = getSafeScheme( schemeHandle );
CScheme* pScheme = getSafeScheme(schemeHandle);
r = pScheme->fgColor[0];
g = pScheme->fgColor[1];
b = pScheme->fgColor[2];
a = pScheme->fgColor[3];
}
void CSchemeManager::getBgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
void CSchemeManager::getBgColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a)
{
CScheme *pScheme = getSafeScheme( schemeHandle );
CScheme* pScheme = getSafeScheme(schemeHandle);
r = pScheme->bgColor[0];
g = pScheme->bgColor[1];
b = pScheme->bgColor[2];
a = pScheme->bgColor[3];
}
void CSchemeManager::getFgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
void CSchemeManager::getFgArmedColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a)
{
CScheme *pScheme = getSafeScheme( schemeHandle );
CScheme* pScheme = getSafeScheme(schemeHandle);
r = pScheme->armedFgColor[0];
g = pScheme->armedFgColor[1];
b = pScheme->armedFgColor[2];
a = pScheme->armedFgColor[3];
}
void CSchemeManager::getBgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
void CSchemeManager::getBgArmedColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a)
{
CScheme *pScheme = getSafeScheme( schemeHandle );
CScheme* pScheme = getSafeScheme(schemeHandle);
r = pScheme->armedBgColor[0];
g = pScheme->armedBgColor[1];
b = pScheme->armedBgColor[2];
a = pScheme->armedBgColor[3];
}
void CSchemeManager::getFgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
void CSchemeManager::getFgMousedownColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a)
{
CScheme *pScheme = getSafeScheme( schemeHandle );
CScheme* pScheme = getSafeScheme(schemeHandle);
r = pScheme->mousedownFgColor[0];
g = pScheme->mousedownFgColor[1];
b = pScheme->mousedownFgColor[2];
a = pScheme->mousedownFgColor[3];
}
void CSchemeManager::getBgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
void CSchemeManager::getBgMousedownColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a)
{
CScheme *pScheme = getSafeScheme( schemeHandle );
CScheme* pScheme = getSafeScheme(schemeHandle);
r = pScheme->mousedownBgColor[0];
g = pScheme->mousedownBgColor[1];
b = pScheme->mousedownBgColor[2];
a = pScheme->mousedownBgColor[3];
}
void CSchemeManager::getBorderColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
void CSchemeManager::getBorderColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a)
{
CScheme *pScheme = getSafeScheme( schemeHandle );
CScheme* pScheme = getSafeScheme(schemeHandle);
r = pScheme->borderColor[0];
g = pScheme->borderColor[1];
b = pScheme->borderColor[2];
a = pScheme->borderColor[3];
}

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -20,37 +20,35 @@ void Scheme_Init();
//-----------------------------------------------------------------------------
// Purpose: Handles the loading of text scheme description from disk
// supports different font/color/size schemes at different resolutions
// supports different font/color/size schemes at different resolutions
//-----------------------------------------------------------------------------
class CSchemeManager
{
public:
// initialization
CSchemeManager( int xRes, int yRes );
CSchemeManager(int xRes, int yRes);
virtual ~CSchemeManager();
// scheme handling
SchemeHandle_t getSchemeHandle( const char *schemeName );
SchemeHandle_t getSchemeHandle(const char* schemeName);
// getting info from schemes
vgui::Font *getFont( SchemeHandle_t schemeHandle );
void getFgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
void getBgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
void getFgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
void getBgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
void getFgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
void getBgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
void getBorderColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
vgui::Font* getFont(SchemeHandle_t schemeHandle);
void getFgColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a);
void getBgColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a);
void getFgArmedColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a);
void getBgArmedColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a);
void getFgMousedownColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a);
void getBgMousedownColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a);
void getBorderColor(SchemeHandle_t schemeHandle, int& r, int& g, int& b, int& a);
private:
class CScheme;
CScheme *m_pSchemeList;
CScheme* m_pSchemeList;
int m_iNumSchemes;
// Resolution we were initted at.
int m_xRes;
int m_xRes;
CScheme *getSafeScheme( SchemeHandle_t schemeHandle );
CScheme* getSafeScheme(SchemeHandle_t schemeHandle);
};

File diff suppressed because it is too large Load diff

View file

@ -1,36 +1,36 @@
//========= Copyright <20> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#include<VGUI_Panel.h>
#include<VGUI_TablePanel.h>
#include<VGUI_HeaderPanel.h>
#include<VGUI_TextGrid.h>
#include<VGUI_Label.h>
#include<VGUI_TextImage.h>
#include <VGUI_Panel.h>
#include <VGUI_TablePanel.h>
#include <VGUI_HeaderPanel.h>
#include <VGUI_TextGrid.h>
#include <VGUI_Label.h>
#include <VGUI_TextImage.h>
#include "../game_shared/vgui_listbox.h"
#include <ctype.h>
#define MAX_SCORES 10
#define MAX_SCOREBOARD_TEAMS 5
#define MAX_SCORES 10
#define MAX_SCOREBOARD_TEAMS 5
// Scoreboard cells
#define COLUMN_TRACKER 0
#define COLUMN_NAME 1
#define COLUMN_CLASS 2
#define COLUMN_KILLS 3
#define COLUMN_DEATHS 4
#define COLUMN_LATENCY 5
#define COLUMN_VOICE 6
#define COLUMN_BLANK 7
#define NUM_COLUMNS 8
#define NUM_ROWS (MAX_PLAYERS + (MAX_SCOREBOARD_TEAMS * 2))
#define COLUMN_TRACKER 0
#define COLUMN_NAME 1
#define COLUMN_CLASS 2
#define COLUMN_KILLS 3
#define COLUMN_DEATHS 4
#define COLUMN_LATENCY 5
#define COLUMN_VOICE 6
#define COLUMN_BLANK 7
#define NUM_COLUMNS 8
#define NUM_ROWS (MAX_PLAYERS + (MAX_SCOREBOARD_TEAMS * 2))
using namespace vgui;
@ -49,13 +49,13 @@ public:
delete _image[1];
}
TextImage *GetImage(int image)
TextImage* GetImage(int image)
{
return _image[image];
}
void getSize(int &wide, int &tall) override
{
void getSize(int& wide, int& tall) override
{
int w1, w2, t1, t2;
_image[0]->getTextSize(w1, t1);
_image[1]->getTextSize(w2, t2);
@ -65,16 +65,16 @@ public:
setSize(wide, tall);
}
void doPaint(Panel *panel) override
{
void doPaint(Panel* panel) override
{
_image[0]->doPaint(panel);
_image[1]->doPaint(panel);
}
void setPos(int x, int y) override
{
{
_image[0]->setPos(x, y);
int swide, stall;
_image[0]->getSize(swide, stall);
@ -84,7 +84,7 @@ public:
}
void setColor(Color color) override
{
{
_image[0]->setColor(color);
}
@ -94,8 +94,7 @@ public:
}
private:
TextImage *_image[2];
TextImage* _image[2];
};
//-----------------------------------------------------------------------------
@ -129,14 +128,14 @@ public:
_useFgColorAsImageColor = state;
}
void setText(int textBufferLen, const char* text) override
{
void setText(int textBufferLen, const char* text) override
{
_dualImage->GetImage(0)->setText(text);
// calculate the text size
Font *font = _dualImage->GetImage(0)->getFont();
Font* font = _dualImage->GetImage(0)->getFont();
_gap = 0;
for (const char *ch = text; *ch != 0; ch++)
for (const char* ch = text; *ch != 0; ch++)
{
int a, b, c;
font->getCharABCwide(*ch, a, b, c);
@ -161,41 +160,41 @@ public:
CLabelHeader::setText(0, buf);
}
void setText2(const char *text)
void setText2(const char* text)
{
_dualImage->GetImage(1)->setText(text);
}
void getTextSize(int &wide, int &tall) override
{
void getTextSize(int& wide, int& tall) override
{
_dualImage->getSize(wide, tall);
}
void setFgColor(int r,int g,int b,int a) override
{
Label::setFgColor(r,g,b,a);
Color color(r,g,b,a);
void setFgColor(int r, int g, int b, int a) override
{
Label::setFgColor(r, g, b, a);
Color color(r, g, b, a);
_dualImage->setColor(color);
_dualImage->setColor2(color);
repaint();
}
void setFgColor(Scheme::SchemeColor sc) override
{
{
int r, g, b, a;
Label::setFgColor(sc);
Label::getFgColor( r, g, b, a );
Label::getFgColor(r, g, b, a);
// Call the r,g,b,a version so it sets the color in the dualImage..
setFgColor( r, g, b, a );
setFgColor(r, g, b, a);
}
void setFont(Font *font) override
{
void setFont(Font* font) override
{
_dualImage->GetImage(0)->setFont(font);
}
void setFont2(Font *font)
void setFont2(Font* font)
{
_dualImage->GetImage(1)->setFont(font);
}
@ -209,10 +208,10 @@ public:
void paint() override;
void paintBackground() override;
void calcAlignment(int iwide, int itall, int &x, int &y);
void calcAlignment(int iwide, int itall, int& x, int& y);
private:
CTextImage2 *_dualImage;
CTextImage2* _dualImage;
int _row;
int _gap;
int _offset[2];
@ -234,62 +233,59 @@ private:
class HitTestPanel : public Panel
{
public:
void internalMousePressed(MouseCode code) override;
void internalMousePressed(MouseCode code) override;
};
private:
Label m_TitleLabel;
Label m_TitleLabel;
// Here is how these controls are arranged hierarchically.
// m_HeaderGrid
// m_HeaderLabels
// m_PlayerGridScroll
// m_PlayerGrid
// m_PlayerEntries
// m_PlayerEntries
CGrid m_HeaderGrid;
CLabelHeader m_HeaderLabels[NUM_COLUMNS]; // Labels above the
CLabelHeader *m_pCurrentHighlightLabel;
int m_iHighlightRow;
vgui::CListBox m_PlayerList;
CGrid m_PlayerGrids[NUM_ROWS]; // The grid with player and team info.
CLabelHeader m_PlayerEntries[NUM_COLUMNS][NUM_ROWS]; // Labels for the grid entries.
CGrid m_HeaderGrid;
CLabelHeader m_HeaderLabels[NUM_COLUMNS]; // Labels above the
CLabelHeader* m_pCurrentHighlightLabel;
int m_iHighlightRow;
ScorePanel::HitTestPanel m_HitTestPanel;
CommandButton *m_pCloseButton;
CLabelHeader* GetPlayerEntry(int x, int y) {return &m_PlayerEntries[x][y];}
vgui::CListBox m_PlayerList;
CGrid m_PlayerGrids[NUM_ROWS]; // The grid with player and team info.
CLabelHeader m_PlayerEntries[NUM_COLUMNS][NUM_ROWS]; // Labels for the grid entries.
ScorePanel::HitTestPanel m_HitTestPanel;
CommandButton* m_pCloseButton;
CLabelHeader* GetPlayerEntry(int x, int y) { return &m_PlayerEntries[x][y]; }
public:
int m_iNumTeams;
int m_iPlayerNum;
int m_iShowscoresHeld;
int m_iNumTeams;
int m_iPlayerNum;
int m_iShowscoresHeld;
int m_iRows;
int m_iSortedRows[NUM_ROWS];
int m_iIsATeam[NUM_ROWS];
bool m_bHasBeenSorted[MAX_PLAYERS];
int m_iLastKilledBy;
int m_fLastKillTime;
int m_iRows;
int m_iSortedRows[NUM_ROWS];
int m_iIsATeam[NUM_ROWS];
bool m_bHasBeenSorted[MAX_PLAYERS];
int m_iLastKilledBy;
int m_fLastKillTime;
public:
ScorePanel(int x,int y,int wide,int tall);
ScorePanel(int x, int y, int wide, int tall);
void Update();
void SortTeams();
void SortPlayers( int iTeam, char *team );
void SortPlayers(int iTeam, char* team);
void RebuildTeams();
void FillGrid();
void DeathMsg( int killer, int victim );
void DeathMsg(int killer, int victim);
void Initialize();
@ -297,11 +293,10 @@ public:
void MouseOverCell(int row, int col);
// InputSignal overrides.
// InputSignal overrides.
public:
void mousePressed(MouseCode code, Panel* panel) override;
void cursorMoved(int x, int y, Panel *panel) override;
void mousePressed(MouseCode code, Panel* panel) override;
void cursorMoved(int x, int y, Panel* panel) override;
friend class CLabelHeader;
};

View file

@ -22,19 +22,19 @@ Sets the location of the input for chat text
==========================
*/
void DLLEXPORT HUD_ChatInputPosition( int *x, int *y )
void DLLEXPORT HUD_ChatInputPosition(int* x, int* y)
{
// RecClChatInputPosition( x, y );
// RecClChatInputPosition( x, y );
if ( g_iUser1 != 0 || 0 != gEngfuncs.IsSpectateOnly() )
if (g_iUser1 != 0 || 0 != gEngfuncs.IsSpectateOnly())
{
if ( gHUD.m_Spectator.m_pip->value == INSET_OFF )
if (gHUD.m_Spectator.m_pip->value == INSET_OFF)
{
*y = YRES( PANEL_HEIGHT );
*y = YRES(PANEL_HEIGHT);
}
else
{
*y = YRES( gHUD.m_Spectator.m_OverviewData.insetWindowHeight + 5 );
*y = YRES(gHUD.m_Spectator.m_OverviewData.insetWindowHeight + 5);
}
}
}
@ -43,60 +43,68 @@ void DLLEXPORT HUD_ChatInputPosition( int *x, int *y )
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
SpectatorPanel::SpectatorPanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
SpectatorPanel::SpectatorPanel(int x, int y, int wide, int tall) : Panel(x, y, wide, tall)
{
}
SpectatorPanel::~SpectatorPanel()
{
}
void SpectatorPanel::ActionSignal(int cmd)
{
switch (cmd)
{
case SPECTATOR_PANEL_CMD_NONE : break;
case SPECTATOR_PANEL_CMD_NONE:
break;
case SPECTATOR_PANEL_CMD_OPTIONS : gViewPort->ShowCommandMenu( gViewPort->m_SpectatorOptionsMenu );
break;
case SPECTATOR_PANEL_CMD_OPTIONS:
gViewPort->ShowCommandMenu(gViewPort->m_SpectatorOptionsMenu);
break;
case SPECTATOR_PANEL_CMD_NEXTPLAYER : gHUD.m_Spectator.FindNextPlayer(true);
break;
case SPECTATOR_PANEL_CMD_NEXTPLAYER:
gHUD.m_Spectator.FindNextPlayer(true);
break;
case SPECTATOR_PANEL_CMD_PREVPLAYER : gHUD.m_Spectator.FindNextPlayer(false);
break;
case SPECTATOR_PANEL_CMD_PREVPLAYER:
gHUD.m_Spectator.FindNextPlayer(false);
break;
case SPECTATOR_PANEL_CMD_PLAYERS : gViewPort->ShowCommandMenu( gViewPort->m_PlayerMenu );
break;
case SPECTATOR_PANEL_CMD_PLAYERS:
gViewPort->ShowCommandMenu(gViewPort->m_PlayerMenu);
break;
case SPECTATOR_PANEL_CMD_HIDEMENU : ShowMenu(false);
break;
case SPECTATOR_PANEL_CMD_HIDEMENU:
ShowMenu(false);
break;
case SPECTATOR_PANEL_CMD_CAMERA : gViewPort->ShowCommandMenu( gViewPort->m_SpectatorCameraMenu );
break;
case SPECTATOR_PANEL_CMD_TOGGLE_INSET : gHUD.m_Spectator.SetModes( -1,
gHUD.m_Spectator.ToggleInset(false) );
break;
case SPECTATOR_PANEL_CMD_CAMERA:
gViewPort->ShowCommandMenu(gViewPort->m_SpectatorCameraMenu);
break;
default : gEngfuncs.Con_DPrintf("Unknown SpectatorPanel ActionSingal %i.\n",cmd); break;
case SPECTATOR_PANEL_CMD_TOGGLE_INSET:
gHUD.m_Spectator.SetModes(-1,
gHUD.m_Spectator.ToggleInset(false));
break;
default:
gEngfuncs.Con_DPrintf("Unknown SpectatorPanel ActionSingal %i.\n", cmd);
break;
}
}
void SpectatorPanel::Initialize()
{
int x,y,wide,tall;
getBounds(x,y,wide,tall);
int x, y, wide, tall;
CSchemeManager * pSchemes = gViewPort->GetSchemeManager();
getBounds(x, y, wide, tall);
CSchemeManager* pSchemes = gViewPort->GetSchemeManager();
SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Team Info Text");
SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle( "Team Info Text" );
m_TopBorder = new CTransparentPanel(64, 0, 0, ScreenWidth, PANEL_HEIGHT);
m_TopBorder->setParent(this);
@ -105,182 +113,185 @@ void SpectatorPanel::Initialize()
setPaintBackgroundEnabled(false);
m_ExtraInfo = new Label( "Extra Info", 0, 0, wide, PANEL_HEIGHT );
m_ExtraInfo = new Label("Extra Info", 0, 0, wide, PANEL_HEIGHT);
m_ExtraInfo->setParent(m_TopBorder);
m_ExtraInfo->setFont( pSchemes->getFont(hSmallScheme) );
m_ExtraInfo->setFont(pSchemes->getFont(hSmallScheme));
m_ExtraInfo->setPaintBackgroundEnabled(false);
m_ExtraInfo->setFgColor( 143, 143, 54, 0 );
m_ExtraInfo->setContentAlignment( vgui::Label::a_west );
m_ExtraInfo->setFgColor(143, 143, 54, 0);
m_ExtraInfo->setContentAlignment(vgui::Label::a_west);
m_TimerImage = new CImageLabel( "timer", 0, 0, 14, 14 );
m_TimerImage = new CImageLabel("timer", 0, 0, 14, 14);
m_TimerImage->setParent(m_TopBorder);
m_TopBanner = new CImageLabel( "banner", 0, 0, XRES(BANNER_WIDTH), YRES(BANNER_HEIGHT) );
m_TopBanner = new CImageLabel("banner", 0, 0, XRES(BANNER_WIDTH), YRES(BANNER_HEIGHT));
m_TopBanner->setParent(this);
m_CurrentTime = new Label( "00:00", 0, 0, wide, PANEL_HEIGHT );
m_CurrentTime = new Label("00:00", 0, 0, wide, PANEL_HEIGHT);
m_CurrentTime->setParent(m_TopBorder);
m_CurrentTime->setFont( pSchemes->getFont(hSmallScheme) );
m_CurrentTime->setFont(pSchemes->getFont(hSmallScheme));
m_CurrentTime->setPaintBackgroundEnabled(false);
m_CurrentTime->setFgColor( 143, 143, 54, 0 );
m_CurrentTime->setContentAlignment( vgui::Label::a_west );
m_CurrentTime->setFgColor(143, 143, 54, 0);
m_CurrentTime->setContentAlignment(vgui::Label::a_west);
m_Separator = new Panel( 0, 0, XRES( 64 ), YRES( 96 ));
m_Separator->setParent( m_TopBorder );
m_Separator->setFgColor( 59, 58, 34, 48 );
m_Separator->setBgColor( 59, 58, 34, 48 );
for ( int j= 0; j < TEAM_NUMBER; j++ )
m_Separator = new Panel(0, 0, XRES(64), YRES(96));
m_Separator->setParent(m_TopBorder);
m_Separator->setFgColor(59, 58, 34, 48);
m_Separator->setBgColor(59, 58, 34, 48);
for (int j = 0; j < TEAM_NUMBER; j++)
{
m_TeamScores[j] = new Label( " ", 0, 0, wide, PANEL_HEIGHT );
m_TeamScores[j]->setParent( m_TopBorder );
m_TeamScores[j]->setFont( pSchemes->getFont(hSmallScheme) );
m_TeamScores[j] = new Label(" ", 0, 0, wide, PANEL_HEIGHT);
m_TeamScores[j]->setParent(m_TopBorder);
m_TeamScores[j]->setFont(pSchemes->getFont(hSmallScheme));
m_TeamScores[j]->setPaintBackgroundEnabled(false);
m_TeamScores[j]->setFgColor( 143, 143, 54, 0 );
m_TeamScores[j]->setContentAlignment( vgui::Label::a_west );
m_TeamScores[j]->setVisible ( false );
m_TeamScores[j]->setFgColor(143, 143, 54, 0);
m_TeamScores[j]->setContentAlignment(vgui::Label::a_west);
m_TeamScores[j]->setVisible(false);
}
// Initialize command buttons.
// m_OptionButton = new ColorButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false );
m_OptionButton = new DropDownButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false );
m_OptionButton->setParent( m_BottomBorder );
m_OptionButton->setContentAlignment( vgui::Label::a_center );
m_OptionButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
m_OptionButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_OPTIONS) );
m_OptionButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
m_OptionButton->setArmedBorderColor ( 194, 202, 54, 0 );
m_OptionButton->setUnArmedColor ( 143, 143, 54, 0 );
m_OptionButton->setArmedColor ( 194, 202, 54, 0 );
// m_OptionButton = new ColorButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false );
m_OptionButton = new DropDownButton(CHudTextMessage::BufferedLocaliseTextString("#SPECT_OPTIONS"), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false);
m_OptionButton->setParent(m_BottomBorder);
m_OptionButton->setContentAlignment(vgui::Label::a_center);
m_OptionButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
m_OptionButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_OPTIONS));
m_OptionButton->setUnArmedBorderColor(59, 58, 34, 48);
m_OptionButton->setArmedBorderColor(194, 202, 54, 0);
m_OptionButton->setUnArmedColor(143, 143, 54, 0);
m_OptionButton->setArmedColor(194, 202, 54, 0);
m_CamButton = new DropDownButton( CHudTextMessage::BufferedLocaliseTextString( "#CAM_OPTIONS" ), ScreenWidth - ( XRES ( CAMOPTIONS_BUTTON_X ) + 15 ), YRES(6), XRES ( CAMOPTIONS_BUTTON_X ), YRES(20), false, false );
m_CamButton->setParent( m_BottomBorder );
m_CamButton->setContentAlignment( vgui::Label::a_center );
m_CamButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
m_CamButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_CAMERA ) );
m_CamButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
m_CamButton->setArmedBorderColor ( 194, 202, 54, 0 );
m_CamButton->setUnArmedColor ( 143, 143, 54, 0 );
m_CamButton->setArmedColor ( 194, 202, 54, 0 );
m_CamButton = new DropDownButton(CHudTextMessage::BufferedLocaliseTextString("#CAM_OPTIONS"), ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15), YRES(6), XRES(CAMOPTIONS_BUTTON_X), YRES(20), false, false);
m_CamButton->setParent(m_BottomBorder);
m_CamButton->setContentAlignment(vgui::Label::a_center);
m_CamButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
m_CamButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_CAMERA));
m_CamButton->setUnArmedBorderColor(59, 58, 34, 48);
m_CamButton->setArmedBorderColor(194, 202, 54, 0);
m_CamButton->setUnArmedColor(143, 143, 54, 0);
m_CamButton->setArmedColor(194, 202, 54, 0);
// m_PrevPlayerButton= new ColorButton("<", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false );
m_PrevPlayerButton= new CImageButton("arrowleft", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false );
m_PrevPlayerButton->setParent( m_BottomBorder );
m_PrevPlayerButton->setContentAlignment( vgui::Label::a_center );
m_PrevPlayerButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
m_PrevPlayerButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_PREVPLAYER) );
m_PrevPlayerButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
m_PrevPlayerButton->setArmedBorderColor ( 194, 202, 54, 0 );
m_PrevPlayerButton->setUnArmedColor ( 143, 143, 54, 0 );
m_PrevPlayerButton->setArmedColor ( 194, 202, 54, 0 );
// m_PrevPlayerButton= new ColorButton("<", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false );
m_PrevPlayerButton = new CImageButton("arrowleft", XRES(15 + OPTIONS_BUTTON_X + 15), YRES(6), XRES(24), YRES(20), false, false);
m_PrevPlayerButton->setParent(m_BottomBorder);
m_PrevPlayerButton->setContentAlignment(vgui::Label::a_center);
m_PrevPlayerButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
m_PrevPlayerButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_PREVPLAYER));
m_PrevPlayerButton->setUnArmedBorderColor(59, 58, 34, 48);
m_PrevPlayerButton->setArmedBorderColor(194, 202, 54, 0);
m_PrevPlayerButton->setUnArmedColor(143, 143, 54, 0);
m_PrevPlayerButton->setArmedColor(194, 202, 54, 0);
// m_NextPlayerButton= new ColorButton(">", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false );
m_NextPlayerButton = new CImageButton("arrowright", (ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15), YRES(6), XRES(24), YRES(20), false, false);
m_NextPlayerButton->setParent(m_BottomBorder);
m_NextPlayerButton->setContentAlignment(vgui::Label::a_center);
m_NextPlayerButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
m_NextPlayerButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_NEXTPLAYER));
m_NextPlayerButton->setUnArmedBorderColor(59, 58, 34, 48);
m_NextPlayerButton->setArmedBorderColor(194, 202, 54, 0);
m_NextPlayerButton->setUnArmedColor(143, 143, 54, 0);
m_NextPlayerButton->setArmedColor(194, 202, 54, 0);
// m_NextPlayerButton= new ColorButton(">", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false );
m_NextPlayerButton= new CImageButton("arrowright", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false );
m_NextPlayerButton->setParent( m_BottomBorder );
m_NextPlayerButton->setContentAlignment( vgui::Label::a_center );
m_NextPlayerButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
m_NextPlayerButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_NEXTPLAYER) );
m_NextPlayerButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
m_NextPlayerButton->setArmedBorderColor ( 194, 202, 54, 0 );
m_NextPlayerButton->setUnArmedColor ( 143, 143, 54, 0 );
m_NextPlayerButton->setArmedColor ( 194, 202, 54, 0 );
// Initialize the bottom title.
float flLabelSize = ( (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ) ) - XRES( (15 + OPTIONS_BUTTON_X + 15) + 38 );
float flLabelSize = ((ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15)) - XRES((15 + OPTIONS_BUTTON_X + 15) + 38);
m_BottomMainButton = new DropDownButton("Spectator Bottom",
XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6), flLabelSize, YRES(20),
false, false );
m_BottomMainButton = new DropDownButton("Spectator Bottom",
XRES((15 + OPTIONS_BUTTON_X + 15) + 31), YRES(6), flLabelSize, YRES(20),
false, false);
m_BottomMainButton->setParent(m_BottomBorder);
m_BottomMainButton->setPaintBackgroundEnabled(false);
m_BottomMainButton->setFgColor( Scheme::sc_primary1 );
m_BottomMainButton->setContentAlignment( vgui::Label::a_center );
m_BottomMainButton->setBorder( new LineBorder( Color( 59, 58, 34, 48 ) ) );
m_BottomMainButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
m_BottomMainButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_PLAYERS) );
m_BottomMainButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
m_BottomMainButton->setArmedBorderColor ( 194, 202, 54, 0 );
m_BottomMainButton->setUnArmedColor ( 143, 143, 54, 0 );
m_BottomMainButton->setArmedColor ( 194, 202, 54, 0 );
m_BottomMainButton->setFgColor(Scheme::sc_primary1);
m_BottomMainButton->setContentAlignment(vgui::Label::a_center);
m_BottomMainButton->setBorder(new LineBorder(Color(59, 58, 34, 48)));
m_BottomMainButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
m_BottomMainButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_PLAYERS));
m_BottomMainButton->setUnArmedBorderColor(59, 58, 34, 48);
m_BottomMainButton->setArmedBorderColor(194, 202, 54, 0);
m_BottomMainButton->setUnArmedColor(143, 143, 54, 0);
m_BottomMainButton->setArmedColor(194, 202, 54, 0);
m_BottomMainLabel = new Label("Spectator Bottom",
XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6), flLabelSize, YRES(20));
m_BottomMainLabel = new Label("Spectator Bottom",
XRES((15 + OPTIONS_BUTTON_X + 15) + 31), YRES(6), flLabelSize, YRES(20));
m_BottomMainLabel->setParent(m_BottomBorder);
m_BottomMainLabel->setPaintBackgroundEnabled(false);
m_BottomMainLabel->setFgColor( Scheme::sc_primary1 );
m_BottomMainLabel->setContentAlignment( vgui::Label::a_center );
m_BottomMainLabel->setBorder( NULL );
m_BottomMainLabel->setFgColor(Scheme::sc_primary1);
m_BottomMainLabel->setContentAlignment(vgui::Label::a_center);
m_BottomMainLabel->setBorder(NULL);
m_BottomMainLabel->setVisible(false);
m_InsetViewButton = new ColorButton("", XRES(2), YRES(2), XRES(240), YRES(180), false, false );
m_InsetViewButton->setParent( this );
m_InsetViewButton->setBoundKey( (char)255 );
m_InsetViewButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_TOGGLE_INSET) );
m_InsetViewButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
m_InsetViewButton->setArmedBorderColor ( 194, 202, 54, 0 );
m_InsetViewButton->setUnArmedColor ( 143, 143, 54, 0 );
m_InsetViewButton->setArmedColor ( 194, 202, 54, 0 );
m_InsetViewButton = new ColorButton("", XRES(2), YRES(2), XRES(240), YRES(180), false, false);
m_InsetViewButton->setParent(this);
m_InsetViewButton->setBoundKey((char)255);
m_InsetViewButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_TOGGLE_INSET));
m_InsetViewButton->setUnArmedBorderColor(59, 58, 34, 48);
m_InsetViewButton->setArmedBorderColor(194, 202, 54, 0);
m_InsetViewButton->setUnArmedColor(143, 143, 54, 0);
m_InsetViewButton->setArmedColor(194, 202, 54, 0);
m_menuVisible = false;
m_insetVisible = false;
// m_HideButton->setVisible(false);
// m_HideButton->setVisible(false);
m_CamButton->setVisible(false);
m_OptionButton->setVisible(false);
m_NextPlayerButton->setVisible(false);
m_PrevPlayerButton->setVisible(false);
m_TopBanner->setVisible( false );
m_ExtraInfo->setVisible( false );
m_Separator->setVisible( false );
m_TimerImage->setVisible( false );
m_TopBanner->setVisible(false);
m_ExtraInfo->setVisible(false);
m_Separator->setVisible(false);
m_TimerImage->setVisible(false);
}
void SpectatorPanel::ShowMenu(bool isVisible)
{
// m_HideButton->setVisible(isVisible); m_HideButton->setArmed( false );
m_OptionButton->setVisible(isVisible); m_OptionButton->setArmed( false );
m_CamButton->setVisible(isVisible); m_CamButton->setArmed( false );
m_NextPlayerButton->setVisible(isVisible); m_NextPlayerButton->setArmed( false );
m_PrevPlayerButton->setVisible(isVisible); m_PrevPlayerButton->setArmed( false );
// m_HideButton->setVisible(isVisible); m_HideButton->setArmed( false );
m_OptionButton->setVisible(isVisible);
m_OptionButton->setArmed(false);
m_CamButton->setVisible(isVisible);
m_CamButton->setArmed(false);
m_NextPlayerButton->setVisible(isVisible);
m_NextPlayerButton->setArmed(false);
m_PrevPlayerButton->setVisible(isVisible);
m_PrevPlayerButton->setArmed(false);
if ( !isVisible )
if (!isVisible)
{
int iLabelSizeX, iLabelSizeY;
m_BottomMainLabel->setVisible(true);
m_BottomMainButton->setVisible(false);
m_BottomMainLabel->getSize( iLabelSizeX, iLabelSizeY );
m_BottomMainLabel->setPos( ( ScreenWidth / 2 ) - (iLabelSizeX/2), YRES(6) );
m_BottomMainLabel->getSize(iLabelSizeX, iLabelSizeY);
m_BottomMainLabel->setPos((ScreenWidth / 2) - (iLabelSizeX / 2), YRES(6));
}
else
{
m_BottomMainButton->setPos( XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6) );
m_BottomMainButton->setPos(XRES((15 + OPTIONS_BUTTON_X + 15) + 31), YRES(6));
m_BottomMainLabel->setVisible(false);
m_BottomMainButton->setVisible(true);
}
if ( !isVisible )
if (!isVisible)
{
gViewPort->HideCommandMenu();
// if switching from visible menu to invisible menu, show help text
if ( m_menuVisible && this->isVisible() )
if (m_menuVisible && this->isVisible())
{
char string[ 64 ];
char string[64];
snprintf( string, sizeof( string ) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( "#Spec_Duck" ) );
string[ sizeof( string ) - 1 ] = '\0';
snprintf(string, sizeof(string) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString("#Spec_Duck"));
string[sizeof(string) - 1] = '\0';
gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( string ) + 1, string );
gHUD.m_TextMessage.MsgFunc_TextMsg(NULL, strlen(string) + 1, string);
}
}
@ -290,31 +301,31 @@ void SpectatorPanel::ShowMenu(bool isVisible)
}
const char *GetSpectatorLabel ( int iMode )
const char* GetSpectatorLabel(int iMode)
{
switch ( iMode )
switch (iMode)
{
case OBS_CHASE_LOCKED:
return "#OBS_CHASE_LOCKED";
case OBS_CHASE_LOCKED:
return "#OBS_CHASE_LOCKED";
case OBS_CHASE_FREE:
return "#OBS_CHASE_FREE";
case OBS_CHASE_FREE:
return "#OBS_CHASE_FREE";
case OBS_ROAMING:
return "#OBS_ROAMING";
case OBS_IN_EYE:
return "#OBS_IN_EYE";
case OBS_ROAMING:
return "#OBS_ROAMING";
case OBS_MAP_FREE:
return "#OBS_MAP_FREE";
case OBS_IN_EYE:
return "#OBS_IN_EYE";
case OBS_MAP_CHASE:
return "#OBS_MAP_CHASE";
case OBS_MAP_FREE:
return "#OBS_MAP_FREE";
case OBS_NONE:
default:
return "#OBS_NONE";
case OBS_MAP_CHASE:
return "#OBS_MAP_CHASE";
case OBS_NONE:
default:
return "#OBS_NONE";
}
return "";
@ -327,38 +338,38 @@ void SpectatorPanel::EnableInsetView(bool isEnabled)
int wide = gHUD.m_Spectator.m_OverviewData.insetWindowWidth;
int tall = gHUD.m_Spectator.m_OverviewData.insetWindowHeight;
int offset = x + wide + 2;
if ( isEnabled )
if (isEnabled)
{
// short black bar to see full inset
m_TopBorder->setBounds( XRES(offset), 0, XRES(640 - offset ), PANEL_HEIGHT );
m_TopBorder->setBounds(XRES(offset), 0, XRES(640 - offset), PANEL_HEIGHT);
if ( 0 != gEngfuncs.IsSpectateOnly() )
if (0 != gEngfuncs.IsSpectateOnly())
{
m_TopBanner->setVisible( true );
m_TopBanner->setPos( XRES(offset), 0 );
m_TopBanner->setVisible(true);
m_TopBanner->setPos(XRES(offset), 0);
}
else
m_TopBanner->setVisible( false );
m_InsetViewButton->setBounds( XRES( x -1 ), YRES( y ),
XRES( wide +2), YRES( tall ) );
m_TopBanner->setVisible(false);
m_InsetViewButton->setBounds(XRES(x - 1), YRES(y),
XRES(wide + 2), YRES(tall));
m_InsetViewButton->setVisible(true);
}
else
{
{
// full black bar, no inset border
// show banner only in real HLTV mode
if ( 0 != gEngfuncs.IsSpectateOnly() )
if (0 != gEngfuncs.IsSpectateOnly())
{
m_TopBanner->setVisible( true );
m_TopBanner->setPos( 0,0 );
m_TopBanner->setVisible(true);
m_TopBanner->setPos(0, 0);
}
else
m_TopBanner->setVisible( false );
m_TopBanner->setVisible(false);
m_TopBorder->setBounds(0, 0, ScreenWidth, PANEL_HEIGHT);
m_TopBorder->setBounds( 0, 0, ScreenWidth, PANEL_HEIGHT );
m_InsetViewButton->setVisible(false);
}
@ -366,7 +377,7 @@ void SpectatorPanel::EnableInsetView(bool isEnabled)
Update();
m_CamButton->setText( CHudTextMessage::BufferedLocaliseTextString( GetSpectatorLabel( g_iUser1 ) ) );
m_CamButton->setText(CHudTextMessage::BufferedLocaliseTextString(GetSpectatorLabel(g_iUser1)));
}
@ -376,51 +387,51 @@ void SpectatorPanel::Update()
{
int iTextWidth, iTextHeight;
int iTimeHeight, iTimeWidth;
int offset,j;
int offset, j;
if ( m_insetVisible )
if (m_insetVisible)
offset = gHUD.m_Spectator.m_OverviewData.insetWindowX + gHUD.m_Spectator.m_OverviewData.insetWindowWidth + 2;
else
offset = 0;
bool visible = gHUD.m_Spectator.m_drawstatus->value != 0;
m_ExtraInfo->setVisible( visible );
m_TimerImage->setVisible( visible );
m_CurrentTime->setVisible( visible );
m_Separator->setVisible( visible );
for ( j= 0; j < TEAM_NUMBER; j++ )
m_TeamScores[j]->setVisible( visible );
m_ExtraInfo->setVisible(visible);
m_TimerImage->setVisible(visible);
m_CurrentTime->setVisible(visible);
m_Separator->setVisible(visible);
if ( !visible )
for (j = 0; j < TEAM_NUMBER; j++)
m_TeamScores[j]->setVisible(visible);
if (!visible)
return;
m_ExtraInfo->getTextSize( iTextWidth, iTextHeight );
m_CurrentTime->getTextSize( iTimeWidth, iTimeHeight );
iTimeWidth += XRES ( SEPERATOR_WIDTH*2 + 1 ); // +timer icon
iTimeWidth += ( SEPERATOR_WIDTH-(iTimeWidth%SEPERATOR_WIDTH) );
m_ExtraInfo->getTextSize(iTextWidth, iTextHeight);
m_CurrentTime->getTextSize(iTimeWidth, iTimeHeight);
if ( iTimeWidth > iTextWidth )
iTimeWidth += XRES(SEPERATOR_WIDTH * 2 + 1); // +timer icon
iTimeWidth += (SEPERATOR_WIDTH - (iTimeWidth % SEPERATOR_WIDTH));
if (iTimeWidth > iTextWidth)
iTextWidth = iTimeWidth;
int xPos = ScreenWidth - ( iTextWidth + XRES ( SEPERATOR_WIDTH + offset ) );
int xPos = ScreenWidth - (iTextWidth + XRES(SEPERATOR_WIDTH + offset));
m_ExtraInfo->setBounds( xPos, YRES( SEPERATOR_HEIGHT ), iTextWidth, iTextHeight );
m_ExtraInfo->setBounds(xPos, YRES(SEPERATOR_HEIGHT), iTextWidth, iTextHeight);
m_TimerImage->setBounds( xPos, YRES( SEPERATOR_HEIGHT ) + iTextHeight , XRES(SEPERATOR_WIDTH*2 + 1), YRES(SEPERATOR_HEIGHT + 1) );
m_CurrentTime->setBounds( xPos + XRES ( SEPERATOR_WIDTH*2 + 1 ), YRES( SEPERATOR_HEIGHT ) + iTextHeight , iTimeWidth, iTimeHeight );
m_TimerImage->setBounds(xPos, YRES(SEPERATOR_HEIGHT) + iTextHeight, XRES(SEPERATOR_WIDTH * 2 + 1), YRES(SEPERATOR_HEIGHT + 1));
m_Separator->setPos( ScreenWidth - ( iTextWidth + XRES ( 2*SEPERATOR_WIDTH+SEPERATOR_WIDTH/2+offset ) ) , YRES( 5 ) );
m_Separator->setSize( XRES( 1 ), PANEL_HEIGHT - 10 );
m_CurrentTime->setBounds(xPos + XRES(SEPERATOR_WIDTH * 2 + 1), YRES(SEPERATOR_HEIGHT) + iTextHeight, iTimeWidth, iTimeHeight);
for ( j= 0; j < TEAM_NUMBER; j++ )
m_Separator->setPos(ScreenWidth - (iTextWidth + XRES(2 * SEPERATOR_WIDTH + SEPERATOR_WIDTH / 2 + offset)), YRES(5));
m_Separator->setSize(XRES(1), PANEL_HEIGHT - 10);
for (j = 0; j < TEAM_NUMBER; j++)
{
int iwidth, iheight;
m_TeamScores[j]->getTextSize( iwidth, iheight );
m_TeamScores[j]->setBounds( ScreenWidth - ( iTextWidth + XRES ( 2*SEPERATOR_WIDTH+2*SEPERATOR_WIDTH/2+offset ) + iwidth ), YRES( SEPERATOR_HEIGHT ) + ( iheight * j ), iwidth, iheight );
m_TeamScores[j]->getTextSize(iwidth, iheight);
m_TeamScores[j]->setBounds(ScreenWidth - (iTextWidth + XRES(2 * SEPERATOR_WIDTH + 2 * SEPERATOR_WIDTH / 2 + offset) + iwidth), YRES(SEPERATOR_HEIGHT) + (iheight * j), iwidth, iheight);
}
}

View file

@ -10,21 +10,21 @@
using namespace vgui;
#define SPECTATOR_PANEL_CMD_NONE 0
#define SPECTATOR_PANEL_CMD_NONE 0
#define SPECTATOR_PANEL_CMD_OPTIONS 1
#define SPECTATOR_PANEL_CMD_PREVPLAYER 2
#define SPECTATOR_PANEL_CMD_NEXTPLAYER 3
#define SPECTATOR_PANEL_CMD_HIDEMENU 4
#define SPECTATOR_PANEL_CMD_TOGGLE_INSET 5
#define SPECTATOR_PANEL_CMD_CAMERA 6
#define SPECTATOR_PANEL_CMD_PLAYERS 7
#define SPECTATOR_PANEL_CMD_OPTIONS 1
#define SPECTATOR_PANEL_CMD_PREVPLAYER 2
#define SPECTATOR_PANEL_CMD_NEXTPLAYER 3
#define SPECTATOR_PANEL_CMD_HIDEMENU 4
#define SPECTATOR_PANEL_CMD_TOGGLE_INSET 5
#define SPECTATOR_PANEL_CMD_CAMERA 6
#define SPECTATOR_PANEL_CMD_PLAYERS 7
// spectator panel sizes
#define PANEL_HEIGHT 64
#define BANNER_WIDTH 256
#define BANNER_HEIGHT 64
#define BANNER_WIDTH 256
#define BANNER_HEIGHT 64
#define OPTIONS_BUTTON_X 96
#define CAMOPTIONS_BUTTON_X 200
@ -40,49 +40,48 @@ class SpectatorPanel : public Panel //, public vgui::CDefaultInputSignal
{
public:
SpectatorPanel(int x,int y,int wide,int tall);
SpectatorPanel(int x, int y, int wide, int tall);
virtual ~SpectatorPanel();
void ActionSignal(int cmd);
void ActionSignal(int cmd);
// InputSignal overrides.
public:
void Initialize();
void Update();
public:
void EnableInsetView(bool isEnabled);
void ShowMenu(bool isVisible);
DropDownButton * m_OptionButton;
// CommandButton * m_HideButton;
DropDownButton* m_OptionButton;
// CommandButton * m_HideButton;
//ColorButton * m_PrevPlayerButton;
//ColorButton * m_NextPlayerButton;
CImageButton * m_PrevPlayerButton;
CImageButton * m_NextPlayerButton;
DropDownButton * m_CamButton;
CImageButton* m_PrevPlayerButton;
CImageButton* m_NextPlayerButton;
DropDownButton* m_CamButton;
CTransparentPanel * m_TopBorder;
CTransparentPanel * m_BottomBorder;
CTransparentPanel* m_TopBorder;
CTransparentPanel* m_BottomBorder;
ColorButton *m_InsetViewButton;
DropDownButton *m_BottomMainButton;
CImageLabel *m_TimerImage;
Label *m_BottomMainLabel;
Label *m_CurrentTime;
Label *m_ExtraInfo;
Panel *m_Separator;
ColorButton* m_InsetViewButton;
Label *m_TeamScores[TEAM_NUMBER];
CImageLabel *m_TopBanner;
DropDownButton* m_BottomMainButton;
CImageLabel* m_TimerImage;
Label* m_BottomMainLabel;
Label* m_CurrentTime;
Label* m_ExtraInfo;
Panel* m_Separator;
bool m_menuVisible;
bool m_insetVisible;
Label* m_TeamScores[TEAM_NUMBER];
CImageLabel* m_TopBanner;
bool m_menuVisible;
bool m_insetVisible;
};
@ -91,18 +90,18 @@ class CSpectatorHandler_Command : public ActionSignal
{
private:
SpectatorPanel * m_pFather;
int m_cmd;
SpectatorPanel* m_pFather;
int m_cmd;
public:
CSpectatorHandler_Command( SpectatorPanel * panel, int cmd )
CSpectatorHandler_Command(SpectatorPanel* panel, int cmd)
{
m_pFather = panel;
m_cmd = cmd;
}
void actionPerformed( Panel * panel ) override
{
void actionPerformed(Panel* panel) override
{
m_pFather->ActionSignal(m_cmd);
}
};

File diff suppressed because it is too large Load diff

View file

@ -1,18 +1,18 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include"vgui_int.h"
#include<VGUI_Label.h>
#include<VGUI_BorderLayout.h>
#include<VGUI_LineBorder.h>
#include<VGUI_SurfaceBase.h>
#include<VGUI_TextEntry.h>
#include<VGUI_ActionSignal.h>
#include<string.h>
#include "vgui_int.h"
#include <VGUI_Label.h>
#include <VGUI_BorderLayout.h>
#include <VGUI_LineBorder.h>
#include <VGUI_SurfaceBase.h>
#include <VGUI_TextEntry.h>
#include <VGUI_ActionSignal.h>
#include <string.h>
#include "hud.h"
#include "cl_util.h"
#include "camera.h"
@ -27,44 +27,47 @@
namespace
{
class TexturePanel : public Panel , public ActionSignal
class TexturePanel : public Panel, public ActionSignal
{
private:
int _bindIndex;
TextEntry* _textEntry;
public:
TexturePanel() : Panel(0,0,256,276)
TexturePanel() : Panel(0, 0, 256, 276)
{
_bindIndex=2700;
_textEntry=new TextEntry("2700",0,0,128,20);
_bindIndex = 2700;
_textEntry = new TextEntry("2700", 0, 0, 128, 20);
_textEntry->setParent(this);
_textEntry->addActionSignal(this);
}
public:
bool isWithin(int x,int y) override
bool isWithin(int x, int y) override
{
return _textEntry->isWithin(x,y);
return _textEntry->isWithin(x, y);
}
public:
void actionPerformed(Panel* panel) override
{
char buf[256];
_textEntry->getText(0,buf,256);
sscanf(buf,"%d",&_bindIndex);
_textEntry->getText(0, buf, 256);
sscanf(buf, "%d", &_bindIndex);
}
protected:
void paintBackground() override
{
Panel::paintBackground();
int wide,tall;
getPaintSize(wide,tall);
drawSetColor(0,0,255,0);
drawSetTexture(_bindIndex);
drawTexturedRect(0,19,257,257);
}
Panel::paintBackground();
int wide, tall;
getPaintSize(wide, tall);
drawSetColor(0, 0, 255, 0);
drawSetTexture(_bindIndex);
drawTexturedRect(0, 19, 257, 257);
}
};
}
@ -83,28 +86,28 @@ void* VGui_GetPanel()
void VGui_Startup()
{
Panel* root=(Panel*)VGui_GetPanel();
root->setBgColor(128,128,0,0);
Panel* root = (Panel*)VGui_GetPanel();
root->setBgColor(128, 128, 0, 0);
//root->setNonPainted(false);
//root->setBorder(new LineBorder());
root->setLayout(new BorderLayout(0));
//root->getSurfaceBase()->setEmulatedCursorVisible(true);
if (gViewPort != NULL)
{
// root->removeChild(gViewPort);
// root->removeChild(gViewPort);
// free the memory
// delete gViewPort;
// gViewPort = NULL;
// delete gViewPort;
// gViewPort = NULL;
gViewPort->Initialize();
}
else
{
gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall());
gViewPort = new TeamFortressViewport(0, 0, root->getWide(), root->getTall());
gViewPort->setParent(root);
}
@ -112,7 +115,6 @@ void VGui_Startup()
TexturePanel* texturePanel=new TexturePanel();
texturePanel->setParent(gViewPort);
*/
}
void VGui_Shutdown()
@ -120,8 +122,3 @@ void VGui_Shutdown()
delete gViewPort;
gViewPort = NULL;
}

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================

View file

@ -26,130 +26,130 @@
#include "vgui_TeamFortressViewport.h"
// Team Menu Dimensions
#define TEAMMENU_TITLE_X XRES(40)
#define TEAMMENU_TITLE_Y YRES(32)
#define TEAMMENU_TOPLEFT_BUTTON_X XRES(40)
#define TEAMMENU_TOPLEFT_BUTTON_Y YRES(80)
#define TEAMMENU_BUTTON_SIZE_X XRES(124)
#define TEAMMENU_BUTTON_SIZE_Y YRES(24)
#define TEAMMENU_BUTTON_SPACER_Y YRES(8)
#define TEAMMENU_WINDOW_X XRES(176)
#define TEAMMENU_WINDOW_Y YRES(80)
#define TEAMMENU_WINDOW_SIZE_X XRES(424)
#define TEAMMENU_WINDOW_SIZE_Y YRES(312)
#define TEAMMENU_WINDOW_TITLE_X XRES(16)
#define TEAMMENU_WINDOW_TITLE_Y YRES(16)
#define TEAMMENU_WINDOW_TEXT_X XRES(16)
#define TEAMMENU_WINDOW_TEXT_Y YRES(48)
#define TEAMMENU_WINDOW_TEXT_SIZE_Y YRES(178)
#define TEAMMENU_WINDOW_INFO_X XRES(16)
#define TEAMMENU_WINDOW_INFO_Y YRES(234)
#define TEAMMENU_TITLE_X XRES(40)
#define TEAMMENU_TITLE_Y YRES(32)
#define TEAMMENU_TOPLEFT_BUTTON_X XRES(40)
#define TEAMMENU_TOPLEFT_BUTTON_Y YRES(80)
#define TEAMMENU_BUTTON_SIZE_X XRES(124)
#define TEAMMENU_BUTTON_SIZE_Y YRES(24)
#define TEAMMENU_BUTTON_SPACER_Y YRES(8)
#define TEAMMENU_WINDOW_X XRES(176)
#define TEAMMENU_WINDOW_Y YRES(80)
#define TEAMMENU_WINDOW_SIZE_X XRES(424)
#define TEAMMENU_WINDOW_SIZE_Y YRES(312)
#define TEAMMENU_WINDOW_TITLE_X XRES(16)
#define TEAMMENU_WINDOW_TITLE_Y YRES(16)
#define TEAMMENU_WINDOW_TEXT_X XRES(16)
#define TEAMMENU_WINDOW_TEXT_Y YRES(48)
#define TEAMMENU_WINDOW_TEXT_SIZE_Y YRES(178)
#define TEAMMENU_WINDOW_INFO_X XRES(16)
#define TEAMMENU_WINDOW_INFO_Y YRES(234)
// Creation
CTeamMenuPanel::CTeamMenuPanel(int iTrans, bool iRemoveMe, int x,int y,int wide,int tall) : CMenuPanel(iTrans, iRemoveMe, x,y,wide,tall)
CTeamMenuPanel::CTeamMenuPanel(int iTrans, bool iRemoveMe, int x, int y, int wide, int tall) : CMenuPanel(iTrans, iRemoveMe, x, y, wide, tall)
{
// Get the scheme used for the Titles
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
CSchemeManager* pSchemes = gViewPort->GetSchemeManager();
// schemes
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
SchemeHandle_t hTeamWindowText = pSchemes->getSchemeHandle( "Briefing Text" );
SchemeHandle_t hTeamInfoText = pSchemes->getSchemeHandle( "Team Info Text" );
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Title Font");
SchemeHandle_t hTeamWindowText = pSchemes->getSchemeHandle("Briefing Text");
SchemeHandle_t hTeamInfoText = pSchemes->getSchemeHandle("Team Info Text");
// get the Font used for the Titles
Font *pTitleFont = pSchemes->getFont( hTitleScheme );
Font* pTitleFont = pSchemes->getFont(hTitleScheme);
int r, g, b, a;
// Create the title
Label *pLabel = new Label( "", TEAMMENU_TITLE_X, TEAMMENU_TITLE_Y );
pLabel->setParent( this );
pLabel->setFont( pTitleFont );
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
pLabel->setFgColor( r, g, b, a );
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
pLabel->setBgColor( r, g, b, a );
pLabel->setContentAlignment( vgui::Label::a_west );
pLabel->setText( "%s", gHUD.m_TextMessage.BufferedLocaliseTextString("#Title_SelectYourTeam"));
Label* pLabel = new Label("", TEAMMENU_TITLE_X, TEAMMENU_TITLE_Y);
pLabel->setParent(this);
pLabel->setFont(pTitleFont);
pSchemes->getFgColor(hTitleScheme, r, g, b, a);
pLabel->setFgColor(r, g, b, a);
pSchemes->getBgColor(hTitleScheme, r, g, b, a);
pLabel->setBgColor(r, g, b, a);
pLabel->setContentAlignment(vgui::Label::a_west);
pLabel->setText("%s", gHUD.m_TextMessage.BufferedLocaliseTextString("#Title_SelectYourTeam"));
// Create the Info Window
m_pTeamWindow = new CTransparentPanel( 255, TEAMMENU_WINDOW_X, TEAMMENU_WINDOW_Y, TEAMMENU_WINDOW_SIZE_X, TEAMMENU_WINDOW_SIZE_Y );
m_pTeamWindow->setParent( this );
m_pTeamWindow->setBorder( new LineBorder( Color(255*0.7,170*0.7,0,0 )) );
m_pTeamWindow = new CTransparentPanel(255, TEAMMENU_WINDOW_X, TEAMMENU_WINDOW_Y, TEAMMENU_WINDOW_SIZE_X, TEAMMENU_WINDOW_SIZE_Y);
m_pTeamWindow->setParent(this);
m_pTeamWindow->setBorder(new LineBorder(Color(255 * 0.7, 170 * 0.7, 0, 0)));
// Create the Map Name Label
m_pMapTitle = new Label( "", TEAMMENU_WINDOW_TITLE_X, TEAMMENU_WINDOW_TITLE_Y );
m_pMapTitle->setFont( pTitleFont );
m_pMapTitle->setParent( m_pTeamWindow );
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
m_pMapTitle->setFgColor( r, g, b, a );
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
m_pMapTitle->setBgColor( r, g, b, a );
m_pMapTitle->setContentAlignment( vgui::Label::a_west );
m_pMapTitle = new Label("", TEAMMENU_WINDOW_TITLE_X, TEAMMENU_WINDOW_TITLE_Y);
m_pMapTitle->setFont(pTitleFont);
m_pMapTitle->setParent(m_pTeamWindow);
pSchemes->getFgColor(hTitleScheme, r, g, b, a);
m_pMapTitle->setFgColor(r, g, b, a);
pSchemes->getBgColor(hTitleScheme, r, g, b, a);
m_pMapTitle->setBgColor(r, g, b, a);
m_pMapTitle->setContentAlignment(vgui::Label::a_west);
// Create the Scroll panel
m_pScrollPanel = new CTFScrollPanel( TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_Y, TEAMMENU_WINDOW_SIZE_X - (TEAMMENU_WINDOW_TEXT_X * 2), TEAMMENU_WINDOW_TEXT_SIZE_Y );
m_pScrollPanel = new CTFScrollPanel(TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_Y, TEAMMENU_WINDOW_SIZE_X - (TEAMMENU_WINDOW_TEXT_X * 2), TEAMMENU_WINDOW_TEXT_SIZE_Y);
m_pScrollPanel->setParent(m_pTeamWindow);
m_pScrollPanel->setScrollBarVisible(false, false);
// Create the Map Briefing panel
m_pBriefing = new TextPanel("", 0,0, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_SIZE_Y );
m_pBriefing->setParent( m_pScrollPanel->getClient() );
m_pBriefing->setFont( pSchemes->getFont(hTeamWindowText) );
pSchemes->getFgColor( hTeamWindowText, r, g, b, a );
m_pBriefing->setFgColor( r, g, b, a );
pSchemes->getBgColor( hTeamWindowText, r, g, b, a );
m_pBriefing->setBgColor( r, g, b, a );
m_pBriefing = new TextPanel("", 0, 0, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_SIZE_Y);
m_pBriefing->setParent(m_pScrollPanel->getClient());
m_pBriefing->setFont(pSchemes->getFont(hTeamWindowText));
pSchemes->getFgColor(hTeamWindowText, r, g, b, a);
m_pBriefing->setFgColor(r, g, b, a);
pSchemes->getBgColor(hTeamWindowText, r, g, b, a);
m_pBriefing->setBgColor(r, g, b, a);
m_pBriefing->setText(gHUD.m_TextMessage.BufferedLocaliseTextString("#Map_Description_not_available"));
m_pBriefing->setText( gHUD.m_TextMessage.BufferedLocaliseTextString("#Map_Description_not_available") );
// Team Menu buttons
for (int i = 1; i <= 5; i++)
{
char sz[256];
char sz[256];
int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y + ( (TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y) * i );
int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y + ((TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y) * i);
// Team button
m_pButtons[i] = new CommandButton( "", TEAMMENU_TOPLEFT_BUTTON_X, iYPos, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true);
m_pButtons[i]->setParent( this );
m_pButtons[i]->setContentAlignment( vgui::Label::a_west );
m_pButtons[i]->setVisible( false );
m_pButtons[i] = new CommandButton("", TEAMMENU_TOPLEFT_BUTTON_X, iYPos, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true);
m_pButtons[i]->setParent(this);
m_pButtons[i]->setContentAlignment(vgui::Label::a_west);
m_pButtons[i]->setVisible(false);
// AutoAssign button uses special case
if (i == 5)
{
m_pButtons[5]->setBoundKey( '5' );
m_pButtons[5]->setText( gHUD.m_TextMessage.BufferedLocaliseTextString("#Team_AutoAssign") );
m_pButtons[5]->setVisible( true );
m_pButtons[5]->setBoundKey('5');
m_pButtons[5]->setText(gHUD.m_TextMessage.BufferedLocaliseTextString("#Team_AutoAssign"));
m_pButtons[5]->setVisible(true);
}
// Create the Signals
sprintf(sz, "jointeam %d", i);
m_pButtons[i]->addActionSignal( new CMenuHandler_StringCommandWatch( sz, true ) );
m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver(this, i) );
m_pButtons[i]->addActionSignal(new CMenuHandler_StringCommandWatch(sz, true));
m_pButtons[i]->addInputSignal(new CHandler_MenuButtonOver(this, i));
// Create the Team Info panel
m_pTeamInfoPanel[i] = new TextPanel("", TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_INFO_Y, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_Y );
m_pTeamInfoPanel[i]->setParent( m_pTeamWindow );
m_pTeamInfoPanel[i]->setFont( pSchemes->getFont(hTeamInfoText) );
m_pTeamInfoPanel[i]->setFgColor( iTeamColors[i % iNumberOfTeamColors][0],
iTeamColors[i % iNumberOfTeamColors][1],
iTeamColors[i % iNumberOfTeamColors][2],
0 );
m_pTeamInfoPanel[i]->setBgColor( 0,0,0, 255 );
m_pTeamInfoPanel[i] = new TextPanel("", TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_INFO_Y, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_Y);
m_pTeamInfoPanel[i]->setParent(m_pTeamWindow);
m_pTeamInfoPanel[i]->setFont(pSchemes->getFont(hTeamInfoText));
m_pTeamInfoPanel[i]->setFgColor(iTeamColors[i % iNumberOfTeamColors][0],
iTeamColors[i % iNumberOfTeamColors][1],
iTeamColors[i % iNumberOfTeamColors][2],
0);
m_pTeamInfoPanel[i]->setBgColor(0, 0, 0, 255);
}
// Create the Cancel button
m_pCancelButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_Cancel" ), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y);
m_pCancelButton->setParent( this );
m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow(HIDE_TEXTWINDOW) );
m_pCancelButton = new CommandButton(CHudTextMessage::BufferedLocaliseTextString("#Menu_Cancel"), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y);
m_pCancelButton->setParent(this);
m_pCancelButton->addActionSignal(new CMenuHandler_TextWindow(HIDE_TEXTWINDOW));
// Create the Spectate button
m_pSpectateButton = new SpectateButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_Spectate" ), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true);
m_pSpectateButton->setParent( this );
m_pSpectateButton->addActionSignal( new CMenuHandler_StringCommand( "spectate", true ) );
m_pSpectateButton->setBoundKey( '6' );
m_pSpectateButton->addInputSignal( new CHandler_MenuButtonOver(this, 6) );
m_pSpectateButton = new SpectateButton(CHudTextMessage::BufferedLocaliseTextString("#Menu_Spectate"), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true);
m_pSpectateButton->setParent(this);
m_pSpectateButton->addActionSignal(new CMenuHandler_StringCommand("spectate", true));
m_pSpectateButton->setBoundKey('6');
m_pSpectateButton->addInputSignal(new CHandler_MenuButtonOver(this, 6));
Initialize();
}
@ -161,7 +161,7 @@ void CTeamMenuPanel::Initialize()
{
m_bUpdatedMapName = false;
m_iCurrentInfo = 0;
m_pScrollPanel->setScrollValue( 0, 0 );
m_pScrollPanel->setScrollValue(0, 0);
}
//-----------------------------------------------------------------------------
@ -169,141 +169,141 @@ void CTeamMenuPanel::Initialize()
//-----------------------------------------------------------------------------
void CTeamMenuPanel::Update()
{
int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y;
int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y;
// Set the team buttons
for (int i = 1; i <= 4; i++)
{
if (m_pButtons[i])
{
if ( i <= gViewPort->GetNumberOfTeams() )
if (i <= gViewPort->GetNumberOfTeams())
{
m_pButtons[i]->setText( gViewPort->GetTeamName(i) );
m_pButtons[i]->setText(gViewPort->GetTeamName(i));
// bound key replacement
char sz[32];
sprintf( sz, "%d", i );
m_pButtons[i]->setBoundKey( sz[0] );
char sz[32];
sprintf(sz, "%d", i);
m_pButtons[i]->setBoundKey(sz[0]);
m_pButtons[i]->setVisible( true );
m_pButtons[i]->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos );
m_pButtons[i]->setVisible(true);
m_pButtons[i]->setPos(TEAMMENU_TOPLEFT_BUTTON_X, iYPos);
iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y;
// Start with the first option up
if (0 == m_iCurrentInfo)
SetActiveInfo( i );
SetActiveInfo(i);
char szPlayerList[ (MAX_PLAYER_NAME_LENGTH + 3) * 31 ]; // name + ", "
char szPlayerList[(MAX_PLAYER_NAME_LENGTH + 3) * 31]; // name + ", "
strcpy(szPlayerList, "\n");
// Update the Team Info
// Now count the number of teammembers of this class
int iTotal = 0;
for ( int j = 1; j < MAX_PLAYERS; j++ )
for (int j = 1; j < MAX_PLAYERS; j++)
{
if ( g_PlayerInfoList[j].name == NULL )
if (g_PlayerInfoList[j].name == NULL)
continue; // empty player slot, skip
if ( 0 != g_PlayerInfoList[j].thisplayer )
if (0 != g_PlayerInfoList[j].thisplayer)
continue; // skip this player
if ( g_PlayerExtraInfo[j].teamnumber != i )
if (g_PlayerExtraInfo[j].teamnumber != i)
continue; // skip over players in other teams
iTotal++;
if (iTotal > 1)
strncat( szPlayerList, ", ", sizeof(szPlayerList) - strlen(szPlayerList) );
strncat( szPlayerList, g_PlayerInfoList[j].name, sizeof(szPlayerList) - strlen(szPlayerList) );
szPlayerList[ sizeof(szPlayerList) - 1 ] = '\0';
strncat(szPlayerList, ", ", sizeof(szPlayerList) - strlen(szPlayerList));
strncat(szPlayerList, g_PlayerInfoList[j].name, sizeof(szPlayerList) - strlen(szPlayerList));
szPlayerList[sizeof(szPlayerList) - 1] = '\0';
}
if (iTotal > 0)
{
// Set the text of the info Panel
char szText[ ((MAX_PLAYER_NAME_LENGTH + 3) * 31) + 256 ];
char szText[((MAX_PLAYER_NAME_LENGTH + 3) * 31) + 256];
if (iTotal == 1)
sprintf(szText, "%s: %d Player (%d points)", gViewPort->GetTeamName(i), iTotal, g_TeamInfo[i].frags );
sprintf(szText, "%s: %d Player (%d points)", gViewPort->GetTeamName(i), iTotal, g_TeamInfo[i].frags);
else
sprintf(szText, "%s: %d Players (%d points)", gViewPort->GetTeamName(i), iTotal, g_TeamInfo[i].frags );
strncat( szText, szPlayerList, sizeof(szText) - strlen(szText) );
szText[ sizeof(szText) - 1 ] = '\0';
sprintf(szText, "%s: %d Players (%d points)", gViewPort->GetTeamName(i), iTotal, g_TeamInfo[i].frags);
strncat(szText, szPlayerList, sizeof(szText) - strlen(szText));
szText[sizeof(szText) - 1] = '\0';
m_pTeamInfoPanel[i]->setText( szText );
m_pTeamInfoPanel[i]->setText(szText);
}
else
{
m_pTeamInfoPanel[i]->setText( "" );
m_pTeamInfoPanel[i]->setText("");
}
}
else
{
// Hide the button (may be visible from previous maps)
m_pButtons[i]->setVisible( false );
m_pButtons[i]->setVisible(false);
}
}
}
// Move the AutoAssign button into place
m_pButtons[5]->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos );
m_pButtons[5]->setPos(TEAMMENU_TOPLEFT_BUTTON_X, iYPos);
iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y;
// Spectate button
if (m_pSpectateButton->IsNotValid())
{
m_pSpectateButton->setVisible( false );
m_pSpectateButton->setVisible(false);
}
else
{
m_pSpectateButton->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos );
m_pSpectateButton->setVisible( true );
m_pSpectateButton->setPos(TEAMMENU_TOPLEFT_BUTTON_X, iYPos);
m_pSpectateButton->setVisible(true);
iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y;
}
// If the player is already in a team, make the cancel button visible
if ( 0 != g_iTeamNumber )
if (0 != g_iTeamNumber)
{
m_pCancelButton->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos );
m_pCancelButton->setPos(TEAMMENU_TOPLEFT_BUTTON_X, iYPos);
iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y;
m_pCancelButton->setVisible( true );
m_pCancelButton->setVisible(true);
}
else
{
m_pCancelButton->setVisible( false );
m_pCancelButton->setVisible(false);
}
// Set the Map Title
if (!m_bUpdatedMapName)
{
const char *level = gEngfuncs.pfnGetLevelName();
const char* level = gEngfuncs.pfnGetLevelName();
if (level && '\0' != level[0])
{
char sz[256];
char szTitle[256];
char *ch;
char sz[256];
char szTitle[256];
char* ch;
// Update the level name
strcpy( sz, level );
ch = strchr( sz, '/' );
strcpy(sz, level);
ch = strchr(sz, '/');
if (!ch)
ch = strchr( sz, '\\' );
strcpy( szTitle, ch+1 );
ch = strchr( szTitle, '.' );
ch = strchr(sz, '\\');
strcpy(szTitle, ch + 1);
ch = strchr(szTitle, '.');
*ch = '\0';
m_pMapTitle->setText( "%s", szTitle );
m_pMapTitle->setText("%s", szTitle);
*ch = '.';
// Update the map briefing
strcpy( sz, level );
ch = strchr( sz, '.' );
strcpy(sz, level);
ch = strchr(sz, '.');
*ch = '\0';
strcat( sz, ".txt" );
char *pfile = (char*)gEngfuncs.COM_LoadFile( sz, 5, NULL );
strcat(sz, ".txt");
char* pfile = (char*)gEngfuncs.COM_LoadFile(sz, 5, NULL);
if (pfile)
{
m_pBriefing->setText( pfile );
m_pBriefing->setText(pfile);
// Get the total size of the Briefing text and resize the text panel
int iXSize, iYSize;
m_pBriefing->getTextImage()->getTextSize( iXSize, iYSize );
m_pBriefing->setSize( iXSize, iYSize );
gEngfuncs.COM_FreeFile( pfile );
m_pBriefing->getTextImage()->getTextSize(iXSize, iYSize);
m_pBriefing->setSize(iXSize, iYSize);
gEngfuncs.COM_FreeFile(pfile);
}
m_bUpdatedMapName = true;
@ -315,32 +315,32 @@ void CTeamMenuPanel::Update()
//=====================================
// Key inputs
bool CTeamMenuPanel::SlotInput( int iSlot )
bool CTeamMenuPanel::SlotInput(int iSlot)
{
// Check for AutoAssign
if ( iSlot == 5)
if (iSlot == 5)
{
m_pButtons[5]->fireActionSignal();
return true;
}
// Spectate
if ( iSlot == 6)
if (iSlot == 6)
{
m_pSpectateButton->fireActionSignal();
return true;
}
// Otherwise, see if a particular team is selectable
if ( (iSlot < 1) || (iSlot > gViewPort->GetNumberOfTeams()) )
if ((iSlot < 1) || (iSlot > gViewPort->GetNumberOfTeams()))
return false;
if ( !m_pButtons[ iSlot ] )
if (!m_pButtons[iSlot])
return false;
// Is the button pushable?
if ( m_pButtons[ iSlot ]->isVisible() )
if (m_pButtons[iSlot]->isVisible())
{
m_pButtons[ iSlot ]->fireActionSignal();
m_pButtons[iSlot]->fireActionSignal();
return true;
}
@ -358,7 +358,7 @@ void CTeamMenuPanel::Open()
void CTeamMenuPanel::paintBackground()
{
// make sure we get the map briefing up
if ( !m_bUpdatedMapName )
if (!m_bUpdatedMapName)
Update();
CMenuPanel::paintBackground();
@ -366,25 +366,25 @@ void CTeamMenuPanel::paintBackground()
//======================================
// Mouse is over a team button, bring up the class info
void CTeamMenuPanel::SetActiveInfo( int iInput )
void CTeamMenuPanel::SetActiveInfo(int iInput)
{
// Remove all the Info panels and bring up the specified one
m_pSpectateButton->setArmed( false );
m_pSpectateButton->setArmed(false);
for (int i = 1; i <= 5; i++)
{
m_pButtons[i]->setArmed( false );
m_pTeamInfoPanel[i]->setVisible( false );
m_pButtons[i]->setArmed(false);
m_pTeamInfoPanel[i]->setVisible(false);
}
// 6 is Spectate
if (iInput == 6)
{
m_pSpectateButton->setArmed( true );
m_pSpectateButton->setArmed(true);
}
else
{
m_pButtons[iInput]->setArmed( true );
m_pTeamInfoPanel[iInput]->setVisible( true );
m_pButtons[iInput]->setArmed(true);
m_pTeamInfoPanel[iInput]->setVisible(true);
}
m_iCurrentInfo = iInput;

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================

View file

@ -1,19 +1,19 @@
//========= Copyright <20> 1996-2001, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// There are hud.h's coming out of the woodwork so this ensures that we get the right one.
#if defined(THREEWAVE) || defined(DMC_BUILD)
#include "../dmc/cl_dll/hud.h"
#include "../dmc/cl_dll/hud.h"
#elif defined(CSTRIKE)
#include "../cstrike/cl_dll/hud.h"
#include "../cstrike/cl_dll/hud.h"
#elif defined(DOD)
#include "../dod/cl_dll/hud.h"
#include "../dod/cl_dll/hud.h"
#else
#include "hud.h"
#include "hud.h"
#endif
#include "cl_util.h"
@ -41,12 +41,12 @@ using namespace vgui;
extern bool cam_thirdperson;
#define VOICE_MODEL_INTERVAL 0.3
#define SCOREBOARD_BLINK_FREQUENCY 0.3 // How often to blink the scoreboard icons.
#define SQUELCHOSCILLATE_PER_SECOND 2.0f
#define VOICE_MODEL_INTERVAL 0.3
#define SCOREBOARD_BLINK_FREQUENCY 0.3 // How often to blink the scoreboard icons.
#define SQUELCHOSCILLATE_PER_SECOND 2.0f
extern BitmapTGA *LoadTGA( const char* pImageName );
extern BitmapTGA* LoadTGA(const char* pImageName);
@ -66,19 +66,19 @@ CVoiceStatus* GetClientVoiceMgr()
// CVoiceStatus.
// ---------------------------------------------------------------------- //
static CVoiceStatus *g_pInternalVoiceStatus = NULL;
static CVoiceStatus* g_pInternalVoiceStatus = NULL;
int __MsgFunc_VoiceMask(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_VoiceMask(const char* pszName, int iSize, void* pbuf)
{
if(g_pInternalVoiceStatus)
if (g_pInternalVoiceStatus)
g_pInternalVoiceStatus->HandleVoiceMaskMsg(iSize, pbuf);
return 1;
}
int __MsgFunc_ReqState(const char *pszName, int iSize, void *pbuf)
int __MsgFunc_ReqState(const char* pszName, int iSize, void* pbuf)
{
if(g_pInternalVoiceStatus)
if (g_pInternalVoiceStatus)
g_pInternalVoiceStatus->HandleReqStateMsg(iSize, pbuf);
return 1;
@ -91,11 +91,10 @@ void ForEachBannedPlayer(char id[16])
char str[256];
sprintf(str, "Ban %d: %2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X\n",
g_BannedPlayerPrintCount++,
id[0], id[1], id[2], id[3],
id[4], id[5], id[6], id[7],
id[8], id[9], id[10], id[11],
id[12], id[13], id[14], id[15]
);
id[0], id[1], id[2], id[3],
id[4], id[5], id[6], id[7],
id[8], id[9], id[10], id[11],
id[12], id[13], id[14], id[15]);
gEngfuncs.pfnConsolePrint(str);
}
@ -103,7 +102,7 @@ void ForEachBannedPlayer(char id[16])
void ShowBannedCallback()
{
if(g_pInternalVoiceStatus)
if (g_pInternalVoiceStatus)
{
g_BannedPlayerPrintCount = 0;
gEngfuncs.pfnConsolePrint("------- BANNED PLAYERS -------\n");
@ -129,7 +128,7 @@ CVoiceStatus::CVoiceStatus()
m_pScoreboardSpeaking2 = NULL;
m_pScoreboardSquelch = NULL;
m_pScoreboardBanned = NULL;
m_pLocalBitmap = NULL;
m_pAckBitmap = NULL;
@ -148,27 +147,27 @@ CVoiceStatus::CVoiceStatus()
CVoiceStatus::~CVoiceStatus()
{
g_pInternalVoiceStatus = NULL;
for(int i=0; i < MAX_VOICE_SPEAKERS; i++)
for (int i = 0; i < MAX_VOICE_SPEAKERS; i++)
{
delete m_Labels[i].m_pLabel;
m_Labels[i].m_pLabel = NULL;
delete m_Labels[i].m_pIcon;
m_Labels[i].m_pIcon = NULL;
delete m_Labels[i].m_pBackground;
m_Labels[i].m_pBackground = NULL;
}
}
delete m_pLocalLabel;
m_pLocalLabel = NULL;
FreeBitmaps();
if(m_pchGameDir)
if (m_pchGameDir)
{
if(m_bBanMgrInitialized)
if (m_bBanMgrInitialized)
{
m_BanMgr.SaveState(m_pchGameDir);
}
@ -179,8 +178,8 @@ CVoiceStatus::~CVoiceStatus()
int CVoiceStatus::Init(
IVoiceStatusHelper *pHelper,
Panel **pParentPanel)
IVoiceStatusHelper* pHelper,
Panel** pParentPanel)
{
// Setup the voice_modenable cvar.
gEngfuncs.pfnRegisterVariable("voice_modenable", "1", FCVAR_ARCHIVE);
@ -189,7 +188,7 @@ int CVoiceStatus::Init(
gEngfuncs.pfnAddCommand("voice_showbanned", ShowBannedCallback);
if(gEngfuncs.pfnGetGameDirectory())
if (gEngfuncs.pfnGetGameDirectory())
{
m_BanMgr.Init(gEngfuncs.pfnGetGameDirectory());
m_bBanMgrInitialized = true;
@ -201,26 +200,26 @@ int CVoiceStatus::Init(
m_BlinkTimer = 0;
m_VoiceHeadModel = 0;
memset(m_Labels, 0, sizeof(m_Labels));
for(int i=0; i < MAX_VOICE_SPEAKERS; i++)
for (int i = 0; i < MAX_VOICE_SPEAKERS; i++)
{
CVoiceLabel *pLabel = &m_Labels[i];
CVoiceLabel* pLabel = &m_Labels[i];
pLabel->m_pBackground = new Label("");
if(pLabel->m_pLabel = new Label(""))
if (pLabel->m_pLabel = new Label(""))
{
pLabel->m_pLabel->setVisible( true );
pLabel->m_pLabel->setFont( Scheme::sf_primary2 );
pLabel->m_pLabel->setTextAlignment( Label::a_east );
pLabel->m_pLabel->setContentAlignment( Label::a_east );
pLabel->m_pLabel->setParent( pLabel->m_pBackground );
pLabel->m_pLabel->setVisible(true);
pLabel->m_pLabel->setFont(Scheme::sf_primary2);
pLabel->m_pLabel->setTextAlignment(Label::a_east);
pLabel->m_pLabel->setContentAlignment(Label::a_east);
pLabel->m_pLabel->setParent(pLabel->m_pBackground);
}
if( pLabel->m_pIcon = new ImagePanel( NULL ) )
if (pLabel->m_pIcon = new ImagePanel(NULL))
{
pLabel->m_pIcon->setVisible( true );
pLabel->m_pIcon->setParent( pLabel->m_pBackground );
pLabel->m_pIcon->setVisible(true);
pLabel->m_pIcon->setParent(pLabel->m_pBackground);
}
pLabel->m_clientindex = -1;
@ -238,8 +237,8 @@ int CVoiceStatus::Init(
HOOK_MESSAGE(ReqState);
// Cache the game directory for use when we shut down
const char *pchGameDirT = gEngfuncs.pfnGetGameDirectory();
m_pchGameDir = (char *)malloc(strlen(pchGameDirT) + 1);
const char* pchGameDirT = gEngfuncs.pfnGetGameDirectory();
m_pchGameDir = (char*)malloc(strlen(pchGameDirT) + 1);
strcpy(m_pchGameDir, pchGameDirT);
return 1;
@ -251,49 +250,49 @@ bool CVoiceStatus::VidInit()
FreeBitmaps();
if( m_pLocalBitmap = vgui_LoadTGA("gfx/vgui/icntlk_pl.tga") )
if (m_pLocalBitmap = vgui_LoadTGA("gfx/vgui/icntlk_pl.tga"))
{
m_pLocalBitmap->setColor(Color(255,255,255,135));
m_pLocalBitmap->setColor(Color(255, 255, 255, 135));
}
if( m_pAckBitmap = vgui_LoadTGA("gfx/vgui/icntlk_sv.tga") )
if (m_pAckBitmap = vgui_LoadTGA("gfx/vgui/icntlk_sv.tga"))
{
m_pAckBitmap->setColor(Color(255,255,255,135)); // Give just a tiny bit of translucency so software draws correctly.
m_pAckBitmap->setColor(Color(255, 255, 255, 135)); // Give just a tiny bit of translucency so software draws correctly.
}
m_pLocalLabel->setImage( m_pLocalBitmap );
m_pLocalLabel->setVisible( false );
m_pLocalLabel->setImage(m_pLocalBitmap);
m_pLocalLabel->setVisible(false);
if( m_pSpeakerLabelIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/speaker4.tga" ) )
m_pSpeakerLabelIcon->setColor( Color(255,255,255,1) ); // Give just a tiny bit of translucency so software draws correctly.
if (m_pSpeakerLabelIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/speaker4.tga"))
m_pSpeakerLabelIcon->setColor(Color(255, 255, 255, 1)); // Give just a tiny bit of translucency so software draws correctly.
if (m_pScoreboardNeverSpoken = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker1.tga"))
m_pScoreboardNeverSpoken->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
m_pScoreboardNeverSpoken->setColor(Color(255, 255, 255, 1)); // Give just a tiny bit of translucency so software draws correctly.
if(m_pScoreboardNotSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker2.tga"))
m_pScoreboardNotSpeaking->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
if(m_pScoreboardSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker3.tga"))
m_pScoreboardSpeaking->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
if(m_pScoreboardSpeaking2 = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker4.tga"))
m_pScoreboardSpeaking2->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
if(m_pScoreboardSquelch = vgui_LoadTGA("gfx/vgui/icntlk_squelch.tga"))
m_pScoreboardSquelch->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
if (m_pScoreboardNotSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker2.tga"))
m_pScoreboardNotSpeaking->setColor(Color(255, 255, 255, 1)); // Give just a tiny bit of translucency so software draws correctly.
if(m_pScoreboardBanned = vgui_LoadTGA("gfx/vgui/640_voiceblocked.tga"))
m_pScoreboardBanned->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
if (m_pScoreboardSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker3.tga"))
m_pScoreboardSpeaking->setColor(Color(255, 255, 255, 1)); // Give just a tiny bit of translucency so software draws correctly.
if (m_pScoreboardSpeaking2 = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker4.tga"))
m_pScoreboardSpeaking2->setColor(Color(255, 255, 255, 1)); // Give just a tiny bit of translucency so software draws correctly.
if (m_pScoreboardSquelch = vgui_LoadTGA("gfx/vgui/icntlk_squelch.tga"))
m_pScoreboardSquelch->setColor(Color(255, 255, 255, 1)); // Give just a tiny bit of translucency so software draws correctly.
if (m_pScoreboardBanned = vgui_LoadTGA("gfx/vgui/640_voiceblocked.tga"))
m_pScoreboardBanned->setColor(Color(255, 255, 255, 1)); // Give just a tiny bit of translucency so software draws correctly.
// Figure out the voice head model height.
m_VoiceHeadModelHeight = 45;
char *pFile = (char *)gEngfuncs.COM_LoadFile("scripts/voicemodel.txt", 5, NULL);
if(pFile)
char* pFile = (char*)gEngfuncs.COM_LoadFile("scripts/voicemodel.txt", 5, NULL);
if (pFile)
{
char token[4096];
gEngfuncs.COM_ParseFile(pFile, token);
if(token[0] >= '0' && token[0] <= '9')
if (token[0] >= '0' && token[0] <= '9')
{
m_VoiceHeadModelHeight = (float)atof(token);
}
@ -309,7 +308,7 @@ bool CVoiceStatus::VidInit()
void CVoiceStatus::Frame(double frametime)
{
// check server banned players once per second
if(gEngfuncs.GetClientTime() - m_LastUpdateServerState > 1)
if (gEngfuncs.GetClientTime() - m_LastUpdateServerState > 1)
{
UpdateServerState(false);
}
@ -317,50 +316,50 @@ void CVoiceStatus::Frame(double frametime)
m_BlinkTimer += frametime;
// Update speaker labels.
if( m_pHelper->CanShowSpeakerLabels() )
if (m_pHelper->CanShowSpeakerLabels())
{
for( int i=0; i < MAX_VOICE_SPEAKERS; i++ )
m_Labels[i].m_pBackground->setVisible( m_Labels[i].m_clientindex != -1 );
for (int i = 0; i < MAX_VOICE_SPEAKERS; i++)
m_Labels[i].m_pBackground->setVisible(m_Labels[i].m_clientindex != -1);
}
else
{
for( int i=0; i < MAX_VOICE_SPEAKERS; i++ )
m_Labels[i].m_pBackground->setVisible( false );
for (int i = 0; i < MAX_VOICE_SPEAKERS; i++)
m_Labels[i].m_pBackground->setVisible(false);
}
for(int i=0; i < VOICE_MAX_PLAYERS; i++)
for (int i = 0; i < VOICE_MAX_PLAYERS; i++)
UpdateBanButton(i);
}
void CVoiceStatus::CreateEntities()
{
if(0 == m_VoiceHeadModel)
if (0 == m_VoiceHeadModel)
return;
cl_entity_t *localPlayer = gEngfuncs.GetLocalPlayer();
cl_entity_t* localPlayer = gEngfuncs.GetLocalPlayer();
int iOutModel = 0;
for(int i=0; i < VOICE_MAX_PLAYERS; i++)
for (int i = 0; i < VOICE_MAX_PLAYERS; i++)
{
if(!m_VoicePlayers[i])
if (!m_VoicePlayers[i])
continue;
cl_entity_s *pClient = gEngfuncs.GetEntityByIndex(i+1);
cl_entity_s* pClient = gEngfuncs.GetEntityByIndex(i + 1);
// Don't show an icon if the player is not in our PVS.
if(!pClient || pClient->curstate.messagenum < localPlayer->curstate.messagenum)
if (!pClient || pClient->curstate.messagenum < localPlayer->curstate.messagenum)
continue;
// Don't show an icon for dead or spectating players (ie: invisible entities).
if((pClient->curstate.effects & EF_NODRAW) != 0)
if ((pClient->curstate.effects & EF_NODRAW) != 0)
continue;
// Don't show an icon for the local player unless we're in thirdperson mode.
if(pClient == localPlayer && !cam_thirdperson)
if (pClient == localPlayer && !cam_thirdperson)
continue;
cl_entity_s *pEnt = &m_VoiceHeadModels[iOutModel];
cl_entity_s* pEnt = &m_VoiceHeadModels[iOutModel];
++iOutModel;
memset(pEnt, 0, sizeof(*pEnt));
@ -374,7 +373,7 @@ void CVoiceStatus::CreateEntities()
pEnt->model = (struct model_s*)gEngfuncs.GetSpritePointer(m_VoiceHeadModel);
pEnt->angles[0] = pEnt->angles[1] = pEnt->angles[2] = 0;
pEnt->curstate.scale = 0.5f;
pEnt->origin[0] = pEnt->origin[1] = 0;
pEnt->origin[2] = 45;
@ -386,92 +385,92 @@ void CVoiceStatus::CreateEntities()
}
void CVoiceStatus::UpdateSpeakerStatus( int entindex, bool bTalking )
void CVoiceStatus::UpdateSpeakerStatus(int entindex, bool bTalking)
{
cvar_t *pVoiceLoopback = NULL;
cvar_t* pVoiceLoopback = NULL;
if ( !m_pParentPanel || !*m_pParentPanel )
if (!m_pParentPanel || !*m_pParentPanel)
{
return;
}
if ( 0 != gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) )
if (0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
{
char msg[256];
snprintf( msg, sizeof( msg ), "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, static_cast<int>(bTalking) );
gEngfuncs.pfnConsolePrint( msg );
snprintf(msg, sizeof(msg), "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, static_cast<int>(bTalking));
gEngfuncs.pfnConsolePrint(msg);
}
int iLocalPlayerIndex = gEngfuncs.GetLocalPlayer()->index;
// Is it the local player talking?
if ( entindex == -1 )
if (entindex == -1)
{
m_bTalking = bTalking;
if( bTalking )
if (bTalking)
{
// Enable voice for them automatically if they try to talk.
gEngfuncs.pfnClientCmd( "voice_modenable 1" );
gEngfuncs.pfnClientCmd("voice_modenable 1");
}
// now set the player index to the correct index for the local player
// this will allow us to have the local player's icon flash in the scoreboard
entindex = iLocalPlayerIndex;
pVoiceLoopback = gEngfuncs.pfnGetCvarPointer( "voice_loopback" );
pVoiceLoopback = gEngfuncs.pfnGetCvarPointer("voice_loopback");
}
else if ( entindex == -2 )
else if (entindex == -2)
{
m_bServerAcked = bTalking;
}
if ( entindex >= 0 && entindex <= VOICE_MAX_PLAYERS )
if (entindex >= 0 && entindex <= VOICE_MAX_PLAYERS)
{
int iClient = entindex - 1;
if ( iClient < 0 )
if (iClient < 0)
{
return;
}
CVoiceLabel *pLabel = FindVoiceLabel( iClient );
if ( bTalking )
CVoiceLabel* pLabel = FindVoiceLabel(iClient);
if (bTalking)
{
m_VoicePlayers[iClient] = true;
m_VoiceEnabledPlayers[iClient] = true;
// If we don't have a label for this guy yet, then create one.
if ( !pLabel )
if (!pLabel)
{
// if this isn't the local player (unless they have voice_loopback on)
if ( ( entindex != iLocalPlayerIndex ) || ( pVoiceLoopback && 0 != pVoiceLoopback->value ) )
if ((entindex != iLocalPlayerIndex) || (pVoiceLoopback && 0 != pVoiceLoopback->value))
{
if ( pLabel = GetFreeVoiceLabel() )
if (pLabel = GetFreeVoiceLabel())
{
// Get the name from the engine.
hud_player_info_t info;
memset( &info, 0, sizeof( info ) );
gEngfuncs.pfnGetPlayerInfo( entindex, &info );
memset(&info, 0, sizeof(info));
gEngfuncs.pfnGetPlayerInfo(entindex, &info);
char paddedName[512];
snprintf( paddedName, sizeof( paddedName ), "%s ", info.name );
snprintf(paddedName, sizeof(paddedName), "%s ", info.name);
int color[3];
m_pHelper->GetPlayerTextColor( entindex, color );
m_pHelper->GetPlayerTextColor(entindex, color);
if ( pLabel->m_pBackground )
if (pLabel->m_pBackground)
{
pLabel->m_pBackground->setBgColor( color[0], color[1], color[2], 135 );
pLabel->m_pBackground->setParent( *m_pParentPanel );
pLabel->m_pBackground->setVisible( m_pHelper->CanShowSpeakerLabels() );
pLabel->m_pBackground->setBgColor(color[0], color[1], color[2], 135);
pLabel->m_pBackground->setParent(*m_pParentPanel);
pLabel->m_pBackground->setVisible(m_pHelper->CanShowSpeakerLabels());
}
if ( pLabel->m_pLabel )
if (pLabel->m_pLabel)
{
pLabel->m_pLabel->setFgColor( 255, 255, 255, 0 );
pLabel->m_pLabel->setBgColor( 0, 0, 0, 255 );
pLabel->m_pLabel->setText( "%s", paddedName );
pLabel->m_pLabel->setFgColor(255, 255, 255, 0);
pLabel->m_pLabel->setBgColor(0, 0, 0, 255);
pLabel->m_pLabel->setText("%s", paddedName);
}
pLabel->m_clientindex = iClient;
}
}
@ -482,9 +481,9 @@ void CVoiceStatus::UpdateSpeakerStatus( int entindex, bool bTalking )
m_VoicePlayers[iClient] = false;
// If we have a label for this guy, kill it.
if ( pLabel )
if (pLabel)
{
pLabel->m_pBackground->setVisible( false );
pLabel->m_pBackground->setVisible(false);
pLabel->m_clientindex = -1;
}
}
@ -497,19 +496,19 @@ void CVoiceStatus::UpdateSpeakerStatus( int entindex, bool bTalking )
void CVoiceStatus::UpdateServerState(bool bForce)
{
// Can't do anything when we're not in a level.
char const *pLevelName = gEngfuncs.pfnGetLevelName();
if( pLevelName[0] == 0 )
char const* pLevelName = gEngfuncs.pfnGetLevelName();
if (pLevelName[0] == 0)
{
if( 0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug") )
if (0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
{
gEngfuncs.pfnConsolePrint( "CVoiceStatus::UpdateServerState: pLevelName[0]==0\n" );
gEngfuncs.pfnConsolePrint("CVoiceStatus::UpdateServerState: pLevelName[0]==0\n");
}
return;
}
int bCVarModEnable = static_cast<int>(0 != gEngfuncs.pfnGetCvarFloat("voice_modenable"));
if(bForce || m_bServerModEnable != bCVarModEnable)
if (bForce || m_bServerModEnable != bCVarModEnable)
{
m_bServerModEnable = bCVarModEnable;
@ -517,7 +516,7 @@ void CVoiceStatus::UpdateServerState(bool bForce)
snprintf(str, sizeof(str), "VModEnable %d", m_bServerModEnable);
ServerCmd(str);
if(0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
if (0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
{
char msg[256];
sprintf(msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str);
@ -529,24 +528,24 @@ void CVoiceStatus::UpdateServerState(bool bForce)
sprintf(str, "vban");
bool bChange = false;
for(unsigned long dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++)
{
for (unsigned long dw = 0; dw < VOICE_MAX_PLAYERS_DW; dw++)
{
unsigned long serverBanMask = 0;
unsigned long banMask = 0;
for(unsigned long i=0; i < 32; i++)
for (unsigned long i = 0; i < 32; i++)
{
char playerID[16];
if(0 == gEngfuncs.GetPlayerUniqueID(i+1, playerID))
if (0 == gEngfuncs.GetPlayerUniqueID(i + 1, playerID))
continue;
if(m_BanMgr.GetPlayerBan(playerID))
if (m_BanMgr.GetPlayerBan(playerID))
banMask |= 1 << i;
if(m_ServerBannedPlayers[dw*32 + i])
if (m_ServerBannedPlayers[dw * 32 + i])
serverBanMask |= 1 << i;
}
if(serverBanMask != banMask)
if (serverBanMask != banMask)
bChange = true;
// Ok, the server needs to be updated.
@ -555,50 +554,50 @@ void CVoiceStatus::UpdateServerState(bool bForce)
strcat(str, numStr);
}
if(bChange || bForce)
if (bChange || bForce)
{
if(0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
if (0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
{
char msg[256];
sprintf(msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str);
gEngfuncs.pfnConsolePrint(msg);
}
gEngfuncs.pfnServerCmdUnreliable(str); // Tell the server..
gEngfuncs.pfnServerCmdUnreliable(str); // Tell the server..
}
else
{
if (0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
{
gEngfuncs.pfnConsolePrint( "CVoiceStatus::UpdateServerState: no change\n" );
gEngfuncs.pfnConsolePrint("CVoiceStatus::UpdateServerState: no change\n");
}
}
m_LastUpdateServerState = gEngfuncs.GetClientTime();
}
void CVoiceStatus::UpdateSpeakerImage(Label *pLabel, int iPlayer)
void CVoiceStatus::UpdateSpeakerImage(Label* pLabel, int iPlayer)
{
m_pBanButtons[iPlayer-1] = pLabel;
UpdateBanButton(iPlayer-1);
m_pBanButtons[iPlayer - 1] = pLabel;
UpdateBanButton(iPlayer - 1);
}
void CVoiceStatus::UpdateBanButton(int iClient)
{
Label *pPanel = m_pBanButtons[iClient];
Label* pPanel = m_pBanButtons[iClient];
if (!pPanel)
return;
char playerID[16];
extern bool HACK_GetPlayerUniqueID( int iPlayer, char playerID[16] );
if(!HACK_GetPlayerUniqueID(iClient+1, playerID))
extern bool HACK_GetPlayerUniqueID(int iPlayer, char playerID[16]);
if (!HACK_GetPlayerUniqueID(iClient + 1, playerID))
return;
// Figure out if it's blinking or not.
bool bBlink = fmod(m_BlinkTimer, SCOREBOARD_BLINK_FREQUENCY*2) < SCOREBOARD_BLINK_FREQUENCY;
bool bBlink = fmod(m_BlinkTimer, SCOREBOARD_BLINK_FREQUENCY * 2) < SCOREBOARD_BLINK_FREQUENCY;
bool bTalking = !!m_VoicePlayers[iClient];
bool bBanned = m_BanMgr.GetPlayerBan(playerID);
bool bBanned = m_BanMgr.GetPlayerBan(playerID);
bool bNeverSpoken = !m_VoiceEnabledPlayers[iClient];
// Get the appropriate image to display on the panel.
@ -630,24 +629,24 @@ void CVoiceStatus::UpdateBanButton(int iClient)
}
void CVoiceStatus::HandleVoiceMaskMsg(int iSize, void *pbuf)
void CVoiceStatus::HandleVoiceMaskMsg(int iSize, void* pbuf)
{
BEGIN_READ( pbuf, iSize );
BEGIN_READ(pbuf, iSize);
unsigned long dw;
for(dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++)
for (dw = 0; dw < VOICE_MAX_PLAYERS_DW; dw++)
{
m_AudiblePlayers.SetDWord(dw, (unsigned long)READ_LONG());
m_ServerBannedPlayers.SetDWord(dw, (unsigned long)READ_LONG());
if(0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
if (0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
{
char str[256];
gEngfuncs.pfnConsolePrint("CVoiceStatus::HandleVoiceMaskMsg\n");
sprintf(str, " - m_AudiblePlayers[%lu] = %u\n", dw, m_AudiblePlayers.GetDWord(dw));
gEngfuncs.pfnConsolePrint(str);
sprintf(str, " - m_ServerBannedPlayers[%lu] = %u\n", dw, m_ServerBannedPlayers.GetDWord(dw));
gEngfuncs.pfnConsolePrint(str);
}
@ -656,19 +655,19 @@ void CVoiceStatus::HandleVoiceMaskMsg(int iSize, void *pbuf)
m_bServerModEnable = READ_BYTE();
}
void CVoiceStatus::HandleReqStateMsg(int iSize, void *pbuf)
void CVoiceStatus::HandleReqStateMsg(int iSize, void* pbuf)
{
if(0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
if (0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
{
gEngfuncs.pfnConsolePrint("CVoiceStatus::HandleReqStateMsg\n");
}
UpdateServerState(true);
UpdateServerState(true);
}
void CVoiceStatus::StartSquelchMode()
{
if(m_bInSquelchMode)
if (m_bInSquelchMode)
return;
m_bInSquelchMode = true;
@ -688,9 +687,9 @@ bool CVoiceStatus::IsInSquelchMode()
CVoiceLabel* CVoiceStatus::FindVoiceLabel(int clientindex)
{
for(int i=0; i < MAX_VOICE_SPEAKERS; i++)
for (int i = 0; i < MAX_VOICE_SPEAKERS; i++)
{
if(m_Labels[i].m_clientindex == clientindex)
if (m_Labels[i].m_clientindex == clientindex)
return &m_Labels[i];
}
@ -708,75 +707,75 @@ void CVoiceStatus::RepositionLabels()
{
// find starting position to draw from, along right-hand side of screen
int y = ScreenHeight / 2;
int iconWide = 8, iconTall = 8;
if( m_pSpeakerLabelIcon )
{
m_pSpeakerLabelIcon->getSize( iconWide, iconTall );
}
// Reposition active labels.
for(int i = 0; i < MAX_VOICE_SPEAKERS; i++)
{
CVoiceLabel *pLabel = &m_Labels[i];
if( pLabel->m_clientindex == -1 || !pLabel->m_pLabel )
int iconWide = 8, iconTall = 8;
if (m_pSpeakerLabelIcon)
{
m_pSpeakerLabelIcon->getSize(iconWide, iconTall);
}
// Reposition active labels.
for (int i = 0; i < MAX_VOICE_SPEAKERS; i++)
{
CVoiceLabel* pLabel = &m_Labels[i];
if (pLabel->m_clientindex == -1 || !pLabel->m_pLabel)
{
if( pLabel->m_pBackground )
pLabel->m_pBackground->setVisible( false );
if (pLabel->m_pBackground)
pLabel->m_pBackground->setVisible(false);
continue;
}
int textWide, textTall;
pLabel->m_pLabel->getContentSize( textWide, textTall );
pLabel->m_pLabel->getContentSize(textWide, textTall);
// Don't let it stretch too far across their screen.
if( textWide > (ScreenWidth*2)/3 )
textWide = (ScreenWidth*2)/3;
if (textWide > (ScreenWidth * 2) / 3)
textWide = (ScreenWidth * 2) / 3;
// Setup the background label to fit everything in.
int border = 2;
int bgWide = textWide + iconWide + border*3;
int bgTall = V_max( textTall, iconTall ) + border*2;
pLabel->m_pBackground->setBounds( ScreenWidth - bgWide - 8, y, bgWide, bgTall );
int bgWide = textWide + iconWide + border * 3;
int bgTall = V_max(textTall, iconTall) + border * 2;
pLabel->m_pBackground->setBounds(ScreenWidth - bgWide - 8, y, bgWide, bgTall);
// Put the text at the left.
pLabel->m_pLabel->setBounds( border, (bgTall - textTall) / 2, textWide, textTall );
pLabel->m_pLabel->setBounds(border, (bgTall - textTall) / 2, textWide, textTall);
// Put the icon at the right.
int iconLeft = border + textWide + border;
int iconTop = (bgTall - iconTall) / 2;
if( pLabel->m_pIcon )
if (pLabel->m_pIcon)
{
pLabel->m_pIcon->setImage( m_pSpeakerLabelIcon );
pLabel->m_pIcon->setBounds( iconLeft, iconTop, iconWide, iconTall );
pLabel->m_pIcon->setImage(m_pSpeakerLabelIcon);
pLabel->m_pIcon->setBounds(iconLeft, iconTop, iconWide, iconTall);
}
y += bgTall + 2;
}
if( m_pLocalBitmap && m_pAckBitmap && m_pLocalLabel && (m_bTalking || m_bServerAcked) )
if (m_pLocalBitmap && m_pAckBitmap && m_pLocalLabel && (m_bTalking || m_bServerAcked))
{
m_pLocalLabel->setParent(*m_pParentPanel);
m_pLocalLabel->setVisible( true );
m_pLocalLabel->setVisible(true);
if( m_bServerAcked && 0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug") )
m_pLocalLabel->setImage( m_pAckBitmap );
if (m_bServerAcked && 0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
m_pLocalLabel->setImage(m_pAckBitmap);
else
m_pLocalLabel->setImage( m_pLocalBitmap );
m_pLocalLabel->setImage(m_pLocalBitmap);
int sizeX, sizeY;
m_pLocalBitmap->getSize(sizeX, sizeY);
int local_xPos = ScreenWidth - sizeX - 10;
int local_yPos = m_pHelper->GetAckIconHeight() - sizeY;
m_pLocalLabel->setPos( local_xPos, local_yPos );
m_pLocalLabel->setPos(local_xPos, local_yPos);
}
else
{
m_pLocalLabel->setVisible( false );
m_pLocalLabel->setVisible(false);
}
}
@ -812,7 +811,7 @@ void CVoiceStatus::FreeBitmaps()
m_pScoreboardBanned = NULL;
// Clear references to the images in panels.
for(int i=0; i < VOICE_MAX_PLAYERS; i++)
for (int i = 0; i < VOICE_MAX_PLAYERS; i++)
{
if (m_pBanButtons[i])
{
@ -820,13 +819,13 @@ void CVoiceStatus::FreeBitmaps()
}
}
if(m_pLocalLabel)
if (m_pLocalLabel)
m_pLocalLabel->setImage(NULL);
}
//-----------------------------------------------------------------------------
// Purpose: returns true if the target client has been banned
// Input : playerID -
// Input : playerID -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CVoiceStatus::IsPlayerBlocked(int iPlayer)
@ -840,24 +839,24 @@ bool CVoiceStatus::IsPlayerBlocked(int iPlayer)
//-----------------------------------------------------------------------------
// Purpose: returns true if the player can't hear the other client due to game rules (eg. the other team)
// Input : playerID -
// Input : playerID -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CVoiceStatus::IsPlayerAudible(int iPlayer)
{
return !!m_AudiblePlayers[iPlayer-1];
return !!m_AudiblePlayers[iPlayer - 1];
}
//-----------------------------------------------------------------------------
// Purpose: blocks/unblocks the target client from being heard
// Input : playerID -
// Input : playerID -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
void CVoiceStatus::SetPlayerBlockedState(int iPlayer, bool blocked)
{
if (0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
{
gEngfuncs.pfnConsolePrint( "CVoiceStatus::SetPlayerBlockedState part 1\n" );
gEngfuncs.pfnConsolePrint("CVoiceStatus::SetPlayerBlockedState part 1\n");
}
char playerID[16];
@ -866,7 +865,7 @@ void CVoiceStatus::SetPlayerBlockedState(int iPlayer, bool blocked)
if (0 != gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
{
gEngfuncs.pfnConsolePrint( "CVoiceStatus::SetPlayerBlockedState part 2\n" );
gEngfuncs.pfnConsolePrint("CVoiceStatus::SetPlayerBlockedState part 2\n");
}
// Squelch or (try to) unsquelch this player.
@ -877,6 +876,6 @@ void CVoiceStatus::SetPlayerBlockedState(int iPlayer, bool blocked)
gEngfuncs.pfnConsolePrint(str);
}
m_BanMgr.SetPlayerBan( playerID, blocked );
m_BanMgr.SetPlayerBan(playerID, blocked);
UpdateServerState(false);
}

View file

@ -27,13 +27,13 @@
#endif
// Silence certain warnings
#pragma warning(disable : 4244) // int or float down-conversion
#pragma warning(disable : 4305) // int or float data truncation
#pragma warning(disable : 4201) // nameless struct/union
#pragma warning(disable : 4514) // unreferenced inline function removed
#pragma warning(disable : 4100) // unreferenced formal parameter
#pragma warning(disable : 4244) // int or float down-conversion
#pragma warning(disable : 4305) // int or float data truncation
#pragma warning(disable : 4201) // nameless struct/union
#pragma warning(disable : 4514) // unreferenced inline function removed
#pragma warning(disable : 4100) // unreferenced formal parameter
#include "steam/steamtypes.h" // DAL
#include "steam/steamtypes.h" // DAL
#include "common_types.h"
// Misc C-runtime library headers
@ -53,7 +53,7 @@ using func_t = unsigned int;
using string_t = unsigned int;
using qboolean = int;
#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0]))
#define ARRAYSIZE(p) (sizeof(p) / sizeof(p[0]))
// Prevent tons of unused windows definitions
#ifdef WIN32
@ -114,7 +114,7 @@ using qboolean = int;
#define itoa _itoa
#define strupr _strupr
#define DLLEXPORT __declspec( dllexport )
#define DLLEXPORT __declspec(dllexport)
#define DLLHIDDEN
#else // WIN32
#define MAX_PATH PATH_MAX
@ -123,11 +123,11 @@ using qboolean = int;
#define strnicmp strncasecmp
#define _alloca alloca
#define DLLEXPORT __attribute__ ( ( visibility( "default" ) ) )
#define DLLHIDDEN __attribute__ ( ( visibility( "hidden" ) ) )
#define DLLEXPORT __attribute__((visibility("default")))
#define DLLHIDDEN __attribute__((visibility("hidden")))
#endif //WIN32
#define V_min(a,b) (((a) < (b)) ? (a) : (b))
#define V_max(a,b) (((a) > (b)) ? (a) : (b))
#define V_min(a, b) (((a) < (b)) ? (a) : (b))
#define V_max(a, b) (((a) > (b)) ? (a) : (b))
#define clamp( val, min, max ) ( ((val) > (max)) ? (max) : ( ((val) < (min)) ? (min) : (val) ) )
#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))

View file

@ -1,7 +1,7 @@
//---------------------------------------------------------------------------
//
//
// S c r i p t e d S e q u e n c e s
//
//
//---------------------------------------------------------------------------
#pragma once
@ -16,46 +16,46 @@ typedef unsigned char byte;
//---------------------------------------------------------------------------
typedef struct client_textmessage_s
{
int effect;
byte r1, g1, b1, a1; // 2 colors for effects
byte r2, g2, b2, a2;
float x;
float y;
float fadein;
float fadeout;
float holdtime;
float fxtime;
const char *pName;
const char *pMessage;
int effect;
byte r1, g1, b1, a1; // 2 colors for effects
byte r2, g2, b2, a2;
float x;
float y;
float fadein;
float fadeout;
float holdtime;
float fxtime;
const char* pName;
const char* pMessage;
} client_textmessage_t;
//--------------------------------------------------------------------------
// sequenceDefaultBits_e
//
//
// Enumerated list of possible modifiers for a command. This enumeration
// is used in a bitarray controlling what modifiers are specified for a command.
//---------------------------------------------------------------------------
enum sequenceModifierBits
{
SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1),
SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2),
SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3),
SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4),
SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5),
SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6),
SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7),
SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8),
SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9),
SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10),
SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11),
SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1),
SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2),
SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3),
SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4),
SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5),
SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6),
SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7),
SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8),
SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9),
SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10),
SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11),
};
typedef enum sequenceModifierBits sequenceModifierBits_e ;
typedef enum sequenceModifierBits sequenceModifierBits_e;
//---------------------------------------------------------------------------
// sequenceCommandEnum_e
//
//
// Enumerated sequence command types.
//---------------------------------------------------------------------------
enum sequenceCommandEnum_
@ -91,7 +91,7 @@ typedef enum sequenceCommandEnum_ sequenceCommandEnum_e;
//---------------------------------------------------------------------------
// sequenceCommandType_e
//
//
// Typeerated sequence command types.
//---------------------------------------------------------------------------
enum sequenceCommandType_
@ -104,57 +104,57 @@ typedef enum sequenceCommandType_ sequenceCommandType_e;
//---------------------------------------------------------------------------
// sequenceCommandMapping_s
//
//
// A mapping of a command enumerated-value to its name.
//---------------------------------------------------------------------------
typedef struct sequenceCommandMapping_ sequenceCommandMapping_s;
struct sequenceCommandMapping_
{
sequenceCommandEnum_e commandEnum;
const char* commandName;
sequenceCommandType_e commandType;
sequenceCommandEnum_e commandEnum;
const char* commandName;
sequenceCommandType_e commandType;
};
//---------------------------------------------------------------------------
// sequenceCommandLine_s
//
//
// Structure representing a single command (usually 1 line) from a
// .SEQ file entry.
//---------------------------------------------------------------------------
typedef struct sequenceCommandLine_ sequenceCommandLine_s;
struct sequenceCommandLine_
{
int commandType; // Specifies the type of command
client_textmessage_t clientMessage; // Text HUD message struct
char* speakerName; // Targetname of speaking entity
char* listenerName; // Targetname of entity being spoken to
char* soundFileName; // Name of sound file to play
char* sentenceName; // Name of sentences.txt to play
char* fireTargetNames; // List of targetnames to fire
char* killTargetNames; // List of targetnames to remove
float delay; // Seconds 'till next command
int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite)
int textChannel; // Display channel on which text message is sent
int modifierBitField; // Bit field to specify what clientmessage fields are valid
sequenceCommandLine_s* nextCommandLine; // Next command (linked list)
int commandType; // Specifies the type of command
client_textmessage_t clientMessage; // Text HUD message struct
char* speakerName; // Targetname of speaking entity
char* listenerName; // Targetname of entity being spoken to
char* soundFileName; // Name of sound file to play
char* sentenceName; // Name of sentences.txt to play
char* fireTargetNames; // List of targetnames to fire
char* killTargetNames; // List of targetnames to remove
float delay; // Seconds 'till next command
int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite)
int textChannel; // Display channel on which text message is sent
int modifierBitField; // Bit field to specify what clientmessage fields are valid
sequenceCommandLine_s* nextCommandLine; // Next command (linked list)
};
//---------------------------------------------------------------------------
// sequenceEntry_s
//
//
// Structure representing a single command (usually 1 line) from a
// .SEQ file entry.
//---------------------------------------------------------------------------
typedef struct sequenceEntry_ sequenceEntry_s;
struct sequenceEntry_
{
char* fileName; // Name of sequence file without .SEQ extension
char* entryName; // Name of entry label in file
sequenceCommandLine_s* firstCommand; // Linked list of commands in entry
sequenceEntry_s* nextEntry; // Next loaded entry
qboolean isGlobal; // Is entry retained over level transitions?
char* fileName; // Name of sequence file without .SEQ extension
char* entryName; // Name of entry label in file
sequenceCommandLine_s* firstCommand; // Linked list of commands in entry
sequenceEntry_s* nextEntry; // Next loaded entry
qboolean isGlobal; // Is entry retained over level transitions?
};
@ -168,10 +168,10 @@ struct sequenceEntry_
typedef struct sentenceEntry_ sentenceEntry_s;
struct sentenceEntry_
{
char* data; // sentence data (ie "We have hostiles" )
sentenceEntry_s* nextEntry; // Next loaded entry
qboolean isGlobal; // Is entry retained over level transitions?
unsigned int index; // this entry's position in the file.
char* data; // sentence data (ie "We have hostiles" )
sentenceEntry_s* nextEntry; // Next loaded entry
qboolean isGlobal; // Is entry retained over level transitions?
unsigned int index; // this entry's position in the file.
};
//--------------------------------------------------------------------------
@ -184,16 +184,16 @@ struct sentenceEntry_
typedef struct sentenceGroupEntry_ sentenceGroupEntry_s;
struct sentenceGroupEntry_
{
char* groupName; // name of the group (ie CT_ALERT )
unsigned int numSentences; // number of sentences in group
sentenceEntry_s* firstSentence; // head of linked list of sentences in group
sentenceGroupEntry_s* nextEntry; // next loaded group
char* groupName; // name of the group (ie CT_ALERT )
unsigned int numSentences; // number of sentences in group
sentenceEntry_s* firstSentence; // head of linked list of sentences in group
sentenceGroupEntry_s* nextEntry; // next loaded group
};
//---------------------------------------------------------------------------
// Function declarations
//---------------------------------------------------------------------------
sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName );
void Sequence_ParseFile( const char* fileName, qboolean isGlobal );
void Sequence_OnLevelLoad( const char* mapName );
sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked );
sequenceEntry_s* SequenceGet(const char* fileName, const char* entryName);
void Sequence_ParseFile(const char* fileName, qboolean isGlobal);
void Sequence_OnLevelLoad(const char* mapName);
sentenceEntry_s* SequencePickSentence(const char* groupName, int pickMethod, int* picked);

View file

@ -15,43 +15,43 @@
#pragma once
#define FBEAM_STARTENTITY 0x00000001
#define FBEAM_ENDENTITY 0x00000002
#define FBEAM_FADEIN 0x00000004
#define FBEAM_FADEOUT 0x00000008
#define FBEAM_SINENOISE 0x00000010
#define FBEAM_SOLID 0x00000020
#define FBEAM_SHADEIN 0x00000040
#define FBEAM_SHADEOUT 0x00000080
#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet?
#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet?
#define FBEAM_ISACTIVE 0x40000000
#define FBEAM_FOREVER 0x80000000
#define FBEAM_STARTENTITY 0x00000001
#define FBEAM_ENDENTITY 0x00000002
#define FBEAM_FADEIN 0x00000004
#define FBEAM_FADEOUT 0x00000008
#define FBEAM_SINENOISE 0x00000010
#define FBEAM_SOLID 0x00000020
#define FBEAM_SHADEIN 0x00000040
#define FBEAM_SHADEOUT 0x00000080
#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet?
#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet?
#define FBEAM_ISACTIVE 0x40000000
#define FBEAM_FOREVER 0x80000000
typedef struct beam_s BEAM;
struct beam_s
{
BEAM *next;
int type;
int flags;
Vector source;
Vector target;
Vector delta;
float t; // 0 .. 1 over lifetime of beam
float freq;
float die;
float width;
float amplitude;
float r, g, b;
float brightness;
float speed;
float frameRate;
float frame;
int segments;
int startEntity;
int endEntity;
int modelIndex;
int frameCount;
struct model_s *pFollowModel;
struct particle_s *particles;
BEAM* next;
int type;
int flags;
Vector source;
Vector target;
Vector delta;
float t; // 0 .. 1 over lifetime of beam
float freq;
float die;
float width;
float amplitude;
float r, g, b;
float brightness;
float speed;
float frameRate;
float frame;
int segments;
int startEntity;
int endEntity;
int modelIndex;
int frameCount;
struct model_s* pFollowModel;
struct particle_s* particles;
};

View file

@ -18,87 +18,87 @@
typedef struct efrag_s
{
struct mleaf_s *leaf;
struct efrag_s *leafnext;
struct cl_entity_s *entity;
struct efrag_s *entnext;
struct mleaf_s* leaf;
struct efrag_s* leafnext;
struct cl_entity_s* entity;
struct efrag_s* entnext;
} efrag_t;
typedef struct
{
byte mouthopen; // 0 = mouth closed, 255 = mouth agape
byte sndcount; // counter for running average
int sndavg; // running average
byte mouthopen; // 0 = mouth closed, 255 = mouth agape
byte sndcount; // counter for running average
int sndavg; // running average
} mouth_t;
typedef struct
{
float prevanimtime;
float sequencetime;
byte prevseqblending[2];
Vector prevorigin;
Vector prevangles;
float prevanimtime;
float sequencetime;
byte prevseqblending[2];
Vector prevorigin;
Vector prevangles;
int prevsequence;
float prevframe;
int prevsequence;
float prevframe;
byte prevcontroller[4];
byte prevblending[2];
byte prevcontroller[4];
byte prevblending[2];
} latchedvars_t;
typedef struct
{
// Time stamp for this movement
float animtime;
float animtime;
Vector origin;
Vector angles;
Vector origin;
Vector angles;
} position_history_t;
typedef struct cl_entity_s cl_entity_t;
#define HISTORY_MAX 64 // Must be power of 2
#define HISTORY_MASK ( HISTORY_MAX - 1 )
#define HISTORY_MAX 64 // Must be power of 2
#define HISTORY_MASK (HISTORY_MAX - 1)
#include "entity_state.h"
#include "progs.h"
struct cl_entity_s
{
int index; // Index into cl_entities ( should match actual slot, but not necessarily )
int index; // Index into cl_entities ( should match actual slot, but not necessarily )
qboolean player; // True if this entity is a "player"
entity_state_t baseline; // The original state from which to delta during an uncompressed message
entity_state_t prevstate; // The state information from the penultimate message received from the server
entity_state_t curstate; // The state information from the last message received from server
qboolean player; // True if this entity is a "player"
int current_position; // Last received history update index
position_history_t ph[ HISTORY_MAX ]; // History of position and angle updates for this player
entity_state_t baseline; // The original state from which to delta during an uncompressed message
entity_state_t prevstate; // The state information from the penultimate message received from the server
entity_state_t curstate; // The state information from the last message received from server
mouth_t mouth; // For synchronizing mouth movements.
int current_position; // Last received history update index
position_history_t ph[HISTORY_MAX]; // History of position and angle updates for this player
latchedvars_t latched; // Variables used by studio model rendering routines
mouth_t mouth; // For synchronizing mouth movements.
latchedvars_t latched; // Variables used by studio model rendering routines
// Information based on interplocation, extrapolation, prediction, or just copied from last msg received.
//
float lastmove;
float lastmove;
// Actual render position and angles
Vector origin;
Vector angles;
Vector origin;
Vector angles;
// Attachment points
Vector attachment[4];
Vector attachment[4];
// Other entity local information
int trivial_accept;
int trivial_accept;
struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model
struct efrag_s *efrag; // linked list of efrags
struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split
struct model_s* model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model
struct efrag_s* efrag; // linked list of efrags
struct mnode_s* topnode; // for bmodels, first world node that splits bmodel, or NULL if not split
float syncbase; // for client-side animations -- used by obsolete alias animation system, remove?
int visframe; // last frame this entity was found in an active leaf
colorVec cvFloorColor;
float syncbase; // for client-side animations -- used by obsolete alias animation system, remove?
int visframe; // last frame this entity was found in an active leaf
colorVec cvFloorColor;
};

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -12,36 +12,36 @@
#define STUDIO_RENDER 1
#define STUDIO_EVENTS 2
#define MAX_CLIENTS 32
#define MAX_EDICTS 900
#define MAX_CLIENTS 32
#define MAX_EDICTS 900
#define MAX_MODEL_NAME 64
#define MAX_MAP_HULLS 4
#define MIPLEVELS 4
#define NUM_AMBIENTS 4 // automatic ambient sounds
#define MAXLIGHTMAPS 4
#define PLANE_ANYZ 5
#define MAX_MODEL_NAME 64
#define MAX_MAP_HULLS 4
#define MIPLEVELS 4
#define NUM_AMBIENTS 4 // automatic ambient sounds
#define MAXLIGHTMAPS 4
#define PLANE_ANYZ 5
#define ALIAS_Z_CLIP_PLANE 5
#define ALIAS_Z_CLIP_PLANE 5
// flags in finalvert_t.flags
#define ALIAS_LEFT_CLIP 0x0001
#define ALIAS_TOP_CLIP 0x0002
#define ALIAS_RIGHT_CLIP 0x0004
#define ALIAS_BOTTOM_CLIP 0x0008
#define ALIAS_Z_CLIP 0x0010
#define ALIAS_ONSEAM 0x0020
#define ALIAS_XY_CLIP_MASK 0x000F
#define ALIAS_LEFT_CLIP 0x0001
#define ALIAS_TOP_CLIP 0x0002
#define ALIAS_RIGHT_CLIP 0x0004
#define ALIAS_BOTTOM_CLIP 0x0008
#define ALIAS_Z_CLIP 0x0010
#define ALIAS_ONSEAM 0x0020
#define ALIAS_XY_CLIP_MASK 0x000F
#define ZISCALE ((float)0x8000)
#define ZISCALE ((float)0x8000)
#define CACHE_SIZE 32 // used to align key data structures
#define CACHE_SIZE 32 // used to align key data structures
typedef enum
{
mod_brush,
mod_sprite,
mod_alias,
mod_brush,
mod_sprite,
mod_alias,
mod_studio
} modtype_t;
@ -51,7 +51,7 @@ typedef enum
typedef enum
{
ST_SYNC=0,
ST_SYNC = 0,
ST_RAND
} synctype_t;
@ -59,236 +59,236 @@ typedef enum
typedef struct
{
float mins[3], maxs[3];
float origin[3];
int headnode[MAX_MAP_HULLS];
int visleafs; // not including the solid leaf 0
int firstface, numfaces;
float mins[3], maxs[3];
float origin[3];
int headnode[MAX_MAP_HULLS];
int visleafs; // not including the solid leaf 0
int firstface, numfaces;
} dmodel_t;
// plane_t structure
typedef struct mplane_s
{
Vector normal; // surface normal
float dist; // closest appoach to origin
byte type; // for texture axis selection and fast side tests
byte signbits; // signx + signy<<1 + signz<<1
byte pad[2];
Vector normal; // surface normal
float dist; // closest appoach to origin
byte type; // for texture axis selection and fast side tests
byte signbits; // signx + signy<<1 + signz<<1
byte pad[2];
} mplane_t;
typedef struct
{
Vector position;
Vector position;
} mvertex_t;
typedef struct
{
unsigned short v[2];
unsigned int cachededgeoffset;
unsigned short v[2];
unsigned int cachededgeoffset;
} medge_t;
typedef struct texture_s
{
char name[16];
unsigned width, height;
int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence
struct texture_s *alternate_anims; // bmodels in frame 1 use these
unsigned offsets[MIPLEVELS]; // four mip maps stored
unsigned paloffset;
char name[16];
unsigned width, height;
int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s* anim_next; // in the animation sequence
struct texture_s* alternate_anims; // bmodels in frame 1 use these
unsigned offsets[MIPLEVELS]; // four mip maps stored
unsigned paloffset;
} texture_t;
typedef struct
{
float vecs[2][4]; // [s/t] unit vectors in world space.
// [i][3] is the s/t offset relative to the origin.
// s or t = dot(3Dpoint,vecs[i])+vecs[i][3]
float mipadjust; // ?? mipmap limits for very small surfaces
texture_t *texture;
int flags; // sky or slime, no lightmap or 256 subdivision
float vecs[2][4]; // [s/t] unit vectors in world space.
// [i][3] is the s/t offset relative to the origin.
// s or t = dot(3Dpoint,vecs[i])+vecs[i][3]
float mipadjust; // ?? mipmap limits for very small surfaces
texture_t* texture;
int flags; // sky or slime, no lightmap or 256 subdivision
} mtexinfo_t;
typedef struct mnode_s
{
// common with leaf
int contents; // 0, to differentiate from leafs
int visframe; // node needs to be traversed if current
short minmaxs[6]; // for bounding box culling
// common with leaf
int contents; // 0, to differentiate from leafs
int visframe; // node needs to be traversed if current
struct mnode_s *parent;
short minmaxs[6]; // for bounding box culling
// node specific
mplane_t *plane;
struct mnode_s *children[2];
struct mnode_s* parent;
unsigned short firstsurface;
unsigned short numsurfaces;
// node specific
mplane_t* plane;
struct mnode_s* children[2];
unsigned short firstsurface;
unsigned short numsurfaces;
} mnode_t;
typedef struct msurface_s msurface_t;
typedef struct decal_s decal_t;
typedef struct msurface_s msurface_t;
typedef struct decal_s decal_t;
// JAY: Compress this as much as possible
struct decal_s
{
decal_t *pnext; // linked list for each surface
msurface_t *psurface; // Surface id for persistence / unlinking
short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats)
short dy;
short texture; // Decal texture
byte scale; // Pixel scale
byte flags; // Decal flags
decal_t* pnext; // linked list for each surface
msurface_t* psurface; // Surface id for persistence / unlinking
short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats)
short dy;
short texture; // Decal texture
byte scale; // Pixel scale
byte flags; // Decal flags
short entityIndex; // Entity this is attached to
short entityIndex; // Entity this is attached to
};
typedef struct mleaf_s
{
// common with node
int contents; // wil be a negative contents number
int visframe; // node needs to be traversed if current
// common with node
int contents; // wil be a negative contents number
int visframe; // node needs to be traversed if current
short minmaxs[6]; // for bounding box culling
short minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
struct mnode_s* parent;
// leaf specific
byte *compressed_vis;
struct efrag_s *efrags;
// leaf specific
byte* compressed_vis;
struct efrag_s* efrags;
msurface_t **firstmarksurface;
int nummarksurfaces;
int key; // BSP sequence number for leaf's contents
byte ambient_sound_level[NUM_AMBIENTS];
msurface_t** firstmarksurface;
int nummarksurfaces;
int key; // BSP sequence number for leaf's contents
byte ambient_sound_level[NUM_AMBIENTS];
} mleaf_t;
struct msurface_s
{
int visframe; // should be drawn when node is crossed
int visframe; // should be drawn when node is crossed
int dlightframe; // last frame the surface was checked by an animated light
int dlightbits; // dynamically generated. Indicates if the surface illumination
// is modified by an animated light.
int dlightframe; // last frame the surface was checked by an animated light
int dlightbits; // dynamically generated. Indicates if the surface illumination
// is modified by an animated light.
mplane_t *plane; // pointer to shared plane
int flags; // see SURF_ #defines
mplane_t* plane; // pointer to shared plane
int flags; // see SURF_ #defines
int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges
// surface generation data
struct surfcache_s *cachespots[MIPLEVELS];
int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges
short texturemins[2]; // smallest s/t position on the surface.
short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces
// surface generation data
struct surfcache_s* cachespots[MIPLEVELS];
mtexinfo_t *texinfo;
// lighting info
byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights
// no one surface can be effected by more than 4
// animated lights.
color24 *samples;
decal_t *pdecals;
short texturemins[2]; // smallest s/t position on the surface.
short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces
mtexinfo_t* texinfo;
// lighting info
byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights
// no one surface can be effected by more than 4
// animated lights.
color24* samples;
decal_t* pdecals;
};
typedef struct
{
int planenum;
short children[2]; // negative numbers are contents
int planenum;
short children[2]; // negative numbers are contents
} dclipnode_t;
typedef struct hull_s
{
dclipnode_t *clipnodes;
mplane_t *planes;
int firstclipnode;
int lastclipnode;
Vector clip_mins;
Vector clip_maxs;
dclipnode_t* clipnodes;
mplane_t* planes;
int firstclipnode;
int lastclipnode;
Vector clip_mins;
Vector clip_maxs;
} hull_t;
#if !defined( CACHE_USER ) && !defined( QUAKEDEF_H )
#if !defined(CACHE_USER) && !defined(QUAKEDEF_H)
#define CACHE_USER
typedef struct cache_user_s
{
void *data;
void* data;
} cache_user_t;
#endif
typedef struct model_s
{
char name[ MAX_MODEL_NAME ];
qboolean needload; // bmodels and sprites don't cache normally
char name[MAX_MODEL_NAME];
qboolean needload; // bmodels and sprites don't cache normally
modtype_t type;
int numframes;
synctype_t synctype;
int flags;
modtype_t type;
int numframes;
synctype_t synctype;
//
// volume occupied by the model
//
Vector mins, maxs;
float radius;
int flags;
//
// brush model
//
int firstmodelsurface, nummodelsurfaces;
//
// volume occupied by the model
//
Vector mins, maxs;
float radius;
int numsubmodels;
dmodel_t *submodels;
//
// brush model
//
int firstmodelsurface, nummodelsurfaces;
int numplanes;
mplane_t *planes;
int numsubmodels;
dmodel_t* submodels;
int numleafs; // number of visible leafs, not counting 0
struct mleaf_s *leafs;
int numplanes;
mplane_t* planes;
int numvertexes;
mvertex_t *vertexes;
int numleafs; // number of visible leafs, not counting 0
struct mleaf_s* leafs;
int numedges;
medge_t *edges;
int numvertexes;
mvertex_t* vertexes;
int numnodes;
mnode_t *nodes;
int numedges;
medge_t* edges;
int numtexinfo;
mtexinfo_t *texinfo;
int numnodes;
mnode_t* nodes;
int numsurfaces;
msurface_t *surfaces;
int numtexinfo;
mtexinfo_t* texinfo;
int numsurfedges;
int *surfedges;
int numsurfaces;
msurface_t* surfaces;
int numclipnodes;
dclipnode_t *clipnodes;
int numsurfedges;
int* surfedges;
int nummarksurfaces;
msurface_t **marksurfaces;
int numclipnodes;
dclipnode_t* clipnodes;
hull_t hulls[MAX_MAP_HULLS];
int nummarksurfaces;
msurface_t** marksurfaces;
int numtextures;
texture_t **textures;
hull_t hulls[MAX_MAP_HULLS];
byte *visdata;
int numtextures;
texture_t** textures;
color24 *lightdata;
byte* visdata;
char *entities;
color24* lightdata;
//
// additional model data
//
cache_user_t cache; // only access through Mod_Extradata
char* entities;
//
// additional model data
//
cache_user_t cache; // only access through Mod_Extradata
} model_t;
@ -296,51 +296,51 @@ typedef vec_t vec4_t[4];
typedef struct alight_s
{
int ambientlight; // clip at 128
int shadelight; // clip at 192 - ambientlight
Vector color;
float *plightvec;
int ambientlight; // clip at 128
int shadelight; // clip at 192 - ambientlight
Vector color;
float* plightvec;
} alight_t;
typedef struct auxvert_s
{
float fv[3]; // viewspace x, y
float fv[3]; // viewspace x, y
} auxvert_t;
#include "custom.h"
#define MAX_INFO_STRING 256
#define MAX_SCOREBOARDNAME 32
#define MAX_INFO_STRING 256
#define MAX_SCOREBOARDNAME 32
typedef struct player_info_s
{
// User id on server
int userid;
int userid;
// User info string
char userinfo[ MAX_INFO_STRING ];
char userinfo[MAX_INFO_STRING];
// Name
char name[ MAX_SCOREBOARDNAME ];
char name[MAX_SCOREBOARDNAME];
// Spectator or not, unused
int spectator;
int spectator;
int ping;
int packet_loss;
int ping;
int packet_loss;
// skin information
char model[MAX_QPATH];
int topcolor;
int bottomcolor;
char model[MAX_QPATH];
int topcolor;
int bottomcolor;
// last frame rendered
int renderframe;
int renderframe;
// Gait frame estimation
int gaitsequence;
float gaitframe;
float gaityaw;
Vector prevgaitorigin;
int gaitsequence;
float gaitframe;
float gaityaw;
Vector prevgaitorigin;
customization_t customdata;

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================

View file

@ -14,13 +14,13 @@
****/
#pragma once
typedef struct con_nprint_s
{
int index; // Row #
float time_to_live; // # of seconds before it dissappears
float color[ 3 ]; // RGB colors ( 0.0 -> 1.0 scale )
int index; // Row #
float time_to_live; // # of seconds before it dissappears
float color[3]; // RGB colors ( 0.0 -> 1.0 scale )
} con_nprint_t;
void Con_NPrintf( int idx, char *fmt, ... );
void Con_NXPrintf( struct con_nprint_s *info, char *fmt, ... );
void Con_NPrintf(int idx, char* fmt, ...);
void Con_NXPrintf(struct con_nprint_s* info, char* fmt, ...);

File diff suppressed because it is too large Load diff

View file

@ -16,35 +16,35 @@
#pragma once
#include "steam/steamtypes.h" // DAL
#include "steam/steamtypes.h" // DAL
// MD5 Hash
typedef struct
{
unsigned int buf[4];
unsigned int bits[2];
unsigned char in[64];
unsigned int bits[2];
unsigned char in[64];
} MD5Context_t;
typedef uint32 CRC32_t;
void CRC32_Init(CRC32_t *pulCRC);
void CRC32_Init(CRC32_t* pulCRC);
CRC32_t CRC32_Final(CRC32_t pulCRC);
void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len);
void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch);
int CRC_File(CRC32_t *crcvalue, char *pszFileName);
void CRC32_ProcessBuffer(CRC32_t* pulCRC, void* p, int len);
void CRC32_ProcessByte(CRC32_t* pulCRC, unsigned char ch);
int CRC_File(CRC32_t* crcvalue, char* pszFileName);
unsigned char COM_BlockSequenceCRCByte (unsigned char *base, int length, int sequence);
unsigned char COM_BlockSequenceCRCByte(unsigned char* base, int length, int sequence);
void MD5Init(MD5Context_t *context);
void MD5Update(MD5Context_t *context, unsigned char const *buf,
unsigned int len);
void MD5Final(unsigned char digest[16], MD5Context_t *context);
void MD5Init(MD5Context_t* context);
void MD5Update(MD5Context_t* context, unsigned char const* buf,
unsigned int len);
void MD5Final(unsigned char digest[16], MD5Context_t* context);
void Transform(unsigned int buf[4], unsigned int const in[16]);
int MD5_Hash_File(unsigned char digest[16], char *pszFileName, int bUsefopen, int bSeed, unsigned int seed[4]);
char *MD5_Print(unsigned char hash[16]);
int MD5_Hash_CachedFile(unsigned char digest[16], unsigned char *pCache, int nFileSize, int bSeed, unsigned int seed[4]);
int MD5_Hash_File(unsigned char digest[16], char* pszFileName, int bUsefopen, int bSeed, unsigned int seed[4]);
char* MD5_Print(unsigned char hash[16]);
int MD5_Hash_CachedFile(unsigned char digest[16], unsigned char* pCache, int nFileSize, int bSeed, unsigned int seed[4]);
int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName);
int CRC_MapFile(CRC32_t* crcvalue, char* pszFileName);

View file

@ -15,25 +15,25 @@
#pragma once
#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc
#define FCVAR_USERINFO (1<<1) // changes the client's info string
#define FCVAR_SERVER (1<<2) // notifies players when changed
#define FCVAR_EXTDLL (1<<3) // defined by external DLL
#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar
#define FCVAR_ISEXECUTED (1 << 12) // This cvar's string contains a value that will be executed as a cfg file; don't allow commands to be appended to it
#define FCVAR_ISPATH (1 << 13) // This cvar's string is a path or filename; don't allow absolute paths, escaping to another directory or backslashes
#define FCVAR_ARCHIVE (1 << 0) // set to cause it to be saved to vars.rc
#define FCVAR_USERINFO (1 << 1) // changes the client's info string
#define FCVAR_SERVER (1 << 2) // notifies players when changed
#define FCVAR_EXTDLL (1 << 3) // defined by external DLL
#define FCVAR_CLIENTDLL (1 << 4) // defined by the client dll
#define FCVAR_PROTECTED (1 << 5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
#define FCVAR_SPONLY (1 << 6) // This cvar cannot be changed by clients connected to a multiplayer server.
#define FCVAR_PRINTABLEONLY (1 << 7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
#define FCVAR_UNLOGGED (1 << 8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
#define FCVAR_NOEXTRAWHITEPACE (1 << 9) // strip trailing/leading white space from this cvar
#define FCVAR_ISEXECUTED (1 << 12) // This cvar's string contains a value that will be executed as a cfg file; don't allow commands to be appended to it
#define FCVAR_ISPATH (1 << 13) // This cvar's string is a path or filename; don't allow absolute paths, escaping to another directory or backslashes
typedef struct cvar_s
{
const char *name;
const char* name;
//Technically this should be non-const but that only matters to engine code
const char *string;
int flags;
float value;
struct cvar_s *next;
const char* string;
int flags;
float value;
struct cvar_s* next;
} cvar_t;

View file

@ -17,10 +17,10 @@
typedef struct demo_api_s
{
int ( *IsRecording ) ( void );
int ( *IsPlayingback ) ( void );
int ( *IsTimeDemo ) ( void );
void ( *WriteBuffer ) ( int size, unsigned char *buffer );
int (*IsRecording)(void);
int (*IsPlayingback)(void);
int (*IsTimeDemo)(void);
void (*WriteBuffer)(int size, unsigned char* buffer);
} demo_api_t;
extern demo_api_t demoapi;

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -11,31 +11,29 @@
// sub commands for svc_director
#define DRC_ACTIVE 0 // tells client that he's an spectator and will get director command
#define DRC_STATUS 1 // send status infos about proxy
#define DRC_CAMERA 2 // set the actual director camera position
#define DRC_EVENT 3 // informs the dircetor about ann important game event
#define DRC_ACTIVE 0 // tells client that he's an spectator and will get director command
#define DRC_STATUS 1 // send status infos about proxy
#define DRC_CAMERA 2 // set the actual director camera position
#define DRC_EVENT 3 // informs the dircetor about ann important game event
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
#define DRC_FLAG_SIDE (1<<4)
#define DRC_FLAG_DRAMATIC (1<<5)
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
#define DRC_FLAG_SIDE (1 << 4)
#define DRC_FLAG_DRAMATIC (1 << 5)
// commands of the director API function CallDirectorProc(...)
#define DRCAPI_NOP 0 // no operation
#define DRCAPI_ACTIVE 1 // de/acivates director mode in engine
#define DRCAPI_STATUS 2 // request proxy information
#define DRCAPI_SETCAM 3 // set camera n to given position and angle
#define DRCAPI_GETCAM 4 // request camera n position and angle
#define DRCAPI_DIRPLAY 5 // set director time and play with normal speed
#define DRCAPI_DIRFREEZE 6 // freeze directo at this time
#define DRCAPI_SETVIEWMODE 7 // overview or 4 cameras
#define DRCAPI_SETOVERVIEWPARAMS 8 // sets parameter for overview mode
#define DRCAPI_SETFOCUS 9 // set the camera which has the input focus
#define DRCAPI_GETTARGETS 10 // queries engine for player list
#define DRCAPI_SETVIEWPOINTS 11 // gives engine all waypoints
#define DRCAPI_NOP 0 // no operation
#define DRCAPI_ACTIVE 1 // de/acivates director mode in engine
#define DRCAPI_STATUS 2 // request proxy information
#define DRCAPI_SETCAM 3 // set camera n to given position and angle
#define DRCAPI_GETCAM 4 // request camera n position and angle
#define DRCAPI_DIRPLAY 5 // set director time and play with normal speed
#define DRCAPI_DIRFREEZE 6 // freeze directo at this time
#define DRCAPI_SETVIEWMODE 7 // overview or 4 cameras
#define DRCAPI_SETOVERVIEWPARAMS 8 // sets parameter for overview mode
#define DRCAPI_SETFOCUS 9 // set the camera which has the input focus
#define DRCAPI_GETTARGETS 10 // queries engine for player list
#define DRCAPI_SETVIEWPOINTS 11 // gives engine all waypoints

View file

@ -17,12 +17,12 @@
typedef struct dlight_s
{
Vector origin;
float radius;
color24 color;
float die; // stop lighting after this time
float decay; // drop this each second
float minlight; // don't add when contributing less
int key;
qboolean dark; // subtracts light instead of adding
Vector origin;
float radius;
color24 color;
float die; // stop lighting after this time
float decay; // drop this each second
float minlight; // don't add when contributing less
int key;
qboolean dark; // subtracts light instead of adding
} dlight_t;

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -9,17 +9,17 @@
//DLL State Flags
#define DLL_INACTIVE 0 // no dll
#define DLL_ACTIVE 1 // dll is running
#define DLL_PAUSED 2 // dll is paused
#define DLL_CLOSE 3 // closing down dll
#define DLL_TRANS 4 // Level Transition
#define DLL_INACTIVE 0 // no dll
#define DLL_ACTIVE 1 // dll is running
#define DLL_PAUSED 2 // dll is paused
#define DLL_CLOSE 3 // closing down dll
#define DLL_TRANS 4 // Level Transition
// DLL Pause reasons
#define DLL_NORMAL 0 // User hit Esc or something.
#define DLL_QUIT 4 // Quit now
#define DLL_RESTART 6 // Switch to launcher for linux, does a quit but returns 1
#define DLL_NORMAL 0 // User hit Esc or something.
#define DLL_QUIT 4 // Quit now
#define DLL_RESTART 6 // Switch to launcher for linux, does a quit but returns 1
// DLL Substate info ( not relevant )
#define ENG_NORMAL (1<<0)
#define ENG_NORMAL (1 << 0)

View file

@ -16,166 +16,166 @@
#pragma once
// For entityType below
#define ENTITY_NORMAL (1<<0)
#define ENTITY_BEAM (1<<1)
#define ENTITY_NORMAL (1 << 0)
#define ENTITY_BEAM (1 << 1)
// Entity state is used for the baseline and for delta compression of a packet of
// Entity state is used for the baseline and for delta compression of a packet of
// entities that is sent to a client.
typedef struct entity_state_s entity_state_t;
struct entity_state_s
{
// Fields which are filled in by routines outside of delta compression
int entityType;
// Fields which are filled in by routines outside of delta compression
int entityType;
// Index into cl_entities array for this entity.
int number;
float msg_time;
int number;
float msg_time;
// Message number last time the player/entity state was updated.
int messagenum;
int messagenum;
// Fields which can be transitted and reconstructed over the network stream
Vector origin;
Vector angles;
Vector origin;
Vector angles;
int modelindex;
int sequence;
float frame;
int colormap;
short skin;
short solid;
int effects;
float scale;
int modelindex;
int sequence;
float frame;
int colormap;
short skin;
short solid;
int effects;
float scale;
byte eflags;
byte eflags;
// Render information
int rendermode;
int renderamt;
color24 rendercolor;
int renderfx;
int rendermode;
int renderamt;
color24 rendercolor;
int renderfx;
int movetype;
float animtime;
float framerate;
int body;
byte controller[4];
byte blending[4];
Vector velocity;
int movetype;
float animtime;
float framerate;
int body;
byte controller[4];
byte blending[4];
Vector velocity;
// Send bbox down to client for use during prediction.
Vector mins;
Vector maxs;
Vector mins;
Vector maxs;
int aiment;
int aiment;
// If owned by a player, the index of that player ( for projectiles ).
int owner;
int owner;
// Friction, for prediction.
float friction;
float friction;
// Gravity multiplier
float gravity;
float gravity;
// PLAYER SPECIFIC
int team;
int playerclass;
int health;
qboolean spectator;
int weaponmodel;
int gaitsequence;
// PLAYER SPECIFIC
int team;
int playerclass;
int health;
qboolean spectator;
int weaponmodel;
int gaitsequence;
// If standing on conveyor, e.g.
Vector basevelocity;
Vector basevelocity;
// Use the crouched hull, or the regular player hull.
int usehull;
int usehull;
// Latched buttons last time state updated.
int oldbuttons;
int oldbuttons;
// -1 = in air, else pmove entity number
int onground;
int iStepLeft;
int onground;
int iStepLeft;
// How fast we are falling
float flFallVelocity;
float flFallVelocity;
float fov;
int weaponanim;
float fov;
int weaponanim;
// Parametric movement overrides
Vector startpos;
Vector endpos;
float impacttime;
float starttime;
Vector startpos;
Vector endpos;
float impacttime;
float starttime;
// For mods
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
Vector vuser1;
Vector vuser2;
Vector vuser3;
Vector vuser4;
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
Vector vuser1;
Vector vuser2;
Vector vuser3;
Vector vuser4;
};
#include "pm_info.h"
typedef struct clientdata_s
{
Vector origin;
Vector velocity;
Vector origin;
Vector velocity;
int viewmodel;
Vector punchangle;
int flags;
int waterlevel;
int watertype;
Vector view_ofs;
float health;
int viewmodel;
Vector punchangle;
int flags;
int waterlevel;
int watertype;
Vector view_ofs;
float health;
int bInDuck;
int bInDuck;
int weapons; // remove?
int flTimeStepSound;
int flDuckTime;
int flSwimTime;
int waterjumptime;
int weapons; // remove?
float maxspeed;
int flTimeStepSound;
int flDuckTime;
int flSwimTime;
int waterjumptime;
float fov;
int weaponanim;
float maxspeed;
int m_iId;
int ammo_shells;
int ammo_nails;
int ammo_cells;
int ammo_rockets;
float m_flNextAttack;
int tfstate;
float fov;
int weaponanim;
int pushmsec;
int m_iId;
int ammo_shells;
int ammo_nails;
int ammo_cells;
int ammo_rockets;
float m_flNextAttack;
int deadflag;
int tfstate;
char physinfo[ MAX_PHYSINFO_STRING ];
int pushmsec;
int deadflag;
char physinfo[MAX_PHYSINFO_STRING];
// For mods
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
Vector vuser1;
Vector vuser2;
Vector vuser3;
Vector vuser4;
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
Vector vuser1;
Vector vuser2;
Vector vuser3;
Vector vuser4;
} clientdata_t;
#include "weaponinfo.h"
@ -183,6 +183,6 @@ typedef struct clientdata_s
typedef struct local_state_s
{
entity_state_t playerstate;
clientdata_t client;
weapon_data_t weapondata[ 64 ];
clientdata_t client;
weapon_data_t weapondata[64];
} local_state_t;

View file

@ -16,9 +16,9 @@
#pragma once
#define ET_NORMAL 0
#define ET_PLAYER 1
#define ET_TEMPENTITY 2
#define ET_BEAM 3
#define ET_NORMAL 0
#define ET_PLAYER 1
#define ET_TEMPENTITY 2
#define ET_BEAM 3
// BMODEL or SPRITE that was split across BSP nodes
#define ET_FRAGMENTED 4
#define ET_FRAGMENTED 4

View file

@ -16,8 +16,8 @@
#pragma once
typedef enum netsrc_s
{
NS_CLIENT,
NS_SERVER,
NS_MULTICAST // xxxMO
} netsrc_t;
{
NS_CLIENT,
NS_SERVER,
NS_MULTICAST // xxxMO
} netsrc_t;

View file

@ -19,28 +19,28 @@
typedef struct event_api_s
{
int version;
void ( *EV_PlaySound ) ( int ent, float *origin, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch );
void ( *EV_StopSound ) ( int ent, int channel, const char *sample );
int ( *EV_FindModelIndex )( const char *pmodel );
int ( *EV_IsLocal ) ( int playernum );
int ( *EV_LocalPlayerDucking ) ( void );
void ( *EV_LocalPlayerViewheight ) ( float * );
void ( *EV_LocalPlayerBounds ) ( int hull, float *mins, float *maxs );
int ( *EV_IndexFromTrace) ( struct pmtrace_s *pTrace );
struct physent_s *( *EV_GetPhysent ) ( int idx );
void ( *EV_SetUpPlayerPrediction ) ( int dopred, int bIncludeLocalClient );
void ( *EV_PushPMStates ) ( void );
void ( *EV_PopPMStates ) ( void );
void ( *EV_SetSolidPlayers ) (int playernum);
void ( *EV_SetTraceHull ) ( int hull );
void ( *EV_PlayerTrace ) ( float *start, float *end, int traceFlags, int ignore_pe, struct pmtrace_s *tr );
void ( *EV_WeaponAnimation ) ( int sequence, int body );
unsigned short ( *EV_PrecacheEvent ) ( int type, const char* psz );
void ( *EV_PlaybackEvent ) ( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
const char *( *EV_TraceTexture ) ( int ground, float *vstart, float *vend );
void ( *EV_StopAllSounds ) ( int entnum, int entchannel );
void ( *EV_KillEvents ) ( int entnum, const char *eventname );
int version;
void (*EV_PlaySound)(int ent, float* origin, int channel, const char* sample, float volume, float attenuation, int fFlags, int pitch);
void (*EV_StopSound)(int ent, int channel, const char* sample);
int (*EV_FindModelIndex)(const char* pmodel);
int (*EV_IsLocal)(int playernum);
int (*EV_LocalPlayerDucking)(void);
void (*EV_LocalPlayerViewheight)(float*);
void (*EV_LocalPlayerBounds)(int hull, float* mins, float* maxs);
int (*EV_IndexFromTrace)(struct pmtrace_s* pTrace);
struct physent_s* (*EV_GetPhysent)(int idx);
void (*EV_SetUpPlayerPrediction)(int dopred, int bIncludeLocalClient);
void (*EV_PushPMStates)(void);
void (*EV_PopPMStates)(void);
void (*EV_SetSolidPlayers)(int playernum);
void (*EV_SetTraceHull)(int hull);
void (*EV_PlayerTrace)(float* start, float* end, int traceFlags, int ignore_pe, struct pmtrace_s* tr);
void (*EV_WeaponAnimation)(int sequence, int body);
unsigned short (*EV_PrecacheEvent)(int type, const char* psz);
void (*EV_PlaybackEvent)(int flags, const struct edict_s* pInvoker, unsigned short eventindex, float delay, float* origin, float* angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
const char* (*EV_TraceTexture)(int ground, float* vstart, float* vend);
void (*EV_StopAllSounds)(int entnum, int entchannel);
void (*EV_KillEvents)(int entnum, const char* eventname);
} event_api_t;
extern event_api_t eventapi;

View file

@ -16,30 +16,30 @@
#pragma once
// Event was invoked with stated origin
#define FEVENT_ORIGIN ( 1<<0 )
#define FEVENT_ORIGIN (1 << 0)
// Event was invoked with stated angles
#define FEVENT_ANGLES ( 1<<1 )
#define FEVENT_ANGLES (1 << 1)
typedef struct event_args_s
{
int flags;
int flags;
// Transmitted
int entindex;
int entindex;
float origin[3];
float angles[3];
float velocity[3];
float origin[3];
float angles[3];
float velocity[3];
int ducking;
int ducking;
float fparam1;
float fparam2;
float fparam1;
float fparam2;
int iparam1;
int iparam2;
int iparam1;
int iparam2;
int bparam1;
int bparam2;
int bparam1;
int bparam2;
} event_args_t;

View file

@ -16,27 +16,27 @@
#pragma once
// Skip local host for event send.
#define FEV_NOTHOST (1<<0)
#define FEV_NOTHOST (1 << 0)
// Send the event reliably. You must specify the origin and angles and use
// PLAYBACK_EVENT_FULL for this to work correctly on the server for anything
// that depends on the event origin/angles. I.e., the origin/angles are not
// taken from the invoking edict for reliable events.
#define FEV_RELIABLE (1<<1)
#define FEV_RELIABLE (1 << 1)
// Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC
// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ).
#define FEV_GLOBAL (1<<2)
#define FEV_GLOBAL (1 << 2)
// If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate
//
#define FEV_UPDATE (1<<3)
#define FEV_UPDATE (1 << 3)
// Only send to entity specified as the invoker
#define FEV_HOSTONLY (1<<4)
#define FEV_HOSTONLY (1 << 4)
// Only send if the event was created on the server.
#define FEV_SERVER (1<<5)
#define FEV_SERVER (1 << 5)
// Only issue event client side ( from shared code )
#define FEV_CLIENT (1<<6)
#define FEV_CLIENT (1 << 6)

View file

@ -3,49 +3,49 @@
#pragma once
#define TYPE_CLIENT 0 // client is a normal HL client (default)
#define TYPE_PROXY 1 // client is another proxy
#define TYPE_COMMENTATOR 3 // client is a commentator
#define TYPE_DEMO 4 // client is a demo file
#define TYPE_CLIENT 0 // client is a normal HL client (default)
#define TYPE_PROXY 1 // client is another proxy
#define TYPE_COMMENTATOR 3 // client is a commentator
#define TYPE_DEMO 4 // client is a demo file
// sub commands of svc_hltv:
#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands
#define HLTV_STATUS 1 // send status infos about proxy
#define HLTV_LISTEN 2 // tell client to listen to a multicast stream
#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands
#define HLTV_STATUS 1 // send status infos about proxy
#define HLTV_LISTEN 2 // tell client to listen to a multicast stream
// director command types:
#define DRC_CMD_NONE 0 // NULL director command
#define DRC_CMD_START 1 // start director mode
#define DRC_CMD_EVENT 2 // informs about director command
#define DRC_CMD_MODE 3 // switches camera modes
#define DRC_CMD_CAMERA 4 // set fixed camera
#define DRC_CMD_TIMESCALE 5 // sets time scale
#define DRC_CMD_MESSAGE 6 // send HUD centerprint
#define DRC_CMD_SOUND 7 // plays a particular sound
#define DRC_CMD_STATUS 8 // HLTV broadcast status
#define DRC_CMD_BANNER 9 // set GUI banner
#define DRC_CMD_STUFFTEXT 10 // like the normal svc_stufftext but as director command
#define DRC_CMD_CHASE 11 // chase a certain player
#define DRC_CMD_INEYE 12 // view player through own eyes
#define DRC_CMD_MAP 13 // show overview map
#define DRC_CMD_CAMPATH 14 // define camera waypoint
#define DRC_CMD_WAYPOINTS 15 // start moving camera, inetranl message
#define DRC_CMD_NONE 0 // NULL director command
#define DRC_CMD_START 1 // start director mode
#define DRC_CMD_EVENT 2 // informs about director command
#define DRC_CMD_MODE 3 // switches camera modes
#define DRC_CMD_CAMERA 4 // set fixed camera
#define DRC_CMD_TIMESCALE 5 // sets time scale
#define DRC_CMD_MESSAGE 6 // send HUD centerprint
#define DRC_CMD_SOUND 7 // plays a particular sound
#define DRC_CMD_STATUS 8 // HLTV broadcast status
#define DRC_CMD_BANNER 9 // set GUI banner
#define DRC_CMD_STUFFTEXT 10 // like the normal svc_stufftext but as director command
#define DRC_CMD_CHASE 11 // chase a certain player
#define DRC_CMD_INEYE 12 // view player through own eyes
#define DRC_CMD_MAP 13 // show overview map
#define DRC_CMD_CAMPATH 14 // define camera waypoint
#define DRC_CMD_WAYPOINTS 15 // start moving camera, inetranl message
#define DRC_CMD_LAST 15
#define DRC_CMD_LAST 15
// DRC_CMD_EVENT event flags
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
#define DRC_FLAG_SIDE (1<<4) //
#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene
#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo
#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc)
#define DRC_FLAG_INTRO (1<<8) // is a introduction scene
#define DRC_FLAG_FINAL (1<<9) // is a final scene
#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
#define DRC_FLAG_SIDE (1 << 4) //
#define DRC_FLAG_DRAMATIC (1 << 5) // is a dramatic scene
#define DRC_FLAG_SLOWMOTION (1 << 6) // would look good in SloMo
#define DRC_FLAG_FACEPLAYER (1 << 7) // player is doning something (reload/defuse bomb etc)
#define DRC_FLAG_INTRO (1 << 8) // is a introduction scene
#define DRC_FLAG_FINAL (1 << 9) // is a final scene
#define DRC_FLAG_NO_RANDOM (1 << 10) // don't randomize event data
// DRC_CMD_WAYPOINT flags
#define DRC_FLAG_STARTPATH 1 // end with speed 0.0
#define DRC_FLAG_SLOWSTART 2 // start with speed 0.0
#define DRC_FLAG_SLOWEND 4 // end with speed 0.0
#define DRC_FLAG_STARTPATH 1 // end with speed 0.0
#define DRC_FLAG_SLOWSTART 2 // start with speed 0.0
#define DRC_FLAG_SLOWEND 4 // end with speed 0.0

View file

@ -15,19 +15,19 @@
#pragma once
#define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4)
#define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9)
#define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4)
#define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9)
#define IN_MOVERIGHT (1 << 10)
#define IN_ATTACK2 (1 << 11)
#define IN_RUN (1 << 12)
#define IN_RELOAD (1 << 13)
#define IN_ALT1 (1 << 14)
#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down
#define IN_ATTACK2 (1 << 11)
#define IN_RUN (1 << 12)
#define IN_RELOAD (1 << 13)
#define IN_ALT1 (1 << 14)
#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -10,22 +10,22 @@
// These provide access to the voice controls.
typedef enum
{
MicrophoneVolume=0, // values 0-1.
OtherSpeakerScale, // values 0-1. Scales how loud other players are.
MicBoost, // 20 db gain to voice input
MicrophoneVolume = 0, // values 0-1.
OtherSpeakerScale, // values 0-1. Scales how loud other players are.
MicBoost, // 20 db gain to voice input
} VoiceTweakControl;
typedef struct IVoiceTweak_s
{
// These turn voice tweak mode on and off. While in voice tweak mode, the user's voice is echoed back
// without sending to the server.
int (*StartVoiceTweakMode)(); // Returns 0 on error.
void (*EndVoiceTweakMode)();
// Get/set control values.
void (*SetControlFloat)(VoiceTweakControl iControl, float value);
float (*GetControlFloat)(VoiceTweakControl iControl);
// without sending to the server.
int (*StartVoiceTweakMode)(); // Returns 0 on error.
void (*EndVoiceTweakMode)();
int (*GetSpeakingVolume)();
// Get/set control values.
void (*SetControlFloat)(VoiceTweakControl iControl, float value);
float (*GetControlFloat)(VoiceTweakControl iControl);
int (*GetSpeakingVolume)();
} IVoiceTweak;

View file

@ -22,87 +22,99 @@ typedef float vec_t;
#include "vector.h"
typedef vec_t vec4_t[4]; // x,y,z,w
typedef vec_t vec4_t[4]; // x,y,z,w
typedef vec_t vec5_t[5];
typedef short vec_s_t;
typedef vec_s_t vec3s_t[3];
typedef vec_s_t vec4s_t[4]; // x,y,z,w
typedef vec_s_t vec4s_t[4]; // x,y,z,w
typedef vec_s_t vec5s_t[5];
typedef int fixed4_t;
typedef int fixed8_t;
typedef int fixed16_t;
typedef int fixed4_t;
typedef int fixed8_t;
typedef int fixed16_t;
#ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif
struct mplane_s;
constexpr Vector vec3_origin(0, 0, 0);
constexpr Vector g_vecZero(0, 0, 0);
extern int nanmask;
extern int nanmask;
#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
#define IS_NAN(x) (((*(int*)&x) & nanmask) == nanmask)
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
inline void VectorClear( float *a ) { a[ 0 ] = 0.0; a[ 1 ] = 0.0; a[ 2 ] = 0.0; }
#define VectorSubtract(a, b, c) \
{ \
(c)[0] = (a)[0] - (b)[0]; \
(c)[1] = (a)[1] - (b)[1]; \
(c)[2] = (a)[2] - (b)[2]; \
}
#define VectorAdd(a, b, c) \
{ \
(c)[0] = (a)[0] + (b)[0]; \
(c)[1] = (a)[1] + (b)[1]; \
(c)[2] = (a)[2] + (b)[2]; \
}
#define VectorCopy(a, b) \
{ \
(b)[0] = (a)[0]; \
(b)[1] = (a)[1]; \
(b)[2] = (a)[2]; \
}
inline void VectorClear(float* a)
{
a[0] = 0.0;
a[1] = 0.0;
a[2] = 0.0;
}
void VectorMA (const float* veca, float scale, const float* vecb, float* vecc);
void VectorMA(const float* veca, float scale, const float* vecb, float* vecc);
bool VectorCompare (const float* v1, const float* v2);
float Length (const float* v);
void CrossProduct (const float* v1, const float* v2, float* cross);
float VectorNormalize (float* v); // returns vector length
void VectorInverse (float* v);
void VectorScale (const float* in, float scale, float* out);
bool VectorCompare(const float* v1, const float* v2);
float Length(const float* v);
void CrossProduct(const float* v1, const float* v2, float* cross);
float VectorNormalize(float* v); // returns vector length
void VectorInverse(float* v);
void VectorScale(const float* in, float scale, float* out);
int Q_log2(int val);
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
void R_ConcatRotations(float in1[3][3], float in2[3][3], float out[3][3]);
void R_ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4]);
void FloorDivMod (double numer, double denom, int *quotient,
int *rem);
void FloorDivMod(double numer, double denom, int* quotient,
int* rem);
fixed16_t Invert24To16(fixed16_t val);
int GreatestCommonDivisor (int i1, int i2);
int GreatestCommonDivisor(int i1, int i2);
void AngleVectors (const Vector& angles, Vector* forward, Vector* right, Vector* up);
void AngleVectorsTranspose (const Vector& angles, Vector* forward, Vector* right, Vector* up);
#define AngleIVectors AngleVectorsTranspose
void AngleVectors(const Vector& angles, Vector* forward, Vector* right, Vector* up);
void AngleVectorsTranspose(const Vector& angles, Vector* forward, Vector* right, Vector* up);
#define AngleIVectors AngleVectorsTranspose
void AngleMatrix (const float* angles, float (*matrix)[4] );
void AngleIMatrix (const Vector& angles, float (*matrix)[4] );
void VectorTransform (const float* in1, float in2[3][4], float* out);
void AngleMatrix(const float* angles, float (*matrix)[4]);
void AngleIMatrix(const Vector& angles, float (*matrix)[4]);
void VectorTransform(const float* in1, float in2[3][4], float* out);
void NormalizeAngles( float* angles );
void InterpolateAngles( float* start, float* end, float* output, float frac );
float AngleBetweenVectors( const float* v1, const float* v2 );
void NormalizeAngles(float* angles);
void InterpolateAngles(float* start, float* end, float* output, float frac);
float AngleBetweenVectors(const float* v1, const float* v2);
void VectorMatrix( const Vector& forward, Vector& right, Vector& up);
void VectorAngles( const float* forward, float* angles );
void VectorMatrix(const Vector& forward, Vector& right, Vector& up);
void VectorAngles(const float* forward, float* angles);
int InvertMatrix( const float * m, float *out );
int InvertMatrix(const float* m, float* out);
int BoxOnPlaneSide (const Vector& emins, const Vector& emaxs, struct mplane_s *plane);
float anglemod(float a);
int BoxOnPlaneSide(const Vector& emins, const Vector& emaxs, struct mplane_s* plane);
float anglemod(float a);
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
(((p)->type < 3)? \
( \
((p)->dist <= (emins)[(p)->type])? \
1 \
: \
( \
((p)->dist >= (emaxs)[(p)->type])?\
2 \
: \
3 \
) \
) \
: \
BoxOnPlaneSide( (emins), (emaxs), (p)))
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
(((p)->type < 3) ? ( \
((p)->dist <= (emins)[(p)->type]) ? 1 \
: ( \
((p)->dist >= (emaxs)[(p)->type]) ? 2 \
: 3)) \
: BoxOnPlaneSide((emins), (emaxs), (p)))

View file

@ -1,6 +1,6 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
// Purpose:
//
// $NoKeywords: $
//=============================================================================
@ -9,83 +9,83 @@
#include "netadr.h"
#define NETAPI_REQUEST_SERVERLIST ( 0 ) // Doesn't need a remote address
#define NETAPI_REQUEST_PING ( 1 )
#define NETAPI_REQUEST_RULES ( 2 )
#define NETAPI_REQUEST_PLAYERS ( 3 )
#define NETAPI_REQUEST_DETAILS ( 4 )
#define NETAPI_REQUEST_SERVERLIST (0) // Doesn't need a remote address
#define NETAPI_REQUEST_PING (1)
#define NETAPI_REQUEST_RULES (2)
#define NETAPI_REQUEST_PLAYERS (3)
#define NETAPI_REQUEST_DETAILS (4)
// Set this flag for things like broadcast requests, etc. where the engine should not
// kill the request hook after receiving the first response
#define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 )
#define FNETAPI_MULTIPLE_RESPONSE (1 << 0)
typedef void ( *net_api_response_func_t ) ( struct net_response_s *response );
typedef void (*net_api_response_func_t)(struct net_response_s* response);
#define NET_SUCCESS ( 0 )
#define NET_ERROR_TIMEOUT ( 1<<0 )
#define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 )
#define NET_ERROR_UNDEFINED ( 1<<2 )
#define NET_SUCCESS (0)
#define NET_ERROR_TIMEOUT (1 << 0)
#define NET_ERROR_PROTO_UNSUPPORTED (1 << 1)
#define NET_ERROR_UNDEFINED (1 << 2)
typedef struct net_adrlist_s
{
struct net_adrlist_s *next;
netadr_t remote_address;
struct net_adrlist_s* next;
netadr_t remote_address;
} net_adrlist_t;
typedef struct net_response_s
{
// NET_SUCCESS or an error code
int error;
int error;
// Context ID
int context;
int context;
// Type
int type;
int type;
// Server that is responding to the request
netadr_t remote_address;
netadr_t remote_address;
// Response RTT ping time
double ping;
double ping;
// Key/Value pair string ( separated by backlash \ characters )
// WARNING: You must copy this buffer in the callback function, because it is freed
// by the engine right after the call!!!!
// ALSO: For NETAPI_REQUEST_SERVERLIST requests, this will be a pointer to a linked list of net_adrlist_t's
void *response;
void* response;
} net_response_t;
typedef struct net_status_s
{
// Connected to remote server? 1 == yes, 0 otherwise
int connected;
// Connected to remote server? 1 == yes, 0 otherwise
int connected;
// Client's IP address
netadr_t local_address;
netadr_t local_address;
// Address of remote server
netadr_t remote_address;
netadr_t remote_address;
// Packet Loss ( as a percentage )
int packet_loss;
int packet_loss;
// Latency, in seconds ( multiply by 1000.0 to get milliseconds )
double latency;
double latency;
// Connection time, in seconds
double connection_time;
double connection_time;
// Rate setting ( for incoming data )
double rate;
double rate;
} net_status_t;
typedef struct net_api_s
{
// APIs
void ( *InitNetworking )( void );
void ( *Status ) ( struct net_status_s *status );
void ( *SendRequest) ( int context, int request, int flags, double timeout, struct netadr_s *remote_address, net_api_response_func_t response );
void ( *CancelRequest ) ( int context );
void ( *CancelAllRequests ) ( void );
char *( *AdrToString ) ( struct netadr_s *a );
int ( *CompareAdr ) ( struct netadr_s *a, struct netadr_s *b );
int ( *StringToAdr ) ( char *s, struct netadr_s *a );
const char *( *ValueForKey ) ( const char *s, const char *key );
void ( *RemoveKey ) ( char *s, const char *key );
void ( *SetValueForKey ) (char *s, const char *key, const char *value, int maxsize );
void (*InitNetworking)(void);
void (*Status)(struct net_status_s* status);
void (*SendRequest)(int context, int request, int flags, double timeout, struct netadr_s* remote_address, net_api_response_func_t response);
void (*CancelRequest)(int context);
void (*CancelAllRequests)(void);
char* (*AdrToString)(struct netadr_s* a);
int (*CompareAdr)(struct netadr_s* a, struct netadr_s* b);
int (*StringToAdr)(char* s, struct netadr_s* a);
const char* (*ValueForKey)(const char* s, const char* key);
void (*RemoveKey)(char* s, const char* key);
void (*SetValueForKey)(char* s, const char* key, const char* value, int maxsize);
} net_api_t;
extern net_api_t netapi;

View file

@ -28,8 +28,8 @@ typedef enum
typedef struct netadr_s
{
netadrtype_t type;
unsigned char ip[4];
unsigned char ipx[10];
unsigned short port;
netadrtype_t type;
unsigned char ip[4];
unsigned char ipx[10];
unsigned short port;
} netadr_t;

Some files were not shown because too many files have changed in this diff Show more