Compare commits

...

4 commits

Author SHA1 Message Date
archive
030f9987fd as released 2002-12-23 2002-12-23 00:00:00 +00:00
archive
4ec16cce0e as released 2001-11-08 2001-11-08 00:00:00 +00:00
archive
d4fc7e405f as released 2001-08-29 2001-08-29 00:00:00 +00:00
archive
e84d04174b as released 2000-11-07 2000-11-07 00:00:00 +00:00
530 changed files with 65188 additions and 10806 deletions

View file

@ -42,13 +42,34 @@ clientdata_t none
DEFINE_DELTA( bInDuck, DT_INTEGER, 1, 1.0 ),
DEFINE_DELTA( flSwimTime, DT_INTEGER, 10, 1.0 ),
DEFINE_DELTA( waterjumptime, DT_INTEGER, 15, 1.0 ),
DEFINE_DELTA( waterlevel, DT_INTEGER, 2, 1.0 )
DEFINE_DELTA( waterlevel, DT_INTEGER, 2, 1.0 ),
DEFINE_DELTA( vuser1[0], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser1[1], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser1[2], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser2[0], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser2[1], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser2[2], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser3[0], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser3[1], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser3[2], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser4[0], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser4[1], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( vuser4[2], DT_SIGNED | DT_FLOAT, 10, 1.0 ),
DEFINE_DELTA( fuser1, DT_SIGNED | DT_FLOAT, 22, 128.0 ),
DEFINE_DELTA( fuser2, DT_SIGNED | DT_FLOAT, 10, 128.0 ),
DEFINE_DELTA( fuser3, DT_SIGNED | DT_FLOAT, 10, 128.0 ),
DEFINE_DELTA( fuser4, DT_SIGNED | DT_FLOAT, 2, 128.0 )
}
entity_state_t gamedll Entity_Encode
{
DEFINE_DELTA( animtime, DT_TIMEWINDOW_8, 8, 1.0 ),
DEFINE_DELTA( frame, DT_FLOAT, 8, 1.0 ),
DEFINE_DELTA( frame, DT_FLOAT, 10, 4.0 ),
DEFINE_DELTA( origin[0], DT_SIGNED | DT_FLOAT, 16, 8.0 ),
DEFINE_DELTA( angles[0], DT_ANGLE, 16, 1.0 ),
DEFINE_DELTA( angles[1], DT_ANGLE, 16, 1.0 ),
@ -99,7 +120,11 @@ entity_state_t gamedll Entity_Encode
DEFINE_DELTA( aiment, DT_INTEGER, 11, 1.0 ),
DEFINE_DELTA( basevelocity[0], DT_SIGNED | DT_FLOAT, 16, 8.0 ),
DEFINE_DELTA( basevelocity[1], DT_SIGNED | DT_FLOAT, 16, 8.0 ),
DEFINE_DELTA( basevelocity[2], DT_SIGNED | DT_FLOAT, 16, 8.0 )
DEFINE_DELTA( basevelocity[2], DT_SIGNED | DT_FLOAT, 16, 8.0 ),
// Playerclass signifies it's a decalable glass item when referring to an object
DEFINE_DELTA( playerclass, DT_INTEGER, 1, 1.0 )
}
entity_state_player_t gamedll Player_Encode
@ -212,7 +237,13 @@ weapon_data_t none
DEFINE_DELTA( m_fAimedDamage, DT_FLOAT, 6, 0.1 ),
DEFINE_DELTA( m_fInZoom, DT_INTEGER, 1, 1.0 ),
DEFINE_DELTA( m_iWeaponState, DT_INTEGER, 2, 1.0 ),
DEFINE_DELTA( m_iId, DT_INTEGER, 5, 1.0 )
DEFINE_DELTA( m_iId, DT_INTEGER, 5, 1.0 ),
DEFINE_DELTA( iuser1, DT_SIGNED | DT_INTEGER, 10, 1.0 ),
DEFINE_DELTA( iuser2, DT_SIGNED | DT_INTEGER, 10, 1.0 ),
DEFINE_DELTA( iuser3, DT_SIGNED | DT_INTEGER, 10, 1.0 ),
DEFINE_DELTA( fuser1, DT_SIGNED | DT_FLOAT, 22, 1000.0 ),
DEFINE_DELTA( fuser2, DT_SIGNED | DT_FLOAT, 22, 128.0 ),
DEFINE_DELTA( fuser3, DT_SIGNED | DT_FLOAT, 22, 128.0 )
}
event_t none

View file

@ -0,0 +1,119 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include <assert.h>
#include "hud.h"
#include "cl_util.h"
#include "const.h"
#include "com_model.h"
#include "studio.h"
#include "entity_state.h"
#include "cl_entity.h"
#include "dlight.h"
#include "triangleapi.h"
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include "studio_util.h"
#include "r_studioint.h"
#include "StudioModelRenderer.h"
#include "GameStudioModelRenderer.h"
//
// Override the StudioModelRender virtual member functions here to implement custom bone
// setup, blending, etc.
//
// Global engine <-> studio model rendering code interface
extern engine_studio_api_t IEngineStudio;
// The renderer object, created on the stack.
CGameStudioModelRenderer g_StudioRenderer;
/*
====================
CGameStudioModelRenderer
====================
*/
CGameStudioModelRenderer::CGameStudioModelRenderer( void )
{
}
////////////////////////////////////
// Hooks to class implementation
////////////////////////////////////
/*
====================
R_StudioDrawPlayer
====================
*/
int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
{
return g_StudioRenderer.StudioDrawPlayer( flags, pplayer );
}
/*
====================
R_StudioDrawModel
====================
*/
int R_StudioDrawModel( int flags )
{
return g_StudioRenderer.StudioDrawModel( flags );
}
/*
====================
R_StudioInit
====================
*/
void R_StudioInit( void )
{
g_StudioRenderer.Init();
}
// The simple drawing interface we'll pass back to the engine
r_studio_interface_t studio =
{
STUDIO_INTERFACE_VERSION,
R_StudioDrawModel,
R_StudioDrawPlayer,
};
/*
====================
HUD_GetStudioModelInterface
Export this function for the engine to use the studio renderer class to render objects.
====================
*/
#define DLLEXPORT __declspec( dllexport )
extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{
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 ) );
// Initialize local variables, etc.
R_StudioInit();
// Success
return 1;
}

View file

@ -0,0 +1,26 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( GAMESTUDIOMODELRENDERER_H )
#define GAMESTUDIOMODELRENDERER_H
#if defined( _WIN32 )
#pragma once
#endif
/*
====================
CGameStudioModelRenderer
====================
*/
class CGameStudioModelRenderer : public CStudioModelRenderer
{
public:
CGameStudioModelRenderer( void );
};
#endif // GAMESTUDIOMODELRENDERER_H

View file

@ -0,0 +1,992 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include <assert.h>
#include "hud.h"
#include "cl_util.h"
#include "const.h"
#include "com_model.h"
#include "studio.h"
#include "entity_state.h"
#include "cl_entity.h"
#include "dlight.h"
#include "triangleapi.h"
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include "studio_util.h"
#include "r_studioint.h"
#include "StudioModelRenderer.h"
#include "GameStudioModelRenderer.h"
// Predicted values saved off in hl_weapons.cpp
void Game_GetSequence( int *seq, int *gaitseq );
void Game_GetOrientation( float *o, float *a );
float g_flStartScaleTime;
int iPrevRenderState;
int iRenderStateChanged;
// Global engine <-> studio model rendering code interface
extern engine_studio_api_t IEngineStudio;
typedef struct
{
vec3_t origin;
vec3_t angles;
vec3_t realangles;
float animtime;
float frame;
int sequence;
int gaitsequence;
float framerate;
int m_fSequenceLoops;
int m_fSequenceFinished;
byte controller[ 4 ];
byte blending[ 2 ];
latchedvars_t lv;
} client_anim_state_t;
static client_anim_state_t g_state;
static client_anim_state_t g_clientstate;
// The renderer object, created on the stack.
CGameStudioModelRenderer g_StudioRenderer;
/*
====================
CGameStudioModelRenderer
====================
*/
CGameStudioModelRenderer::CGameStudioModelRenderer( void )
{
// If you want to predict animations locally, set this to TRUE
// NOTE: The animation code is somewhat broken, but gives you a sense for how
// to do client side animation of the predicted player in a third person game.
m_bLocal = false;
}
/*
====================
StudioSetupBones
====================
*/
void CGameStudioModelRenderer::StudioSetupBones ( void )
{
int i;
double f;
mstudiobone_t *pbones;
mstudioseqdesc_t *pseqdesc;
mstudioanim_t *panim;
static float pos[MAXSTUDIOBONES][3];
static vec4_t q[MAXSTUDIOBONES];
float bonematrix[3][4];
static float pos2[MAXSTUDIOBONES][3];
static vec4_t q2[MAXSTUDIOBONES];
static float pos3[MAXSTUDIOBONES][3];
static vec4_t q3[MAXSTUDIOBONES];
static float pos4[MAXSTUDIOBONES][3];
static vec4_t q4[MAXSTUDIOBONES];
// Use default bone setup for nonplayers
if ( !m_pCurrentEntity->player )
{
CStudioModelRenderer::StudioSetupBones();
return;
}
// Bound sequence number.
if ( m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq )
{
m_pCurrentEntity->curstate.sequence = 0;
}
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence;
if ( m_pPlayerInfo && m_pPlayerInfo->gaitsequence != 0 )
{
f = m_pPlayerInfo->gaitframe;
}
else
{
f = StudioEstimateFrame( pseqdesc );
}
// This game knows how to do three way blending
if ( pseqdesc->numblends == 3 )
{
float s;
// Get left anim
panim = StudioGetAnim( m_pRenderModel, pseqdesc );
// Blending is 0-127 == Left to Middle, 128 to 255 == Middle to right
if ( m_pCurrentEntity->curstate.blending[0] <= 127 )
{
StudioCalcRotations( pos, q, pseqdesc, panim, f );
// Scale 0-127 blending up to 0-255
s = m_pCurrentEntity->curstate.blending[0];
s = ( s * 2.0 );
}
else
{
// Skip ahead to middle
panim += m_pStudioHeader->numbones;
StudioCalcRotations( pos, q, pseqdesc, panim, f );
// Scale 127-255 blending up to 0-255
s = m_pCurrentEntity->curstate.blending[0];
s = 2.0 * ( s - 127.0 );
}
// Normalize interpolant
s /= 255.0;
// Go to middle or right
panim += m_pStudioHeader->numbones;
StudioCalcRotations( pos2, q2, pseqdesc, panim, f );
// Spherically interpolate the bones
StudioSlerpBones( q, pos, q2, pos2, s );
}
else
{
panim = StudioGetAnim( m_pRenderModel, pseqdesc );
StudioCalcRotations( pos, q, pseqdesc, panim, f );
}
// Are we in the process of transitioning from one sequence to another.
if ( m_fDoInterp &&
m_pCurrentEntity->latched.sequencetime &&
( m_pCurrentEntity->latched.sequencetime + 0.2 > m_clTime ) &&
( m_pCurrentEntity->latched.prevsequence < m_pStudioHeader->numseq ))
{
// blend from last sequence
static float pos1b[MAXSTUDIOBONES][3];
static vec4_t q1b[MAXSTUDIOBONES];
float s;
// Blending value into last sequence
unsigned char prevseqblending = m_pCurrentEntity->latched.prevseqblending[ 0 ];
// Point at previous sequenece
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->latched.prevsequence;
// Know how to do three way blends
if ( pseqdesc->numblends == 3 )
{
float s;
// Get left animation
panim = StudioGetAnim( m_pRenderModel, pseqdesc );
if ( prevseqblending <= 127 )
{
// Set up bones based on final frame of previous sequence
StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
s = prevseqblending;
s = ( s * 2.0 );
}
else
{
// Skip to middle blend
panim += m_pStudioHeader->numbones;
StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
s = prevseqblending;
s = 2.0 * ( s - 127.0 );
}
// Normalize
s /= 255.0;
panim += m_pStudioHeader->numbones;
StudioCalcRotations( pos2, q2, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
// Interpolate bones
StudioSlerpBones( q1b, pos1b, q2, pos2, s );
}
else
{
panim = StudioGetAnim( m_pRenderModel, pseqdesc );
// clip prevframe
StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
}
// Now blend last frame of previous sequence with current sequence.
s = 1.0 - (m_clTime - m_pCurrentEntity->latched.sequencetime) / 0.2;
StudioSlerpBones( q, pos, q1b, pos1b, s );
}
else
{
m_pCurrentEntity->latched.prevframe = f;
}
// Now convert quaternions and bone positions into matrices
pbones = (mstudiobone_t *)((byte *)m_pStudioHeader + m_pStudioHeader->boneindex);
for (i = 0; i < m_pStudioHeader->numbones; i++)
{
QuaternionMatrix( q[i], bonematrix );
bonematrix[0][3] = pos[i][0];
bonematrix[1][3] = pos[i][1];
bonematrix[2][3] = pos[i][2];
if (pbones[i].parent == -1)
{
if ( IEngineStudio.IsHardware() )
{
ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_pbonetransform)[i]);
ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]);
}
else
{
ConcatTransforms ((*m_paliastransform), bonematrix, (*m_pbonetransform)[i]);
ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]);
}
// Apply client-side effects to the transformation matrix
StudioFxTransform( m_pCurrentEntity, (*m_pbonetransform)[i] );
}
else
{
ConcatTransforms ((*m_pbonetransform)[pbones[i].parent], bonematrix, (*m_pbonetransform)[i]);
ConcatTransforms ((*m_plighttransform)[pbones[i].parent], bonematrix, (*m_plighttransform)[i]);
}
}
}
/*
====================
StudioEstimateGait
====================
*/
void CGameStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer )
{
float dt;
vec3_t est_velocity;
dt = (m_clTime - m_clOldTime);
dt = max( 0.0, dt );
dt = min( 1.0, dt );
if (dt == 0 || m_pPlayerInfo->renderframe == m_nFrameCount)
{
m_flGaitMovement = 0;
return;
}
// VectorAdd( pplayer->velocity, pplayer->prediction_error, est_velocity );
if ( m_fGaitEstimation )
{
VectorSubtract( m_pCurrentEntity->origin, m_pPlayerInfo->prevgaitorigin, est_velocity );
VectorCopy( m_pCurrentEntity->origin, m_pPlayerInfo->prevgaitorigin );
m_flGaitMovement = Length( est_velocity );
if (dt <= 0 || m_flGaitMovement / dt < 5)
{
m_flGaitMovement = 0;
est_velocity[0] = 0;
est_velocity[1] = 0;
}
}
else
{
VectorCopy( pplayer->velocity, est_velocity );
m_flGaitMovement = Length( est_velocity ) * dt;
}
if (est_velocity[1] == 0 && est_velocity[0] == 0)
{
float flYawDiff = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw;
flYawDiff = flYawDiff - (int)(flYawDiff / 360) * 360;
if (flYawDiff > 180)
flYawDiff -= 360;
if (flYawDiff < -180)
flYawDiff += 360;
if (dt < 0.25)
flYawDiff *= dt * 4;
else
flYawDiff *= dt;
m_pPlayerInfo->gaityaw += flYawDiff;
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)(m_pPlayerInfo->gaityaw / 360) * 360;
m_flGaitMovement = 0;
}
else
{
m_pPlayerInfo->gaityaw = (atan2(est_velocity[1], est_velocity[0]) * 180 / M_PI);
if (m_pPlayerInfo->gaityaw > 180)
m_pPlayerInfo->gaityaw = 180;
if (m_pPlayerInfo->gaityaw < -180)
m_pPlayerInfo->gaityaw = -180;
}
}
/*
====================
StudioProcessGait
====================
*/
void CGameStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer )
{
mstudioseqdesc_t *pseqdesc;
float dt;
float flYaw; // view direction relative to movement
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence;
m_pCurrentEntity->angles[PITCH] = 0;
m_pCurrentEntity->latched.prevangles[PITCH] = m_pCurrentEntity->angles[PITCH];
dt = (m_clTime - m_clOldTime);
dt = max( 0.0, dt );
dt = min( 1.0, dt );
StudioEstimateGait( pplayer );
// calc side to side turning
flYaw = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw;
flYaw = fmod( flYaw, 360.0 );
if (flYaw < -180)
{
flYaw = flYaw + 360;
}
else if (flYaw > 180)
{
flYaw = flYaw - 360;
}
float maxyaw = 120.0;
if (flYaw > maxyaw)
{
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - 180;
m_flGaitMovement = -m_flGaitMovement;
flYaw = flYaw - 180;
}
else if (flYaw < -maxyaw)
{
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw + 180;
m_flGaitMovement = -m_flGaitMovement;
flYaw = flYaw + 180;
}
float blend_yaw = ( flYaw / 90.0 ) * 128.0 + 127.0;
blend_yaw = min( 255.0, blend_yaw );
blend_yaw = max( 0.0, blend_yaw );
blend_yaw = 255.0 - blend_yaw;
m_pCurrentEntity->curstate.blending[0] = (int)(blend_yaw);
m_pCurrentEntity->latched.prevblending[0] = m_pCurrentEntity->curstate.blending[0];
m_pCurrentEntity->latched.prevseqblending[0] = m_pCurrentEntity->curstate.blending[0];
m_pCurrentEntity->angles[YAW] = m_pPlayerInfo->gaityaw;
if (m_pCurrentEntity->angles[YAW] < -0)
{
m_pCurrentEntity->angles[YAW] += 360;
}
m_pCurrentEntity->latched.prevangles[YAW] = m_pCurrentEntity->angles[YAW];
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + pplayer->gaitsequence;
// Calc gait frame
if (pseqdesc->linearmovement[0] > 0)
{
m_pPlayerInfo->gaitframe += (m_flGaitMovement / pseqdesc->linearmovement[0]) * pseqdesc->numframes;
}
else
{
m_pPlayerInfo->gaitframe += pseqdesc->fps * dt * m_pCurrentEntity->curstate.framerate;
}
// Do modulo
m_pPlayerInfo->gaitframe = m_pPlayerInfo->gaitframe - (int)(m_pPlayerInfo->gaitframe / pseqdesc->numframes) * pseqdesc->numframes;
if (m_pPlayerInfo->gaitframe < 0)
{
m_pPlayerInfo->gaitframe += pseqdesc->numframes;
}
}
/*
==============================
SavePlayerState
For local player, in third person, we need to store real render data and then
setup for with fake/client side animation data
==============================
*/
void CGameStudioModelRenderer::SavePlayerState( entity_state_t *pplayer )
{
client_anim_state_t *st;
cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
assert( ent );
if ( !ent )
return;
st = &g_state;
st->angles = ent->curstate.angles;
st->origin = ent->curstate.origin;
st->realangles = ent->angles;
st->sequence = ent->curstate.sequence;
st->gaitsequence = pplayer->gaitsequence;
st->animtime = ent->curstate.animtime;
st->frame = ent->curstate.frame;
st->framerate = ent->curstate.framerate;
memcpy( st->blending, ent->curstate.blending, 2 );
memcpy( st->controller, ent->curstate.controller, 4 );
st->lv = ent->latched;
}
void GetSequenceInfo( void *pmodel, client_anim_state_t *pev, float *pflFrameRate, float *pflGroundSpeed )
{
studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr)
return;
mstudioseqdesc_t *pseqdesc;
if (pev->sequence >= pstudiohdr->numseq)
{
*pflFrameRate = 0.0;
*pflGroundSpeed = 0.0;
return;
}
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence;
if (pseqdesc->numframes > 1)
{
*pflFrameRate = 256 * pseqdesc->fps / (pseqdesc->numframes - 1);
*pflGroundSpeed = sqrt( pseqdesc->linearmovement[0]*pseqdesc->linearmovement[0]+ pseqdesc->linearmovement[1]*pseqdesc->linearmovement[1]+ pseqdesc->linearmovement[2]*pseqdesc->linearmovement[2] );
*pflGroundSpeed = *pflGroundSpeed * pseqdesc->fps / (pseqdesc->numframes - 1);
}
else
{
*pflFrameRate = 256.0;
*pflGroundSpeed = 0.0;
}
}
int GetSequenceFlags( void *pmodel, client_anim_state_t *pev )
{
studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel;
if ( !pstudiohdr || pev->sequence >= pstudiohdr->numseq )
return 0;
mstudioseqdesc_t *pseqdesc;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence;
return pseqdesc->flags;
}
float StudioFrameAdvance ( client_anim_state_t *st, float framerate, float flInterval )
{
if (flInterval == 0.0)
{
flInterval = (gEngfuncs.GetClientTime() - st->animtime);
if (flInterval <= 0.001)
{
st->animtime = gEngfuncs.GetClientTime();
return 0.0;
}
}
if (!st->animtime)
flInterval = 0.0;
st->frame += flInterval * framerate * st->framerate;
st->animtime = gEngfuncs.GetClientTime();
if (st->frame < 0.0 || st->frame >= 256.0)
{
if ( st->m_fSequenceLoops )
st->frame -= (int)(st->frame / 256.0) * 256.0;
else
st->frame = (st->frame < 0.0) ? 0 : 255;
st->m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents
}
return flInterval;
}
/*
==============================
SetupClientAnimation
Called to set up local player's animation values
==============================
*/
void CGameStudioModelRenderer::SetupClientAnimation( entity_state_t *pplayer )
{
static double oldtime;
double curtime, dt;
client_anim_state_t *st;
float fr, gs;
cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
assert( ent );
if ( !ent )
return;
curtime = gEngfuncs.GetClientTime();
dt = curtime - oldtime;
dt = min( 1.0, max( 0.0, dt ) );
oldtime = curtime;
st = &g_clientstate;
st->framerate = 1.0;
int oldseq = st->sequence;
Game_GetSequence( &st->sequence, &st->gaitsequence ); //CVAR_GET_FLOAT( "sequence" );
Game_GetOrientation( (float *)&st->origin, (float *)&st->angles );
st->realangles = st->angles;
if ( st->sequence != oldseq )
{
st->frame = 0.0;
st->lv.prevsequence = oldseq;
st->lv.sequencetime = st->animtime;
memcpy( st->lv.prevseqblending, st->blending, 2 );
memcpy( st->lv.prevcontroller, st->controller, 4 );
}
void *pmodel = (studiohdr_t *)IEngineStudio.Mod_Extradata( ent->model );
GetSequenceInfo( pmodel, st, &fr, &gs );
st->m_fSequenceLoops = ((GetSequenceFlags( pmodel, st ) & STUDIO_LOOPING) != 0);
StudioFrameAdvance( st, fr, dt );
// gEngfuncs.Con_Printf( "gs %i frame %f\n", st->gaitsequence, st->frame );
ent->angles = st->realangles;
ent->curstate.angles = st->angles;
ent->curstate.origin = st->origin;
ent->curstate.sequence = st->sequence;
pplayer->gaitsequence = st->gaitsequence;
ent->curstate.animtime = st->animtime;
ent->curstate.frame = st->frame;
ent->curstate.framerate = st->framerate;
memcpy( ent->curstate.blending, st->blending, 2 );
memcpy( ent->curstate.controller, st->controller, 4 );
ent->latched = st->lv;
}
/*
==============================
RestorePlayerState
Called to restore original player state information
==============================
*/
void CGameStudioModelRenderer::RestorePlayerState( entity_state_t *pplayer )
{
client_anim_state_t *st;
cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
assert( ent );
if ( !ent )
return;
st = &g_clientstate;
st->angles = ent->curstate.angles;
st->origin = ent->curstate.origin;
st->realangles = ent->angles;
st->sequence = ent->curstate.sequence;
st->gaitsequence = pplayer->gaitsequence;
st->animtime = ent->curstate.animtime;
st->frame = ent->curstate.frame;
st->framerate = ent->curstate.framerate;
memcpy( st->blending, ent->curstate.blending, 2 );
memcpy( st->controller, ent->curstate.controller, 4 );
st->lv = ent->latched;
st = &g_state;
ent->curstate.angles = st->angles;
ent->curstate.origin = st->origin;
ent->angles = st->realangles;
ent->curstate.sequence = st->sequence;
pplayer->gaitsequence = st->gaitsequence;
ent->curstate.animtime = st->animtime;
ent->curstate.frame = st->frame;
ent->curstate.framerate = st->framerate;
memcpy( ent->curstate.blending, st->blending, 2 );
memcpy( ent->curstate.controller, st->controller, 4 );
ent->latched = st->lv;
}
/*
==============================
StudioDrawPlayer
==============================
*/
int CGameStudioModelRenderer::StudioDrawPlayer( int flags, entity_state_t *pplayer )
{
int iret = 0;
bool isLocalPlayer = false;
// Set up for client?
if ( m_bLocal && IEngineStudio.GetCurrentEntity() == gEngfuncs.GetLocalPlayer() )
{
isLocalPlayer = true;
}
if ( isLocalPlayer )
{
// Store original data
SavePlayerState( pplayer );
// Copy in client side animation data
SetupClientAnimation( pplayer );
}
// Call real draw function
iret = _StudioDrawPlayer( flags, pplayer );
// Restore for client?
if ( isLocalPlayer )
{
// Restore the original data for the player
RestorePlayerState( pplayer );
}
return iret;
}
/*
====================
_StudioDrawPlayer
====================
*/
int CGameStudioModelRenderer::_StudioDrawPlayer( int flags, entity_state_t *pplayer )
{
alight_t lighting;
vec3_t dir;
m_pCurrentEntity = IEngineStudio.GetCurrentEntity();
IEngineStudio.GetTimes( &m_nFrameCount, &m_clTime, &m_clOldTime );
IEngineStudio.GetViewInfo( m_vRenderOrigin, m_vUp, m_vRight, m_vNormal );
IEngineStudio.GetAliasScale( &m_fSoftwareXScale, &m_fSoftwareYScale );
m_nPlayerIndex = pplayer->number - 1;
if (m_nPlayerIndex < 0 || m_nPlayerIndex >= gEngfuncs.GetMaxClients())
return 0;
m_pRenderModel = IEngineStudio.SetupPlayerModel( m_nPlayerIndex );
if (m_pRenderModel == NULL)
return 0;
m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata (m_pRenderModel);
IEngineStudio.StudioSetHeader( m_pStudioHeader );
IEngineStudio.SetRenderModel( m_pRenderModel );
if (pplayer->gaitsequence)
{
vec3_t orig_angles;
m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
VectorCopy( m_pCurrentEntity->angles, orig_angles );
StudioProcessGait( pplayer );
m_pPlayerInfo->gaitsequence = pplayer->gaitsequence;
m_pPlayerInfo = NULL;
StudioSetUpTransform( 0 );
VectorCopy( orig_angles, m_pCurrentEntity->angles );
}
else
{
m_pCurrentEntity->curstate.controller[0] = 127;
m_pCurrentEntity->curstate.controller[1] = 127;
m_pCurrentEntity->curstate.controller[2] = 127;
m_pCurrentEntity->curstate.controller[3] = 127;
m_pCurrentEntity->latched.prevcontroller[0] = m_pCurrentEntity->curstate.controller[0];
m_pCurrentEntity->latched.prevcontroller[1] = m_pCurrentEntity->curstate.controller[1];
m_pCurrentEntity->latched.prevcontroller[2] = m_pCurrentEntity->curstate.controller[2];
m_pCurrentEntity->latched.prevcontroller[3] = m_pCurrentEntity->curstate.controller[3];
m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
m_pPlayerInfo->gaitsequence = 0;
StudioSetUpTransform( 0 );
}
if (flags & STUDIO_RENDER)
{
// see if the bounding box lets us trivially reject, also sets
if (!IEngineStudio.StudioCheckBBox ())
return 0;
(*m_pModelsDrawn)++;
(*m_pStudioModelCount)++; // render data cache cookie
if (m_pStudioHeader->numbodyparts == 0)
return 1;
}
m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
StudioSetupBones( );
StudioSaveBones( );
m_pPlayerInfo->renderframe = m_nFrameCount;
m_pPlayerInfo = NULL;
if (flags & STUDIO_EVENTS)
{
StudioCalcAttachments( );
IEngineStudio.StudioClientEvents( );
// copy attachments into global entity array
if ( m_pCurrentEntity->index > 0 )
{
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( m_pCurrentEntity->index );
memcpy( ent->attachment, m_pCurrentEntity->attachment, sizeof( vec3_t ) * 4 );
}
}
if (flags & STUDIO_RENDER)
{
/*
if (m_pCvarHiModels->value && m_pRenderModel != m_pCurrentEntity->model )
{
// show highest resolution multiplayer model
m_pCurrentEntity->curstate.body = 255;
}
if (!(m_pCvarDeveloper->value == 0 && gEngfuncs.GetMaxClients() == 1 ) && ( m_pRenderModel == m_pCurrentEntity->model ) )
{
m_pCurrentEntity->curstate.body = 1; // force helmet
}
*/
lighting.plightvec = dir;
IEngineStudio.StudioDynamicLight(m_pCurrentEntity, &lighting );
IEngineStudio.StudioEntityLight( &lighting );
// model and frame independant
IEngineStudio.StudioSetupLighting (&lighting);
m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
// get remap colors
m_nTopColor = m_pPlayerInfo->topcolor;
if (m_nTopColor < 0)
m_nTopColor = 0;
if (m_nTopColor > 360)
m_nTopColor = 360;
m_nBottomColor = m_pPlayerInfo->bottomcolor;
if (m_nBottomColor < 0)
m_nBottomColor = 0;
if (m_nBottomColor > 360)
m_nBottomColor = 360;
IEngineStudio.StudioSetRemapColors( m_nTopColor, m_nBottomColor );
StudioRenderModel( );
m_pPlayerInfo = NULL;
if (pplayer->weaponmodel)
{
cl_entity_t saveent = *m_pCurrentEntity;
model_t *pweaponmodel = IEngineStudio.GetModelByIndex( pplayer->weaponmodel );
m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata (pweaponmodel);
IEngineStudio.StudioSetHeader( m_pStudioHeader );
StudioMergeBones( pweaponmodel);
IEngineStudio.StudioSetupLighting (&lighting);
StudioRenderModel( );
StudioCalcAttachments( );
*m_pCurrentEntity = saveent;
}
}
return 1;
}
/*
====================
Studio_FxTransform
====================
*/
void CGameStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[3][4] )
{
switch( ent->curstate.renderfx )
{
case kRenderFxDistort:
case kRenderFxHologram:
if ( gEngfuncs.pfnRandomLong(0,49) == 0 )
{
int axis = gEngfuncs.pfnRandomLong(0,1);
if ( axis == 1 ) // Choose between x & z
axis = 2;
VectorScale( transform[axis], gEngfuncs.pfnRandomFloat(1,1.484), transform[axis] );
}
else if ( gEngfuncs.pfnRandomLong(0,49) == 0 )
{
float offset;
int axis = gEngfuncs.pfnRandomLong(0,1);
if ( axis == 1 ) // Choose between x & z
axis = 2;
offset = gEngfuncs.pfnRandomFloat(-10,10);
transform[gEngfuncs.pfnRandomLong(0,2)][3] += offset;
}
break;
case kRenderFxExplode:
{
if ( iRenderStateChanged )
{
g_flStartScaleTime = m_clTime;
iRenderStateChanged = FALSE;
}
// Make the Model continue to shrink
float flTimeDelta = m_clTime - g_flStartScaleTime;
if ( flTimeDelta > 0 )
{
float flScale = 0.001;
// Goes almost all away
if ( flTimeDelta <= 2.0 )
flScale = 1.0 - (flTimeDelta / 2.0);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
transform[i][j] *= flScale;
}
}
}
break;
}
}
////////////////////////////////////
// Hooks to class implementation
////////////////////////////////////
/*
====================
R_StudioDrawPlayer
====================
*/
int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
{
return g_StudioRenderer.StudioDrawPlayer( flags, pplayer );
}
/*
====================
R_StudioDrawModel
====================
*/
int R_StudioDrawModel( int flags )
{
return g_StudioRenderer.StudioDrawModel( flags );
}
/*
====================
R_StudioInit
====================
*/
void R_StudioInit( void )
{
g_StudioRenderer.Init();
}
// The simple drawing interface we'll pass back to the engine
r_studio_interface_t studio =
{
STUDIO_INTERFACE_VERSION,
R_StudioDrawModel,
R_StudioDrawPlayer,
};
/*
====================
HUD_GetStudioModelInterface
Export this function for the engine to use the studio renderer class to render objects.
====================
*/
#define DLLEXPORT __declspec( dllexport )
extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{
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 ) );
// Initialize local variables, etc.
R_StudioInit();
// Success
return 1;
}

View file

@ -0,0 +1,55 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( GAMESTUDIOMODELRENDERER_H )
#define GAMESTUDIOMODELRENDERER_H
#if defined( _WIN32 )
#pragma once
#endif
/*
====================
CGameStudioModelRenderer
====================
*/
class CGameStudioModelRenderer : public CStudioModelRenderer
{
public:
CGameStudioModelRenderer( void );
// Set up model bone positions
virtual void StudioSetupBones ( void );
// Estimate gait frame for player
virtual void StudioEstimateGait ( entity_state_t *pplayer );
// Process movement of player
virtual void StudioProcessGait ( entity_state_t *pplayer );
// Player drawing code
virtual int StudioDrawPlayer( int flags, entity_state_t *pplayer );
virtual int _StudioDrawPlayer( int flags, entity_state_t *pplayer );
// Apply special effects to transform matrix
virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] );
private:
// For local player, in third person, we need to store real render data and then
// setup for with fake/client side animation data
void SavePlayerState( entity_state_t *pplayer );
// Called to set up local player's animation values
void SetupClientAnimation( entity_state_t *pplayer );
// Called to restore original player state information
void RestorePlayerState( entity_state_t *pplayer );
private:
// Private data
bool m_bLocal;
};
#endif // GAMESTUDIOMODELRENDERER_H

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,189 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined ( STUDIOMODELRENDERER_H )
#define STUDIOMODELRENDERER_H
#if defined( _WIN32 )
#pragma once
#endif
/*
====================
CStudioModelRenderer
====================
*/
class CStudioModelRenderer
{
public:
// Construction/Destruction
CStudioModelRenderer( void );
virtual ~CStudioModelRenderer( void );
// Initialization
virtual void Init( void );
public:
// Public Interfaces
virtual int StudioDrawModel ( int flags );
virtual int 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 );
// Interpolate model position and angles and set up matrices
virtual void StudioSetUpTransform (int trivial_accept);
// Set up model bone positions
virtual void StudioSetupBones ( void );
// Find final attachment points
virtual void StudioCalcAttachments ( void );
// Save bone matrices and names
virtual void StudioSaveBones( void );
// Merge cached bones with current bones for model
virtual void StudioMergeBones ( model_t *m_pSubModel );
// Determine interpolation fraction
virtual float StudioEstimateInterpolant( void );
// Determine current frame for rendering
virtual float StudioEstimateFrame ( mstudioseqdesc_t *pseqdesc );
// Apply special effects to transform matrix
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 );
// Compute bone adjustments ( bone controllers )
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 );
// Get bone positions
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 );
// Send bones and verts to renderer
virtual void StudioRenderModel ( void );
// Finalize rendering
virtual void StudioRenderFinal (void);
// GL&D3D vs. Software renderer finishing functions
virtual void StudioRenderFinal_Software ( void );
virtual void StudioRenderFinal_Hardware ( void );
// Player specific data
// Determine pitch and blending amounts for players
virtual void StudioPlayerBlend ( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch );
// Estimate gait frame for player
virtual void StudioEstimateGait ( entity_state_t *pplayer );
// Process movement of player
virtual void StudioProcessGait ( entity_state_t *pplayer );
public:
// Client clock
double m_clTime;
// Old Client clock
double m_clOldTime;
// Do interpolation?
int m_fDoInterp;
// Do gait estimation?
int m_fGaitEstimation;
// Current render frame #
int m_nFrameCount;
// Cvars that studio model code needs to reference
//
// Use high quality models?
cvar_t *m_pCvarHiModels;
// Developer debug output desired?
cvar_t *m_pCvarDeveloper;
// Draw entities bone hit boxes, etc?
cvar_t *m_pCvarDrawEntities;
// The entity which we are currently rendering.
cl_entity_t *m_pCurrentEntity;
// The model for the entity being rendered
model_t *m_pRenderModel;
// Player info for current player, if drawing a player
player_info_t *m_pPlayerInfo;
// The index of the player being drawn
int m_nPlayerIndex;
// The player's gait movement
float m_flGaitMovement;
// Pointer to header block for studio model data
studiohdr_t *m_pStudioHeader;
// Pointers to current body part and submodel
mstudiobodyparts_t *m_pBodyPart;
mstudiomodel_t *m_pSubModel;
// Palette substition for top and bottom of model
int m_nTopColor;
int m_nBottomColor;
//
// Sprite model used for drawing studio model chrome
model_t *m_pChromeSprite;
// Caching
// Number of bones in bone cache
int m_nCachedBones;
// Names of cached bones
char m_nCachedBoneNames[ MAXSTUDIOBONES ][ 32 ];
// Cached bone & light transformation matrices
float m_rgCachedBoneTransform [ MAXSTUDIOBONES ][ 3 ][ 4 ];
float m_rgCachedLightTransform[ MAXSTUDIOBONES ][ 3 ][ 4 ];
// Software renderer scale factors
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_vRenderOrigin[ 3 ];
// Model render counters ( from engine )
int *m_pStudioModelCount;
int *m_pModelsDrawn;
// Matrices
// Model to world transformation
float (*m_protationmatrix)[ 3 ][ 4 ];
// Model to view transformation
float (*m_paliastransform)[ 3 ][ 4 ];
// Concatenated bone and light transforms
float (*m_pbonetransform) [ MAXSTUDIOBONES ][ 3 ][ 4 ];
float (*m_plighttransform)[ MAXSTUDIOBONES ][ 3 ][ 4 ];
};
#endif // STUDIOMODELRENDERER_H

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -21,6 +21,7 @@
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include "pm_shared.h"
#include <string.h>
#include <stdio.h>
@ -538,6 +539,9 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf )
gHUD.m_iHideHUDDisplay = READ_BYTE();
if (gEngfuncs.IsSpectateOnly())
return 1;
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) )
{
static wrect_t nullrc;
@ -581,14 +585,17 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf )
return 0;
}
// Is player dead???
if ((iId == -1) && (iClip == -1))
if ( g_iUser1 != OBS_IN_EYE )
{
gHUD.m_fPlayerDead = TRUE;
gpActiveSel = NULL;
return 1;
// Is player dead???
if ((iId == -1) && (iClip == -1))
{
gHUD.m_fPlayerDead = TRUE;
gpActiveSel = NULL;
return 1;
}
gHUD.m_fPlayerDead = FALSE;
}
gHUD.m_fPlayerDead = FALSE;
WEAPON *pWeapon = gWR.GetWeapon( iId );
@ -606,22 +613,20 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf )
m_pWeapon = pWeapon;
if ( !(gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
{
if ( gHUD.m_iFOV >= 90 )
{ // normal crosshairs
if (fOnTarget && m_pWeapon->hAutoaim)
SetCrosshair(m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255);
else
SetCrosshair(m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255);
}
if ( gHUD.m_iFOV >= 90 )
{ // normal crosshairs
if (fOnTarget && m_pWeapon->hAutoaim)
SetCrosshair(m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255);
else
{ // zoomed crosshairs
if (fOnTarget && m_pWeapon->hZoomedAutoaim)
SetCrosshair(m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255);
else
SetCrosshair(m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255);
}
SetCrosshair(m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255);
}
else
{ // zoomed crosshairs
if (fOnTarget && m_pWeapon->hZoomedAutoaim)
SetCrosshair(m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255);
else
SetCrosshair(m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255);
}
m_fFade = 200.0f; //!!!

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// Camera.h -- defines and such for a 3rd person camera
// NOTE: must include quakedef.h first

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -31,9 +31,11 @@ extern "C"
#include <string.h>
#include "hud_servers.h"
#include "vgui_int.h"
#include "interface.h"
#define DLLEXPORT __declspec( dllexport )
cl_enginefunc_t gEngfuncs;
CHud gHUD;
TeamFortressViewport *gViewPort = NULL;
@ -51,18 +53,20 @@ Called when the DLL is first loaded.
*/
extern "C"
{
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
int DLLEXPORT HUD_VidInit( void );
int DLLEXPORT HUD_Init( void );
int DLLEXPORT HUD_Redraw( float flTime, int intermission );
int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
int DLLEXPORT HUD_Reset ( void );
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
char DLLEXPORT HUD_PlayerMoveTexture( char *name );
int DLLEXPORT HUD_ConnectionlessPacket( struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
void DLLEXPORT HUD_Frame( double time );
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
int DLLEXPORT HUD_VidInit( void );
void DLLEXPORT HUD_Init( void );
int DLLEXPORT HUD_Redraw( float flTime, int intermission );
int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
void DLLEXPORT HUD_Reset ( void );
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
char DLLEXPORT HUD_PlayerMoveTexture( char *name );
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
void DLLEXPORT HUD_Frame( double time );
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf );
}
/*
@ -106,7 +110,7 @@ HUD_ConnectionlessPacket
size of the response_buffer, so you must zero it out if you choose not to respond.
================================
*/
int DLLEXPORT HUD_ConnectionlessPacket( 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 )
{
// Parse stuff from args
int max_buffer_size = *response_buffer_size;
@ -139,10 +143,6 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{
gEngfuncs = *pEnginefuncs;
//!!! mwh UNDONE We need to think about our versioning strategy. Do we want to try to be compatible
// with previous versions, especially when we're only 'bonus' functionality? Should it be the engine
// that decides if the DLL is compliant?
if (iVersion != CLDLL_INTERFACE_VERSION)
return 0;
@ -183,13 +183,11 @@ the hud variables.
==========================
*/
int DLLEXPORT HUD_Init( void )
void DLLEXPORT HUD_Init( void )
{
InitInput();
gHUD.Init();
Scheme_Init();
return 1;
}
@ -238,10 +236,9 @@ Called at start and end of demos to restore to "non"HUD state.
==========================
*/
int DLLEXPORT HUD_Reset( void )
void DLLEXPORT HUD_Reset( void )
{
gHUD.VidInit();
return 1;
}
/*
@ -255,4 +252,35 @@ Called by engine every frame that client .dll is loaded
void DLLEXPORT HUD_Frame( double time )
{
ServersThink( time );
}
GetClientVoiceMgr()->Frame(time);
}
/*
==========================
HUD_VoiceStatus
Called when a player starts or stops talking.
==========================
*/
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking)
{
GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
}
/*
==========================
HUD_DirectorEvent
Called when a director event message was received
==========================
*/
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )
{
gHUD.m_Spectator.DirectorMessage( iSize, pbuf );
}

View file

@ -23,8 +23,8 @@ CFG=cl_dll - Win32 Release
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/GoldSrc/cl_dll", HGEBAAAA"
# PROP Scc_LocalPath "."
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\utils\vgui\include" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "..\utils\vgui\include" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
@ -54,15 +54,6 @@ BSC32=bscmake.exe
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib winmm.lib ../utils/vgui/lib/win32_vc6/vgui.lib wsock32.lib /nologo /subsystem:windows /dll /map /machine:I386 /out:".\Release\client.dll"
# Begin Custom Build - Copying to \quiver\valve\cl_dlls
TargetDir=.\Release
InputPath=.\Release\client.dll
SOURCE="$(InputPath)"
"\quiver\valve\cl_dlls\client.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\client.dll \quiver\valve\cl_dlls
# End Custom Build
!ELSEIF "$(CFG)" == "cl_dll - Win32 Debug"
@ -78,7 +69,7 @@ SOURCE="$(InputPath)"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /G5 /MTd /W3 /Gm /GX /ZI /Od /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\utils\vgui\include" /I "..\dlls" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /YX /FD /c
# ADD CPP /nologo /G5 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\vgui\include" /I "..\game_shared" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
@ -89,15 +80,6 @@ BSC32=bscmake.exe
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
# ADD LINK32 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib winmm.lib ../utils/vgui/lib/win32_vc6/vgui.lib wsock32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:".\Debug\client.dll"
# Begin Custom Build - Copying to \half-life\mp\cl_dlls
TargetDir=.\Debug
InputPath=.\Debug\client.dll
SOURCE="$(InputPath)"
"\half-life\mp\cl_dlls\client.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\client.dll \half-life\mp\cl_dlls
# End Custom Build
!ENDIF
@ -110,13 +92,33 @@ SOURCE="$(InputPath)"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
# Begin Group "hl"
# PROP Default_Filter "*.cpp"
# PROP Default_Filter "*.CPP"
# Begin Source File
SOURCE=..\dlls\crossbow.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\crowbar.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\egon.cpp
# End Source File
# Begin Source File
SOURCE=.\ev_hldm.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\gauss.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\handgrenade.cpp
# End Source File
# Begin Source File
SOURCE=.\hl\hl_baseentity.cpp
# End Source File
# Begin Source File
@ -135,6 +137,58 @@ SOURCE=.\hl\hl_weapons.cpp
SOURCE=..\dlls\wpn_shared\hl_wpn_glock.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\hornetgun.cpp
# End Source File
# Begin Source File
SOURCE=..\common\interface.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\mp5.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\python.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\rpg.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\satchel.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\shotgun.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\squeakgrenade.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\tripmine.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\vgui_scrollbar2.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\vgui_slider2.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\voice_banmgr.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\voice_status.cpp
# End Source File
# End Group
# Begin Source File
@ -186,6 +240,10 @@ SOURCE=.\flashlight.cpp
# End Source File
# Begin Source File
SOURCE=.\GameStudioModelRenderer.cpp
# End Source File
# Begin Source File
SOURCE=.\geiger.cpp
# End Source File
# Begin Source File
@ -210,6 +268,10 @@ SOURCE=.\hud_servers.cpp
# End Source File
# Begin Source File
SOURCE=.\hud_spectator.cpp
# End Source File
# Begin Source File
SOURCE=.\hud_update.cpp
# End Source File
# Begin Source File
@ -234,6 +296,11 @@ SOURCE=.\message.cpp
# End Source File
# Begin Source File
SOURCE=.\overview.cpp
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\parsemsg.cpp
# End Source File
# Begin Source File
@ -266,6 +333,14 @@ SOURCE=.\statusbar.cpp
# End Source File
# Begin Source File
SOURCE=.\studio_util.cpp
# End Source File
# Begin Source File
SOURCE=.\StudioModelRenderer.cpp
# End Source File
# Begin Source File
SOURCE=.\text_message.cpp
# End Source File
# Begin Source File
@ -282,6 +357,10 @@ SOURCE=.\util.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\vgui_checkbutton2.cpp
# End Source File
# Begin Source File
SOURCE=.\vgui_ClassMenu.cpp
# End Source File
# Begin Source File
@ -298,10 +377,26 @@ SOURCE=.\vgui_CustomObjects.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\vgui_grid.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\vgui_helpers.cpp
# End Source File
# Begin Source File
SOURCE=.\vgui_int.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\vgui_listbox.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\vgui_loadtga.cpp
# End Source File
# Begin Source File
SOURCE=.\vgui_MOTDWindow.cpp
# End Source File
# Begin Source File
@ -318,6 +413,10 @@ SOURCE=.\vgui_ServerBrowser.cpp
# End Source File
# Begin Source File
SOURCE=.\vgui_SpectatorPanel.cpp
# End Source File
# Begin Source File
SOURCE=.\vgui_TeamFortressViewport.cpp
# End Source File
# Begin Source File
@ -366,6 +465,10 @@ SOURCE=.\eventscripts.h
# End Source File
# Begin Source File
SOURCE=.\GameStudioModelRenderer.h
# End Source File
# Begin Source File
SOURCE=.\health.h
# End Source File
# Begin Source File
@ -386,14 +489,26 @@ SOURCE=.\hud_servers_priv.h
# End Source File
# Begin Source File
SOURCE=.\hud_spectator.h
# End Source File
# Begin Source File
SOURCE=.\in_defs.h
# End Source File
# Begin Source File
SOURCE=..\common\itrackeruser.h
# End Source File
# Begin Source File
SOURCE=.\kbutton.h
# End Source File
# Begin Source File
SOURCE=.\overview.h
# End Source File
# Begin Source File
SOURCE=..\pm_shared\pm_debug.h
# End Source File
# Begin Source File
@ -418,6 +533,14 @@ SOURCE=..\pm_shared\pm_shared.h
# End Source File
# Begin Source File
SOURCE=.\studio_util.h
# End Source File
# Begin Source File
SOURCE=.\StudioModelRenderer.h
# End Source File
# Begin Source File
SOURCE=.\util.h
# End Source File
# Begin Source File
@ -450,6 +573,10 @@ SOURCE=.\vgui_ServerBrowser.h
# End Source File
# Begin Source File
SOURCE=.\vgui_SpectatorPanel.h
# End Source File
# Begin Source File
SOURCE=.\vgui_TeamFortressViewport.h
# End Source File
# Begin Source File
@ -458,6 +585,18 @@ SOURCE=.\view.h
# End Source File
# Begin Source File
SOURCE=..\game_shared\voice_banmgr.h
# End Source File
# Begin Source File
SOURCE=..\game_shared\voice_status.h
# End Source File
# Begin Source File
SOURCE=..\game_shared\voice_vgui_tweakdlg.h
# End Source File
# Begin Source File
SOURCE=.\wrect.h
# End Source File
# End Group

View file

@ -1,33 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "cl_dll"=.\cl_dll.dsp - Package Owner=<4>
Package=<5>
{{{
begin source code control
"$/HLStandardSDK/SourceCode/cl_dll", NUWHAAAA
.
end source code control
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -67,6 +67,14 @@ inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int fl
// ScreenWidth returns the width of the screen, in pixels
#define ScreenWidth (gHUD.m_scrinfo.iWidth)
// Use this to set any co-ords in 640x480 space
#define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f))
#define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f))
// 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 GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
#define ServerCmd (*gEngfuncs.pfnServerCmd)
#define ClientCmd (*gEngfuncs.pfnClientCmd)
@ -128,7 +136,7 @@ void ScaleColors( int &r, int &g, int &b, int a );
#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];}
#define VectorClear(a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;}
inline void VectorClear(float *a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;}
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);

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -133,7 +133,7 @@ void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short event
vec3_t ang;
if ( !g_runfuncs || !g_finalstate )
return;
return;
// Weapon prediction events are assumed to occur at the player's origin
org = g_finalstate->playerstate.origin;

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// com_weapons.h
// Shared weapons common function prototypes
#if !defined( COM_WEAPONSH )

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -41,7 +41,7 @@ struct DeathNoticeItem {
#define MAX_DEATHNOTICES 4
static int DEATHNOTICE_DISPLAY_TIME = 6;
#define DEATHNOTICE_TOP 20
#define DEATHNOTICE_TOP 32
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
@ -49,6 +49,7 @@ 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 )
{
@ -58,6 +59,9 @@ float *GetClientColor( int clientIndex )
case 2: return g_ColorRed;
case 3: return g_ColorYellow;
case 4: return g_ColorGreen;
case 0: return g_ColorYellow;
default : return g_ColorGrey;
}
return NULL;
@ -111,7 +115,7 @@ int CHudDeathNotice :: Draw( float flTime )
if ( gViewPort && gViewPort->AllowedToPrintText() )
{
// Draw the death notice
y = DEATHNOTICE_TOP + (20 * i); //!!!
y = YRES(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);
@ -168,6 +172,8 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
if (gViewPort)
gViewPort->DeathMsg( killer, victim );
gHUD.m_Spectator.DeathMessage(victim);
for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
{
if ( rgDeathNoticeList[i].iId == 0 )

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( DEMOH )
#define DEMOH
#pragma once

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// Client side entity management functions
#include <memory.h>
@ -11,6 +18,7 @@
#include "event_api.h"
#include "pm_defs.h"
#include "pmtrace.h"
#include "pm_shared.h"
#define DLLEXPORT __declspec( dllexport )
@ -18,6 +26,8 @@ void Game_AddObjects( void );
extern vec3_t v_origin;
int g_iAlive = 1;
extern "C"
{
int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname );
@ -48,6 +58,20 @@ int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *mode
default:
break;
}
// 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
// it to filter the overview entities
if ( 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
}
return 1;
}
@ -68,6 +92,12 @@ void DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const stru
// Spectator
state->iuser1 = client->iuser1;
state->iuser2 = client->iuser2;
// Duck prevention
state->iuser3 = client->iuser3;
// Fire prevention
state->iuser4 = client->iuser4;
}
/*
@ -127,8 +157,10 @@ void DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct
{
g_iPlayerClass = dst->playerclass;
g_iTeamNumber = dst->team;
g_iUser1 = src->iuser1;
g_iUser2 = src->iuser2;
g_iUser3 = src->iuser3;
}
}
@ -163,10 +195,37 @@ void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct
pcd->deadflag = ppcd->deadflag;
// Spectating or not dead == get control over view angles.
g_iAlive = ( ppcd->iuser1 || ( pcd->deadflag == DEAD_NO ) ) ? 1 : 0;
// Spectator
pcd->iuser1 = ppcd->iuser1;
pcd->iuser2 = ppcd->iuser2;
// Duck prevention
pcd->iuser3 = ppcd->iuser3;
if ( 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->iuser2 = g_iUser2; // first target
pcd->iuser3 = g_iUser3; // second target
}
// Fire prevention
pcd->iuser4 = ppcd->iuser4;
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 );
memcpy( wd, pwd, 32 * sizeof( weapon_data_t ) );
}
@ -479,6 +538,8 @@ void DLLEXPORT HUD_CreateEntities( void )
// Add in any game specific objects
Game_AddObjects();
GetClientVoiceMgr()->CreateEntities();
}
/*
@ -669,6 +730,7 @@ void DLLEXPORT HUD_TempEntUpdate (
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
{
for ( i = 0; i < 3; i++ )
@ -911,4 +973,5 @@ cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index )
#else
return NULL;
#endif
}
}

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -23,7 +23,9 @@
#include "eventscripts.h"
#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)) )
/*
=================
GetEntity
@ -84,7 +86,11 @@ Is the entity == the local player
*/
qboolean EV_IsLocal( int idx )
{
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
// check if we are in some way in first person spec mode
if ( IS_FIRSTPERSON_SPEC )
return (g_iUser2 == idx);
else
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
}
/*
@ -106,7 +112,8 @@ void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
if ( EV_IsPlayer( idx ) )
{
if ( EV_IsLocal( idx ) )
// in spec mode use entity viewheigh, not own
if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC )
{
// Grab predicted result for local player
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined ( EV_HLDMH )
#define EV_HLDMH
@ -83,6 +90,6 @@ enum gauss_e {
void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName );
void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType );
int 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 *vecSpread, float flDistance, 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 );
#endif // EV_HLDMH

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "hud.h"
#include "cl_util.h"

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// eventscripts.h
#if !defined ( EVENTSCRIPTSH )
#define EVENTSCRIPTSH

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -173,10 +173,7 @@ int CHudHealth::Draw(float flTime)
int a = 0, x, y;
int HealthWidth;
// if (m_iHealth <= 0)
// return 1;
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() )
return 1;
if ( !m_hSprite )

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -27,6 +27,8 @@ This file contains "stubs" of class member implementations so that we can predic
#include "player.h"
#include "weapons.h"
#include "nodes.h"
#include "soundent.h"
#include "skill.h"
// Globals used by game logic
const Vector g_vecZero = Vector( 0, 0, 0 );
@ -91,24 +93,95 @@ void CGrenade::Explode( Vector, Vector ) { }
void CGrenade::Explode( TraceResult *, int ) { }
void CGrenade::Killed( entvars_t *, int ) { }
void CGrenade::Spawn( void ) { }
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;}
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 ( void ) { return TRUE; }
void CBaseMonster :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { }
void CBaseMonster :: BarnacleVictimReleased ( void ) { }
void CBaseMonster :: Listen ( void ) { }
float CBaseMonster :: FLSoundVolume ( CSound *pSound ) { return 0.0; }
BOOL CBaseMonster :: FValidateHintType ( short sHint ) { return FALSE; }
void CBaseMonster :: Look ( int iDistance ) { }
int CBaseMonster :: ISoundMask ( void ) { return 0; }
CSound* CBaseMonster :: PBestSound ( void ) { return NULL; }
CSound* CBaseMonster :: PBestScent ( void ) { return NULL; }
float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) { return 0.0; }
void CBaseMonster :: MonsterThink ( void ) { }
void CBaseMonster :: MonsterUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { }
int CBaseMonster :: IgnoreConditions ( void ) { return 0; }
void CBaseMonster :: RouteClear ( void ) { }
void CBaseMonster :: RouteNew ( void ) { }
BOOL CBaseMonster :: FRouteClear ( void ) { return FALSE; }
BOOL CBaseMonster :: FRefreshRoute ( void ) { return 0; }
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; }
int ShouldSimplify( int routeType ) { return TRUE; }
void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) { }
BOOL CBaseMonster :: FBecomeProne ( void ) { 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 ( void ) { return FALSE; }
int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) { return 0; }
void CBaseMonster :: PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { }
BOOL CBaseMonster :: PopEnemy( ) { return FALSE; }
void CBaseMonster :: SetActivity ( Activity NewActivity ) { }
void CBaseMonster :: SetSequenceByName ( 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 ) { }
void CBaseMonster :: MonsterInitThink ( void ) { }
void CBaseMonster :: StartMonster ( void ) { }
void CBaseMonster :: MovementComplete( void ) { }
int CBaseMonster::TaskIsRunning( void ) { return 0; }
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 ( void ) { 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 ( void ) { 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 ( void ) { }
int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; }
void CBaseAnimating :: ResetSequenceInfo ( ) { }
BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; }
void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { }
void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) { }
float CBaseAnimating :: SetBoneController ( int iController, float flValue ) { return 0.0; }
void CBaseAnimating :: InitBoneControllers ( void ) { }
float CBaseAnimating :: SetBlending ( int iBlender, float flValue ) { return 0; }
@ -118,16 +191,30 @@ int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, in
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( void ) { return g_vecZero; }
void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
void CBaseEntity::FireBullets(ULONG 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 ( void ) { return NO_NODE; }
void CBaseMonster::ReportAIState( void ) { }
void CBaseMonster :: KeyValue( KeyValueData *pkvd ) { }
BOOL CBaseMonster :: FCheckAITrigger ( void ) { return FALSE; }
int 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( void ) { return FALSE; }
BOOL CBaseMonster :: FCanActiveIdle ( void ) { 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 ) { }
void CBaseMonster::CorpseFallThink( void ) { }
void CBaseMonster :: MonsterInitDead( void ) { }
BOOL CBaseMonster :: BBoxFlat ( void ) { return TRUE; }
BOOL CBaseMonster :: GetEnemy ( void ) { return FALSE; }
void CBaseMonster :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
CBaseEntity* CBaseMonster :: DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; }
BOOL CBaseMonster :: ShouldFadeOnDeath( void ) { 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 ) { }
@ -136,16 +223,26 @@ void CBaseMonster :: GibMonster( void ) { }
BOOL CBaseMonster :: HasHumanGibs( void ) { return FALSE; }
BOOL CBaseMonster :: HasAlienGibs( void ) { return FALSE; }
Activity CBaseMonster :: GetDeathActivity ( void ) { return ACT_DIE_HEADSHOT; }
MONSTERSTATE CBaseMonster :: GetIdealState ( void ) { return MONSTERSTATE_ALERT; }
Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type ) { return NULL; }
Schedule_t *CBaseMonster :: GetSchedule ( void ) { 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 ) {}
void CBaseMonster :: RunAI ( void ) {}
void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) {}
int CBaseMonster :: TakeHealth (float flHealth, int bitsDamageType) { return 0; }
int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
int CBaseMonster::Restore( class CRestore & ) { return 1; }
int CBaseMonster::Save( class CSave & ) { return 1; }
int TrainSpeed(int iSpeed, int iMax) { return 0; }
void CBasePlayer :: DeathSound( void ) { }
int CBasePlayer :: TakeHealth( float flHealth, int bitsDamageType ) { return 0; }
void CBasePlayer :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
void CBasePlayer::PackDeadPlayerItems( void ) { }
void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { }
void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) { }
void CBasePlayer::WaterMove() { }
@ -157,8 +254,6 @@ void CBasePlayer::PlayerUse ( void ) { }
void CBasePlayer::Jump() { }
void CBasePlayer::Duck( ) { }
int CBasePlayer::Classify ( void ) { return 0; }
void CBasePlayer :: PlayStepSound(int step, float fvol) { }
void CBasePlayer :: UpdateStepSound( void ) { }
void CBasePlayer::PreThink(void) { }
void CBasePlayer::CheckTimeBasedDamage() { }
void CBasePlayer :: UpdateGeigerCounter( void ) { }
@ -247,4 +342,6 @@ void CBasePlayerAmmo::Materialize( void ) { }
void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther ) { }
int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { return 0; }
int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return 0; }
void CBasePlayerWeapon::RetireWeapon( void ) { }
void CBasePlayerWeapon::RetireWeapon( void ) { }
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

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -24,9 +24,22 @@ void EV_FireGlock2( struct event_args_s *args );
void EV_FireShotGunSingle( struct event_args_s *args );
void EV_FireShotGunDouble( struct event_args_s *args );
void EV_FireMP5( struct event_args_s *args );
void EV_FireMP52( struct event_args_s *args );
void EV_FirePython( struct event_args_s *args );
void EV_FireGauss( struct event_args_s *args );
void EV_SpinGauss( struct event_args_s *args );
void EV_Crowbar( struct event_args_s *args );
void EV_FireCrossbow( struct event_args_s *args );
void EV_FireCrossbow2( struct event_args_s *args );
void EV_FireRpg( struct event_args_s *args );
void EV_EgonFire( struct event_args_s *args );
void EV_EgonStop( struct event_args_s *args );
void EV_HornetGunFire( struct event_args_s *args );
void EV_TripmineFire( struct event_args_s *args );
void EV_SnarkFire( struct event_args_s *args );
void EV_TrainPitchAdjust( struct event_args_s *args );
}
@ -50,8 +63,18 @@ void Game_HookEvents( void )
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

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -16,6 +16,66 @@
#include "../cl_util.h"
#include "../demo.h"
#include "demo_api.h"
#include "const.h"
#include "entity_state.h"
#include "cl_entity.h"
#include "pm_defs.h"
#include "event_api.h"
#include "entity_types.h"
#include "r_efx.h"
extern BEAM *pBeam;
extern BEAM *pBeam2;
void HUD_GetLastOrg( float *org );
void UpdateBeams ( void )
{
vec3_t forward, vecSrc, vecEnd, origin, angles, right, up;
vec3_t view_ofs;
pmtrace_t tr;
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer();
int idx = pthisplayer->index;
// Get our exact viewangles from engine
gEngfuncs.GetViewAngles( (float *)angles );
// Determine our last predicted origin
HUD_GetLastOrg( (float *)&origin );
AngleVectors( angles, forward, right, up );
VectorCopy( origin, vecSrc );
VectorMA( vecSrc, 2048, forward, vecEnd );
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
// 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 );
gEngfuncs.pEventAPI->EV_PopPMStates();
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.
}
}
/*
=====================
Game_AddObjects
@ -25,4 +85,6 @@ Add game specific, client-side objects here
*/
void Game_AddObjects( void )
{
}
if ( pBeam && pBeam2 )
UpdateBeams();
}

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -32,6 +32,7 @@
#include "../demo.h"
extern globalvars_t *gpGlobals;
extern int g_iUser1;
// Pool of client side entities/entvars_t
static entvars_t ev[ 32 ];
@ -45,8 +46,27 @@ static globalvars_t Globals;
static CBasePlayerWeapon *g_pWpns[ 32 ];
float g_flApplyVel = 0.0;
int g_irunninggausspred = 0;
vec3_t previousorigin;
// HLDM Weapon placeholder entities.
CGlock g_Glock;
CCrowbar g_Crowbar;
CPython g_Python;
CMP5 g_Mp5;
CCrossbow g_Crossbow;
CShotgun g_Shotgun;
CRpg g_Rpg;
CGauss g_Gauss;
CEgon g_Egon;
CHgun g_HGun;
CHandGrenade g_HandGren;
CSatchel g_Satchel;
CTripmine g_Tripmine;
CSqueak g_Snark;
/*
======================
@ -68,6 +88,18 @@ void AlertMessage( ALERT_TYPE atype, char *szFmt, ... )
gEngfuncs.Con_Printf( string );
}
//Returns if it's multiplayer.
//Mostly used by the client side weapons.
bool bIsMultiplayer ( void )
{
return gEngfuncs.GetMaxClients() == 1 ? 0 : 1;
}
//Just loads a v_ model.
void LoadVModel ( char *szViewModel, CBasePlayer *m_pPlayer )
{
gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel );
}
/*
=====================
HUD_PrepEntity
@ -113,9 +145,9 @@ void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib )
CBasePlayerWeapon :: DefaultReload
=====================
*/
BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay )
BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay, int body )
{
#if 0 // FIXME, need to know primary ammo to get this right
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
return FALSE;
@ -123,12 +155,11 @@ BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay
if (j == 0)
return FALSE;
#endif
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay;
//!!UNDONE -- reload sound goes here !!!
SendWeaponAnim( iAnim );
SendWeaponAnim( iAnim, UseDecrement(), body );
m_fInReload = TRUE;
@ -177,15 +208,16 @@ CBasePlayerWeapon :: DefaultDeploy
=====================
*/
BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal )
BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal, int body )
{
if ( !CanDeploy() )
return FALSE;
gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel );
SendWeaponAnim( iAnim );
SendWeaponAnim( iAnim, skiplocal, body );
g_irunninggausspred = false;
m_pPlayer->m_flNextAttack = 0.5;
m_flTimeWeaponIdle = 1.0;
return TRUE;
@ -229,6 +261,7 @@ Put away weapon
void CBasePlayerWeapon::Holster( int skiplocal /* = 0 */ )
{
m_fInReload = FALSE; // cancel any reload in progress.
g_irunninggausspred = false;
m_pPlayer->pev->viewmodel = 0;
}
@ -239,15 +272,49 @@ CBasePlayerWeapon::SendWeaponAnim
Animate weapon model
=====================
*/
void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal )
void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body )
{
m_pPlayer->pev->weaponanim = iAnim;
int body = 0;
HUD_SendWeaponAnim( iAnim, body, 0 );
}
/*
=====================
CBaseEntity::FireBulletsPlayer
Only produces random numbers to match the server ones.
=====================
*/
Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker, int shared_rand )
{
float x, y, z;
for ( ULONG iShot = 1; iShot <= cShots; iShot++ )
{
if ( pevAttacker == NULL )
{
// get circular gaussian spread
do {
x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5);
y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5);
z = x*x+y*y;
} while (z > 1);
}
else
{
//Use player's random seed.
// get circular gaussian spread
x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 );
y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 );
z = x * x + y * y;
}
}
return Vector ( x * vecSpread.x, y * vecSpread.y, 0.0 );
}
/*
=====================
CBasePlayerWeapon::ItemPostFrame
@ -389,8 +456,10 @@ CBasePlayer::Killed
void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib )
{
// Holster weapon immediately, to allow it to cleanup
if (m_pActiveItem)
m_pActiveItem->Holster( );
if ( m_pActiveItem )
m_pActiveItem->Holster( );
g_irunninggausspred = false;
}
/*
@ -403,6 +472,8 @@ void CBasePlayer::Spawn( void )
{
if (m_pActiveItem)
m_pActiveItem->Deploy( );
g_irunninggausspred = false;
}
/*
@ -551,6 +622,55 @@ void HUD_InitClientWeapons( void )
// Allocate slot(s) for each weapon that we are going to be predicting
HUD_PrepEntity( &g_Glock , &player );
HUD_PrepEntity( &g_Crowbar , &player );
HUD_PrepEntity( &g_Python , &player );
HUD_PrepEntity( &g_Mp5 , &player );
HUD_PrepEntity( &g_Crossbow , &player );
HUD_PrepEntity( &g_Shotgun , &player );
HUD_PrepEntity( &g_Rpg , &player );
HUD_PrepEntity( &g_Gauss , &player );
HUD_PrepEntity( &g_Egon , &player );
HUD_PrepEntity( &g_HGun , &player );
HUD_PrepEntity( &g_HandGren , &player );
HUD_PrepEntity( &g_Satchel , &player );
HUD_PrepEntity( &g_Tripmine , &player );
HUD_PrepEntity( &g_Snark , &player );
}
/*
=====================
HUD_GetLastOrg
Retruns the last position that we stored for egon beam endpoint.
=====================
*/
void HUD_GetLastOrg( float *org )
{
int i;
// Return last origin
for ( i = 0; i < 3; i++ )
{
org[i] = previousorigin[i];
}
}
/*
=====================
HUD_SetLastOrg
Remember our exact predicted origin so we can draw the egon to the right position.
=====================
*/
void HUD_SetLastOrg( void )
{
int i;
// Offset final origin by view_offset
for ( i = 0; i < 3; i++ )
{
previousorigin[i] = g_finalstate->playerstate.origin[i] + g_finalstate->client.view_ofs[ i ];
}
}
/*
@ -580,9 +700,83 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
// FIXME, make this a method in each weapon? where you pass in an entity_state_t *?
switch ( from->client.m_iId )
{
case WEAPON_GLOCK:
pWeapon = &g_Glock;
break;
case WEAPON_CROWBAR:
pWeapon = &g_Crowbar;
break;
case WEAPON_GLOCK:
pWeapon = &g_Glock;
break;
case WEAPON_PYTHON:
pWeapon = &g_Python;
break;
case WEAPON_MP5:
pWeapon = &g_Mp5;
break;
case WEAPON_CROSSBOW:
pWeapon = &g_Crossbow;
break;
case WEAPON_SHOTGUN:
pWeapon = &g_Shotgun;
break;
case WEAPON_RPG:
pWeapon = &g_Rpg;
break;
case WEAPON_GAUSS:
pWeapon = &g_Gauss;
break;
case WEAPON_EGON:
pWeapon = &g_Egon;
break;
case WEAPON_HORNETGUN:
pWeapon = &g_HGun;
break;
case WEAPON_HANDGRENADE:
pWeapon = &g_HandGren;
break;
case WEAPON_SATCHEL:
pWeapon = &g_Satchel;
break;
case WEAPON_TRIPMINE:
pWeapon = &g_Tripmine;
break;
case WEAPON_SNARK:
pWeapon = &g_Snark;
break;
}
// Store pointer to our destination entity_state_t so we can get our origin, etc. from it
// for setting up events on the client
g_finalstate = to;
// If we are running events/etc. go ahead and see if we
// managed to die between last frame and this one
// If so, run the appropriate player killed or spawn function
if ( g_runfuncs )
{
if ( to->client.health <= 0 && lasthealth > 0 )
{
player.Killed( NULL, 0 );
}
else if ( to->client.health > 0 && lasthealth <= 0 )
{
player.Spawn();
}
lasthealth = to->client.health;
}
// We are not predicting the current weapon, just bow out here.
@ -600,10 +794,23 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
pfrom = &from->weapondata[ i ];
pCurrent->m_fInReload = pfrom->m_fInReload;
pCurrent->m_fInSpecialReload = pfrom->m_fInSpecialReload;
// pCurrent->m_flPumpTime = pfrom->m_flPumpTime;
pCurrent->m_iClip = pfrom->m_iClip;
pCurrent->m_flNextPrimaryAttack = pfrom->m_flNextPrimaryAttack;
pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack;
pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle;
pCurrent->pev->fuser1 = pfrom->fuser1;
pCurrent->m_flStartThrow = pfrom->fuser2;
pCurrent->m_flReleaseThrow = pfrom->fuser3;
pCurrent->m_chargeReady = pfrom->iuser1;
pCurrent->m_fInAttack = pfrom->iuser2;
pCurrent->m_fireState = pfrom->iuser3;
pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[ 2 ];
pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[ 0 ];
player.m_rgAmmo[ pCurrent->m_iPrimaryAmmoType ] = (int)from->client.vuser4[ 1 ];
player.m_rgAmmo[ pCurrent->m_iSecondaryAmmoType ] = (int)from->client.vuser4[ 2 ];
}
// For random weapon events, use this seed to seed random # generator
@ -634,20 +841,36 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
player.pev->weaponanim = from->client.weaponanim;
player.pev->viewmodel = from->client.viewmodel;
player.m_flNextAttack = from->client.m_flNextAttack;
player.m_flNextAmmoBurn = from->client.fuser2;
player.m_flAmmoStartCharge = from->client.fuser3;
//Stores all our ammo info, so the client side weapons can use them.
player.ammo_9mm = (int)from->client.vuser1[0];
player.ammo_357 = (int)from->client.vuser1[1];
player.ammo_argrens = (int)from->client.vuser1[2];
player.ammo_bolts = (int)from->client.ammo_nails; //is an int anyways...
player.ammo_buckshot = (int)from->client.ammo_shells;
player.ammo_uranium = (int)from->client.ammo_cells;
player.ammo_hornets = (int)from->client.vuser2[0];
player.ammo_rockets = (int)from->client.ammo_rockets;
// Point to current weapon object
if ( from->client.m_iId )
{
player.m_pActiveItem = g_pWpns[ from->client.m_iId ];
}
// Store pointer to our destination entity_state_t so we can get our origin, etc. from it
// for setting up events on the client
g_finalstate = to;
if ( player.m_pActiveItem->m_iId == WEAPON_RPG )
{
( ( CRpg * )player.m_pActiveItem)->m_fSpotActive = (int)from->client.vuser2[ 1 ];
( ( CRpg * )player.m_pActiveItem)->m_cActiveRockets = (int)from->client.vuser2[ 2 ];
}
// Don't go firing anything if we have died.
// Or if we don't have a weapon model deployed
if ( ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) && !CL_IsDead() && player.pev->viewmodel )
if ( ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) &&
!CL_IsDead() && player.pev->viewmodel && !g_iUser1 )
{
if ( player.m_flNextAttack <= 0 )
{
@ -655,23 +878,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
}
}
// If we are running events/etc. go ahead and see if we
// managed to die between last frame and this one
// If so, run the appropriate player killed or spawn function
if ( g_runfuncs )
{
if ( to->client.health <= 0 && lasthealth > 0 )
{
player.Killed( NULL, 0 );
}
else if ( to->client.health > 0 && lasthealth <= 0 )
{
player.Spawn();
}
lasthealth = to->client.health;
}
// Assume that we are not going to switch weapons
to->client.m_iId = from->client.m_iId;
@ -703,18 +909,46 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
}
}
// Copy in results of predcition code
// Copy in results of prediction code
to->client.viewmodel = player.pev->viewmodel;
to->client.fov = player.pev->fov;
to->client.weaponanim = player.pev->weaponanim;
to->client.m_flNextAttack = player.m_flNextAttack;
to->client.fuser2 = player.m_flNextAmmoBurn;
to->client.fuser3 = player.m_flAmmoStartCharge;
to->client.maxspeed = player.pev->maxspeed;
//HL Weapons
to->client.vuser1[0] = player.ammo_9mm;
to->client.vuser1[1] = player.ammo_357;
to->client.vuser1[2] = player.ammo_argrens;
to->client.ammo_nails = player.ammo_bolts;
to->client.ammo_shells = player.ammo_buckshot;
to->client.ammo_cells = player.ammo_uranium;
to->client.vuser2[0] = player.ammo_hornets;
to->client.ammo_rockets = player.ammo_rockets;
if ( player.m_pActiveItem->m_iId == WEAPON_RPG )
{
from->client.vuser2[ 1 ] = ( ( CRpg * )player.m_pActiveItem)->m_fSpotActive;
from->client.vuser2[ 2 ] = ( ( CRpg * )player.m_pActiveItem)->m_cActiveRockets;
}
// Make sure that weapon animation matches what the game .dll is telling us
// over the wire ( fixes some animation glitches )
if ( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) )
{
int body = 2;
//Pop the model to body 0.
if ( pWeapon == &g_Tripmine )
body = 0;
//Show laser sight/scope combo
if ( pWeapon == &g_Python && bIsMultiplayer() )
body = 1;
// Force a fixed anim down to viewmodel
HUD_SendWeaponAnim( to->client.weaponanim, body, 1 );
}
@ -732,10 +966,18 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
}
pto->m_fInReload = pCurrent->m_fInReload;
pto->m_fInSpecialReload = pCurrent->m_fInSpecialReload;
// pto->m_flPumpTime = pCurrent->m_flPumpTime;
pto->m_iClip = pCurrent->m_iClip;
pto->m_flNextPrimaryAttack = pCurrent->m_flNextPrimaryAttack;
pto->m_flNextSecondaryAttack = pCurrent->m_flNextSecondaryAttack;
pto->m_flTimeWeaponIdle = pCurrent->m_flTimeWeaponIdle;
pto->fuser1 = pCurrent->pev->fuser1;
pto->fuser2 = pCurrent->m_flStartThrow;
pto->fuser3 = pCurrent->m_flReleaseThrow;
pto->iuser1 = pCurrent->m_chargeReady;
pto->iuser2 = pCurrent->m_fInAttack;
pto->iuser3 = pCurrent->m_fireState;
// Decrement weapon counters, server does this at same time ( during post think, after doing everything else )
pto->m_flNextReload -= cmd->msec / 1000.0;
@ -743,13 +985,19 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
pto->m_flNextPrimaryAttack -= cmd->msec / 1000.0;
pto->m_flNextSecondaryAttack -= cmd->msec / 1000.0;
pto->m_flTimeWeaponIdle -= cmd->msec / 1000.0;
pto->fuser1 -= cmd->msec / 1000.0;
if ( pto->m_flPumpTime != -9999 )
to->client.vuser3[2] = pCurrent->m_iSecondaryAmmoType;
to->client.vuser4[0] = pCurrent->m_iPrimaryAmmoType;
to->client.vuser4[1] = player.m_rgAmmo[ pCurrent->m_iPrimaryAmmoType ];
to->client.vuser4[2] = player.m_rgAmmo[ pCurrent->m_iSecondaryAmmoType ];
/* if ( pto->m_flPumpTime != -9999 )
{
pto->m_flPumpTime -= cmd->msec / 1000.0;
if ( pto->m_flPumpTime < -0.001 )
pto->m_flPumpTime = -0.001;
}
}*/
if ( pto->m_fNextAimBonus < -1.0 )
{
@ -775,6 +1023,11 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
{
pto->m_flNextReload = -0.001;
}
if ( pto->fuser1 < -0.001 )
{
pto->fuser1 = -0.001;
}
}
// m_flNextAttack is now part of the weapons, but is part of the player instead
@ -784,6 +1037,21 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
to->client.m_flNextAttack = -0.001;
}
to->client.fuser2 -= cmd->msec / 1000.0;
if ( to->client.fuser2 < -0.001 )
{
to->client.fuser2 = -0.001;
}
to->client.fuser3 -= cmd->msec / 1000.0;
if ( to->client.fuser3 < -0.001 )
{
to->client.fuser3 = -0.001;
}
// Store off the last position from the predicted state.
HUD_SetLastOrg();
// Wipe it so we can't use it after this frame
g_finalstate = NULL;
}
@ -803,11 +1071,8 @@ void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s
{
g_runfuncs = runfuncs;
// Only run post think stuff for glock for the sample
// implementation
#if defined( CLIENT_WEAPONS )
if ( cl_lw && cl_lw->value &&
from->client.m_iId == WEAPON_GLOCK )
if ( cl_lw && cl_lw->value )
{
HUD_WeaponsPostThink( from, to, cmd, time, random_seed );
}
@ -817,6 +1082,14 @@ void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s
to->client.fov = g_lastFOV;
}
if ( g_irunninggausspred == 1 )
{
Vector forward;
gEngfuncs.pfnAngleVectors( v_angles, forward, NULL, NULL );
to->client.velocity = to->client.velocity - forward * g_flApplyVel * 5;
g_irunninggausspred = false;
}
// All games can use FOV state
g_lastFOV = to->client.fov;
}

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -24,10 +24,59 @@
#include <stdio.h>
#include "parsemsg.h"
#include "hud_servers.h"
#include "vgui_int.h"
#include "vgui_TeamFortressViewport.h"
#include "demo.h"
#include "demo_api.h"
#include "vgui_scorepanel.h"
class CHLVoiceStatusHelper : public IVoiceStatusHelper
{
public:
virtual void GetPlayerTextColor(int entindex, int color[3])
{
color[0] = color[1] = color[2] = 255;
if( entindex >= 0 && entindex < sizeof(g_PlayerExtraInfo)/sizeof(g_PlayerExtraInfo[0]) )
{
int iTeam = g_PlayerExtraInfo[entindex].teamnumber;
if ( iTeam < 0 )
{
iTeam = 0;
}
iTeam = iTeam % iNumberOfTeamColors;
color[0] = iTeamColors[iTeam][0];
color[1] = iTeamColors[iTeam][1];
color[2] = iTeamColors[iTeam][2];
}
}
virtual void UpdateCursorState()
{
gViewPort->UpdateCursorState();
}
virtual int GetAckIconHeight()
{
return ScreenHeight - gHUD.m_iFontHeight*3 - 6;
}
virtual bool CanShowSpeakerLabels()
{
if( gViewPort && gViewPort->m_pScoreBoard )
return !gViewPort->m_pScoreBoard->isVisible();
else
return false;
}
};
static CHLVoiceStatusHelper g_VoiceStatusHelper;
extern client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, int iRes, int iCount);
@ -54,6 +103,12 @@ int __MsgFunc_InitHUD(const char *pszName, int iSize, void *pbuf)
return 1;
}
int __MsgFunc_ViewMode(const char *pszName, int iSize, void *pbuf)
{
gHUD.MsgFunc_ViewMode( pszName, iSize, pbuf );
return 1;
}
int __MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
{
return gHUD.MsgFunc_SetFOV( pszName, iSize, pbuf );
@ -74,7 +129,7 @@ void __CmdFunc_OpenCommandMenu(void)
{
if ( gViewPort )
{
gViewPort->ShowCommandMenu();
gViewPort->ShowCommandMenu( gViewPort->m_StandardMenu );
}
}
@ -217,6 +272,7 @@ void CHud :: Init( void )
HOOK_MESSAGE( ResetHUD );
HOOK_MESSAGE( GameMode );
HOOK_MESSAGE( InitHUD );
HOOK_MESSAGE( ViewMode );
HOOK_MESSAGE( SetFOV );
HOOK_MESSAGE( Concuss );
@ -245,13 +301,17 @@ void CHud :: Init( void )
// VGUI Menus
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
m_iLogo = 0;
m_iFOV = 0;
CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 );
default_fov = CVAR_CREATE( "default_fov", "90", 0 );
m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE );
m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE );
cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" );
m_pSpriteList = NULL;
@ -274,6 +334,8 @@ void CHud :: Init( void )
m_Ammo.Init();
m_Health.Init();
m_SayText.Init();
m_Spectator.Init();
m_Geiger.Init();
m_Train.Init();
m_Battery.Init();
@ -284,8 +346,8 @@ void CHud :: Init( void )
m_AmmoSecondary.Init();
m_TextMessage.Init();
m_StatusIcons.Init();
GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort);
m_SayText.Init();
m_Menu.Init();
ServersInit();
@ -419,6 +481,7 @@ void CHud :: VidInit( void )
m_Ammo.VidInit();
m_Health.VidInit();
m_Spectator.VidInit();
m_Geiger.VidInit();
m_Train.VidInit();
m_Battery.VidInit();
@ -431,6 +494,7 @@ void CHud :: VidInit( void )
m_AmmoSecondary.VidInit();
m_TextMessage.VidInit();
m_StatusIcons.VidInit();
GetClientVoiceMgr()->VidInit();
}
int CHud::MsgFunc_Logo(const char *pszName, int iSize, void *pbuf)
@ -544,10 +608,8 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
int newfov = READ_BYTE();
int def_fov = CVAR_GET_FLOAT( "default_fov" );
int tfc = 0;
tfc = HUD_IsGame( "tfc" );
if ( tfc && cl_lw && cl_lw->value )
//Weapon prediction already takes care of changing the fog. ( g_lastFOV ).
if ( cl_lw && cl_lw->value )
return 1;
g_lastFOV = newfov;

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -40,17 +40,26 @@ typedef struct {
int x, y;
} POSITION;
enum
{
MAX_PLAYERS = 64,
MAX_TEAMS = 64,
MAX_TEAM_NAME = 16,
};
typedef struct {
unsigned char r,g,b,a;
} RGBA;
typedef struct cvar_s cvar_t;
#define HUD_ACTIVE 1
#define HUD_INTERMISSION 2
#define MAX_PLAYER_NAME_LENGTH 32
#define MAX_MOTD_LENGTH 1024
#define MAX_MOTD_LENGTH 1536
//
//-----------------------------------------------------
@ -61,6 +70,7 @@ public:
POSITION m_pos;
int m_type;
int m_iFlags; // active, moving,
virtual ~CHudBase() {}
virtual int Init( void ) {return 0;}
virtual int VidInit( void ) {return 0;}
virtual int Draw(float flTime) {return 0;}
@ -76,6 +86,14 @@ struct HUDLIST {
};
//
//-----------------------------------------------------
//
#include "..\game_shared\voice_status.h"
#include "hud_spectator.h"
//
//-----------------------------------------------------
//
@ -236,6 +254,9 @@ protected:
int m_iStatusValues[MAX_STATUSBAR_VALUES]; // an array of values for use in the status bar
int 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];
};
//
@ -273,13 +294,6 @@ private:
};
*/
enum
{
MAX_PLAYERS = 64,
MAX_TEAMS = 64,
MAX_TEAM_NAME = 16,
};
struct extra_player_info_t
{
short frags;
@ -359,6 +373,12 @@ public:
int 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;
};
//
@ -463,6 +483,7 @@ public:
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 MessageScanStart( void );
void MessageScanNextChar( void );
@ -522,7 +543,7 @@ private:
//-----------------------------------------------------
//
typedef struct cvar_s cvar_t;
class CHud
{
@ -550,6 +571,7 @@ public:
int 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 );
@ -580,17 +602,18 @@ public:
int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array
CHudAmmo m_Ammo;
CHudHealth m_Health;
CHudGeiger m_Geiger;
CHudBattery m_Battery;
CHudTrain m_Train;
CHudFlashlight m_Flash;
CHudMessage m_Message;
CHudStatusBar m_StatusBar;
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;
CHudSayText m_SayText;
CHudMenu m_Menu;
CHudAmmoSecondary m_AmmoSecondary;
CHudTextMessage m_TextMessage;
CHudStatusIcons m_StatusIcons;
@ -610,8 +633,10 @@ public:
int _cdecl MsgFunc_Logo(const char *pszName, int iSize, void *pbuf);
int _cdecl MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf);
void _cdecl MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf );
void _cdecl MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf );
int _cdecl MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf);
int _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf );
// Screen information
SCREENINFO m_scrinfo;
@ -638,4 +663,5 @@ extern int g_iPlayerClass;
extern int g_iTeamNumber;
extern int g_iUser1;
extern int g_iUser2;
extern int g_iUser3;

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( HUD_IFACEH )
#define HUD_IFACEH
#pragma once

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -19,6 +19,12 @@
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include "r_efx.h"
#define MAX_CLIENTS 32
extern BEAM *pBeam;
extern BEAM *pBeam2;
/// USER-DEFINED SERVER MESSAGE HANDLERS
@ -45,6 +51,13 @@ int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
return 1;
}
void CAM_ToFirstPerson(void);
void CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
{
CAM_ToFirstPerson();
}
void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
{
// prepare all hud data
@ -56,6 +69,9 @@ void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
pList->p->InitHUDData();
pList = pList->pNext;
}
//Probably not a good place to put this.
pBeam = pBeam2 = NULL;
}
@ -102,4 +118,3 @@ int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
this->m_StatusIcons.DisableIcon("dmg_concuss");
return 1;
}

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -104,11 +104,15 @@ int CHud :: Redraw( float flTime, int intermission )
m_iIntermission = intermission;
gViewPort->HideCommandMenu();
gViewPort->HideScoreBoard();
gViewPort->UpdateSpectatorPanel();
}
else if ( !m_iIntermission && intermission )
{
m_iIntermission = intermission;
gViewPort->HideCommandMenu();
gViewPort->HideVGUIMenu();
gViewPort->ShowScoreBoard();
gViewPort->UpdateSpectatorPanel();
// Take a screenshot if the client's got the cvar set
if ( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
@ -127,22 +131,25 @@ int CHud :: Redraw( float flTime, int intermission )
// if no redrawing is necessary
// return 0;
HUDLIST *pList = m_pHudList;
while (pList)
if ( m_pCvarDraw->value )
{
if ( !intermission )
{
if ( (pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL) )
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 )
pList->p->Draw( flTime );
}
HUDLIST *pList = m_pHudList;
pList = pList->pNext;
while (pList)
{
if ( !intermission )
{
if ( (pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL) )
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 )
pList->p->Draw( flTime );
}
pList = pList->pNext;
}
}
// are we in demo mode? do we need to draw the logo in the top corner?

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// hud_servers.cpp
#include "hud.h"
#include "cl_util.h"

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( HUD_SERVERSH )
#define HUD_SERVERSH
#pragma once

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( HUD_SERVERS_PRIVH )
#define HUD_SERVERS_PRIVH
#pragma once

1623
cl_dll/hud_spectator.cpp Normal file

File diff suppressed because it is too large Load diff

132
cl_dll/hud_spectator.h Normal file
View file

@ -0,0 +1,132 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef SPECTATOR_H
#define SPECTATOR_H
#pragma once
#include "cl_entity.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 MAX_SPEC_HUD_MESSAGES 8
#define OVERVIEW_TILE_SIZE 128 // don't change this
#define OVERVIEW_MAX_LAYERS 1
//-----------------------------------------------------------------------------
// 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
vec3_t 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];
qboolean rotated; // are map images rotated (90 degrees) ?
int insetWindowX;
int insetWindowY;
int insetWindowHeight;
int insetWindowWidth;
} overviewInfo_t;
typedef struct overviewEntity_s {
HSPRITE hSprite;
struct cl_entity_s * entity;
double killTime;
} overviewEntity_t;
#define MAX_OVERVIEW_ENTITIES 128
class CHudSpectator : public CHudBase
{
public:
void Reset();
int ToggleInset(bool allowOff);
void CheckSettings();
void InitHUDData( void );
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 );
void CheckOverviewEntities();
void DrawOverview();
void DrawOverviewEntities();
void GetMapPosition( float * returnvec );
void DrawOverviewLayer();
void LoadMapSprites();
bool ParseOverviewFile();
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 DirectorMessage( int iSize, void *pbuf );
void SetSpectatorStartPosition();
int Init();
int VidInit();
int Draw(float flTime);
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
vec3_t 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;
qboolean m_chatEnabled;
vec3_t m_cameraOrigin; // a help camera
vec3_t m_cameraAngles; // and it's angles
private:
vec3_t 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;
wrect_t 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_zoomDelta;
float m_moveDelta;
int m_lastPrimaryObject;
int m_lastSecondaryObject;
};
#endif // SPECTATOR_H

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "hud.h"
#include "cl_util.h"
#include "camera.h"
@ -605,7 +612,7 @@ void CAM_EndDistance(void)
int DLLEXPORT CL_IsThirdPerson( void )
{
return cam_thirdperson ? 1 : 0;
return (cam_thirdperson ? 1 : 0) || (g_iUser1 && (g_iUser2 == gEngfuncs.GetLocalPlayer()->index) );
}
void DLLEXPORT CL_CameraOffset( float *ofs )

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( IN_DEFSH )
#define IN_DEFSH
#pragma once

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// cl.input.c -- builds an intended movement command to send to the server
//xxxxxx Move bob and pitch drifting code here and other stuff from view if needed
@ -22,6 +29,7 @@ extern "C"
#include "vgui_TeamFortressViewport.h"
extern "C"
{
struct kbutton_s DLLEXPORT *KB_Find( const char *name );
@ -30,6 +38,8 @@ extern "C"
int DLLEXPORT HUD_Key_Event( int eventcode, int keynum, const char *pszCurrentBinding );
}
extern int g_iAlive;
extern int g_weaponselect;
extern cl_enginefunc_t gEngfuncs;
@ -389,18 +399,57 @@ void IN_LeftDown(void) {KeyDown(&in_left);}
void IN_LeftUp(void) {KeyUp(&in_left);}
void IN_RightDown(void) {KeyDown(&in_right);}
void IN_RightUp(void) {KeyUp(&in_right);}
void IN_ForwardDown(void) {KeyDown(&in_forward);}
void IN_ForwardUp(void) {KeyUp(&in_forward);}
void IN_BackDown(void) {KeyDown(&in_back);}
void IN_BackUp(void) {KeyUp(&in_back);}
void IN_ForwardDown(void)
{
KeyDown(&in_forward);
gHUD.m_Spectator.HandleButtonsDown( IN_FORWARD );
}
void IN_ForwardUp(void)
{
KeyUp(&in_forward);
gHUD.m_Spectator.HandleButtonsUp( IN_FORWARD );
}
void IN_BackDown(void)
{
KeyDown(&in_back);
gHUD.m_Spectator.HandleButtonsDown( IN_BACK );
}
void IN_BackUp(void)
{
KeyUp(&in_back);
gHUD.m_Spectator.HandleButtonsUp( IN_BACK );
}
void IN_LookupDown(void) {KeyDown(&in_lookup);}
void IN_LookupUp(void) {KeyUp(&in_lookup);}
void IN_LookdownDown(void) {KeyDown(&in_lookdown);}
void IN_LookdownUp(void) {KeyUp(&in_lookdown);}
void IN_MoveleftDown(void) {KeyDown(&in_moveleft);}
void IN_MoveleftUp(void) {KeyUp(&in_moveleft);}
void IN_MoverightDown(void) {KeyDown(&in_moveright);}
void IN_MoverightUp(void) {KeyUp(&in_moveright);}
void IN_MoveleftDown(void)
{
KeyDown(&in_moveleft);
gHUD.m_Spectator.HandleButtonsDown( IN_MOVELEFT );
}
void IN_MoveleftUp(void)
{
KeyUp(&in_moveleft);
gHUD.m_Spectator.HandleButtonsUp( IN_MOVELEFT );
}
void IN_MoverightDown(void)
{
KeyDown(&in_moveright);
gHUD.m_Spectator.HandleButtonsDown( IN_MOVERIGHT );
}
void IN_MoverightUp(void)
{
KeyUp(&in_moveright);
gHUD.m_Spectator.HandleButtonsUp( IN_MOVERIGHT );
}
void IN_SpeedDown(void) {KeyDown(&in_speed);}
void IN_SpeedUp(void) {KeyUp(&in_speed);}
void IN_StrafeDown(void) {KeyDown(&in_strafe);}
@ -408,18 +457,34 @@ void IN_StrafeUp(void) {KeyUp(&in_strafe);}
// needs capture by hud/vgui also
extern void __CmdFunc_InputPlayerSpecial(void);
void IN_Attack2Down(void)
{
KeyDown(&in_attack2);
__CmdFunc_InputPlayerSpecial();
gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK2 );
}
void IN_Attack2Up(void) {KeyUp(&in_attack2);}
void IN_UseDown (void) {KeyDown(&in_use);}
void IN_UseDown (void)
{
KeyDown(&in_use);
gHUD.m_Spectator.HandleButtonsDown( IN_USE );
}
void IN_UseUp (void) {KeyUp(&in_use);}
void IN_JumpDown (void) {KeyDown(&in_jump);}
void IN_JumpDown (void)
{
KeyDown(&in_jump);
gHUD.m_Spectator.HandleButtonsDown( IN_JUMP );
}
void IN_JumpUp (void) {KeyUp(&in_jump);}
void IN_DuckDown(void) {KeyDown(&in_duck);}
void IN_DuckDown(void)
{
KeyDown(&in_duck);
gHUD.m_Spectator.HandleButtonsDown( IN_DUCK );
}
void IN_DuckUp(void) {KeyUp(&in_duck);}
void IN_ReloadDown(void) {KeyDown(&in_reload);}
void IN_ReloadUp(void) {KeyUp(&in_reload);}
@ -431,6 +496,7 @@ void IN_GraphUp(void) {KeyUp(&in_graph);}
void IN_AttackDown(void)
{
KeyDown( &in_attack );
gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK );
}
void IN_AttackUp(void)
@ -670,6 +736,10 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ
//
cmd->buttons = CL_ButtonBits( 1 );
// If they're in a modal dialog, ignore the attack button.
if(GetClientVoiceMgr()->IsInSquelchMode())
cmd->buttons &= ~IN_ATTACK;
// Using joystick?
if ( in_joystick->value )
{
@ -686,7 +756,7 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ
gEngfuncs.GetViewAngles( (float *)viewangles );
// Set current view angles.
if ( gHUD.m_Health.m_iHealth > 0 )
if ( g_iAlive )
{
VectorCopy( viewangles, cmd->viewangles );
VectorCopy( viewangles, oldangles );
@ -695,6 +765,7 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ
{
VectorCopy( oldangles, cmd->viewangles );
}
}
/*
@ -954,4 +1025,4 @@ void ShutdownInput (void)
void DLLEXPORT HUD_Shutdown( void )
{
ShutdownInput();
}
}

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// in_win.c -- windows 95 mouse and joystick code
// 02/21/97 JCB Added extended DirectInput code to support external controllers.

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( KBUTTONH )
#define KBUTTONH
#pragma once

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -27,6 +27,10 @@
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;
char *g_pCustomName = "Custom";
char g_pCustomText[1024];
int CHudMessage::Init(void)
{
@ -415,13 +419,62 @@ int CHudMessage::Draw( float fTime )
void CHudMessage::MessageAdd( const char *pName, float time )
{
int i;
int i,j;
client_textmessage_t *tempMessage;
for ( i = 0; i < maxHUDMessages; i++ )
{
if ( !m_pMessages[i] )
{
m_pMessages[i] = TextMessageGet( pName );
// Trim off a leading # if it's there
if ( pName[0] == '#' )
tempMessage = TextMessageGet( pName+1 );
else
tempMessage = TextMessageGet( pName );
// If we couldnt find it in the titles.txt, just create it
if ( !tempMessage )
{
g_pCustomMessage.effect = 2;
g_pCustomMessage.r1 = g_pCustomMessage.g1 = g_pCustomMessage.b1 = g_pCustomMessage.a1 = 100;
g_pCustomMessage.r2 = 240;
g_pCustomMessage.g2 = 110;
g_pCustomMessage.b2 = 0;
g_pCustomMessage.a2 = 0;
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 );
g_pCustomMessage.pMessage = g_pCustomText;
tempMessage = &g_pCustomMessage;
}
for ( j = 0; j < maxHUDMessages; j++ )
{
if ( m_pMessages[j] )
{
// is this message already in the list
if ( !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->x - m_pMessages[j]->x ) < 0.0001 )
{
m_pMessages[j] = NULL;
}
}
}
}
m_pMessages[i] = tempMessage;
m_startTime[i] = time;
return;
}
@ -461,3 +514,23 @@ int CHudMessage::MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf
return 1;
}
void CHudMessage::MessageAdd(client_textmessage_t * newMessage )
{
m_parms.time = gHUD.m_flTime;
// Turn on drawing
if ( !(m_iFlags & HUD_ACTIVE) )
m_iFlags |= HUD_ACTIVE;
for ( int i = 0; i < maxHUDMessages; i++ )
{
if ( !m_pMessages[i] )
{
m_pMessages[i] = newMessage;
m_startTime[i] = gHUD.m_flTime;
return;
}
}
}

View file

@ -1,5 +0,0 @@
SCC = This is a Source Code Control file
[cl_dll.mak]
SCC_Aux_Path = "\\Jeeves\VSSCODE\"
SCC_Project_Name = "$/Sdk/Standard/cl_dll", UBZBAAAA

160
cl_dll/overview.cpp Normal file
View file

@ -0,0 +1,160 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "hud.h"
#include "cl_util.h"
#include "cl_entity.h"
#include "triangleapi.h"
#include "vgui_TeamFortressViewport.h"
// these are included for the math functions
#include "com_model.h"
#include "studio_util.h"
#pragma warning(disable: 4244)
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CHudOverview::Init()
{
gHUD.AddHudElem(this);
m_iFlags |= HUD_ACTIVE;
return 1;
}
//-----------------------------------------------------------------------------
// Purpose: Loads new icons
//-----------------------------------------------------------------------------
int CHudOverview::VidInit()
{
m_hsprPlayer = gEngfuncs.pfnSPR_Load("sprites/ring.spr");
m_hsprViewcone = gEngfuncs.pfnSPR_Load("sprites/camera.spr");
return 1;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : flTime -
// intermission -
//-----------------------------------------------------------------------------
int CHudOverview::Draw(float flTime)
{
// only draw in overview mode
if (!gEngfuncs.Overview_GetOverviewState())
return 1;
// make sure we have player info
gViewPort->GetAllPlayersInfo();
// calculate player size on the overview
int x1, y1, x2, y2;
float v0[3]={0,0,0}, v1[3]={64,64,0};
gEngfuncs.Overview_WorldToScreen(v0, &x1, &y1);
gEngfuncs.Overview_WorldToScreen(v1, &x2, &y2);
float scale = abs(x2 - x1);
// loop through all the players and draw them on the map
for (int i = 1; i < MAX_PLAYERS; i++)
{
cl_entity_t *pl = gEngfuncs.GetEntityByIndex(i);
if (pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT)
{
int x, y, z = 0;
float v[3]={pl->origin[0], pl->origin[1], 0};
gEngfuncs.Overview_WorldToScreen(v, &x, &y);
// hack in some team colors
float r, g, bc;
if (g_PlayerExtraInfo[i].teamnumber == 1)
{
r = 0.0f; g = 0.0f; bc = 1.0f;
}
else if (g_PlayerExtraInfo[i].teamnumber == 2)
{
r = 1.0f; g = 0.0f; bc = 0.0f;
}
else
{
// just use the default orange color if the team isn't set
r = 1.0f; g = 0.7f; bc = 0.0f;
}
// set the current texture
gEngfuncs.pTriAPI->SpriteTexture((struct model_s *)gEngfuncs.GetSpritePointer(m_hsprPlayer), 0);
// additive render mode
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd);
// no culling
gEngfuncs.pTriAPI->CullFace(TRI_NONE);
// draw a square
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
// set the color to be that of the team
gEngfuncs.pTriAPI->Color4f(r, g, bc, 1.0f);
// calculate rotational matrix
vec3_t a, b, angles;
float rmatrix[3][4]; // transformation matrix
VectorCopy(pl->angles, angles);
angles[0] = 0.0f;
angles[1] += 90.f;
angles[1] = -angles[1];
angles[2] = 0.0f;
AngleMatrix(angles, rmatrix);
a[2] = 0;
a[0] = -scale; a[1] = -scale;
VectorTransform(a, rmatrix , b );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f(x + b[0], y + b[1], z);
a[0]=-scale; a[1] = scale;
VectorTransform(a, rmatrix , b );
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z);
a[0]=scale; a[1] = scale;
VectorTransform(a, rmatrix , b );
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z);
a[0]=scale; a[1] = -scale;
VectorTransform(a, rmatrix , b );
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z);
// finish up
gEngfuncs.pTriAPI->End();
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
// draw the players name and health underneath
char string[256];
sprintf(string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health);
DrawConsoleString(x, y + (1.1 * scale), string);
}
}
return 1;
}
//-----------------------------------------------------------------------------
// Purpose: called every time a server is connected to
//-----------------------------------------------------------------------------
void CHudOverview::InitHUDData()
{
// this block would force the spectator view to be on
// gEngfuncs.Overview_SetDrawOverview( 1 );
// gEngfuncs.Overview_SetDrawInset( 0 );
}

31
cl_dll/overview.h Normal file
View file

@ -0,0 +1,31 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef OVERVIEW_H
#define OVERVIEW_H
#pragma once
//-----------------------------------------------------------------------------
// Purpose: Handles the drawing of the top-down map and all the things on it
//-----------------------------------------------------------------------------
class CHudOverview : public CHudBase
{
public:
int Init();
int VidInit();
int Draw(float flTime);
void InitHUDData( void );
private:
HSPRITE m_hsprPlayer;
HSPRITE m_hsprViewcone;
};
#endif // OVERVIEW_H

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -55,7 +55,10 @@ int CHudSayText :: Init( void )
InitHUDData();
CVAR_CREATE( "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
return 1;
}
@ -96,20 +99,20 @@ int CHudSayText :: Draw( float flTime )
{
int y = Y_START;
if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
if ( ( gViewPort && gViewPort->AllowedToPrintText() == FALSE) || !m_HUD_saytext->value )
return 1;
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + SCROLL_SPEED );
flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value );
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + SCROLL_SPEED );
flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value );
if ( flScrollTime <= flTime )
{
if ( *g_szLineBuffer[0] )
{
flScrollTime = flTime + SCROLL_SPEED;
flScrollTime = flTime + m_HUD_saytext_time->value;
// push the console up
ScrollTextUp();
}
@ -164,7 +167,11 @@ int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
{
if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
{
// Print it straight to the console
ConsolePrint( pszBuf );
return;
}
// find an empty string slot
for ( int i = 0; i < MAX_LINES; i++ )
@ -208,8 +215,7 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn
// Set scroll time
if ( i == 0 )
{
SCROLL_SPEED = CVAR_GET_FLOAT( "hud_saytext_time" );
flScrollTime = gHUD.m_flTime + SCROLL_SPEED;
flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value;
}
m_iFlags |= HUD_ACTIVE;

162
cl_dll/soundsystem.cpp Normal file
View file

@ -0,0 +1,162 @@
//======== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// 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:
//
// $Workfile: $
// $Date: $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================
#include <windows.h>
#include <dsound.h>
#include <mmsystem.h>
#include "r_studioint.h"
extern engine_studio_api_t IEngineStudio;
#define RENDERTYPE_UNDEFINED 0
#define RENDERTYPE_SOFTWARE 1
#define RENDERTYPE_HARDWARE 2
#define ENGINE_LAUNCHER_API_VERSION 1
LPDIRECTSOUND lpDS = NULL;
LPDIRECTSOUNDBUFFER lpDSBuf = NULL;
LPHWAVEOUT lpHW = NULL;
static HMODULE hEngine = 0;
typedef struct engine_api_s
{
int version;
int rendertype;
int size;
// Functions
void ( *unused1 ) ( void );
void ( *unused2 ) ( void );
void ( *unused3 ) ( void );
void ( *unused4 ) ( void );
void ( *unused5 ) ( void );
void ( *unused6 ) ( void );
void ( *unused7 ) ( void );
void ( *unused8 ) ( void );
void ( *unused9 ) ( void );
void ( *unused10 ) ( void );
void ( *unused11 ) ( void );
void ( *unused12 ) ( void );
void ( *unused13 ) ( void );
void ( *unused14 ) ( void );
void ( *unused15 ) ( void );
void ( *unused16 ) ( void );
void ( *unused17 ) ( void );
void ( *unused18 ) ( void );
void ( *unused19 ) ( void );
void ( *unused20 ) ( void );
void ( *unused21 ) ( void );
void ( *unused22 ) ( void );
void ( *unused23 ) ( void );
void ( *unused24 ) ( void );
void ( *unused25 ) ( void );
void ( *unused26 ) ( void );
void ( *unused27 ) ( void );
void ( *unused28 ) ( void );
void ( *unused29 ) ( void );
void ( *unused30 ) ( void );
void ( *unused31 ) ( void );
void ( *unused32 ) ( void );
void ( *unused33 ) ( void );
void ( *unused34 ) ( void );
void ( *S_GetDSPointer ) ( struct IDirectSound **lpDS, struct IDirectSoundBuffer **lpDSBuf );
void *( *S_GetWAVPointer ) ( void );
void ( *unused35 ) ( void );
void ( *unused36 ) ( void );
void ( *unused37 ) ( void );
void ( *unused38 ) ( void );
void ( *unused39 ) ( void );
void ( *unused40 ) ( void );
void ( *unused41 ) ( void );
void ( *unused42 ) ( void );
void ( *unused43 ) ( void );
void ( *unused44 ) ( void );
void ( *unused45 ) ( void );
void ( *unused46 ) ( void );
void ( *unused47 ) ( void );
void ( *unused48 ) ( void );
void ( *unused49 ) ( void );
void ( *unused50 ) ( void );
void ( *unused51 ) ( void );
void ( *unused52 ) ( void );
void ( *unused53 ) ( void );
void ( *unused54 ) ( void );
void ( *unused55 ) ( void );
} engine_api_t;
static engine_api_t engineapi;
typedef int (*engine_api_func)( int version, int size, struct engine_api_s *api );
//-----------------------------------------------------------------------------
// Purpose: Get launcher/engine interface from engine module
// Input : hMod -
// Output : int
//-----------------------------------------------------------------------------
int Eng_LoadFunctions( HMODULE hMod )
{
engine_api_func pfnEngineAPI;
pfnEngineAPI = ( engine_api_func )GetProcAddress( hMod, "Sys_EngineAPI" );
if ( !pfnEngineAPI )
return 0;
if ( !(*pfnEngineAPI)( ENGINE_LAUNCHER_API_VERSION, sizeof( engine_api_t ), &engineapi ) )
return 0;
// All is okay
return 1;
}
//-----------------------------------------------------------------------------
// Purpose: Load proper engine .dll and get pointer to either DSound and primary buffer or HWAVEOUT ( NT 4.0, e.g. )
//-----------------------------------------------------------------------------
void LoadSoundAPIs( void )
{
hEngine = ::LoadLibrary( IEngineStudio.IsHardware() ? "hw.dll" : "sw.dll" );
if ( hEngine )
{
if ( Eng_LoadFunctions( hEngine ) )
{
if ( engineapi.S_GetDSPointer && engineapi.S_GetWAVPointer )
{
engineapi.S_GetDSPointer(&lpDS, &lpDSBuf);
lpHW = (HWAVEOUT FAR *)engineapi.S_GetWAVPointer();
}
}
}
}
//-----------------------------------------------------------------------------
// Purpose: Close engine library, release sound pointers
//-----------------------------------------------------------------------------
void ShutdownSoundAPIs( void )
{
if( hEngine )
{
FreeLibrary( hEngine );
hEngine = 0;
}
lpDS = 0;
lpDSBuf = 0;
lpHW = 0;
}

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -53,6 +53,8 @@ void CHudStatusIcons::Reset( void )
// Draw status icons along the left-hand side of the screen
int CHudStatusIcons::Draw( float flTime )
{
if (gEngfuncs.IsSpectateOnly())
return 1;
// find starting position to draw from, along right-hand side of screen
int x = 5;
int y = ScreenHeight / 2;

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -31,6 +31,9 @@ DECLARE_MESSAGE( m_StatusBar, StatusValue );
#define STATUSBAR_ID_LINE 1
float *GetClientColor( int clientIndex );
extern float g_ColorYellow[3];
int CHudStatusBar :: Init( void )
{
gHUD.AddHudElem( this );
@ -54,12 +57,18 @@ int CHudStatusBar :: VidInit( void )
void CHudStatusBar :: Reset( void )
{
int i = 0;
m_iFlags &= ~HUD_ACTIVE; // start out inactive
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ )
m_szStatusText[i][0] = 0;
memset( m_iStatusValues, 0, sizeof m_iStatusValues );
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++ )
m_pflNameColors[i] = g_ColorYellow;
}
void CHudStatusBar :: ParseStatusString( int line_num )
@ -133,11 +142,13 @@ void CHudStatusBar :: ParseStatusString( int line_num )
if ( g_PlayerInfoList[indexval].name != NULL )
{
strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH );
m_pflNameColors[line_num] = GetClientColor( indexval );
}
else
{
strcpy( szRepString, "******" );
}
break;
case 'i': // number
sprintf( szRepString, "%d", indexval );
@ -166,24 +177,23 @@ int CHudStatusBar :: Draw( float fTime )
if ( m_bReparseString )
{
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
{
m_pflNameColors[i] = g_ColorYellow;
ParseStatusString( i );
}
m_bReparseString = FALSE;
}
int Y_START = ScreenHeight - YRES(32 + 4);
// Draw the status bar lines
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
{
int TextHeight, TextWidth;
GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );
int Y_START;
if ( ScreenHeight >= 480 )
Y_START = ScreenHeight - 55;
else
Y_START = ScreenHeight - 45;
int x = 5;
int y = Y_START - ( TextHeight * i ); // draw along bottom of screen
int x = 4;
int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen
// let user set status ID bar centering
if ( (i == STATUSBAR_ID_LINE) && CVAR_GET_FLOAT("hud_centerid") )
@ -192,6 +202,9 @@ int CHudStatusBar :: Draw( float fTime )
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] );
DrawConsoleString( x, y, m_szStatusBar[i] );
}

251
cl_dll/studio_util.cpp Normal file
View file

@ -0,0 +1,251 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include <memory.h>
#include "hud.h"
#include "cl_util.h"
#include "const.h"
#include "com_model.h"
#include "studio_util.h"
/*
====================
AngleMatrix
====================
*/
void AngleMatrix (const float *angles, float (*matrix)[4] )
{
float angle;
float sr, sp, sy, cr, cp, cy;
angle = angles[YAW] * (M_PI*2 / 360);
sy = sin(angle);
cy = cos(angle);
angle = angles[PITCH] * (M_PI*2 / 360);
sp = sin(angle);
cp = cos(angle);
angle = angles[ROLL] * (M_PI*2 / 360);
sr = sin(angle);
cr = cos(angle);
// matrix = (YAW * PITCH) * ROLL
matrix[0][0] = cp*cy;
matrix[1][0] = cp*sy;
matrix[2][0] = -sp;
matrix[0][1] = sr*sp*cy+cr*-sy;
matrix[1][1] = sr*sp*sy+cr*cy;
matrix[2][1] = sr*cp;
matrix[0][2] = (cr*sp*cy+-sr*-sy);
matrix[1][2] = (cr*sp*sy+-sr*cy);
matrix[2][2] = cr*cp;
matrix[0][3] = 0.0;
matrix[1][3] = 0.0;
matrix[2][3] = 0.0;
}
/*
====================
VectorCompare
====================
*/
int VectorCompare (const float *v1, const float *v2)
{
int i;
for (i=0 ; i<3 ; i++)
if (v1[i] != v2[i])
return 0;
return 1;
}
/*
====================
CrossProduct
====================
*/
void CrossProduct (const float *v1, const float *v2, float *cross)
{
cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
}
/*
====================
VectorTransform
====================
*/
void VectorTransform (const float *in1, float in2[3][4], float *out)
{
out[0] = DotProduct(in1, in2[0]) + in2[0][3];
out[1] = DotProduct(in1, in2[1]) + in2[1][3];
out[2] = DotProduct(in1, in2[2]) + in2[2][3];
}
/*
================
ConcatTransforms
================
*/
void ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4])
{
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
in1[0][2] * in2[2][0];
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
in1[0][2] * in2[2][1];
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
in1[0][2] * in2[2][2];
out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] +
in1[0][2] * in2[2][3] + in1[0][3];
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
in1[1][2] * in2[2][0];
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
in1[1][2] * in2[2][1];
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
in1[1][2] * in2[2][2];
out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] +
in1[1][2] * in2[2][3] + in1[1][3];
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
in1[2][2] * in2[2][0];
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
in1[2][2] * in2[2][1];
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
in1[2][2] * in2[2][2];
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] +
in1[2][2] * in2[2][3] + in1[2][3];
}
// angles index are not the same as ROLL, PITCH, YAW
/*
====================
AngleQuaternion
====================
*/
void AngleQuaternion( float *angles, vec4_t quaternion )
{
float angle;
float sr, sp, sy, cr, cp, cy;
// FIXME: rescale the inputs to 1/2 angle
angle = angles[2] * 0.5;
sy = sin(angle);
cy = cos(angle);
angle = angles[1] * 0.5;
sp = sin(angle);
cp = cos(angle);
angle = angles[0] * 0.5;
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
}
/*
====================
QuaternionSlerp
====================
*/
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
{
int i;
float omega, cosom, sinom, sclp, sclq;
// decide if one of the quaternions is backwards
float a = 0;
float b = 0;
for (i = 0; i < 4; i++)
{
a += (p[i]-q[i])*(p[i]-q[i]);
b += (p[i]+q[i])*(p[i]+q[i]);
}
if (a > b)
{
for (i = 0; i < 4; i++)
{
q[i] = -q[i];
}
}
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;
}
else
{
sclp = 1.0 - t;
sclq = t;
}
for (i = 0; i < 4; i++) {
qt[i] = sclp * p[i] + sclq * q[i];
}
}
else
{
qt[0] = -q[1];
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));
for (i = 0; i < 3; i++)
{
qt[i] = sclp * p[i] + sclq * qt[i];
}
}
}
/*
====================
QuaternionMatrix
====================
*/
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];
matrix[2][0] = 2.0 * quaternion[0] * quaternion[2] - 2.0 * quaternion[3] * quaternion[1];
matrix[0][1] = 2.0 * quaternion[0] * quaternion[1] - 2.0 * quaternion[3] * quaternion[2];
matrix[1][1] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[2] * quaternion[2];
matrix[2][1] = 2.0 * quaternion[1] * quaternion[2] + 2.0 * quaternion[3] * quaternion[0];
matrix[0][2] = 2.0 * quaternion[0] * quaternion[2] + 2.0 * quaternion[3] * quaternion[1];
matrix[1][2] = 2.0 * quaternion[1] * quaternion[2] - 2.0 * quaternion[3] * quaternion[0];
matrix[2][2] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[1] * quaternion[1];
}
/*
====================
MatrixCopy
====================
*/
void MatrixCopy( float in[3][4], float out[3][4] )
{
memcpy( out, in, sizeof( float ) * 3 * 4 );
}

40
cl_dll/studio_util.h Normal file
View file

@ -0,0 +1,40 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( STUDIO_UTIL_H )
#define STUDIO_UTIL_H
#if defined( WIN32 )
#pragma once
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif
#ifndef PITCH
// MOVEMENT INFO
// up / down
#define PITCH 0
// left / right
#define YAW 1
// fall over
#define ROLL 2
#endif
#define FDotProduct( a, b ) (fabs((a[0])*(b[0])) + fabs((a[1])*(b[1])) + fabs((a[2])*(b[2])))
void AngleMatrix (const float *angles, float (*matrix)[4] );
int VectorCompare (const float *v1, const float *v2);
void CrossProduct (const float *v1, const float *v2, float *cross);
void VectorTransform (const float *in1, float in2[3][4], float *out);
void ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
void MatrixCopy( float in[3][4], float out[3][4] );
void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] );
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt );
void AngleQuaternion( float *angles, vec4_t quaternion );
#endif // STUDIO_UTIL_H

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1998, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -177,6 +177,8 @@
#define PC_LASTCLASS 12 // Use this as the high-boundary for any loops
// through the playerclass.
#define SENTRY_COLOR 10 // will be in the PC_RANDOM slot for team colors
// These are just for the scanner
#define SCAN_SENTRY 13
#define SCAN_GOALITEM 14
@ -361,14 +363,6 @@ enum
#define TF_SPY_SILENTDIE 199
/*==================================================*/
/* Colors */
/*==================================================*/
#define TEAM1_COLOR 150
#define TEAM2_COLOR 250
#define TEAM3_COLOR 45
#define TEAM4_COLOR 100
/*==================================================*/
/* Defines for the ENGINEER's Building ability */
/*==================================================*/
@ -676,7 +670,7 @@ enum
#define PC_SOLDIER_INITAMMO_ROCKET 10
#define PC_SOLDIER_GRENADE_TYPE_1 GR_TYPE_NORMAL
#define PC_SOLDIER_GRENADE_TYPE_2 GR_TYPE_NAIL
#define PC_SOLDIER_GRENADE_INIT_1 4
#define PC_SOLDIER_GRENADE_INIT_1 2
#define PC_SOLDIER_GRENADE_INIT_2 1
#define PC_SOLDIER_TF_ITEMS 0
@ -711,8 +705,8 @@ enum
#define PC_DEMOMAN_INITAMMO_DETPACK 1
#define PC_DEMOMAN_GRENADE_TYPE_1 GR_TYPE_NORMAL
#define PC_DEMOMAN_GRENADE_TYPE_2 GR_TYPE_MIRV
#define PC_DEMOMAN_GRENADE_INIT_1 4
#define PC_DEMOMAN_GRENADE_INIT_2 4
#define PC_DEMOMAN_GRENADE_INIT_1 2
#define PC_DEMOMAN_GRENADE_INIT_2 2
#define PC_DEMOMAN_TF_ITEMS 0
// Class Details for COMBAT MEDIC
@ -739,7 +733,7 @@ enum
#define PC_MEDIC_INITAMMO_MEDIKIT 50
#define PC_MEDIC_GRENADE_TYPE_1 GR_TYPE_NORMAL
#define PC_MEDIC_GRENADE_TYPE_2 GR_TYPE_CONCUSSION
#define PC_MEDIC_GRENADE_INIT_1 3
#define PC_MEDIC_GRENADE_INIT_1 2
#define PC_MEDIC_GRENADE_INIT_2 2
#define PC_MEDIC_TF_ITEMS 0
#define PC_MEDIC_REGEN_TIME 3 // Number of seconds between each regen.
@ -767,7 +761,7 @@ enum
#define PC_HVYWEAP_INITAMMO_ROCKET 0
#define PC_HVYWEAP_GRENADE_TYPE_1 GR_TYPE_NORMAL
#define PC_HVYWEAP_GRENADE_TYPE_2 GR_TYPE_MIRV
#define PC_HVYWEAP_GRENADE_INIT_1 4
#define PC_HVYWEAP_GRENADE_INIT_1 2
#define PC_HVYWEAP_GRENADE_INIT_2 1
#define PC_HVYWEAP_TF_ITEMS 0
#define PC_HVYWEAP_CELL_USAGE 7 // Amount of cells spent to power up assault cannon
@ -796,7 +790,7 @@ enum
#define PC_PYRO_INITAMMO_ROCKET 5
#define PC_PYRO_GRENADE_TYPE_1 GR_TYPE_NORMAL
#define PC_PYRO_GRENADE_TYPE_2 GR_TYPE_NAPALM
#define PC_PYRO_GRENADE_INIT_1 1
#define PC_PYRO_GRENADE_INIT_1 2
#define PC_PYRO_GRENADE_INIT_2 4
#define PC_PYRO_TF_ITEMS 0
#define PC_PYRO_ROCKET_USAGE 3 // Number of rockets per incendiary cannon shot
@ -980,7 +974,7 @@ enum
/*==========================================================================*/
/* Flamethrower */
/*==========================================================================*/
#define FLAME_PLYRMAXTIME 4.5 // lifetime in seconds of a flame on a player
#define FLAME_PLYRMAXTIME 5.0 // lifetime in seconds of a flame on a player
#define FLAME_MAXBURNTIME 8 // lifetime in seconds of a flame on the world (big ones)
#define NAPALM_MAXBURNTIME 20 // lifetime in seconds of flame from a napalm grenade
#define FLAME_MAXPLYRFLAMES 4 // maximum number of flames on a player
@ -990,6 +984,7 @@ enum
#define FLAME_DAMAGE_TIME 1 // Interval between damage burns from flames
#define FLAME_EFFECT_TIME 0.2 // frequency at which we display flame effects.
#define FLAME_THINK_TIME 0.1 // Seconds between times the flame checks burn
#define PER_FLAME_DAMAGE 2 // Damage taken per second per flame by burning players
/*==================================================*/
/* CTF Support defines */
@ -1114,6 +1109,7 @@ float already_chosen_map;
#define MENU_CLASSHELP2 7
#define MENU_REPEATHELP 8
#define MENU_SPECHELP 9
#define MENU_SPY 12
@ -1129,6 +1125,8 @@ float already_chosen_map;
#define MENU_REFRESH_RATE 25
#define MENU_VOICETWEAK 50
//============================
// Timer Types
#define TF_TIMER_ANY 0
@ -1145,10 +1143,12 @@ float already_chosen_map;
#define TF_TIMER_BUILD 11
#define TF_TIMER_CHECKBUILDDISTANCE 12
#define TF_TIMER_DISGUISE 13
#define TF_TIMER_DISPENSERREFILL 14
// Non Player timers
#define TF_TIMER_RETURNITEM 100
#define TF_TIMER_DELAYEDGOAL 101
#define TF_TIMER_ENDROUND 102
//============================
// Teamscore printing
@ -1157,6 +1157,14 @@ float already_chosen_map;
#define TS_PRINT_LONG_TO_ALL 3
#ifndef TF_DEFS_ONLY
typedef struct
{
int topColor;
int bottomColor;
} team_color_t;
/*==================================================*/
/* GLOBAL VARIABLES */
/*==================================================*/
@ -1165,7 +1173,9 @@ extern float number_of_teams; // number of teams supported by the map
extern int illegalclasses[5]; // Illegal playerclasses for all teams
extern int civilianteams; // Bitfield holding Civilian teams
extern Vector rgbcolors[5]; // RGB colors for each of the 4 teams
extern int teamcolors[5]; // Colours for each of the 4 teams
extern team_color_t teamcolors[5][PC_LASTCLASS]; // Colors for each of the 4 teams
extern int teamscores[5]; // Goal Score of each team
extern int g_iOrderedTeams[5]; // Teams ordered into order of winners->losers
extern int teamfrags[5]; // Total Frags for each team
@ -1194,6 +1204,7 @@ extern float old_grens;
extern float flagem_checked;
extern float flNextEqualisationCalc;
extern BOOL cease_fire;
extern BOOL no_cease_fire_text;
extern BOOL initial_cease_fire;
extern BOOL last_cease_fire;
// Autokick stuff
@ -1204,7 +1215,8 @@ extern float deathmsg; // Global, which is set before every T_Damage, to indica
extern char *sTeamSpawnNames[];
extern char *sClassNames[];
extern char *sClassModelFiles[];
extern char *sNewClassModelFiles[];
extern char *sOldClassModelFiles[];
extern char *sClassModels[];
extern char *sClassCfgs[];
extern char *sGrenadeNames[];
@ -1284,6 +1296,7 @@ extern cvar_t tfc_spam_limit; // at this many points, gag the spammer
extern cvar_t tfc_clanbattle, tfc_clanbattle_prematch, tfc_prematch, tfc_clanbattle_ceasefire, tfc_balance_teams, tfc_balance_scores;
extern cvar_t tfc_clanbattle_locked, tfc_birthday, tfc_autokick_kills, tfc_fragscoring, tfc_autokick_time, tfc_adminpwd;
extern cvar_t weaponstay, footsteps, flashlight, aimcrosshair, falldamage, teamplay;
extern cvar_t allow_spectators;
/*==========================================================================*/
class CTFFlame : public CBaseMonster
@ -1334,7 +1347,11 @@ class CTFSpawn : public CBaseEntity
{
public:
void Spawn( void );
void Activate( void );
int Classify ( void ) { return CLASS_TFSPAWN; }
BOOL CheckTeam( int iTeamNo );
EHANDLE m_pTeamCheck;
};
class CTFDetect : public CBaseEntity
@ -1351,6 +1368,21 @@ public:
void EXPORT DeathTouch( CBaseEntity *pOther );
};
class CTeamCheck : public CBaseDelay
{
public:
void Spawn( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
BOOL TeamMatches( int iTeam );
};
class CTeamSet : public CBaseDelay
{
public:
void Spawn( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
};
#endif // TF_DEFS_ONLY
#endif // __TF_DEFS_H

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// Triangle rendering, if any
#include "hud.h"
@ -94,6 +101,8 @@ Non-transparent triangles-- add them here
void DLLEXPORT HUD_DrawNormalTriangles( void )
{
gHUD.m_Spectator.DrawOverview();
#if defined( TEST_IT )
// Draw_Triangles();
#endif

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.

View file

@ -1,4 +1,4 @@
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
@ -198,9 +198,11 @@ CClassMenuPanel::CClassMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide
// 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 *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);
@ -215,7 +217,7 @@ CClassMenuPanel::CClassMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide
int wide,tall;
pTextWindow->getTextImage()->getTextSizeWrapped( wide,tall);
pTextWindow->setSize(wide,tall);
//pTextWindow->setBorder(new LineBorder());
int xx,yy;
pTextWindow->getPos(xx,yy);
int maxX=xx+wide;
@ -233,6 +235,7 @@ CClassMenuPanel::CClassMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide
}
m_pClassInfoPanel[i]->setSize( maxX , maxY );
if (pfile) gEngfuncs.COM_FreeFile( pfile );
//m_pClassInfoPanel[i]->setBorder(new LineBorder());
}
@ -318,7 +321,10 @@ void CClassMenuPanel::Update()
m_pPlayers[i]->setText( sz );
// Set the text color to the teamcolor
m_pPlayers[i]->setFgColor( iTeamColors[g_iTeamNumber][0], iTeamColors[g_iTeamNumber][1], iTeamColors[g_iTeamNumber][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++ )

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include"vgui_ConsolePanel.h"
#include"hud.h"

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef CONSOLEPANEL_H
#define CONSOLEPANEL_H

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include<stdio.h>
#include"vgui_ControlConfigPanel.h"

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef CONTROLCONFIGPANEL_H
#define CONTROLCONFIGPANEL_H

View file

@ -1,4 +1,4 @@
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
@ -32,6 +32,7 @@
#include "vgui_int.h"
#include "vgui_TeamFortressViewport.h"
#include "vgui_ServerBrowser.h"
#include "..\game_shared\vgui_LoadTGA.h"
// Arrow filenames
char *sArrowFilenames[] =
@ -42,20 +43,31 @@ char *sArrowFilenames[] =
"arrowrt",
};
// Get the name of TGA file, without a gamedir
char *GetTGANameForRes(const char *pszName)
{
int i;
char sz[256];
static char gd[256];
if (ScreenWidth < 640)
i = 320;
else
i = 640;
sprintf(sz, pszName, i);
sprintf(gd, "gfx/vgui/%s.tga", sz);
return gd;
}
//-----------------------------------------------------------------------------
// Purpose: Loads a .tga file and returns a pointer to the VGUI tga object
//-----------------------------------------------------------------------------
BitmapTGA *LoadTGA( const char* pImageName )
BitmapTGA *LoadTGAForRes( const char* pImageName )
{
BitmapTGA *pTGA;
char sz[256];
sprintf(sz, "%%d_%s", pImageName);
// Load the Image
FileInputStream* fis = new FileInputStream( GetVGUITGAName(sz), false );
pTGA = new BitmapTGA(fis,true);
fis->close();
pTGA = vgui_LoadTGA(GetTGANameForRes(sz));
return pTGA;
}
@ -66,14 +78,25 @@ CommandButton::CommandButton( const char* text,int x,int y,int wide,int tall, bo
{
m_iPlayerClass = 0;
m_bNoHighlight = bNoHighlight;
m_bFlat = false;
Init();
setText( text );
}
CommandButton::CommandButton( int iPlayerClass, const char* text,int x,int y,int wide,int tall) : 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 );
}
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 );
}
@ -108,7 +131,14 @@ void CommandButton::RecalculateText( void )
if ( m_cBoundKey != 0 )
{
sprintf( szBuf, " %c %s", m_cBoundKey, m_sMainText );
if ( m_cBoundKey == (char)255 )
{
strcpy( szBuf, m_sMainText );
}
else
{
sprintf( szBuf, " %c %s", m_cBoundKey, m_sMainText );
}
szBuf[MAX_BUTTON_SIZE-1] = 0;
}
else
@ -180,16 +210,28 @@ void CommandButton::paint()
void CommandButton::paintBackground()
{
if ( isArmed() )
if ( m_bFlat )
{
// Orange highlight background
drawSetColor( Scheme::sc_primary2 );
drawFilledRect(0,0,_size[0],_size[1]);
if ( isArmed() )
{
// Orange Border
drawSetColor( Scheme::sc_secondary1 );
drawOutlinedRect(0,0,_size[0],_size[1]);
}
}
else
{
if ( isArmed() )
{
// Orange highlight background
drawSetColor( Scheme::sc_primary2 );
drawFilledRect(0,0,_size[0],_size[1]);
}
// Orange Border
drawSetColor( Scheme::sc_secondary1 );
drawOutlinedRect(0,0,_size[0],_size[1]);
// Orange Border
drawSetColor( Scheme::sc_secondary1 );
drawOutlinedRect(0,0,_size[0],_size[1]);
}
}
//-----------------------------------------------------------------------------
@ -283,14 +325,14 @@ int ClassButton::IsNotValid()
CImageLabel::CImageLabel( const char* pImageName,int x,int y ) : Label( "", x,y )
{
setContentFitted(true);
m_pTGA = LoadTGA(pImageName);
m_pTGA = LoadTGAForRes(pImageName);
setImage( m_pTGA );
}
CImageLabel::CImageLabel( const char* pImageName,int x,int y,int wide,int tall ) : Label( "", x,y,wide,tall )
{
setContentFitted(true);
m_pTGA = LoadTGA(pImageName);
m_pTGA = LoadTGAForRes(pImageName);
setImage( m_pTGA );
}
@ -298,16 +340,61 @@ CImageLabel::CImageLabel( const char* pImageName,int x,int y,int wide,int tall )
// Image size
int CImageLabel::getImageWide( void )
{
int iXSize, iYSize;
m_pTGA->getSize( iXSize, iYSize );
return iXSize;
if( m_pTGA )
{
int iXSize, iYSize;
m_pTGA->getSize( iXSize, iYSize );
return iXSize;
}
else
{
return 1;
}
}
int CImageLabel::getImageTall( void )
{
int iXSize, iYSize;
m_pTGA->getSize( iXSize, iYSize );
return iYSize;
if( m_pTGA )
{
int iXSize, iYSize;
m_pTGA->getSize( iXSize, iYSize );
return iYSize;
}
else
{
return 1;
}
}
void CImageLabel::LoadImage(const char * pImageName)
{
if ( m_pTGA )
delete m_pTGA;
// Load the Image
m_pTGA = LoadTGAForRes(pImageName);
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 = new FileInputStream( sz, false );
m_pTGA = new BitmapTGA(fis,true);
fis->close();
}
if ( m_pTGA == NULL )
return; // unable to load image
int w,t;
m_pTGA->getSize( w, t );
setSize( XRES (w),YRES (t) );
setImage( m_pTGA );
}
//===========================================================
@ -315,7 +402,12 @@ int CImageLabel::getImageTall( void )
void CCommandMenu::paintBackground()
{
// Transparent black background
drawSetColor(Scheme::sc_primary3);
if ( m_iSpectCmdMenu )
drawSetColor( 0, 0, 0, 64 );
else
drawSetColor(Scheme::sc_primary3);
drawFilledRect(0,0,_size[0],_size[1]);
}
@ -328,7 +420,7 @@ CTFScrollButton::CTFScrollButton(int iArrow, const char* text,int x,int y,int wi
setFgColor(Scheme::sc_primary1);
// Load in the arrow
m_pTGA = LoadTGA( sArrowFilenames[iArrow] );
m_pTGA = LoadTGAForRes( sArrowFilenames[iArrow] );
setImage( m_pTGA );
// Highlight signal
@ -338,6 +430,9 @@ CTFScrollButton::CTFScrollButton(int iArrow, const char* text,int x,int y,int wi
void CTFScrollButton::paint( void )
{
if (!m_pTGA)
return;
// draw armed button text in white
if ( isArmed() )
{

View file

@ -1,4 +1,4 @@
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
@ -104,6 +104,7 @@ CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitl
// 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) );
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);
@ -120,13 +121,19 @@ CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitl
pSchemes->getBgColor( hMOTDText, r, g, b, a );
pText->setBgColor( r, g, b, a );
pText->setText(szMOTD);
pText->setSize(pScrollPanel->getClientClip()->getWide()-2, 5000);
// Get the total size of the MOTD text and resize the text panel
int iScrollSizeX, iScrollSizeY;
// First, set the size so that the client's wdith is correct at least because the
// width is critical for getting the "wrapped" size right.
// 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 );
// Now resize the textpanel to fit the scrolled size
pText->setSize( iScrollSizeX , iScrollSizeY );
//pText->setBorder(new LineBorder());
//turn the scrollbars back into automode
pScrollPanel->setScrollBarAutoVisible(true, true);

View file

@ -1,4 +1,4 @@
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include <VGUI_Font.h>

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef SCOREPANEL_H
#define SCOREPANEL_H
@ -7,116 +13,298 @@
#include<VGUI_HeaderPanel.h>
#include<VGUI_TextGrid.h>
#include<VGUI_Label.h>
#include<VGUI_TextImage.h>
#include "..\game_shared\vgui_listbox.h"
#define MAX_SCORES 10
#include <ctype.h>
#define MAX_SCORES 10
#define MAX_SCOREBOARD_TEAMS 5
// Scoreboard cells
#define NUM_COLUMNS 5
#define NUM_ROWS (MAX_PLAYERS + MAX_TEAMS)
// Scoreboard positions
#define SBOARD_INDENT_X XRES(104)
#define SBOARD_INDENT_Y YRES(40)
#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;
class CTextImage2 : public Image
{
public:
CTextImage2()
{
_image[0] = new TextImage("");
_image[1] = new TextImage("");
}
~CTextImage2()
{
delete _image[0];
delete _image[1];
}
TextImage *GetImage(int image)
{
return _image[image];
}
void getSize(int &wide, int &tall)
{
int w1, w2, t1, t2;
_image[0]->getTextSize(w1, t1);
_image[1]->getTextSize(w2, t2);
wide = w1 + w2;
tall = max(t1, t2);
setSize(wide, tall);
}
void doPaint(Panel *panel)
{
_image[0]->doPaint(panel);
_image[1]->doPaint(panel);
}
void setPos(int x, int y)
{
_image[0]->setPos(x, y);
int swide, stall;
_image[0]->getSize(swide, stall);
int wide, tall;
_image[1]->getSize(wide, tall);
_image[1]->setPos(x + wide, y + (stall * 0.9) - tall);
}
void setColor(Color color)
{
_image[0]->setColor(color);
}
void setColor2(Color color)
{
_image[1]->setColor(color);
}
private:
TextImage *_image[2];
};
//-----------------------------------------------------------------------------
// Purpose: Custom label for cells in the Scoreboard's Table Header
//-----------------------------------------------------------------------------
class CLabelHeader : public Label
{
private:
void Init( void )
{
setFont( Scheme::sf_primary1 );
setFgColor( Scheme::sc_primary1 );
setBgColor( 0,0,0, 255 );
}
public:
CLabelHeader(const char* text,int x,int y,int wide,int tall) : Label(text,x,y,wide,tall)
CLabelHeader() : Label("")
{
Init();
_dualImage = new CTextImage2();
_dualImage->setColor2(Color(255, 170, 0, 0));
_row = -2;
_useFgColorAsImageColor = true;
_offset[0] = 0;
_offset[1] = 0;
}
CLabelHeader(const char* text, bool bAlignLeft = false) : Label(text)
~CLabelHeader()
{
Init();
if (bAlignLeft)
setContentAlignment(Label::a_west);
delete _dualImage;
}
void setRow(int row)
{
_row = row;
}
void setFgColorAsImageColor(bool state)
{
_useFgColorAsImageColor = state;
}
virtual void setText(int textBufferLen, const char* text)
{
_dualImage->GetImage(0)->setText(text);
// calculate the text size
Font *font = _dualImage->GetImage(0)->getFont();
_gap = 0;
for (const char *ch = text; *ch != 0; ch++)
{
int a, b, c;
font->getCharABCwide(*ch, a, b, c);
_gap += (a + b + c);
}
_gap += XRES(5);
}
virtual void setText(const char* text)
{
// strip any non-alnum characters from the end
char buf[512];
strcpy(buf, text);
int len = strlen(buf);
while (len && isspace(buf[--len]))
{
buf[len] = 0;
}
CLabelHeader::setText(0, buf);
}
void setText2(const char *text)
{
_dualImage->GetImage(1)->setText(text);
}
void getTextSize(int &wide, int &tall)
{
_dualImage->getSize(wide, tall);
}
void setFgColor(int r,int g,int b,int a)
{
Label::setFgColor(r,g,b,a);
Color color(r,g,b,a);
_dualImage->setColor(color);
_dualImage->setColor2(color);
repaint();
}
void setFgColor(Scheme::SchemeColor sc)
{
int r, g, b, a;
Label::setFgColor(sc);
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 );
}
void setFont(Font *font)
{
_dualImage->GetImage(0)->setFont(font);
}
void setFont2(Font *font)
{
_dualImage->GetImage(1)->setFont(font);
}
// this adjust the absolute position of the text after alignment is calculated
void setTextOffset(int x, int y)
{
_offset[0] = x;
_offset[1] = y;
}
void paint();
void paintBackground();
void calcAlignment(int iwide, int itall, int &x, int &y);
private:
CTextImage2 *_dualImage;
int _row;
int _gap;
int _offset[2];
bool _useFgColorAsImageColor;
};
//-----------------------------------------------------------------------------
// Purpose: Custom Table for the scoreboard
//-----------------------------------------------------------------------------
class ScoreTablePanel : public TablePanel
{
private:
TextGrid *_textGrid;
Label *m_pLabel;
class ScoreTablePanel;
public:
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:
ScoreTablePanel(int x,int y,int wide,int tall,int columnCount) : TablePanel(x,y,wide,tall,columnCount)
{
setCellEditingEnabled(false);
m_pLabel = new Label( "", 0, 0, wide, tall );
m_pLabel->setFont( Scheme::sf_primary2 );
}
virtual int getRowCount()
{
return m_iRows;
}
virtual Panel* startCellEditing(int column,int row)
{
return null;
}
virtual Panel* getCellRenderer(int column,int row,bool columnSelected,bool rowSelected,bool cellSelected);
virtual int getCellTall(int row);
};
#include "..\game_shared\vgui_grid.h"
#include "..\game_shared\vgui_defaultinputsignal.h"
//-----------------------------------------------------------------------------
// Purpose: Scoreboard back panel
//-----------------------------------------------------------------------------
class ScorePanel : public Panel
class ScorePanel : public Panel, public vgui::CDefaultInputSignal
{
private:
HeaderPanel *_headerPanel;
ScoreTablePanel *_tablePanel;
Label *m_pTitleLabel;
// Default panel implementation doesn't forward mouse messages when there is no cursor and we need them.
class HitTestPanel : public Panel
{
public:
virtual void internalMousePressed(MouseCode code);
};
private:
Label m_TitleLabel;
// Here is how these controls are arranged hierarchically.
// m_HeaderGrid
// m_HeaderLabels
// m_PlayerGridScroll
// m_PlayerGrid
// 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.
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;
public:
ScorePanel(int x,int y,int wide,int tall);
virtual void setSize(int wide,int tall);
void Update( void );
void SortTeams( void );
void SortPlayers( int iTeam, char *team );
void RebuildTeams( void );
void FillGrid();
void DeathMsg( int killer, int victim );
void Initialize( void );
void Open( void )
{
RebuildTeams();
setVisible(true);
}
void Open( void );
void MouseOverCell(int row, int col);
// InputSignal overrides.
public:
virtual void mousePressed(MouseCode code, Panel* panel);
virtual void cursorMoved(int x, int y, Panel *panel);
friend CLabelHeader;
};
#endif
#endif

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include<VGUI_HeaderPanel.h>
#include<VGUI_TablePanel.h>

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef ServerBrowser_H
#define ServerBrowser_H

View file

@ -0,0 +1,383 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// vgui_SpectatorPanel.cpp: implementation of the SpectatorPanel class.
//
//////////////////////////////////////////////////////////////////////
#include "hud.h"
#include "cl_util.h"
#include "const.h"
#include "entity_state.h"
#include "cl_entity.h"
#include "pm_shared.h"
#include "vgui_TeamFortressViewport.h"
#include "vgui_SpectatorPanel.h"
#include "vgui_scorepanel.h"
#define PANEL_HEIGHT 32
#define BANNER_WIDTH 256
#define BANNER_HEIGHT 64
#define OPTIONS_BUTTON_X 96
#define CAMOPTIONS_BUTTON_X 200
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
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_OPTIONS : gViewPort->ShowCommandMenu( gViewPort->m_SpectatorOptionsMenu );
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_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;
default : gEngfuncs.Con_DPrintf("Unknown SpectatorPanel ActionSingal %i.\n",cmd); break;
}
}
void SpectatorPanel::Initialize()
{
int x,y,wide,tall;
getBounds(x,y,wide,tall);
CSchemeManager * pSchemes = gViewPort->GetSchemeManager();
SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle( "Team Info Text" );
m_TopBorder = new CTransparentPanel(64, 0, 0, ScreenWidth, YRES(PANEL_HEIGHT));
m_TopBorder->setParent(this);
m_BottomBorder = new CTransparentPanel(64, 0, ScreenHeight - YRES(32), ScreenWidth, YRES(PANEL_HEIGHT));
m_BottomBorder->setParent(this);
setPaintBackgroundEnabled(false);
m_ExtraInfo = new Label( "Extra Info", 0, 0, wide, YRES(PANEL_HEIGHT) );
m_ExtraInfo->setParent(m_TopBorder);
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_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->setParent(this);
m_CurrentTime = new Label( "00:00", 0, 0, wide, YRES(PANEL_HEIGHT) );
m_CurrentTime->setParent(m_TopBorder);
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_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, YRES(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 );
}
// 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->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 ColorButton( 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->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->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 );
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( new LineBorder( Color( 59, 58, 34, 48 ) ) );
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_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 );
}
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 );
if ( !isVisible )
{
int iLabelSizeX, iLabelSizeY;
m_BottomMainLabel->getSize( iLabelSizeX, iLabelSizeY );
m_BottomMainLabel->setPos( ( ScreenWidth / 2 ) - (iLabelSizeX/2), YRES(6) );
}
else
m_BottomMainLabel->setPos( XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6) );
if ( !isVisible )
{
gViewPort->HideCommandMenu();
// if switching from visible menu to invisible menu, show help text
if ( m_menuVisible && this->isVisible() )
{
char string[ 64 ];
_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 );
}
}
m_menuVisible = isVisible;
gViewPort->UpdateCursorState();
}
const char *GetSpectatorLabel ( int iMode )
{
switch ( iMode )
{
case OBS_CHASE_LOCKED:
return "#OBS_CHASE_LOCKED";
case OBS_CHASE_FREE:
return "#OBS_CHASE_FREE";
case OBS_ROAMING:
return "#OBS_ROAMING";
case OBS_IN_EYE:
return "#OBS_IN_EYE";
case OBS_MAP_FREE:
return "#OBS_MAP_FREE";
case OBS_MAP_CHASE:
return "#OBS_MAP_CHASE";
case OBS_NONE:
default:
return "#OBS_NONE";
}
return "";
}
void SpectatorPanel::EnableInsetView(bool isEnabled)
{
int x = gHUD.m_Spectator.m_OverviewData.insetWindowX;
int y = gHUD.m_Spectator.m_OverviewData.insetWindowY;
int wide = gHUD.m_Spectator.m_OverviewData.insetWindowWidth;
int tall = gHUD.m_Spectator.m_OverviewData.insetWindowHeight;
int offset = x + wide + 2;
if ( isEnabled )
{
// short black bar to see full inset
m_TopBorder->setBounds( XRES(offset), 0, XRES(640 - offset ), YRES(PANEL_HEIGHT) );
if ( gEngfuncs.IsSpectateOnly() )
{
m_TopBanner->setVisible( true );
m_TopBanner->setPos( XRES(offset), 0 );
}
else
m_TopBanner->setVisible( false );
m_InsetViewButton->setBounds( XRES( x ), YRES( y ),
XRES( wide ), YRES( tall ) );
m_InsetViewButton->setVisible(true);
}
else
{
// full black bar, no inset border
// show banner only in real HLTV mode
if ( gEngfuncs.IsSpectateOnly() )
{
m_TopBanner->setVisible( true );
m_TopBanner->setPos( 0,0 );
}
else
m_TopBanner->setVisible( false );
m_TopBorder->setBounds( 0, 0, ScreenWidth, YRES(PANEL_HEIGHT) );
m_InsetViewButton->setVisible(false);
}
m_insetVisible = isEnabled;
Update();
m_CamButton->setText( CHudTextMessage::BufferedLocaliseTextString( GetSpectatorLabel( g_iUser1 ) ) );
}
void SpectatorPanel::Update()
{
int iTextWidth, iTextHeight;
int iTimeHeight, iTimeWidth;
int offset,j;
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 );
if ( !visible )
return;
m_ExtraInfo->getTextSize( iTextWidth, iTextHeight );
m_CurrentTime->getTextSize( iTimeWidth, iTimeHeight );
iTimeWidth += XRES ( 14 ); // +timer icon
iTimeWidth += ( 4-(iTimeWidth%4) );
if ( iTimeWidth > iTextWidth )
iTextWidth = iTimeWidth;
int xPos = ScreenWidth - ( iTextWidth + XRES ( 4 + offset ) );
m_ExtraInfo->setBounds( xPos, YRES( 1 ), iTextWidth, iTextHeight );
m_TimerImage->setBounds( xPos, YRES( 2 ) + iTextHeight , XRES(14), YRES(14) );
m_CurrentTime->setBounds( xPos + XRES ( 14 + 1 ), YRES( 2 ) + iTextHeight , iTimeWidth, iTimeHeight );
m_Separator->setPos( ScreenWidth - ( iTextWidth + XRES ( 4+2+4+offset ) ) , YRES( 1 ) );
m_Separator->setSize( XRES( 4 ), YRES( PANEL_HEIGHT - 2 ) );
for ( j= 0; j < TEAM_NUMBER; j++ )
{
int iwidth, iheight;
m_TeamScores[j]->getTextSize( iwidth, iheight );
m_TeamScores[j]->setBounds( ScreenWidth - ( iTextWidth + XRES ( 4+2+4+2+offset ) + iwidth ), YRES( 1 ) + ( iheight * j ), iwidth, iheight );
}
}

View file

@ -0,0 +1,102 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// vgui_SpectatorPanel.h: interface for the SpectatorPanel class.
//
//////////////////////////////////////////////////////////////////////
#ifndef SPECTATORPANEL_H
#define SPECTATORPANEL_H
#include <VGUI_Panel.h>
#include <VGUI_Label.h>
#include <VGUI_Button.h>
using namespace vgui;
#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 TEAM_NUMBER 2
class SpectatorPanel : public Panel //, public vgui::CDefaultInputSignal
{
public:
SpectatorPanel(int x,int y,int wide,int tall);
virtual ~SpectatorPanel();
void ActionSignal(int cmd);
// InputSignal overrides.
public:
void Initialize();
void Update();
public:
void EnableInsetView(bool isEnabled);
void ShowMenu(bool isVisible);
ColorButton * m_OptionButton;
// CommandButton * m_HideButton;
ColorButton * m_PrevPlayerButton;
ColorButton * m_NextPlayerButton;
ColorButton * m_CamButton;
CTransparentPanel * m_TopBorder;
CTransparentPanel * m_BottomBorder;
ColorButton *m_InsetViewButton;
Label *m_BottomMainLabel;
CImageLabel *m_TimerImage;
Label *m_CurrentTime;
Label *m_ExtraInfo;
Panel *m_Separator;
Label *m_TeamScores[TEAM_NUMBER];
CImageLabel *m_TopBanner;
bool m_menuVisible;
bool m_insetVisible;
};
class CSpectatorHandler_Command : public ActionSignal
{
private:
SpectatorPanel * m_pFather;
int m_cmd;
public:
CSpectatorHandler_Command( SpectatorPanel * panel, int cmd )
{
m_pFather = panel;
m_cmd = cmd;
}
virtual void actionPerformed( Panel * panel )
{
m_pFather->ActionSignal(m_cmd);
}
};
#endif // !defined SPECTATORPANEL_H

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef TEAMFORTRESSVIEWPORT_H
#define TEAMFORTRESSVIEWPORT_H
@ -32,6 +38,7 @@ using namespace vgui;
class Cursor;
class ScorePanel;
class SpectatorPanel;
class CCommandMenu;
class CommandLabel;
class CommandButton;
@ -45,21 +52,18 @@ class CClassMenuPanel;
class CTeamMenuPanel;
char* GetVGUITGAName(const char *pszName);
BitmapTGA *LoadTGA( const char* pImageName );
BitmapTGA *LoadTGAForRes(const char* pImageName);
void ScaleColors( int &r, int &g, int &b, int a );
extern char *sTFClassSelection[];
extern int sTFValidClassInts[];
extern char *sLocalisedClasses[];
extern int iTeamColors[5][3];
extern int iNumberOfTeamColors;
#define MAX_SERVERNAME_LENGTH 32
// Use this to set any co-ords in 640x480 space
#define XRES(x) (x * ((float)ScreenWidth / 640))
#define YRES(y) (y * ((float)ScreenHeight / 480))
// Command Menu positions
#define MAX_MENUS 40
#define MAX_MENUS 80
#define MAX_BUTTONS 100
#define BUTTON_SIZE_Y YRES(30)
@ -111,6 +115,7 @@ public:
BitmapTGA *m_pTGA;
public:
void LoadImage(const char * pImageName);
CImageLabel( const char* pImageName,int x,int y );
CImageLabel( const char* pImageName,int x,int y,int wide,int tall );
@ -155,6 +160,7 @@ class CommandButton : public Button
{
private:
int m_iPlayerClass;
bool m_bFlat;
// Submenus under this button
CCommandMenu *m_pSubMenu;
@ -172,9 +178,10 @@ public:
bool m_bNoHighlight;
public:
CommandButton(const char* text,int x,int y,int wide,int tall, bool bNoHighlight, bool bFlat);
// Constructors
CommandButton( const char* text,int x,int y,int wide,int tall, bool bNoHighlight = false);
CommandButton( int iPlayerClass, const char* text,int x,int y,int wide,int tall);
CommandButton( int iPlayerClass, const char* text,int x,int y,int wide,int tall, bool bFlat );
void Init( void );
@ -209,6 +216,142 @@ public:
char getBoundKey( void );
};
class ColorButton : public CommandButton
{
private:
Color *ArmedColor;
Color *UnArmedColor;
Color *ArmedBorderColor;
Color *UnArmedBorderColor;
public:
ColorButton( const char* text,int x,int y,int wide,int tall, bool bNoHighlight, bool bFlat ) :
CommandButton( text, x, y, wide, tall, bNoHighlight, bFlat )
{
ArmedColor = NULL;
UnArmedColor = NULL;
ArmedBorderColor = NULL;
UnArmedBorderColor = NULL;
}
virtual void paintBackground()
{
int r, g, b, a;
Color bgcolor;
if ( isArmed() )
{
// Highlight background
/* getBgColor(bgcolor);
bgcolor.getColor(r, g, b, a);
drawSetColor( r,g,b,a );
drawFilledRect(0,0,_size[0],_size[1]);*/
if ( ArmedBorderColor )
{
ArmedBorderColor->getColor( r, g, b, a);
drawSetColor( r, g, b, a );
drawOutlinedRect(0,0,_size[0],_size[1]);
}
}
else
{
if ( UnArmedBorderColor )
{
UnArmedBorderColor->getColor( r, g, b, a);
drawSetColor( r, g, b, a );
drawOutlinedRect(0,0,_size[0],_size[1]);
}
}
}
void paint()
{
int r, g, b, a;
if ( isArmed() )
{
if (ArmedColor)
{
ArmedColor->getColor(r, g, b, a);
setFgColor(r, g, b, a);
}
else
setFgColor( Scheme::sc_secondary2 );
}
else
{
if (UnArmedColor)
{
UnArmedColor->getColor(r, g, b, a);
setFgColor(r, g, b, a);
}
else
setFgColor( Scheme::sc_primary1 );
}
Button::paint();
}
void setArmedColor ( int r, int g, int b, int a )
{
ArmedColor = new Color( r, g, b, a );
}
void setUnArmedColor ( int r, int g, int b, int a )
{
UnArmedColor = new Color( r, g, b, a );
}
void setArmedBorderColor ( int r, int g, int b, int a )
{
ArmedBorderColor = new Color( r, g, b, a );
}
void setUnArmedBorderColor ( int r, int g, int b, int a )
{
UnArmedBorderColor = new Color( r, g, b, a );
}
};
class SpectButton : public CommandButton
{
private:
public:
SpectButton( int iPlayerClass, const char* text,int x,int y,int wide,int tall ) :
CommandButton( text, x, y, wide, tall, false)
{
Init();
setText( text );
}
virtual void paintBackground()
{
if ( isArmed())
{
drawSetColor( 143,143, 54, 125 );
drawFilledRect( 5, 0,_size[0] - 5,_size[1]);
}
}
virtual void paint()
{
if ( isArmed() )
{
setFgColor( 194, 202, 54, 0 );
}
else
{
setFgColor( 143, 143, 54, 15 );
}
Button::paint();
}
};
//============================================================
// Command Menus
class CCommandMenu : public Panel
@ -222,6 +365,8 @@ private:
CommandButton *m_aButtons[ MAX_BUTTONS ];
int m_iButtons;
// opens menu from top to bottom (0 = default), or from bottom to top (1)?
int m_iDirection;
public:
CCommandMenu( CCommandMenu *pParentMenu, int x,int y,int wide,int tall ) : Panel(x,y,wide,tall)
{
@ -229,8 +374,20 @@ public:
m_iXOffset = x;
m_iYOffset = y;
m_iButtons = 0;
m_iDirection = 0;
}
CCommandMenu( CCommandMenu *pParentMenu, int direction, int x,int y,int wide,int tall ) : Panel(x,y,wide,tall)
{
m_pParentMenu = pParentMenu;
m_iXOffset = x;
m_iYOffset = y;
m_iButtons = 0;
m_iDirection = direction;
}
float m_flButtonSizeY;
int m_iSpectCmdMenu;
void AddButton( CommandButton *pButton );
bool RecalculateVisibles( int iNewYPos, bool bHideAll );
void RecalculatePositions( int iYOffset );
@ -239,6 +396,7 @@ public:
CCommandMenu *GetParentMenu() { return m_pParentMenu; };
int GetXOffset() { return m_iXOffset; };
int GetYOffset() { return m_iYOffset; };
int GetDirection() { return m_iDirection; };
int GetNumButtons() { return m_iButtons; };
CommandButton *FindButtonWithSubmenu( CCommandMenu *pSubMenu );
@ -263,11 +421,13 @@ private:
CCommandMenu *m_pCurrentCommandMenu;
float m_flMenuOpenTime;
float m_flScoreBoardLastUpdated;
float m_flSpectatorPanelLastUpdated;
int m_iNumMenus;
int m_iCurrentTeamNumber;
int m_iCurrentPlayerClass;
int m_iUser1;
int m_iUser2;
int m_iUser3;
// VGUI Menus
void CreateTeamMenu( void );
@ -292,9 +452,6 @@ private:
// Server Browser
ServerBrowser *m_pServerBrowser;
// Spectator "menu"
CTransparentPanel *m_pSpectatorMenu;
Label *m_pSpectatorLabel;
int m_iAllowSpectators;
// Data for specific sections of the Command Menu
@ -314,24 +471,24 @@ public:
TeamFortressViewport(int x,int y,int wide,int tall);
void Initialize( void );
void CreateCommandMenu( void );
void CreateScoreBoard( void );
void CreateServerBrowser( void );
CommandButton *CreateCustomButton( char *pButtonText, char *pButtonName );
CCommandMenu *CreateDisguiseSubmenu( CommandButton *pButton, CCommandMenu *pParentMenu, const char *commandText );
int CreateCommandMenu( char * menuFile, int direction, int yOffset, bool flatDesign, float flButtonSizeX, float flButtonSizeY, int xOffset );
void CreateScoreBoard( void );
void CreateServerBrowser( void );
CommandButton * CreateCustomButton( char *pButtonText, char * pButtonName, int iYOffset );
CCommandMenu * CreateDisguiseSubmenu( CommandButton *pButton, CCommandMenu *pParentMenu, const char *commandText, int iYOffset, int iXOffset = 0 );
void UpdateCursorState( void );
void UpdateCommandMenu( void );
void UpdateCommandMenu(int menuIndex);
void UpdateOnPlayerInfo( void );
void UpdateHighlights( void );
void UpdateSpectatorMenu( void );
void UpdateSpectatorPanel( void );
int KeyInput( int down, int keynum, const char *pszCurrentBinding );
void InputPlayerSpecial( void );
void GetAllPlayersInfo( void );
void DeathMsg( int killer, int victim );
void ShowCommandMenu( void );
void ShowCommandMenu(int menuIndex);
void InputSignalHideCommandMenu( void );
void HideCommandMenu( void );
void SetCurrentCommandMenu( CCommandMenu *pNewMenu );
@ -351,7 +508,7 @@ public:
CMenuPanel* CreateTextWindow( int iTextToShow );
CCommandMenu *CreateSubMenu( CommandButton *pButton, CCommandMenu *pParentMenu );
CCommandMenu *CreateSubMenu( CommandButton *pButton, CCommandMenu *pParentMenu, int iYOffset, int iXOffset = 0 );
// Data Handlers
int GetValidClasses(int iTeam) { return m_iValidClasses[iTeam]; };
@ -385,6 +542,7 @@ public:
virtual void paintBackground();
CSchemeManager *GetSchemeManager( void ) { return &m_SchemeManager; }
ScorePanel *GetScoreBoard( void ) { return m_pScoreBoard; }
void *operator new( size_t stAllocateBlock );
@ -392,8 +550,12 @@ public:
// VGUI Menus
CMenuPanel *m_pCurrentMenu;
CTeamMenuPanel *m_pTeamMenu;
int m_StandardMenu; // indexs in m_pCommandMenus
int m_SpectatorOptionsMenu;
int m_SpectatorCameraMenu;
CClassMenuPanel *m_pClassMenu;
ScorePanel *m_pScoreBoard;
SpectatorPanel * m_pSpectatorPanel;
char m_szServerName[ MAX_SERVERNAME_LENGTH ];
};
@ -545,6 +707,7 @@ public:
#define SHOW_MAPBRIEFING 1
#define SHOW_CLASSDESC 2
#define SHOW_MOTD 3
#define SHOW_SPECHELP 4
class CMenuHandler_TextWindow : public ActionSignal
{
@ -570,6 +733,29 @@ public:
}
};
class CMenuHandler_ToggleCvar : public ActionSignal
{
private:
struct cvar_s * m_cvar;
public:
CMenuHandler_ToggleCvar( char * cvarname )
{
m_cvar = gEngfuncs.pfnGetCvarPointer( cvarname );
}
virtual void actionPerformed(Panel* panel)
{
if ( m_cvar->value )
m_cvar->value = 0.0f;
else
m_cvar->value = 1.0f;
gViewPort->UpdateSpectatorPanel();
}
};
class CDragNDropHandler : public InputSignal
{
private:
@ -936,8 +1122,8 @@ private:
int m_iTeamNum;
public:
TeamOnlyCommandButton( int iTeamNum, const char* text,int x,int y,int wide,int tall ) :
CommandButton( text, x, y, wide, tall ), m_iTeamNum(iTeamNum) {}
TeamOnlyCommandButton( int iTeamNum, const char* text,int x,int y,int wide,int tall, bool flat ) :
CommandButton( text, x, y, wide, tall, false, flat ), m_iTeamNum(iTeamNum) {}
virtual int IsNotValid()
{
@ -946,8 +1132,282 @@ public:
return CommandButton::IsNotValid();
}
virtual void paintBackground()
{
if ( isArmed() )
{
drawSetColor( 143,143, 54, 125 );
drawFilledRect( 5, 0,_size[0] - 5,_size[1]);
}
}
virtual void paint( void )
{
if ( isArmed() )
{
setFgColor( 194, 202, 54, 0 );
}
else
{
setFgColor( 143, 143, 54, 15 );
}
Button::paint();
}
};
//-----------------------------------------------------------------------------
// Purpose: CommandButton which is only displayed if the player is on team X
//-----------------------------------------------------------------------------
class ToggleCommandButton : public CommandButton, public InputSignal
{
private:
struct cvar_s * m_cvar;
CImageLabel * pLabelOn;
CImageLabel * pLabelOff;
public:
ToggleCommandButton( const char* cvarname, const char* text,int x,int y,int wide,int tall, bool flat ) :
CommandButton( text, x, y, wide, tall, false, flat )
{
m_cvar = gEngfuncs.pfnGetCvarPointer( cvarname );
// Put a > to show it's a submenu
pLabelOn = new CImageLabel( "checked", 0, 0 );
pLabelOn->setParent(this);
pLabelOn->addInputSignal(this);
pLabelOff = new CImageLabel( "unchecked", 0, 0 );
pLabelOff->setParent(this);
pLabelOff->setEnabled(true);
pLabelOff->addInputSignal(this);
int textwide, texttall;
getTextSize( textwide, texttall);
// Reposition
pLabelOn->setPos( textwide, (tall - pLabelOn->getTall()) / 2 );
pLabelOff->setPos( textwide, (tall - pLabelOff->getTall()) / 2 );
// Set text color to orange
setFgColor(Scheme::sc_primary1);
}
virtual void cursorEntered(Panel* panel)
{
CommandButton::cursorEntered();
}
virtual void cursorExited(Panel* panel)
{
CommandButton::cursorExited();
}
virtual void mousePressed(MouseCode code,Panel* panel)
{
doClick();
};
virtual void cursorMoved(int x,int y,Panel* panel) {};
virtual void mouseDoublePressed(MouseCode code,Panel* panel) {};
virtual void mouseReleased(MouseCode code,Panel* panel) {};
virtual void mouseWheeled(int delta,Panel* panel) {};
virtual void keyPressed(KeyCode code,Panel* panel) {};
virtual void keyTyped(KeyCode code,Panel* panel) {};
virtual void keyReleased(KeyCode code,Panel* panel) {};
virtual void keyFocusTicked(Panel* panel) {};
virtual void paint( void )
{
if ( !m_cvar )
{
pLabelOff->setVisible(false);
pLabelOn->setVisible(false);
}
else if ( m_cvar->value )
{
pLabelOff->setVisible(false);
pLabelOn->setVisible(true);
}
else
{
pLabelOff->setVisible(true);
pLabelOn->setVisible(false);
}
CommandButton::paint();
}
};
class SpectToggleButton : public CommandButton, public InputSignal
{
private:
struct cvar_s * m_cvar;
CImageLabel * pLabelOn;
public:
SpectToggleButton( const char* cvarname, const char* text,int x,int y,int wide,int tall, bool flat ) :
CommandButton( text, x, y, wide, tall, false, flat )
{
m_cvar = gEngfuncs.pfnGetCvarPointer( cvarname );
// Put a > to show it's a submenu
pLabelOn = new CImageLabel( "checked", 0, 0 );
pLabelOn->setParent(this);
pLabelOn->addInputSignal(this);
int textwide, texttall;
getTextSize( textwide, texttall);
// Reposition
pLabelOn->setPos( textwide, (tall - pLabelOn->getTall()) / 2 );
}
virtual void cursorEntered(Panel* panel)
{
CommandButton::cursorEntered();
}
virtual void cursorExited(Panel* panel)
{
CommandButton::cursorExited();
}
virtual void mousePressed(MouseCode code,Panel* panel)
{
doClick();
};
virtual void cursorMoved(int x,int y,Panel* panel) {};
virtual void mouseDoublePressed(MouseCode code,Panel* panel) {};
virtual void mouseReleased(MouseCode code,Panel* panel) {};
virtual void mouseWheeled(int delta,Panel* panel) {};
virtual void keyPressed(KeyCode code,Panel* panel) {};
virtual void keyTyped(KeyCode code,Panel* panel) {};
virtual void keyReleased(KeyCode code,Panel* panel) {};
virtual void keyFocusTicked(Panel* panel) {};
virtual void paintBackground()
{
if ( isArmed() )
{
drawSetColor( 143,143, 54, 125 );
drawFilledRect( 5, 0,_size[0] - 5,_size[1]);
}
}
virtual void paint( void )
{
if ( isArmed() )
{
setFgColor( 194, 202, 54, 0 );
}
else
{
setFgColor( 143, 143, 54, 15 );
}
if ( !m_cvar )
{
pLabelOn->setVisible(false);
}
else if ( m_cvar->value )
{
pLabelOn->setVisible(true);
}
else
{
pLabelOn->setVisible(false);
}
Button::paint();
}
};
/*
class SpectToggleButton : public ToggleCommandButton
{
private:
struct cvar_s * m_cvar;
CImageLabel * pLabelOn;
CImageLabel * pLabelOff;
public:
SpectToggleButton( const char* cvarname, const char* text,int x,int y,int wide,int tall, bool flat ) :
ToggleCommandButton( cvarname, text, x, y, wide, tall, flat, TRUE )
{
m_cvar = gEngfuncs.pfnGetCvarPointer( cvarname );
// Put a > to show it's a submenu
pLabelOn = new CImageLabel( "checked", 0, 0 );
pLabelOn->setParent(this);
pLabelOn->addInputSignal(this);
pLabelOff = new CImageLabel( "unchecked", 0, 0 );
pLabelOff->setParent(this);
pLabelOff->setEnabled(true);
pLabelOff->addInputSignal(this);
int textwide, texttall;
getTextSize( textwide, texttall);
// Reposition
pLabelOn->setPos( textwide, (tall - pLabelOn->getTall()) / 2 );
pLabelOff->setPos( textwide, (tall - pLabelOff->getTall()) / 2 );
// Set text color to orange
setFgColor(Scheme::sc_primary1);
}
virtual void paintBackground()
{
if ( isArmed())
{
drawSetColor( 143,143, 54, 125 );
drawFilledRect( 5, 0,_size[0] - 5,_size[1]);
}
}
virtual void paint()
{
if ( isArmed() )
{
setFgColor( 194, 202, 54, 0 );
}
else
{
setFgColor( 143, 143, 54, 15 );
}
if ( !m_cvar )
{
pLabelOff->setVisible(false);
pLabelOn->setVisible(false);
}
else if ( m_cvar->value )
{
pLabelOff->setVisible(false);
pLabelOn->setVisible(true);
}
else
{
pLabelOff->setVisible(true);
pLabelOn->setVisible(false);
}
Button::paint();
}
};
*/
//============================================================
// Panel that can be dragged around
class DragNDropPanel : public Panel
@ -1252,4 +1712,4 @@ public:
}
};
#endif
#endif

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include"vgui_int.h"
#include<VGUI_Label.h>

View file

@ -1,3 +1,9 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_INT_H
#define VGUI_INT_H

View file

@ -1,4 +1,4 @@
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
@ -100,7 +100,7 @@ CTeamMenuPanel::CTeamMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide,i
pSchemes->getBgColor( hTeamWindowText, r, g, b, a );
m_pBriefing->setBgColor( r, g, b, a );
m_pBriefing->setText("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++)
@ -132,7 +132,10 @@ CTeamMenuPanel::CTeamMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide,i
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][0], iTeamColors[i][1], iTeamColors[i][2], 0 );
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 );
}
@ -300,6 +303,7 @@ void CTeamMenuPanel::Update( void )
int iXSize, iYSize;
m_pBriefing->getTextImage()->getTextSize( iXSize, iYSize );
m_pBriefing->setSize( iXSize, iYSize );
gEngfuncs.COM_FreeFile( pfile );
}
m_bUpdatedMapName = true;

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined ( VIEWH )
#define VIEWH
#pragma once

View file

@ -1,3 +1,10 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( WRECTH )
#define WRECTH

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, 2000 Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -59,4 +59,4 @@ struct beam_s
struct particle_s *particles;
};
#endif
#endif

View file

@ -1,6 +1,6 @@
/***
*
* Copyright (c) 1999, 2000 Valve LLC. All rights reserved.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
@ -112,4 +112,4 @@ struct cl_entity_s
colorVec cvFloorColor;
};
#endif // !CL_ENTITYH
#endif // !CL_ENTITYH

351
common/com_model.h Normal file
View file

@ -0,0 +1,351 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// com_model.h
#if !defined( COM_MODEL_H )
#define COM_MODEL_H
#if defined( _WIN32 )
#pragma once
#endif
#define STUDIO_RENDER 1
#define STUDIO_EVENTS 2
#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 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 ZISCALE ((float)0x8000)
#define CACHE_SIZE 32 // used to align key data structures
typedef enum
{
mod_brush,
mod_sprite,
mod_alias,
mod_studio
} modtype_t;
// must match definition in modelgen.h
#ifndef SYNCTYPE_T
#define SYNCTYPE_T
typedef enum
{
ST_SYNC=0,
ST_RAND
} synctype_t;
#endif
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;
} dmodel_t;
// plane_t structure
typedef struct mplane_s
{
vec3_t 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
{
vec3_t position;
} mvertex_t;
typedef struct
{
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;
} 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
} 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
struct mnode_s *parent;
// 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;
// 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
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
short minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
// 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];
} mleaf_t;
struct msurface_s
{
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.
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];
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
} dclipnode_t;
typedef struct hull_s
{
dclipnode_t *clipnodes;
mplane_t *planes;
int firstclipnode;
int lastclipnode;
vec3_t clip_mins;
vec3_t clip_maxs;
} hull_t;
#if !defined( CACHE_USER ) && !defined( QUAKEDEF_H )
#define CACHE_USER
typedef struct cache_user_s
{
void *data;
} cache_user_t;
#endif
typedef struct model_s
{
char name[ MAX_MODEL_NAME ];
qboolean needload; // bmodels and sprites don't cache normally
modtype_t type;
int numframes;
synctype_t synctype;
int flags;
//
// volume occupied by the model
//
vec3_t mins, maxs;
float radius;
//
// brush model
//
int firstmodelsurface, nummodelsurfaces;
int numsubmodels;
dmodel_t *submodels;
int numplanes;
mplane_t *planes;
int numleafs; // number of visible leafs, not counting 0
struct mleaf_s *leafs;
int numvertexes;
mvertex_t *vertexes;
int numedges;
medge_t *edges;
int numnodes;
mnode_t *nodes;
int numtexinfo;
mtexinfo_t *texinfo;
int numsurfaces;
msurface_t *surfaces;
int numsurfedges;
int *surfedges;
int numclipnodes;
dclipnode_t *clipnodes;
int nummarksurfaces;
msurface_t **marksurfaces;
hull_t hulls[MAX_MAP_HULLS];
int numtextures;
texture_t **textures;
byte *visdata;
color24 *lightdata;
char *entities;
//
// additional model data
//
cache_user_t cache; // only access through Mod_Extradata
} model_t;
typedef vec_t vec4_t[4];
typedef struct alight_s
{
int ambientlight; // clip at 128
int shadelight; // clip at 192 - ambientlight
vec3_t color;
float *plightvec;
} alight_t;
typedef struct auxvert_s
{
float fv[3]; // viewspace x, y
} auxvert_t;
#include "custom.h"
#define MAX_INFO_STRING 256
#define MAX_SCOREBOARDNAME 32
typedef struct player_info_s
{
// User id on server
int userid;
// User info string
char userinfo[ MAX_INFO_STRING ];
// Name
char name[ MAX_SCOREBOARDNAME ];
// Spectator or not, unused
int spectator;
int ping;
int packet_loss;
// skin information
char model[MAX_QPATH];
int topcolor;
int bottomcolor;
// last frame rendered
int renderframe;
// Gait frame estimation
int gaitsequence;
float gaitframe;
float gaityaw;
vec3_t prevgaitorigin;
customization_t customdata;
} player_info_t;
#endif // #define COM_MODEL_H

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