mirror of https://github.com/FWGS/hlsdk-xash3d
CRLF to LF all.
This commit is contained in:
parent
e0136428bb
commit
4304846337
|
@ -1,118 +1,118 @@
|
|||
//========= 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.
|
||||
====================
|
||||
*/
|
||||
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;
|
||||
}
|
||||
//========= 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.
|
||||
====================
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1,26 +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 );
|
||||
};
|
||||
|
||||
//========= 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
|
File diff suppressed because it is too large
Load Diff
|
@ -1,55 +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;
|
||||
};
|
||||
|
||||
//========= 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
|
@ -1,189 +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 ];
|
||||
};
|
||||
|
||||
//========= 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
|
2406
cl_dll/ammo.cpp
2406
cl_dll/ammo.cpp
File diff suppressed because it is too large
Load Diff
122
cl_dll/ammo.h
122
cl_dll/ammo.h
|
@ -1,62 +1,62 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef __AMMO_H__
|
||||
#define __AMMO_H__
|
||||
|
||||
#define MAX_WEAPON_NAME 128
|
||||
|
||||
|
||||
#define WEAPON_FLAGS_SELECTONEMPTY 1
|
||||
|
||||
#define WEAPON_IS_ONTARGET 0x40
|
||||
|
||||
struct WEAPON
|
||||
{
|
||||
char szName[MAX_WEAPON_NAME];
|
||||
int iAmmoType;
|
||||
int iAmmo2Type;
|
||||
int iMax1;
|
||||
int iMax2;
|
||||
int iSlot;
|
||||
int iSlotPos;
|
||||
int iFlags;
|
||||
int iId;
|
||||
int iClip;
|
||||
|
||||
int iCount; // # of itesm in plist
|
||||
|
||||
HSPRITE hActive;
|
||||
wrect_t rcActive;
|
||||
HSPRITE hInactive;
|
||||
wrect_t rcInactive;
|
||||
HSPRITE hAmmo;
|
||||
wrect_t rcAmmo;
|
||||
HSPRITE hAmmo2;
|
||||
wrect_t rcAmmo2;
|
||||
HSPRITE hCrosshair;
|
||||
wrect_t rcCrosshair;
|
||||
HSPRITE hAutoaim;
|
||||
wrect_t rcAutoaim;
|
||||
HSPRITE hZoomedCrosshair;
|
||||
wrect_t rcZoomedCrosshair;
|
||||
HSPRITE hZoomedAutoaim;
|
||||
wrect_t rcZoomedAutoaim;
|
||||
};
|
||||
|
||||
typedef int AMMO;
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef __AMMO_H__
|
||||
#define __AMMO_H__
|
||||
|
||||
#define MAX_WEAPON_NAME 128
|
||||
|
||||
|
||||
#define WEAPON_FLAGS_SELECTONEMPTY 1
|
||||
|
||||
#define WEAPON_IS_ONTARGET 0x40
|
||||
|
||||
struct WEAPON
|
||||
{
|
||||
char szName[MAX_WEAPON_NAME];
|
||||
int iAmmoType;
|
||||
int iAmmo2Type;
|
||||
int iMax1;
|
||||
int iMax2;
|
||||
int iSlot;
|
||||
int iSlotPos;
|
||||
int iFlags;
|
||||
int iId;
|
||||
int iClip;
|
||||
|
||||
int iCount; // # of itesm in plist
|
||||
|
||||
HSPRITE hActive;
|
||||
wrect_t rcActive;
|
||||
HSPRITE hInactive;
|
||||
wrect_t rcInactive;
|
||||
HSPRITE hAmmo;
|
||||
wrect_t rcAmmo;
|
||||
HSPRITE hAmmo2;
|
||||
wrect_t rcAmmo2;
|
||||
HSPRITE hCrosshair;
|
||||
wrect_t rcCrosshair;
|
||||
HSPRITE hAutoaim;
|
||||
wrect_t rcAutoaim;
|
||||
HSPRITE hZoomedCrosshair;
|
||||
wrect_t rcZoomedCrosshair;
|
||||
HSPRITE hZoomedAutoaim;
|
||||
wrect_t rcZoomedAutoaim;
|
||||
};
|
||||
|
||||
typedef int AMMO;
|
||||
|
||||
|
||||
#endif
|
|
@ -1,159 +1,159 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammo_secondary.cpp
|
||||
//
|
||||
// implementation of CHudAmmoSecondary class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
|
||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
|
||||
|
||||
int CHudAmmoSecondary :: Init( void )
|
||||
{
|
||||
HOOK_MESSAGE( SecAmmoVal );
|
||||
HOOK_MESSAGE( SecAmmoIcon );
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
m_HUD_ammoicon = 0;
|
||||
|
||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
||||
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
|
||||
|
||||
Reset();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudAmmoSecondary :: Reset( void )
|
||||
{
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
int CHudAmmoSecondary :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudAmmoSecondary :: Draw(float flTime)
|
||||
{
|
||||
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
|
||||
return 1;
|
||||
|
||||
// draw secondary ammo icons above normal ammo readout
|
||||
int a, x, y, r, g, b, AmmoWidth;
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
a = (int) max( MIN_ALPHA, m_fFade );
|
||||
if (m_fFade > 0)
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
|
||||
ScaleColors( r, g, b, a );
|
||||
|
||||
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
|
||||
|
||||
y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values
|
||||
x = ScreenWidth - AmmoWidth;
|
||||
|
||||
if ( m_HUD_ammoicon )
|
||||
{
|
||||
// Draw the ammo icon
|
||||
x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left);
|
||||
y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom);
|
||||
|
||||
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
|
||||
}
|
||||
else
|
||||
{ // move the cursor by the '0' char instead, since we don't have an icon to work with
|
||||
x -= AmmoWidth;
|
||||
y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom);
|
||||
}
|
||||
|
||||
// draw the ammo counts, in reverse order, from right to left
|
||||
for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
|
||||
{
|
||||
if ( m_iAmmoAmounts[i] < 0 )
|
||||
continue; // negative ammo amounts imply that they shouldn't be drawn
|
||||
|
||||
// half a char gap between the ammo number and the previous pic
|
||||
x -= (AmmoWidth / 2);
|
||||
|
||||
// draw the number, right-aligned
|
||||
x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
|
||||
gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
|
||||
|
||||
if ( i != 0 )
|
||||
{
|
||||
// draw the divider bar
|
||||
x -= (AmmoWidth / 2);
|
||||
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for Secondary Ammo Value
|
||||
// accepts one value:
|
||||
// string: sprite name
|
||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for Secondary Ammo Icon
|
||||
// Sets an ammo value
|
||||
// takes two values:
|
||||
// byte: ammo index
|
||||
// byte: ammo value
|
||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int index = READ_BYTE();
|
||||
if ( index < 0 || index >= MAX_SEC_AMMO_VALUES )
|
||||
return 1;
|
||||
|
||||
m_iAmmoAmounts[index] = READ_BYTE();
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
// check to see if there is anything left to draw
|
||||
int count = 0;
|
||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
||||
{
|
||||
count += max( 0, m_iAmmoAmounts[i] );
|
||||
}
|
||||
|
||||
if ( count == 0 )
|
||||
{ // the ammo fields are all empty, so turn off this hud area
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// make the icons light up
|
||||
m_fFade = 200.0f;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammo_secondary.cpp
|
||||
//
|
||||
// implementation of CHudAmmoSecondary class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
|
||||
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
|
||||
|
||||
int CHudAmmoSecondary :: Init( void )
|
||||
{
|
||||
HOOK_MESSAGE( SecAmmoVal );
|
||||
HOOK_MESSAGE( SecAmmoIcon );
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
m_HUD_ammoicon = 0;
|
||||
|
||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
||||
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
|
||||
|
||||
Reset();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudAmmoSecondary :: Reset( void )
|
||||
{
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
int CHudAmmoSecondary :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudAmmoSecondary :: Draw(float flTime)
|
||||
{
|
||||
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
|
||||
return 1;
|
||||
|
||||
// draw secondary ammo icons above normal ammo readout
|
||||
int a, x, y, r, g, b, AmmoWidth;
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
a = (int) max( MIN_ALPHA, m_fFade );
|
||||
if (m_fFade > 0)
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
|
||||
ScaleColors( r, g, b, a );
|
||||
|
||||
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
|
||||
|
||||
y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values
|
||||
x = ScreenWidth - AmmoWidth;
|
||||
|
||||
if ( m_HUD_ammoicon )
|
||||
{
|
||||
// Draw the ammo icon
|
||||
x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left);
|
||||
y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom);
|
||||
|
||||
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
|
||||
}
|
||||
else
|
||||
{ // move the cursor by the '0' char instead, since we don't have an icon to work with
|
||||
x -= AmmoWidth;
|
||||
y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom);
|
||||
}
|
||||
|
||||
// draw the ammo counts, in reverse order, from right to left
|
||||
for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
|
||||
{
|
||||
if ( m_iAmmoAmounts[i] < 0 )
|
||||
continue; // negative ammo amounts imply that they shouldn't be drawn
|
||||
|
||||
// half a char gap between the ammo number and the previous pic
|
||||
x -= (AmmoWidth / 2);
|
||||
|
||||
// draw the number, right-aligned
|
||||
x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
|
||||
gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
|
||||
|
||||
if ( i != 0 )
|
||||
{
|
||||
// draw the divider bar
|
||||
x -= (AmmoWidth / 2);
|
||||
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for Secondary Ammo Value
|
||||
// accepts one value:
|
||||
// string: sprite name
|
||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for Secondary Ammo Icon
|
||||
// Sets an ammo value
|
||||
// takes two values:
|
||||
// byte: ammo index
|
||||
// byte: ammo value
|
||||
int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int index = READ_BYTE();
|
||||
if ( index < 0 || index >= MAX_SEC_AMMO_VALUES )
|
||||
return 1;
|
||||
|
||||
m_iAmmoAmounts[index] = READ_BYTE();
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
// check to see if there is anything left to draw
|
||||
int count = 0;
|
||||
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
|
||||
{
|
||||
count += max( 0, m_iAmmoAmounts[i] );
|
||||
}
|
||||
|
||||
if ( count == 0 )
|
||||
{ // the ammo fields are all empty, so turn off this hud area
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// make the icons light up
|
||||
m_fFade = 200.0f;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,192 +1,192 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammohistory.cpp
|
||||
//
|
||||
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ammohistory.h"
|
||||
|
||||
HistoryResource gHR;
|
||||
|
||||
#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5)
|
||||
#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2))
|
||||
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100)
|
||||
|
||||
#define MAX_ITEM_NAME 32
|
||||
int HISTORY_DRAW_TIME = 5;
|
||||
|
||||
// keep a list of items
|
||||
struct ITEM_INFO
|
||||
{
|
||||
char szName[MAX_ITEM_NAME];
|
||||
HSPRITE spr;
|
||||
wrect_t rect;
|
||||
};
|
||||
|
||||
void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
|
||||
{
|
||||
if ( iType == HISTSLOT_AMMO && !iCount )
|
||||
return; // no amount, so don't add
|
||||
|
||||
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
|
||||
{ // the pic would have to be drawn too high
|
||||
// so start from the bottom
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
||||
|
||||
freeslot->type = iType;
|
||||
freeslot->iId = iId;
|
||||
freeslot->iCount = iCount;
|
||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
||||
}
|
||||
|
||||
void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount )
|
||||
{
|
||||
if ( iType != HISTSLOT_ITEM )
|
||||
return;
|
||||
|
||||
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
|
||||
{ // the pic would have to be drawn too high
|
||||
// so start from the bottom
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
||||
|
||||
// I am really unhappy with all the code in this file
|
||||
|
||||
int i = gHUD.GetSpriteIndex( szName );
|
||||
if ( i == -1 )
|
||||
return; // unknown sprite name, don't add it to history
|
||||
|
||||
freeslot->iId = i;
|
||||
freeslot->type = iType;
|
||||
freeslot->iCount = iCount;
|
||||
|
||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
||||
}
|
||||
|
||||
|
||||
void HistoryResource :: CheckClearHistory( void )
|
||||
{
|
||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
||||
{
|
||||
if ( rgAmmoHistory[i].type )
|
||||
return;
|
||||
}
|
||||
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Ammo pickup history
|
||||
//
|
||||
int HistoryResource :: DrawAmmoHistory( float flTime )
|
||||
{
|
||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
||||
{
|
||||
if ( rgAmmoHistory[i].type )
|
||||
{
|
||||
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
|
||||
|
||||
if ( rgAmmoHistory[i].DisplayTime <= flTime )
|
||||
{ // pic drawing time has expired
|
||||
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
|
||||
CheckClearHistory();
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO )
|
||||
{
|
||||
wrect_t rcPic;
|
||||
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
// Draw the pic
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - 24;
|
||||
if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic
|
||||
{ // the dll has to make sure it has sent info the weapons you need
|
||||
SPR_Set( *spr, r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammohistory.cpp
|
||||
//
|
||||
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ammohistory.h"
|
||||
|
||||
HistoryResource gHR;
|
||||
|
||||
#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5)
|
||||
#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2))
|
||||
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100)
|
||||
|
||||
#define MAX_ITEM_NAME 32
|
||||
int HISTORY_DRAW_TIME = 5;
|
||||
|
||||
// keep a list of items
|
||||
struct ITEM_INFO
|
||||
{
|
||||
char szName[MAX_ITEM_NAME];
|
||||
HSPRITE spr;
|
||||
wrect_t rect;
|
||||
};
|
||||
|
||||
void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
|
||||
{
|
||||
if ( iType == HISTSLOT_AMMO && !iCount )
|
||||
return; // no amount, so don't add
|
||||
|
||||
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
|
||||
{ // the pic would have to be drawn too high
|
||||
// so start from the bottom
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
||||
|
||||
freeslot->type = iType;
|
||||
freeslot->iId = iId;
|
||||
freeslot->iCount = iCount;
|
||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
||||
}
|
||||
|
||||
void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount )
|
||||
{
|
||||
if ( iType != HISTSLOT_ITEM )
|
||||
return;
|
||||
|
||||
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
|
||||
{ // the pic would have to be drawn too high
|
||||
// so start from the bottom
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
|
||||
|
||||
// I am really unhappy with all the code in this file
|
||||
|
||||
int i = gHUD.GetSpriteIndex( szName );
|
||||
if ( i == -1 )
|
||||
return; // unknown sprite name, don't add it to history
|
||||
|
||||
freeslot->iId = i;
|
||||
freeslot->type = iType;
|
||||
freeslot->iCount = iCount;
|
||||
|
||||
HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
|
||||
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
|
||||
}
|
||||
|
||||
|
||||
void HistoryResource :: CheckClearHistory( void )
|
||||
{
|
||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
||||
{
|
||||
if ( rgAmmoHistory[i].type )
|
||||
return;
|
||||
}
|
||||
|
||||
iCurrentHistorySlot = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Ammo pickup history
|
||||
//
|
||||
int HistoryResource :: DrawAmmoHistory( float flTime )
|
||||
{
|
||||
for ( int i = 0; i < MAX_HISTORY; i++ )
|
||||
{
|
||||
if ( rgAmmoHistory[i].type )
|
||||
{
|
||||
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
|
||||
|
||||
if ( rgAmmoHistory[i].DisplayTime <= flTime )
|
||||
{ // pic drawing time has expired
|
||||
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
|
||||
CheckClearHistory();
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO )
|
||||
{
|
||||
wrect_t rcPic;
|
||||
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
// Draw the pic
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - 24;
|
||||
if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic
|
||||
{ // the dll has to make sure it has sent info the weapons you need
|
||||
SPR_Set( *spr, r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
|
||||
}
|
||||
|
||||
// do not draw black console string
|
||||
if( !(( hud_textmode->value == 2 ) && ( scale < 200 )) )
|
||||
// Draw the number
|
||||
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
|
||||
{
|
||||
WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
|
||||
|
||||
if ( !weap )
|
||||
return 1; // we don't know about the weapon yet, so don't draw anything
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
if ( !gWR.HasAmmo( weap ) )
|
||||
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
|
||||
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
|
||||
SPR_Set( weap->hInactive, r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM )
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
if ( !rgAmmoHistory[i].iId )
|
||||
continue; // sprite not loaded
|
||||
|
||||
wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (rect.right - rect.left) - 10;
|
||||
|
||||
SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &rect );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
|
||||
{
|
||||
WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
|
||||
|
||||
if ( !weap )
|
||||
return 1; // we don't know about the weapon yet, so don't draw anything
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
if ( !gWR.HasAmmo( weap ) )
|
||||
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
|
||||
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
|
||||
SPR_Set( weap->hInactive, r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
|
||||
}
|
||||
else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM )
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
if ( !rgAmmoHistory[i].iId )
|
||||
continue; // sprite not loaded
|
||||
|
||||
wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
|
||||
ScaleColors(r, g, b, min(scale, 255) );
|
||||
|
||||
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
|
||||
int xpos = ScreenWidth - (rect.right - rect.left) - 10;
|
||||
|
||||
SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
|
||||
SPR_DrawAdditive( 0, xpos, ypos, &rect );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,143 +1,143 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammohistory.h
|
||||
//
|
||||
|
||||
// this is the max number of items in each bucket
|
||||
#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS
|
||||
|
||||
class WeaponsResource
|
||||
{
|
||||
private:
|
||||
// Information about weapons & ammo
|
||||
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
|
||||
|
||||
// counts of weapons * ammo
|
||||
WEAPON* rgSlots[MAX_WEAPON_SLOTS+1][MAX_WEAPON_POSITIONS+1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there
|
||||
int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type
|
||||
|
||||
public:
|
||||
void Init( void )
|
||||
{
|
||||
memset( rgWeapons, 0, sizeof rgWeapons );
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset( void )
|
||||
{
|
||||
iOldWeaponBits = 0;
|
||||
memset( rgSlots, 0, sizeof rgSlots );
|
||||
memset( riAmmo, 0, sizeof riAmmo );
|
||||
}
|
||||
|
||||
///// WEAPON /////
|
||||
int iOldWeaponBits;
|
||||
|
||||
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
|
||||
void AddWeapon( WEAPON *wp )
|
||||
{
|
||||
rgWeapons[ wp->iId ] = *wp;
|
||||
LoadWeaponSprites( &rgWeapons[ wp->iId ] );
|
||||
}
|
||||
|
||||
void PickupWeapon( WEAPON *wp )
|
||||
{
|
||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
|
||||
}
|
||||
|
||||
void DropWeapon( WEAPON *wp )
|
||||
{
|
||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
|
||||
}
|
||||
|
||||
void DropAllWeapons( void )
|
||||
{
|
||||
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
if ( rgWeapons[i].iId )
|
||||
DropWeapon( &rgWeapons[i] );
|
||||
}
|
||||
}
|
||||
|
||||
WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
|
||||
|
||||
void LoadWeaponSprites( WEAPON* wp );
|
||||
void LoadAllWeaponSprites( void );
|
||||
WEAPON* GetFirstPos( int iSlot );
|
||||
void SelectSlot( int iSlot, int fAdvance, int iDirection );
|
||||
WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
|
||||
|
||||
int HasAmmo( WEAPON *p );
|
||||
|
||||
///// AMMO /////
|
||||
AMMO GetAmmo( int iId ) { return iId; }
|
||||
|
||||
void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; }
|
||||
|
||||
int CountAmmo( int iId );
|
||||
|
||||
HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect );
|
||||
};
|
||||
|
||||
extern WeaponsResource gWR;
|
||||
|
||||
|
||||
#define MAX_HISTORY 12
|
||||
enum {
|
||||
HISTSLOT_EMPTY,
|
||||
HISTSLOT_AMMO,
|
||||
HISTSLOT_WEAP,
|
||||
HISTSLOT_ITEM,
|
||||
};
|
||||
|
||||
class HistoryResource
|
||||
{
|
||||
private:
|
||||
struct HIST_ITEM {
|
||||
int type;
|
||||
float DisplayTime; // the time at which this item should be removed from the history
|
||||
int iCount;
|
||||
int iId;
|
||||
};
|
||||
|
||||
HIST_ITEM rgAmmoHistory[MAX_HISTORY];
|
||||
|
||||
public:
|
||||
|
||||
void Init( void )
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset( void )
|
||||
{
|
||||
memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
|
||||
}
|
||||
|
||||
int iHistoryGap;
|
||||
int iCurrentHistorySlot;
|
||||
|
||||
void AddToHistory( int iType, int iId, int iCount = 0 );
|
||||
void AddToHistory( int iType, const char *szName, int iCount = 0 );
|
||||
|
||||
void CheckClearHistory( void );
|
||||
int DrawAmmoHistory( float flTime );
|
||||
};
|
||||
|
||||
extern HistoryResource gHR;
|
||||
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ammohistory.h
|
||||
//
|
||||
|
||||
// this is the max number of items in each bucket
|
||||
#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS
|
||||
|
||||
class WeaponsResource
|
||||
{
|
||||
private:
|
||||
// Information about weapons & ammo
|
||||
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
|
||||
|
||||
// counts of weapons * ammo
|
||||
WEAPON* rgSlots[MAX_WEAPON_SLOTS+1][MAX_WEAPON_POSITIONS+1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there
|
||||
int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type
|
||||
|
||||
public:
|
||||
void Init( void )
|
||||
{
|
||||
memset( rgWeapons, 0, sizeof rgWeapons );
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset( void )
|
||||
{
|
||||
iOldWeaponBits = 0;
|
||||
memset( rgSlots, 0, sizeof rgSlots );
|
||||
memset( riAmmo, 0, sizeof riAmmo );
|
||||
}
|
||||
|
||||
///// WEAPON /////
|
||||
int iOldWeaponBits;
|
||||
|
||||
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
|
||||
void AddWeapon( WEAPON *wp )
|
||||
{
|
||||
rgWeapons[ wp->iId ] = *wp;
|
||||
LoadWeaponSprites( &rgWeapons[ wp->iId ] );
|
||||
}
|
||||
|
||||
void PickupWeapon( WEAPON *wp )
|
||||
{
|
||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
|
||||
}
|
||||
|
||||
void DropWeapon( WEAPON *wp )
|
||||
{
|
||||
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
|
||||
}
|
||||
|
||||
void DropAllWeapons( void )
|
||||
{
|
||||
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
if ( rgWeapons[i].iId )
|
||||
DropWeapon( &rgWeapons[i] );
|
||||
}
|
||||
}
|
||||
|
||||
WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
|
||||
|
||||
void LoadWeaponSprites( WEAPON* wp );
|
||||
void LoadAllWeaponSprites( void );
|
||||
WEAPON* GetFirstPos( int iSlot );
|
||||
void SelectSlot( int iSlot, int fAdvance, int iDirection );
|
||||
WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
|
||||
|
||||
int HasAmmo( WEAPON *p );
|
||||
|
||||
///// AMMO /////
|
||||
AMMO GetAmmo( int iId ) { return iId; }
|
||||
|
||||
void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; }
|
||||
|
||||
int CountAmmo( int iId );
|
||||
|
||||
HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect );
|
||||
};
|
||||
|
||||
extern WeaponsResource gWR;
|
||||
|
||||
|
||||
#define MAX_HISTORY 12
|
||||
enum {
|
||||
HISTSLOT_EMPTY,
|
||||
HISTSLOT_AMMO,
|
||||
HISTSLOT_WEAP,
|
||||
HISTSLOT_ITEM,
|
||||
};
|
||||
|
||||
class HistoryResource
|
||||
{
|
||||
private:
|
||||
struct HIST_ITEM {
|
||||
int type;
|
||||
float DisplayTime; // the time at which this item should be removed from the history
|
||||
int iCount;
|
||||
int iId;
|
||||
};
|
||||
|
||||
HIST_ITEM rgAmmoHistory[MAX_HISTORY];
|
||||
|
||||
public:
|
||||
|
||||
void Init( void )
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Reset( void )
|
||||
{
|
||||
memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
|
||||
}
|
||||
|
||||
int iHistoryGap;
|
||||
int iCurrentHistorySlot;
|
||||
|
||||
void AddToHistory( int iType, int iId, int iCount = 0 );
|
||||
void AddToHistory( int iType, const char *szName, int iCount = 0 );
|
||||
|
||||
void CheckClearHistory( void );
|
||||
int DrawAmmoHistory( float flTime );
|
||||
};
|
||||
|
||||
extern HistoryResource gHR;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,138 +1,138 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// battery.cpp
|
||||
//
|
||||
// implementation of CHudBattery class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
DECLARE_MESSAGE(m_Battery, Battery)
|
||||
|
||||
int CHudBattery::Init(void)
|
||||
{
|
||||
m_iBat = 0;
|
||||
m_fFade = 0;
|
||||
m_iFlags = 0;
|
||||
|
||||
HOOK_MESSAGE(Battery);
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
||||
int CHudBattery::VidInit(void)
|
||||
{
|
||||
int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" );
|
||||
int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" );
|
||||
|
||||
m_hSprite1 = m_hSprite2 = 0; // delaying get sprite handles until we know the sprites are loaded
|
||||
m_prc1 = &gHUD.GetSpriteRect( HUD_suit_empty );
|
||||
m_prc2 = &gHUD.GetSpriteRect( HUD_suit_full );
|
||||
m_iHeight = m_prc2->bottom - m_prc1->top;
|
||||
m_fFade = 0;
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_SHORT();
|
||||
|
||||
if (x != m_iBat)
|
||||
{
|
||||
m_fFade = FADE_TIME;
|
||||
m_iBat = x;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHudBattery::Draw(float flTime)
|
||||
{
|
||||
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
|
||||
return 1;
|
||||
|
||||
int r, g, b, x, y, a;
|
||||
wrect_t rc;
|
||||
|
||||
rc = *m_prc2;
|
||||
rc.top += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
|
||||
return 1;
|
||||
|
||||
// Has health changed? Flash the health #
|
||||
if (m_fFade)
|
||||
{
|
||||
if (m_fFade > FADE_TIME)
|
||||
m_fFade = FADE_TIME;
|
||||
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20);
|
||||
if (m_fFade <= 0)
|
||||
{
|
||||
a = 128;
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
// Fade the health number back to dim
|
||||
|
||||
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
|
||||
|
||||
}
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
ScaleColors(r, g, b, a );
|
||||
|
||||
int iOffset = (m_prc1->bottom - m_prc1->top)/6;
|
||||
|
||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
||||
x = ScreenWidth/5;
|
||||
|
||||
// make sure we have the right sprite handles
|
||||
if ( !m_hSprite1 )
|
||||
m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
|
||||
if ( !m_hSprite2 )
|
||||
m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
|
||||
|
||||
SPR_Set(m_hSprite1, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y - iOffset, m_prc1);
|
||||
|
||||
if (rc.bottom > rc.top)
|
||||
{
|
||||
SPR_Set(m_hSprite2, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
|
||||
}
|
||||
|
||||
x += (m_prc1->right - m_prc1->left);
|
||||
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
|
||||
|
||||
return 1;
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// battery.cpp
|
||||
//
|
||||
// implementation of CHudBattery class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
DECLARE_MESSAGE(m_Battery, Battery)
|
||||
|
||||
int CHudBattery::Init(void)
|
||||
{
|
||||
m_iBat = 0;
|
||||
m_fFade = 0;
|
||||
m_iFlags = 0;
|
||||
|
||||
HOOK_MESSAGE(Battery);
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
||||
int CHudBattery::VidInit(void)
|
||||
{
|
||||
int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" );
|
||||
int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" );
|
||||
|
||||
m_hSprite1 = m_hSprite2 = 0; // delaying get sprite handles until we know the sprites are loaded
|
||||
m_prc1 = &gHUD.GetSpriteRect( HUD_suit_empty );
|
||||
m_prc2 = &gHUD.GetSpriteRect( HUD_suit_full );
|
||||
m_iHeight = m_prc2->bottom - m_prc1->top;
|
||||
m_fFade = 0;
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_SHORT();
|
||||
|
||||
if (x != m_iBat)
|
||||
{
|
||||
m_fFade = FADE_TIME;
|
||||
m_iBat = x;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHudBattery::Draw(float flTime)
|
||||
{
|
||||
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
|
||||
return 1;
|
||||
|
||||
int r, g, b, x, y, a;
|
||||
wrect_t rc;
|
||||
|
||||
rc = *m_prc2;
|
||||
rc.top += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
|
||||
return 1;
|
||||
|
||||
// Has health changed? Flash the health #
|
||||
if (m_fFade)
|
||||
{
|
||||
if (m_fFade > FADE_TIME)
|
||||
m_fFade = FADE_TIME;
|
||||
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20);
|
||||
if (m_fFade <= 0)
|
||||
{
|
||||
a = 128;
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
// Fade the health number back to dim
|
||||
|
||||
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
|
||||
|
||||
}
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
ScaleColors(r, g, b, a );
|
||||
|
||||
int iOffset = (m_prc1->bottom - m_prc1->top)/6;
|
||||
|
||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
||||
x = ScreenWidth/5;
|
||||
|
||||
// make sure we have the right sprite handles
|
||||
if ( !m_hSprite1 )
|
||||
m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
|
||||
if ( !m_hSprite2 )
|
||||
m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
|
||||
|
||||
SPR_Set(m_hSprite1, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y - iOffset, m_prc1);
|
||||
|
||||
if (rc.bottom > rc.top)
|
||||
{
|
||||
SPR_Set(m_hSprite2, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
|
||||
}
|
||||
|
||||
x += (m_prc1->right - m_prc1->left);
|
||||
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -1,24 +1,24 @@
|
|||
//========= 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
|
||||
|
||||
#ifndef _CAMERA_H_
|
||||
#define _CAMERA_H_
|
||||
|
||||
// pitch, yaw, dist
|
||||
extern vec3_t cam_ofs;
|
||||
// Using third person camera
|
||||
extern int cam_thirdperson;
|
||||
|
||||
void CAM_Init( void );
|
||||
void CAM_ClearStates( void );
|
||||
void CAM_StartMouseMove(void);
|
||||
void CAM_EndMouseMove(void);
|
||||
|
||||
#endif // _CAMERA_H_
|
||||
//========= 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
|
||||
|
||||
#ifndef _CAMERA_H_
|
||||
#define _CAMERA_H_
|
||||
|
||||
// pitch, yaw, dist
|
||||
extern vec3_t cam_ofs;
|
||||
// Using third person camera
|
||||
extern int cam_thirdperson;
|
||||
|
||||
void CAM_Init( void );
|
||||
void CAM_ClearStates( void );
|
||||
void CAM_StartMouseMove(void);
|
||||
void CAM_EndMouseMove(void);
|
||||
|
||||
#endif // _CAMERA_H_
|
||||
|
|
|
@ -1,278 +1,278 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cdll_int.c
|
||||
//
|
||||
// this implementation handles the linking of the engine to the DLL
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "netadr.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "pm_shared.h"
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
|
||||
cl_enginefunc_t gEngfuncs;
|
||||
CHud gHUD;
|
||||
mobile_engfuncs_t *gMobileEngfuncs = NULL;
|
||||
void InitInput (void);
|
||||
void EV_HookEvents( void );
|
||||
void IN_Commands( void );
|
||||
|
||||
/*
|
||||
==========================
|
||||
Initialize
|
||||
|
||||
Called when the DLL is first loaded.
|
||||
==========================
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
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 );
|
||||
void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs );
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
HUD_GetHullBounds
|
||||
|
||||
Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist.
|
||||
================================
|
||||
*/
|
||||
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
|
||||
{
|
||||
int iret = 0;
|
||||
|
||||
switch ( hullnumber )
|
||||
{
|
||||
case 0: // Normal player
|
||||
mins = Vector(-16, -16, -36);
|
||||
maxs = Vector(16, 16, 36);
|
||||
iret = 1;
|
||||
break;
|
||||
case 1: // Crouched player
|
||||
mins = Vector(-16, -16, -18 );
|
||||
maxs = Vector(16, 16, 18 );
|
||||
iret = 1;
|
||||
break;
|
||||
case 2: // Point based hull
|
||||
mins = Vector( 0, 0, 0 );
|
||||
maxs = Vector( 0, 0, 0 );
|
||||
iret = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return iret;
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
HUD_ConnectionlessPacket
|
||||
|
||||
Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max
|
||||
size of the response_buffer, so you must zero it out if you choose not to respond.
|
||||
================================
|
||||
*/
|
||||
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
|
||||
{
|
||||
// Parse stuff from args
|
||||
int max_buffer_size = *response_buffer_size;
|
||||
|
||||
// Zero it out since we aren't going to respond.
|
||||
// If we wanted to response, we'd write data into response_buffer
|
||||
*response_buffer_size = 0;
|
||||
|
||||
// Since we don't listen for anything here, just respond that it's a bogus message
|
||||
// If we didn't reject the message, we'd return 1 for success instead.
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
|
||||
{
|
||||
PM_Init( ppmove );
|
||||
}
|
||||
|
||||
char DLLEXPORT HUD_PlayerMoveTexture( char *name )
|
||||
{
|
||||
return PM_FindTextureType( name );
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
|
||||
{
|
||||
PM_Move( ppmove, server );
|
||||
}
|
||||
|
||||
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
|
||||
{
|
||||
gEngfuncs = *pEnginefuncs;
|
||||
|
||||
if (iVersion != CLDLL_INTERFACE_VERSION)
|
||||
return 0;
|
||||
|
||||
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));
|
||||
|
||||
EV_HookEvents();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_VidInit
|
||||
|
||||
Called when the game initializes
|
||||
and whenever the vid_mode is changed
|
||||
so the HUD can reinitialize itself.
|
||||
==========================
|
||||
*/
|
||||
|
||||
int DLLEXPORT HUD_VidInit( void )
|
||||
{
|
||||
gHUD.VidInit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Init
|
||||
|
||||
Called whenever the client connects
|
||||
to a server. Reinitializes all
|
||||
the hud variables.
|
||||
==========================
|
||||
*/
|
||||
|
||||
void DLLEXPORT HUD_Init( void )
|
||||
{
|
||||
InitInput();
|
||||
gHUD.Init();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Redraw
|
||||
|
||||
called every screen frame to
|
||||
redraw the HUD.
|
||||
===========================
|
||||
*/
|
||||
|
||||
int DLLEXPORT HUD_Redraw( float time, int intermission )
|
||||
{
|
||||
gHUD.Redraw( time, intermission );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_UpdateClientData
|
||||
|
||||
called every time shared client
|
||||
dll/engine data gets changed,
|
||||
and gives the cdll a chance
|
||||
to modify the data.
|
||||
|
||||
returns 1 if anything has been changed, 0 otherwise.
|
||||
==========================
|
||||
*/
|
||||
|
||||
int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime )
|
||||
{
|
||||
IN_Commands();
|
||||
|
||||
return gHUD.UpdateClientData(pcldata, flTime );
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Reset
|
||||
|
||||
Called at start and end of demos to restore to "non"HUD state.
|
||||
==========================
|
||||
*/
|
||||
|
||||
void DLLEXPORT HUD_Reset( void )
|
||||
{
|
||||
gHUD.VidInit();
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Frame
|
||||
|
||||
Called by engine every frame that client .dll is loaded
|
||||
==========================
|
||||
*/
|
||||
|
||||
void DLLEXPORT HUD_Frame( double time )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_VoiceStatus
|
||||
|
||||
Called when a player starts or stops talking.
|
||||
==========================
|
||||
*/
|
||||
|
||||
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean 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 );
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs )
|
||||
{
|
||||
if( gpMobileEngfuncs->version != MOBILITY_API_VERSION )
|
||||
return;
|
||||
gMobileEngfuncs = gpMobileEngfuncs;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cdll_int.c
|
||||
//
|
||||
// this implementation handles the linking of the engine to the DLL
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "netadr.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "pm_shared.h"
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
|
||||
cl_enginefunc_t gEngfuncs;
|
||||
CHud gHUD;
|
||||
mobile_engfuncs_t *gMobileEngfuncs = NULL;
|
||||
void InitInput (void);
|
||||
void EV_HookEvents( void );
|
||||
void IN_Commands( void );
|
||||
|
||||
/*
|
||||
==========================
|
||||
Initialize
|
||||
|
||||
Called when the DLL is first loaded.
|
||||
==========================
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
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 );
|
||||
void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs );
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
HUD_GetHullBounds
|
||||
|
||||
Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist.
|
||||
================================
|
||||
*/
|
||||
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
|
||||
{
|
||||
int iret = 0;
|
||||
|
||||
switch ( hullnumber )
|
||||
{
|
||||
case 0: // Normal player
|
||||
mins = Vector(-16, -16, -36);
|
||||
maxs = Vector(16, 16, 36);
|
||||
iret = 1;
|
||||
break;
|
||||
case 1: // Crouched player
|
||||
mins = Vector(-16, -16, -18 );
|
||||
maxs = Vector(16, 16, 18 );
|
||||
iret = 1;
|
||||
break;
|
||||
case 2: // Point based hull
|
||||
mins = Vector( 0, 0, 0 );
|
||||
maxs = Vector( 0, 0, 0 );
|
||||
iret = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return iret;
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
HUD_ConnectionlessPacket
|
||||
|
||||
Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max
|
||||
size of the response_buffer, so you must zero it out if you choose not to respond.
|
||||
================================
|
||||
*/
|
||||
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
|
||||
{
|
||||
// Parse stuff from args
|
||||
int max_buffer_size = *response_buffer_size;
|
||||
|
||||
// Zero it out since we aren't going to respond.
|
||||
// If we wanted to response, we'd write data into response_buffer
|
||||
*response_buffer_size = 0;
|
||||
|
||||
// Since we don't listen for anything here, just respond that it's a bogus message
|
||||
// If we didn't reject the message, we'd return 1 for success instead.
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
|
||||
{
|
||||
PM_Init( ppmove );
|
||||
}
|
||||
|
||||
char DLLEXPORT HUD_PlayerMoveTexture( char *name )
|
||||
{
|
||||
return PM_FindTextureType( name );
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
|
||||
{
|
||||
PM_Move( ppmove, server );
|
||||
}
|
||||
|
||||
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
|
||||
{
|
||||
gEngfuncs = *pEnginefuncs;
|
||||
|
||||
if (iVersion != CLDLL_INTERFACE_VERSION)
|
||||
return 0;
|
||||
|
||||
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));
|
||||
|
||||
EV_HookEvents();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_VidInit
|
||||
|
||||
Called when the game initializes
|
||||
and whenever the vid_mode is changed
|
||||
so the HUD can reinitialize itself.
|
||||
==========================
|
||||
*/
|
||||
|
||||
int DLLEXPORT HUD_VidInit( void )
|
||||
{
|
||||
gHUD.VidInit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Init
|
||||
|
||||
Called whenever the client connects
|
||||
to a server. Reinitializes all
|
||||
the hud variables.
|
||||
==========================
|
||||
*/
|
||||
|
||||
void DLLEXPORT HUD_Init( void )
|
||||
{
|
||||
InitInput();
|
||||
gHUD.Init();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Redraw
|
||||
|
||||
called every screen frame to
|
||||
redraw the HUD.
|
||||
===========================
|
||||
*/
|
||||
|
||||
int DLLEXPORT HUD_Redraw( float time, int intermission )
|
||||
{
|
||||
gHUD.Redraw( time, intermission );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_UpdateClientData
|
||||
|
||||
called every time shared client
|
||||
dll/engine data gets changed,
|
||||
and gives the cdll a chance
|
||||
to modify the data.
|
||||
|
||||
returns 1 if anything has been changed, 0 otherwise.
|
||||
==========================
|
||||
*/
|
||||
|
||||
int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime )
|
||||
{
|
||||
IN_Commands();
|
||||
|
||||
return gHUD.UpdateClientData(pcldata, flTime );
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Reset
|
||||
|
||||
Called at start and end of demos to restore to "non"HUD state.
|
||||
==========================
|
||||
*/
|
||||
|
||||
void DLLEXPORT HUD_Reset( void )
|
||||
{
|
||||
gHUD.VidInit();
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_Frame
|
||||
|
||||
Called by engine every frame that client .dll is loaded
|
||||
==========================
|
||||
*/
|
||||
|
||||
void DLLEXPORT HUD_Frame( double time )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_VoiceStatus
|
||||
|
||||
Called when a player starts or stops talking.
|
||||
==========================
|
||||
*/
|
||||
|
||||
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean 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 );
|
||||
}
|
||||
|
||||
void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs )
|
||||
{
|
||||
if( gpMobileEngfuncs->version != MOBILITY_API_VERSION )
|
||||
return;
|
||||
gMobileEngfuncs = gpMobileEngfuncs;
|
||||
}
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cl_dll.h
|
||||
//
|
||||
|
||||
// 4-23-98 JOHN
|
||||
|
||||
//
|
||||
// This DLL is linked by the client when they first initialize.
|
||||
// This DLL is responsible for the following tasks:
|
||||
// - Loading the HUD graphics upon initialization
|
||||
// - Drawing the HUD graphics every frame
|
||||
// - Handling the custum HUD-update packets
|
||||
//
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef float vec_t;
|
||||
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
#include "util_vector.h"
|
||||
|
||||
#include "../engine/cdll_int.h"
|
||||
#include "../dlls/cdll_dll.h"
|
||||
|
||||
#ifndef __MSC_VER
|
||||
#define _cdecl
|
||||
#endif
|
||||
#include "exportdef.h"
|
||||
#include <string.h>
|
||||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
#include "../engine/mobility_int.h"
|
||||
extern mobile_engfuncs_t *gMobileEngfuncs;
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cl_dll.h
|
||||
//
|
||||
|
||||
// 4-23-98 JOHN
|
||||
|
||||
//
|
||||
// This DLL is linked by the client when they first initialize.
|
||||
// This DLL is responsible for the following tasks:
|
||||
// - Loading the HUD graphics upon initialization
|
||||
// - Drawing the HUD graphics every frame
|
||||
// - Handling the custum HUD-update packets
|
||||
//
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef float vec_t;
|
||||
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
#include "util_vector.h"
|
||||
|
||||
#include "../engine/cdll_int.h"
|
||||
#include "../dlls/cdll_dll.h"
|
||||
|
||||
#ifndef __MSC_VER
|
||||
#define _cdecl
|
||||
#endif
|
||||
#include "exportdef.h"
|
||||
#include <string.h>
|
||||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
#include "../engine/mobility_int.h"
|
||||
extern mobile_engfuncs_t *gMobileEngfuncs;
|
||||
|
|
352
cl_dll/cl_util.h
352
cl_dll/cl_util.h
|
@ -1,176 +1,176 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cl_util.h
|
||||
//
|
||||
#include "exportdef.h"
|
||||
#include "cvardef.h"
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
// Macros to hook function calls into the HUD object
|
||||
|
||||
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );
|
||||
|
||||
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
|
||||
{ \
|
||||
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \
|
||||
}
|
||||
|
||||
|
||||
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
|
||||
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
|
||||
{ \
|
||||
gHUD.y.UserCmd_##x( ); \
|
||||
}
|
||||
|
||||
|
||||
inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); }
|
||||
inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); }
|
||||
inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); }
|
||||
|
||||
#define SPR_Load (*gEngfuncs.pfnSPR_Load)
|
||||
#define SPR_Set (*gEngfuncs.pfnSPR_Set)
|
||||
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
|
||||
#define SPR_GetList (*gEngfuncs.pfnSPR_GetList)
|
||||
|
||||
// SPR_Draw draws a the current sprite as solid
|
||||
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
|
||||
// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent)
|
||||
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
|
||||
// SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency)
|
||||
#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive)
|
||||
|
||||
// SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen.
|
||||
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
|
||||
// SPR_DisableScissor disables the clipping rect
|
||||
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
|
||||
//
|
||||
#define FillRGBA (*gEngfuncs.pfnFillRGBA)
|
||||
|
||||
|
||||
// ScreenHeight returns the height of the screen, in pixels
|
||||
#define ScreenHeight (gHUD.m_scrinfo.iHeight)
|
||||
// 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)
|
||||
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
|
||||
#define AngleVectors (*gEngfuncs.pfnAngleVectors)
|
||||
extern cvar_t *hud_textmode;
|
||||
extern float g_hud_text_color[3];
|
||||
inline void DrawSetTextColor(float r, float g, float b)
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
g_hud_text_color[0]=r, g_hud_text_color[1] = g, g_hud_text_color[2] = b;
|
||||
else
|
||||
gEngfuncs.pfnDrawSetTextColor( r, g, b );
|
||||
}
|
||||
// Gets the height & width of a sprite, at the specified frame
|
||||
inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); }
|
||||
inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); }
|
||||
|
||||
inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); }
|
||||
inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
|
||||
{
|
||||
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
|
||||
}
|
||||
|
||||
inline int DrawConsoleString( int x, int y, const char *string )
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
return gHUD.DrawHudString( x, y, 9999, (char*)string, 255*g_hud_text_color[0], 255*g_hud_text_color[1], 255*g_hud_text_color[2]);
|
||||
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
|
||||
}
|
||||
|
||||
inline void GetConsoleStringSize( const char *string, int *width, int *height )
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
*height = 13, *width = gHUD.DrawHudStringLen( (char*)string );
|
||||
else
|
||||
gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height );
|
||||
}
|
||||
|
||||
inline int ConsoleStringLen( const char *string )
|
||||
{
|
||||
int _width = 0, _height = 0;
|
||||
if( hud_textmode->value == 1 )
|
||||
return gHUD.DrawHudStringLen((char*)string);
|
||||
GetConsoleStringSize( string, &_width, &_height );
|
||||
return _width;
|
||||
}
|
||||
|
||||
inline void ConsolePrint( const char *string )
|
||||
{
|
||||
gEngfuncs.pfnConsolePrint( string );
|
||||
}
|
||||
|
||||
inline void CenterPrint( const char *string )
|
||||
{
|
||||
gEngfuncs.pfnCenterPrint( string );
|
||||
}
|
||||
|
||||
// returns the players name of entity no.
|
||||
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo)
|
||||
|
||||
// sound functions
|
||||
inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
|
||||
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
|
||||
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define fabs(x) ((x) > 0 ? (x) : 0 - (x))
|
||||
|
||||
void ScaleColors( int &r, int &g, int &b, int a );
|
||||
|
||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
||||
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
|
||||
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
|
||||
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
|
||||
inline void VectorClear(float *a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;}
|
||||
float Length(const float *v);
|
||||
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc);
|
||||
void VectorScale (const float *in, float scale, float *out);
|
||||
float VectorNormalize (float *v);
|
||||
void VectorInverse ( float *v );
|
||||
|
||||
extern vec3_t vec3_origin;
|
||||
|
||||
// disable 'possible loss of data converting float to int' warning message
|
||||
#pragma warning( disable: 4244 )
|
||||
// disable 'truncation from 'const double' to 'float' warning message
|
||||
#pragma warning( disable: 4305 )
|
||||
|
||||
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\
|
||||
{\
|
||||
r = (ulRGB & 0xFF0000) >>16;\
|
||||
g = (ulRGB & 0xFF00) >> 8;\
|
||||
b = ulRGB & 0xFF;\
|
||||
}
|
||||
|
||||
HSPRITE LoadSprite(const char *pszName);
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cl_util.h
|
||||
//
|
||||
#include "exportdef.h"
|
||||
#include "cvardef.h"
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
// Macros to hook function calls into the HUD object
|
||||
|
||||
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );
|
||||
|
||||
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
|
||||
{ \
|
||||
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \
|
||||
}
|
||||
|
||||
|
||||
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
|
||||
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
|
||||
{ \
|
||||
gHUD.y.UserCmd_##x( ); \
|
||||
}
|
||||
|
||||
|
||||
inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); }
|
||||
inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); }
|
||||
inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); }
|
||||
|
||||
#define SPR_Load (*gEngfuncs.pfnSPR_Load)
|
||||
#define SPR_Set (*gEngfuncs.pfnSPR_Set)
|
||||
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
|
||||
#define SPR_GetList (*gEngfuncs.pfnSPR_GetList)
|
||||
|
||||
// SPR_Draw draws a the current sprite as solid
|
||||
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
|
||||
// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent)
|
||||
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
|
||||
// SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency)
|
||||
#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive)
|
||||
|
||||
// SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen.
|
||||
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
|
||||
// SPR_DisableScissor disables the clipping rect
|
||||
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
|
||||
//
|
||||
#define FillRGBA (*gEngfuncs.pfnFillRGBA)
|
||||
|
||||
|
||||
// ScreenHeight returns the height of the screen, in pixels
|
||||
#define ScreenHeight (gHUD.m_scrinfo.iHeight)
|
||||
// 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)
|
||||
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
|
||||
#define AngleVectors (*gEngfuncs.pfnAngleVectors)
|
||||
extern cvar_t *hud_textmode;
|
||||
extern float g_hud_text_color[3];
|
||||
inline void DrawSetTextColor(float r, float g, float b)
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
g_hud_text_color[0]=r, g_hud_text_color[1] = g, g_hud_text_color[2] = b;
|
||||
else
|
||||
gEngfuncs.pfnDrawSetTextColor( r, g, b );
|
||||
}
|
||||
// Gets the height & width of a sprite, at the specified frame
|
||||
inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); }
|
||||
inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); }
|
||||
|
||||
inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); }
|
||||
inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
|
||||
{
|
||||
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
|
||||
}
|
||||
|
||||
inline int DrawConsoleString( int x, int y, const char *string )
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
return gHUD.DrawHudString( x, y, 9999, (char*)string, 255*g_hud_text_color[0], 255*g_hud_text_color[1], 255*g_hud_text_color[2]);
|
||||
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
|
||||
}
|
||||
|
||||
inline void GetConsoleStringSize( const char *string, int *width, int *height )
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
*height = 13, *width = gHUD.DrawHudStringLen( (char*)string );
|
||||
else
|
||||
gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height );
|
||||
}
|
||||
|
||||
inline int ConsoleStringLen( const char *string )
|
||||
{
|
||||
int _width = 0, _height = 0;
|
||||
if( hud_textmode->value == 1 )
|
||||
return gHUD.DrawHudStringLen((char*)string);
|
||||
GetConsoleStringSize( string, &_width, &_height );
|
||||
return _width;
|
||||
}
|
||||
|
||||
inline void ConsolePrint( const char *string )
|
||||
{
|
||||
gEngfuncs.pfnConsolePrint( string );
|
||||
}
|
||||
|
||||
inline void CenterPrint( const char *string )
|
||||
{
|
||||
gEngfuncs.pfnCenterPrint( string );
|
||||
}
|
||||
|
||||
// returns the players name of entity no.
|
||||
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo)
|
||||
|
||||
// sound functions
|
||||
inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
|
||||
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
|
||||
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define fabs(x) ((x) > 0 ? (x) : 0 - (x))
|
||||
|
||||
void ScaleColors( int &r, int &g, int &b, int a );
|
||||
|
||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
||||
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
|
||||
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
|
||||
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
|
||||
inline void VectorClear(float *a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;}
|
||||
float Length(const float *v);
|
||||
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc);
|
||||
void VectorScale (const float *in, float scale, float *out);
|
||||
float VectorNormalize (float *v);
|
||||
void VectorInverse ( float *v );
|
||||
|
||||
extern vec3_t vec3_origin;
|
||||
|
||||
// disable 'possible loss of data converting float to int' warning message
|
||||
#pragma warning( disable: 4244 )
|
||||
// disable 'truncation from 'const double' to 'float' warning message
|
||||
#pragma warning( disable: 4305 )
|
||||
|
||||
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\
|
||||
{\
|
||||
r = (ulRGB & 0xFF0000) >>16;\
|
||||
g = (ulRGB & 0xFF00) >> 8;\
|
||||
b = ulRGB & 0xFF;\
|
||||
}
|
||||
|
||||
HSPRITE LoadSprite(const char *pszName);
|
||||
|
|
|
@ -1,277 +1,277 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
// Com_Weapons.cpp
|
||||
// Shared weapons common/shared functions
|
||||
#include <stdarg.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "com_weapons.h"
|
||||
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "r_efx.h"
|
||||
|
||||
// g_runfuncs is true if this is the first time we've "predicated" a particular movement/firing
|
||||
// command. If it is 1, then we should play events/sounds etc., otherwise, we just will be
|
||||
// updating state info, but not firing events
|
||||
int g_runfuncs = 0;
|
||||
|
||||
// During our weapon prediction processing, we'll need to reference some data that is part of
|
||||
// the final state passed into the postthink functionality. We'll set this pointer and then
|
||||
// reset it to NULL as appropriate
|
||||
struct local_state_s *g_finalstate = NULL;
|
||||
|
||||
/*
|
||||
====================
|
||||
COM_Log
|
||||
|
||||
Log debug messages to file ( appends )
|
||||
====================
|
||||
*/
|
||||
void COM_Log( char *pszFile, char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
FILE *fp;
|
||||
char *pfilename;
|
||||
|
||||
if ( !pszFile )
|
||||
{
|
||||
pfilename = "c:\\hllog.txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
pfilename = pszFile;
|
||||
}
|
||||
|
||||
va_start (argptr,fmt);
|
||||
vsprintf (string, fmt,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
fp = fopen( pfilename, "a+t");
|
||||
if (fp)
|
||||
{
|
||||
fprintf(fp, "%s", string);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
// remember the current animation for the view model, in case we get out of sync with
|
||||
// server.
|
||||
static int g_currentanim;
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_SendWeaponAnim
|
||||
|
||||
Change weapon model animation
|
||||
=====================
|
||||
*/
|
||||
void HUD_SendWeaponAnim( int iAnim, int body, int force )
|
||||
{
|
||||
// Don't actually change it.
|
||||
if ( !g_runfuncs && !force )
|
||||
return;
|
||||
|
||||
g_currentanim = iAnim;
|
||||
|
||||
// Tell animation system new info
|
||||
gEngfuncs.pfnWeaponAnim( iAnim, body );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_GetWeaponAnim
|
||||
|
||||
Retrieve current predicted weapon animation
|
||||
=====================
|
||||
*/
|
||||
int HUD_GetWeaponAnim( void )
|
||||
{
|
||||
return g_currentanim;
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_PlaySound
|
||||
|
||||
Play a sound, if we are seeing this command for the first time
|
||||
=====================
|
||||
*/
|
||||
void HUD_PlaySound( char *sound, float volume )
|
||||
{
|
||||
if ( !g_runfuncs || !g_finalstate )
|
||||
return;
|
||||
|
||||
gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_PlaybackEvent
|
||||
|
||||
Directly queue up an event on the client
|
||||
=====================
|
||||
*/
|
||||
void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay,
|
||||
float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 )
|
||||
{
|
||||
vec3_t org;
|
||||
vec3_t ang;
|
||||
|
||||
if ( !g_runfuncs || !g_finalstate )
|
||||
return;
|
||||
|
||||
// Weapon prediction events are assumed to occur at the player's origin
|
||||
org = g_finalstate->playerstate.origin;
|
||||
ang = v_angles;
|
||||
gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, (float *)&org, (float *)&ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_SetMaxSpeed
|
||||
|
||||
=====================
|
||||
*/
|
||||
void HUD_SetMaxSpeed( const edict_t *ed, float speed )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=====================
|
||||
UTIL_WeaponTimeBase
|
||||
|
||||
Always 0.0 on client, even if not predicting weapons ( won't get called
|
||||
in that case )
|
||||
=====================
|
||||
*/
|
||||
float UTIL_WeaponTimeBase( void )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
static unsigned int glSeed = 0;
|
||||
|
||||
unsigned int seed_table[ 256 ] =
|
||||
{
|
||||
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103,
|
||||
27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315,
|
||||
26766, 907, 24102, 12370, 9674, 2972, 10472, 16492, 22683, 11529, 27968, 30406, 13213, 2319, 23620, 16823,
|
||||
10013, 23772, 21567, 1251, 19579, 20313, 18241, 30130, 8402, 20807, 27354, 7169, 21211, 17293, 5410, 19223,
|
||||
10255, 22480, 27388, 9946, 15628, 24389, 17308, 2370, 9530, 31683, 25927, 23567, 11694, 26397, 32602, 15031,
|
||||
18255, 17582, 1422, 28835, 23607, 12597, 20602, 10138, 5212, 1252, 10074, 23166, 19823, 31667, 5902, 24630,
|
||||
18948, 14330, 14950, 8939, 23540, 21311, 22428, 22391, 3583, 29004, 30498, 18714, 4278, 2437, 22430, 3439,
|
||||
28313, 23161, 25396, 13471, 19324, 15287, 2563, 18901, 13103, 16867, 9714, 14322, 15197, 26889, 19372, 26241,
|
||||
31925, 14640, 11497, 8941, 10056, 6451, 28656, 10737, 13874, 17356, 8281, 25937, 1661, 4850, 7448, 12744,
|
||||
21826, 5477, 10167, 16705, 26897, 8839, 30947, 27978, 27283, 24685, 32298, 3525, 12398, 28726, 9475, 10208,
|
||||
617, 13467, 22287, 2376, 6097, 26312, 2974, 9114, 21787, 28010, 4725, 15387, 3274, 10762, 31695, 17320,
|
||||
18324, 12441, 16801, 27376, 22464, 7500, 5666, 18144, 15314, 31914, 31627, 6495, 5226, 31203, 2331, 4668,
|
||||
12650, 18275, 351, 7268, 31319, 30119, 7600, 2905, 13826, 11343, 13053, 15583, 30055, 31093, 5067, 761,
|
||||
9685, 11070, 21369, 27155, 3663, 26542, 20169, 12161, 15411, 30401, 7580, 31784, 8985, 29367, 20989, 14203,
|
||||
29694, 21167, 10337, 1706, 28578, 887, 3373, 19477, 14382, 675, 7033, 15111, 26138, 12252, 30996, 21409,
|
||||
25678, 18555, 13256, 23316, 22407, 16727, 991, 9236, 5373, 29402, 6117, 15241, 27715, 19291, 19888, 19847
|
||||
};
|
||||
|
||||
unsigned int U_Random( void )
|
||||
{
|
||||
glSeed *= 69069;
|
||||
glSeed += seed_table[ glSeed & 0xff ];
|
||||
|
||||
return ( ++glSeed & 0x0fffffff );
|
||||
}
|
||||
|
||||
void U_Srand( unsigned int seed )
|
||||
{
|
||||
glSeed = seed_table[ seed & 0xff ];
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
UTIL_SharedRandomLong
|
||||
=====================
|
||||
*/
|
||||
int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
|
||||
{
|
||||
unsigned int range;
|
||||
|
||||
U_Srand( (int)seed + low + high );
|
||||
|
||||
range = high - low + 1;
|
||||
if ( !(range - 1) )
|
||||
{
|
||||
return low;
|
||||
}
|
||||
else
|
||||
{
|
||||
int offset;
|
||||
int rnum;
|
||||
|
||||
rnum = U_Random();
|
||||
|
||||
offset = rnum % range;
|
||||
|
||||
return (low + offset);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
UTIL_SharedRandomFloat
|
||||
=====================
|
||||
*/
|
||||
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
|
||||
{
|
||||
//
|
||||
unsigned int range;
|
||||
|
||||
U_Srand( (int)seed + *(int *)&low + *(int *)&high );
|
||||
|
||||
U_Random();
|
||||
U_Random();
|
||||
|
||||
range = high - low;
|
||||
if ( !range )
|
||||
{
|
||||
return low;
|
||||
}
|
||||
else
|
||||
{
|
||||
int tensixrand;
|
||||
float offset;
|
||||
|
||||
tensixrand = U_Random() & 65535;
|
||||
|
||||
offset = (float)tensixrand / 65536.0;
|
||||
|
||||
return (low + offset * range );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
======================
|
||||
stub_*
|
||||
|
||||
stub functions for such things as precaching. So we don't have to modify weapons code that
|
||||
is compiled into both game and client .dlls.
|
||||
======================
|
||||
*/
|
||||
int stub_PrecacheModel ( char* s ) { return 0; }
|
||||
int stub_PrecacheSound ( char* s ) { return 0; }
|
||||
unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; }
|
||||
const char *stub_NameForFunction ( unsigned long function ) { return "func"; }
|
||||
void stub_SetModel ( edict_t *e, const char *m ) {}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
// Com_Weapons.cpp
|
||||
// Shared weapons common/shared functions
|
||||
#include <stdarg.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "com_weapons.h"
|
||||
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "r_efx.h"
|
||||
|
||||
// g_runfuncs is true if this is the first time we've "predicated" a particular movement/firing
|
||||
// command. If it is 1, then we should play events/sounds etc., otherwise, we just will be
|
||||
// updating state info, but not firing events
|
||||
int g_runfuncs = 0;
|
||||
|
||||
// During our weapon prediction processing, we'll need to reference some data that is part of
|
||||
// the final state passed into the postthink functionality. We'll set this pointer and then
|
||||
// reset it to NULL as appropriate
|
||||
struct local_state_s *g_finalstate = NULL;
|
||||
|
||||
/*
|
||||
====================
|
||||
COM_Log
|
||||
|
||||
Log debug messages to file ( appends )
|
||||
====================
|
||||
*/
|
||||
void COM_Log( char *pszFile, char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
FILE *fp;
|
||||
char *pfilename;
|
||||
|
||||
if ( !pszFile )
|
||||
{
|
||||
pfilename = "c:\\hllog.txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
pfilename = pszFile;
|
||||
}
|
||||
|
||||
va_start (argptr,fmt);
|
||||
vsprintf (string, fmt,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
fp = fopen( pfilename, "a+t");
|
||||
if (fp)
|
||||
{
|
||||
fprintf(fp, "%s", string);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
// remember the current animation for the view model, in case we get out of sync with
|
||||
// server.
|
||||
static int g_currentanim;
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_SendWeaponAnim
|
||||
|
||||
Change weapon model animation
|
||||
=====================
|
||||
*/
|
||||
void HUD_SendWeaponAnim( int iAnim, int body, int force )
|
||||
{
|
||||
// Don't actually change it.
|
||||
if ( !g_runfuncs && !force )
|
||||
return;
|
||||
|
||||
g_currentanim = iAnim;
|
||||
|
||||
// Tell animation system new info
|
||||
gEngfuncs.pfnWeaponAnim( iAnim, body );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_GetWeaponAnim
|
||||
|
||||
Retrieve current predicted weapon animation
|
||||
=====================
|
||||
*/
|
||||
int HUD_GetWeaponAnim( void )
|
||||
{
|
||||
return g_currentanim;
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_PlaySound
|
||||
|
||||
Play a sound, if we are seeing this command for the first time
|
||||
=====================
|
||||
*/
|
||||
void HUD_PlaySound( char *sound, float volume )
|
||||
{
|
||||
if ( !g_runfuncs || !g_finalstate )
|
||||
return;
|
||||
|
||||
gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_PlaybackEvent
|
||||
|
||||
Directly queue up an event on the client
|
||||
=====================
|
||||
*/
|
||||
void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay,
|
||||
float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 )
|
||||
{
|
||||
vec3_t org;
|
||||
vec3_t ang;
|
||||
|
||||
if ( !g_runfuncs || !g_finalstate )
|
||||
return;
|
||||
|
||||
// Weapon prediction events are assumed to occur at the player's origin
|
||||
org = g_finalstate->playerstate.origin;
|
||||
ang = v_angles;
|
||||
gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, (float *)&org, (float *)&ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
HUD_SetMaxSpeed
|
||||
|
||||
=====================
|
||||
*/
|
||||
void HUD_SetMaxSpeed( const edict_t *ed, float speed )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=====================
|
||||
UTIL_WeaponTimeBase
|
||||
|
||||
Always 0.0 on client, even if not predicting weapons ( won't get called
|
||||
in that case )
|
||||
=====================
|
||||
*/
|
||||
float UTIL_WeaponTimeBase( void )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
static unsigned int glSeed = 0;
|
||||
|
||||
unsigned int seed_table[ 256 ] =
|
||||
{
|
||||
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103,
|
||||
27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315,
|
||||
26766, 907, 24102, 12370, 9674, 2972, 10472, 16492, 22683, 11529, 27968, 30406, 13213, 2319, 23620, 16823,
|
||||
10013, 23772, 21567, 1251, 19579, 20313, 18241, 30130, 8402, 20807, 27354, 7169, 21211, 17293, 5410, 19223,
|
||||
10255, 22480, 27388, 9946, 15628, 24389, 17308, 2370, 9530, 31683, 25927, 23567, 11694, 26397, 32602, 15031,
|
||||
18255, 17582, 1422, 28835, 23607, 12597, 20602, 10138, 5212, 1252, 10074, 23166, 19823, 31667, 5902, 24630,
|
||||
18948, 14330, 14950, 8939, 23540, 21311, 22428, 22391, 3583, 29004, 30498, 18714, 4278, 2437, 22430, 3439,
|
||||
28313, 23161, 25396, 13471, 19324, 15287, 2563, 18901, 13103, 16867, 9714, 14322, 15197, 26889, 19372, 26241,
|
||||
31925, 14640, 11497, 8941, 10056, 6451, 28656, 10737, 13874, 17356, 8281, 25937, 1661, 4850, 7448, 12744,
|
||||
21826, 5477, 10167, 16705, 26897, 8839, 30947, 27978, 27283, 24685, 32298, 3525, 12398, 28726, 9475, 10208,
|
||||
617, 13467, 22287, 2376, 6097, 26312, 2974, 9114, 21787, 28010, 4725, 15387, 3274, 10762, 31695, 17320,
|
||||
18324, 12441, 16801, 27376, 22464, 7500, 5666, 18144, 15314, 31914, 31627, 6495, 5226, 31203, 2331, 4668,
|
||||
12650, 18275, 351, 7268, 31319, 30119, 7600, 2905, 13826, 11343, 13053, 15583, 30055, 31093, 5067, 761,
|
||||
9685, 11070, 21369, 27155, 3663, 26542, 20169, 12161, 15411, 30401, 7580, 31784, 8985, 29367, 20989, 14203,
|
||||
29694, 21167, 10337, 1706, 28578, 887, 3373, 19477, 14382, 675, 7033, 15111, 26138, 12252, 30996, 21409,
|
||||
25678, 18555, 13256, 23316, 22407, 16727, 991, 9236, 5373, 29402, 6117, 15241, 27715, 19291, 19888, 19847
|
||||
};
|
||||
|
||||
unsigned int U_Random( void )
|
||||
{
|
||||
glSeed *= 69069;
|
||||
glSeed += seed_table[ glSeed & 0xff ];
|
||||
|
||||
return ( ++glSeed & 0x0fffffff );
|
||||
}
|
||||
|
||||
void U_Srand( unsigned int seed )
|
||||
{
|
||||
glSeed = seed_table[ seed & 0xff ];
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
UTIL_SharedRandomLong
|
||||
=====================
|
||||
*/
|
||||
int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
|
||||
{
|
||||
unsigned int range;
|
||||
|
||||
U_Srand( (int)seed + low + high );
|
||||
|
||||
range = high - low + 1;
|
||||
if ( !(range - 1) )
|
||||
{
|
||||
return low;
|
||||
}
|
||||
else
|
||||
{
|
||||
int offset;
|
||||
int rnum;
|
||||
|
||||
rnum = U_Random();
|
||||
|
||||
offset = rnum % range;
|
||||
|
||||
return (low + offset);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
UTIL_SharedRandomFloat
|
||||
=====================
|
||||
*/
|
||||
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
|
||||
{
|
||||
//
|
||||
unsigned int range;
|
||||
|
||||
U_Srand( (int)seed + *(int *)&low + *(int *)&high );
|
||||
|
||||
U_Random();
|
||||
U_Random();
|
||||
|
||||
range = high - low;
|
||||
if ( !range )
|
||||
{
|
||||
return low;
|
||||
}
|
||||
else
|
||||
{
|
||||
int tensixrand;
|
||||
float offset;
|
||||
|
||||
tensixrand = U_Random() & 65535;
|
||||
|
||||
offset = (float)tensixrand / 65536.0;
|
||||
|
||||
return (low + offset * range );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
======================
|
||||
stub_*
|
||||
|
||||
stub functions for such things as precaching. So we don't have to modify weapons code that
|
||||
is compiled into both game and client .dlls.
|
||||
======================
|
||||
*/
|
||||
int stub_PrecacheModel ( char* s ) { return 0; }
|
||||
int stub_PrecacheSound ( char* s ) { return 0; }
|
||||
unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; }
|
||||
const char *stub_NameForFunction ( unsigned long function ) { return "func"; }
|
||||
void stub_SetModel ( edict_t *e, const char *m ) {}
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// com_weapons.h
|
||||
// Shared weapons common function prototypes
|
||||
#if !defined( COM_WEAPONSH )
|
||||
#define COM_WEAPONSH
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "hud_iface.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed );
|
||||
}
|
||||
|
||||
void COM_Log( char *pszFile, char *fmt, ...);
|
||||
int CL_IsDead( void );
|
||||
|
||||
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
|
||||
int UTIL_SharedRandomLong( unsigned int seed, int low, int high );
|
||||
|
||||
int HUD_GetWeaponAnim( void );
|
||||
void HUD_SendWeaponAnim( int iAnim, int body, int force );
|
||||
void HUD_PlaySound( char *sound, float volume );
|
||||
void HUD_PlaybackEvent( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
||||
void HUD_SetMaxSpeed( const struct edict_s *ed, float speed );
|
||||
int stub_PrecacheModel( char* s );
|
||||
int stub_PrecacheSound( char* s );
|
||||
unsigned short stub_PrecacheEvent( int type, const char *s );
|
||||
const char *stub_NameForFunction ( unsigned long function );
|
||||
void stub_SetModel ( struct edict_s *e, const char *m );
|
||||
|
||||
|
||||
extern cvar_t *cl_lw;
|
||||
|
||||
extern int g_runfuncs;
|
||||
extern vec3_t v_angles;
|
||||
extern float g_lastFOV;
|
||||
extern struct local_state_s *g_finalstate;
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// com_weapons.h
|
||||
// Shared weapons common function prototypes
|
||||
#if !defined( COM_WEAPONSH )
|
||||
#define COM_WEAPONSH
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "hud_iface.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed );
|
||||
}
|
||||
|
||||
void COM_Log( char *pszFile, char *fmt, ...);
|
||||
int CL_IsDead( void );
|
||||
|
||||
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
|
||||
int UTIL_SharedRandomLong( unsigned int seed, int low, int high );
|
||||
|
||||
int HUD_GetWeaponAnim( void );
|
||||
void HUD_SendWeaponAnim( int iAnim, int body, int force );
|
||||
void HUD_PlaySound( char *sound, float volume );
|
||||
void HUD_PlaybackEvent( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
||||
void HUD_SetMaxSpeed( const struct edict_s *ed, float speed );
|
||||
int stub_PrecacheModel( char* s );
|
||||
int stub_PrecacheSound( char* s );
|
||||
unsigned short stub_PrecacheEvent( int type, const char *s );
|
||||
const char *stub_NameForFunction ( unsigned long function );
|
||||
void stub_SetModel ( struct edict_s *e, const char *m );
|
||||
|
||||
|
||||
extern cvar_t *cl_lw;
|
||||
|
||||
extern int g_runfuncs;
|
||||
extern vec3_t v_angles;
|
||||
extern float g_lastFOV;
|
||||
extern struct local_state_s *g_finalstate;
|
||||
|
||||
#endif
|
606
cl_dll/death.cpp
606
cl_dll/death.cpp
|
@ -1,304 +1,304 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// death notice
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
DECLARE_MESSAGE( m_DeathNotice, DeathMsg );
|
||||
|
||||
struct DeathNoticeItem {
|
||||
char szKiller[MAX_PLAYER_NAME_LENGTH*2];
|
||||
char szVictim[MAX_PLAYER_NAME_LENGTH*2];
|
||||
int iId; // the index number of the associated sprite
|
||||
int iSuicide;
|
||||
int iTeamKill;
|
||||
int iNonPlayerKill;
|
||||
float flDisplayTime;
|
||||
float *KillerColor;
|
||||
float *VictimColor;
|
||||
};
|
||||
|
||||
#define MAX_DEATHNOTICES 4
|
||||
static int DEATHNOTICE_DISPLAY_TIME = 6;
|
||||
|
||||
#define DEATHNOTICE_TOP 32
|
||||
|
||||
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
|
||||
|
||||
float g_ColorBlue[3] = { 0.6, 0.8, 1.0 };
|
||||
float g_ColorRed[3] = { 1.0, 0.25, 0.25 };
|
||||
float g_ColorGreen[3] = { 0.6, 1.0, 0.6 };
|
||||
float g_ColorYellow[3] = { 1.0, 0.7, 0.0 };
|
||||
float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
|
||||
|
||||
float *GetClientColor( int clientIndex )
|
||||
{
|
||||
switch ( g_PlayerExtraInfo[clientIndex].teamnumber )
|
||||
{
|
||||
case 1: return g_ColorBlue;
|
||||
case 2: return g_ColorRed;
|
||||
case 3: return g_ColorYellow;
|
||||
case 4: return g_ColorGreen;
|
||||
case 0: return g_ColorYellow;
|
||||
|
||||
default : return g_ColorGrey;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CHudDeathNotice :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( DeathMsg );
|
||||
|
||||
CVAR_CREATE( "hud_deathnotice_time", "6", 0 );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CHudDeathNotice :: InitHUDData( void )
|
||||
{
|
||||
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
|
||||
}
|
||||
|
||||
|
||||
int CHudDeathNotice :: VidInit( void )
|
||||
{
|
||||
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudDeathNotice :: Draw( float flTime )
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
|
||||
for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
|
||||
{
|
||||
if ( rgDeathNoticeList[i].iId == 0 )
|
||||
break; // we've gone through them all
|
||||
|
||||
if ( rgDeathNoticeList[i].flDisplayTime < flTime )
|
||||
{ // display time has expired
|
||||
// remove the current item from the list
|
||||
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) );
|
||||
i--; // continue on the next item; stop the counter getting incremented
|
||||
continue;
|
||||
}
|
||||
|
||||
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
|
||||
|
||||
// Only draw if the viewport will let me
|
||||
// vgui dropped out
|
||||
//if ( gViewPort && gViewPort->AllowedToPrintText() )
|
||||
{
|
||||
// Draw the death notice
|
||||
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);
|
||||
|
||||
if ( !rgDeathNoticeList[i].iSuicide )
|
||||
{
|
||||
x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
|
||||
|
||||
// Draw killers name
|
||||
if ( rgDeathNoticeList[i].KillerColor )
|
||||
DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
|
||||
}
|
||||
|
||||
r = 255; g = 80; b = 0;
|
||||
if ( rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
r = 10; g = 240; b = 10; // display it in sickly green
|
||||
}
|
||||
|
||||
// Draw death weapon
|
||||
SPR_Set( gHUD.GetSprite(id), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );
|
||||
|
||||
x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
|
||||
|
||||
// Draw victims name (if it was a player that was killed)
|
||||
if (rgDeathNoticeList[i].iNonPlayerKill == FALSE)
|
||||
{
|
||||
if ( rgDeathNoticeList[i].VictimColor )
|
||||
DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// This message handler may be better off elsewhere
|
||||
int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// death notice
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
DECLARE_MESSAGE( m_DeathNotice, DeathMsg );
|
||||
|
||||
struct DeathNoticeItem {
|
||||
char szKiller[MAX_PLAYER_NAME_LENGTH*2];
|
||||
char szVictim[MAX_PLAYER_NAME_LENGTH*2];
|
||||
int iId; // the index number of the associated sprite
|
||||
int iSuicide;
|
||||
int iTeamKill;
|
||||
int iNonPlayerKill;
|
||||
float flDisplayTime;
|
||||
float *KillerColor;
|
||||
float *VictimColor;
|
||||
};
|
||||
|
||||
#define MAX_DEATHNOTICES 4
|
||||
static int DEATHNOTICE_DISPLAY_TIME = 6;
|
||||
|
||||
#define DEATHNOTICE_TOP 32
|
||||
|
||||
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
|
||||
|
||||
float g_ColorBlue[3] = { 0.6, 0.8, 1.0 };
|
||||
float g_ColorRed[3] = { 1.0, 0.25, 0.25 };
|
||||
float g_ColorGreen[3] = { 0.6, 1.0, 0.6 };
|
||||
float g_ColorYellow[3] = { 1.0, 0.7, 0.0 };
|
||||
float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
|
||||
|
||||
float *GetClientColor( int clientIndex )
|
||||
{
|
||||
switch ( g_PlayerExtraInfo[clientIndex].teamnumber )
|
||||
{
|
||||
case 1: return g_ColorBlue;
|
||||
case 2: return g_ColorRed;
|
||||
case 3: return g_ColorYellow;
|
||||
case 4: return g_ColorGreen;
|
||||
case 0: return g_ColorYellow;
|
||||
|
||||
default : return g_ColorGrey;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CHudDeathNotice :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( DeathMsg );
|
||||
|
||||
CVAR_CREATE( "hud_deathnotice_time", "6", 0 );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CHudDeathNotice :: InitHUDData( void )
|
||||
{
|
||||
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
|
||||
}
|
||||
|
||||
|
||||
int CHudDeathNotice :: VidInit( void )
|
||||
{
|
||||
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudDeathNotice :: Draw( float flTime )
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
|
||||
for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
|
||||
{
|
||||
if ( rgDeathNoticeList[i].iId == 0 )
|
||||
break; // we've gone through them all
|
||||
|
||||
if ( rgDeathNoticeList[i].flDisplayTime < flTime )
|
||||
{ // display time has expired
|
||||
// remove the current item from the list
|
||||
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) );
|
||||
i--; // continue on the next item; stop the counter getting incremented
|
||||
continue;
|
||||
}
|
||||
|
||||
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
|
||||
|
||||
// Only draw if the viewport will let me
|
||||
// vgui dropped out
|
||||
//if ( gViewPort && gViewPort->AllowedToPrintText() )
|
||||
{
|
||||
// Draw the death notice
|
||||
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);
|
||||
|
||||
if ( !rgDeathNoticeList[i].iSuicide )
|
||||
{
|
||||
x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
|
||||
|
||||
// Draw killers name
|
||||
if ( rgDeathNoticeList[i].KillerColor )
|
||||
DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
|
||||
}
|
||||
|
||||
r = 255; g = 80; b = 0;
|
||||
if ( rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
r = 10; g = 240; b = 10; // display it in sickly green
|
||||
}
|
||||
|
||||
// Draw death weapon
|
||||
SPR_Set( gHUD.GetSprite(id), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );
|
||||
|
||||
x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
|
||||
|
||||
// Draw victims name (if it was a player that was killed)
|
||||
if (rgDeathNoticeList[i].iNonPlayerKill == FALSE)
|
||||
{
|
||||
if ( rgDeathNoticeList[i].VictimColor )
|
||||
DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// This message handler may be better off elsewhere
|
||||
int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
int i;
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int killer = READ_BYTE();
|
||||
int victim = READ_BYTE();
|
||||
|
||||
char killedwith[32];
|
||||
strcpy( killedwith, "d_" );
|
||||
strncat( killedwith, READ_STRING(), 32 );
|
||||
|
||||
|
||||
gHUD.m_Spectator.DeathMessage(victim);
|
||||
|
||||
for ( i = 0; i < MAX_DEATHNOTICES; i++ )
|
||||
{
|
||||
if ( rgDeathNoticeList[i].iId == 0 )
|
||||
break;
|
||||
}
|
||||
if ( i == MAX_DEATHNOTICES )
|
||||
{ // move the rest of the list forward to make room for this item
|
||||
memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
|
||||
i = MAX_DEATHNOTICES - 1;
|
||||
}
|
||||
|
||||
//if (gViewPort)
|
||||
// gViewPort->GetAllPlayersInfo();
|
||||
gHUD.m_Scoreboard.GetAllPlayersInfo();
|
||||
|
||||
|
||||
// Get the Killer's name
|
||||
char *killer_name = g_PlayerInfoList[ killer ].name;
|
||||
if ( !killer_name )
|
||||
{
|
||||
killer_name = "";
|
||||
rgDeathNoticeList[i].szKiller[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
|
||||
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
|
||||
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
||||
}
|
||||
|
||||
// Get the Victim's name
|
||||
char *victim_name = NULL;
|
||||
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
|
||||
if ( ((char)victim) != -1 )
|
||||
victim_name = g_PlayerInfoList[ victim ].name;
|
||||
if ( !victim_name )
|
||||
{
|
||||
victim_name = "";
|
||||
rgDeathNoticeList[i].szVictim[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
|
||||
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
|
||||
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
||||
}
|
||||
|
||||
// Is it a non-player object kill?
|
||||
if ( ((char)victim) == -1 )
|
||||
{
|
||||
rgDeathNoticeList[i].iNonPlayerKill = TRUE;
|
||||
|
||||
// Store the object's name in the Victim slot (skip the d_ bit)
|
||||
strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( killer == victim || killer == 0 )
|
||||
rgDeathNoticeList[i].iSuicide = TRUE;
|
||||
|
||||
if ( !strcmp( killedwith, "d_teammate" ) )
|
||||
rgDeathNoticeList[i].iTeamKill = TRUE;
|
||||
}
|
||||
|
||||
// Find the sprite in the list
|
||||
int spr = gHUD.GetSpriteIndex( killedwith );
|
||||
|
||||
rgDeathNoticeList[i].iId = spr;
|
||||
|
||||
DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" );
|
||||
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME;
|
||||
|
||||
if (rgDeathNoticeList[i].iNonPlayerKill)
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed a " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
ConsolePrint( "\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// record the death notice in the console
|
||||
if ( rgDeathNoticeList[i].iSuicide )
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
|
||||
if ( !strcmp( killedwith, "d_world" ) )
|
||||
{
|
||||
ConsolePrint( " died" );
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsolePrint( " killed self" );
|
||||
}
|
||||
}
|
||||
else if ( rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed his teammate " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
|
||||
if ( *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
ConsolePrint( " with " );
|
||||
|
||||
// replace the code names with the 'real' names
|
||||
if ( !strcmp( killedwith+2, "egon" ) )
|
||||
strcpy( killedwith, "d_gluon gun" );
|
||||
if ( !strcmp( killedwith+2, "gauss" ) )
|
||||
strcpy( killedwith, "d_tau cannon" );
|
||||
|
||||
ConsolePrint( killedwith+2 ); // skip over the "d_" part
|
||||
}
|
||||
|
||||
ConsolePrint( "\n" );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int killer = READ_BYTE();
|
||||
int victim = READ_BYTE();
|
||||
|
||||
char killedwith[32];
|
||||
strcpy( killedwith, "d_" );
|
||||
strncat( killedwith, READ_STRING(), 32 );
|
||||
|
||||
|
||||
gHUD.m_Spectator.DeathMessage(victim);
|
||||
|
||||
for ( i = 0; i < MAX_DEATHNOTICES; i++ )
|
||||
{
|
||||
if ( rgDeathNoticeList[i].iId == 0 )
|
||||
break;
|
||||
}
|
||||
if ( i == MAX_DEATHNOTICES )
|
||||
{ // move the rest of the list forward to make room for this item
|
||||
memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
|
||||
i = MAX_DEATHNOTICES - 1;
|
||||
}
|
||||
|
||||
//if (gViewPort)
|
||||
// gViewPort->GetAllPlayersInfo();
|
||||
gHUD.m_Scoreboard.GetAllPlayersInfo();
|
||||
|
||||
|
||||
// Get the Killer's name
|
||||
char *killer_name = g_PlayerInfoList[ killer ].name;
|
||||
if ( !killer_name )
|
||||
{
|
||||
killer_name = "";
|
||||
rgDeathNoticeList[i].szKiller[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
|
||||
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
|
||||
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
||||
}
|
||||
|
||||
// Get the Victim's name
|
||||
char *victim_name = NULL;
|
||||
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
|
||||
if ( ((char)victim) != -1 )
|
||||
victim_name = g_PlayerInfoList[ victim ].name;
|
||||
if ( !victim_name )
|
||||
{
|
||||
victim_name = "";
|
||||
rgDeathNoticeList[i].szVictim[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
|
||||
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
|
||||
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0;
|
||||
}
|
||||
|
||||
// Is it a non-player object kill?
|
||||
if ( ((char)victim) == -1 )
|
||||
{
|
||||
rgDeathNoticeList[i].iNonPlayerKill = TRUE;
|
||||
|
||||
// Store the object's name in the Victim slot (skip the d_ bit)
|
||||
strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( killer == victim || killer == 0 )
|
||||
rgDeathNoticeList[i].iSuicide = TRUE;
|
||||
|
||||
if ( !strcmp( killedwith, "d_teammate" ) )
|
||||
rgDeathNoticeList[i].iTeamKill = TRUE;
|
||||
}
|
||||
|
||||
// Find the sprite in the list
|
||||
int spr = gHUD.GetSpriteIndex( killedwith );
|
||||
|
||||
rgDeathNoticeList[i].iId = spr;
|
||||
|
||||
DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" );
|
||||
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME;
|
||||
|
||||
if (rgDeathNoticeList[i].iNonPlayerKill)
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed a " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
ConsolePrint( "\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// record the death notice in the console
|
||||
if ( rgDeathNoticeList[i].iSuicide )
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
|
||||
if ( !strcmp( killedwith, "d_world" ) )
|
||||
{
|
||||
ConsolePrint( " died" );
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsolePrint( " killed self" );
|
||||
}
|
||||
}
|
||||
else if ( rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed his teammate " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsolePrint( rgDeathNoticeList[i].szKiller );
|
||||
ConsolePrint( " killed " );
|
||||
ConsolePrint( rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
|
||||
if ( *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill )
|
||||
{
|
||||
ConsolePrint( " with " );
|
||||
|
||||
// replace the code names with the 'real' names
|
||||
if ( !strcmp( killedwith+2, "egon" ) )
|
||||
strcpy( killedwith, "d_gluon gun" );
|
||||
if ( !strcmp( killedwith+2, "gauss" ) )
|
||||
strcpy( killedwith, "d_tau cannon" );
|
||||
|
||||
ConsolePrint( killedwith+2 ); // skip over the "d_" part
|
||||
}
|
||||
|
||||
ConsolePrint( "\n" );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
202
cl_dll/demo.cpp
202
cl_dll/demo.cpp
|
@ -1,101 +1,101 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "demo.h"
|
||||
#include "demo_api.h"
|
||||
#include <memory.h>
|
||||
|
||||
int g_demosniper = 0;
|
||||
int g_demosniperdamage = 0;
|
||||
float g_demosniperorg[3];
|
||||
float g_demosniperangles[3];
|
||||
float g_demozoom;
|
||||
|
||||
// FIXME: There should be buffer helper functions to avoid all of the *(int *)& crap.
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Demo_WriteBuffer
|
||||
|
||||
Write some data to the demo stream
|
||||
=====================
|
||||
*/
|
||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer )
|
||||
{
|
||||
int pos = 0;
|
||||
unsigned char buf[ 32 * 1024 ];
|
||||
*( int * )&buf[pos] = type;
|
||||
pos+=sizeof( int );
|
||||
|
||||
memcpy( &buf[pos], buffer, size );
|
||||
|
||||
// Write full buffer out
|
||||
gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Demo_ReadBuffer
|
||||
|
||||
Engine wants us to parse some data from the demo stream
|
||||
=====================
|
||||
*/
|
||||
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
|
||||
{
|
||||
int type;
|
||||
int i = 0;
|
||||
|
||||
type = *( int * )buffer;
|
||||
i += sizeof( int );
|
||||
switch ( type )
|
||||
{
|
||||
case TYPE_SNIPERDOT:
|
||||
g_demosniper = *(int * )&buffer[ i ];
|
||||
i += sizeof( int );
|
||||
|
||||
if ( g_demosniper )
|
||||
{
|
||||
g_demosniperdamage = *( int * )&buffer[ i ];
|
||||
i += sizeof( int );
|
||||
|
||||
g_demosniperangles[ 0 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperangles[ 1 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperangles[ 2 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 0 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 1 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 2 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
}
|
||||
break;
|
||||
case TYPE_ZOOM:
|
||||
g_demozoom = *(float * )&buffer[ i ];
|
||||
i += sizeof( float );
|
||||
break;
|
||||
default:
|
||||
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "demo.h"
|
||||
#include "demo_api.h"
|
||||
#include <memory.h>
|
||||
|
||||
int g_demosniper = 0;
|
||||
int g_demosniperdamage = 0;
|
||||
float g_demosniperorg[3];
|
||||
float g_demosniperangles[3];
|
||||
float g_demozoom;
|
||||
|
||||
// FIXME: There should be buffer helper functions to avoid all of the *(int *)& crap.
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Demo_WriteBuffer
|
||||
|
||||
Write some data to the demo stream
|
||||
=====================
|
||||
*/
|
||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer )
|
||||
{
|
||||
int pos = 0;
|
||||
unsigned char buf[ 32 * 1024 ];
|
||||
*( int * )&buf[pos] = type;
|
||||
pos+=sizeof( int );
|
||||
|
||||
memcpy( &buf[pos], buffer, size );
|
||||
|
||||
// Write full buffer out
|
||||
gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
Demo_ReadBuffer
|
||||
|
||||
Engine wants us to parse some data from the demo stream
|
||||
=====================
|
||||
*/
|
||||
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
|
||||
{
|
||||
int type;
|
||||
int i = 0;
|
||||
|
||||
type = *( int * )buffer;
|
||||
i += sizeof( int );
|
||||
switch ( type )
|
||||
{
|
||||
case TYPE_SNIPERDOT:
|
||||
g_demosniper = *(int * )&buffer[ i ];
|
||||
i += sizeof( int );
|
||||
|
||||
if ( g_demosniper )
|
||||
{
|
||||
g_demosniperdamage = *( int * )&buffer[ i ];
|
||||
i += sizeof( int );
|
||||
|
||||
g_demosniperangles[ 0 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperangles[ 1 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperangles[ 2 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 0 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 1 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
g_demosniperorg[ 2 ] = *(float *)&buffer[i];
|
||||
i += sizeof( float );
|
||||
}
|
||||
break;
|
||||
case TYPE_ZOOM:
|
||||
g_demozoom = *(float * )&buffer[ i ];
|
||||
i += sizeof( float );
|
||||
break;
|
||||
default:
|
||||
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( DEMOH )
|
||||
#define DEMOH
|
||||
#pragma once
|
||||
|
||||
// Types of demo messages we can write/parse
|
||||
enum
|
||||
{
|
||||
TYPE_SNIPERDOT = 0,
|
||||
TYPE_ZOOM
|
||||
};
|
||||
|
||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer );
|
||||
|
||||
extern int g_demosniper;
|
||||
extern int g_demosniperdamage;
|
||||
extern float g_demosniperorg[3];
|
||||
extern float g_demosniperangles[3];
|
||||
extern float g_demozoom;
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( DEMOH )
|
||||
#define DEMOH
|
||||
#pragma once
|
||||
|
||||
// Types of demo messages we can write/parse
|
||||
enum
|
||||
{
|
||||
TYPE_SNIPERDOT = 0,
|
||||
TYPE_ZOOM
|
||||
};
|
||||
|
||||
void Demo_WriteBuffer( int type, int size, unsigned char *buffer );
|
||||
|
||||
extern int g_demosniper;
|
||||
extern int g_demosniperdamage;
|
||||
extern float g_demosniperorg[3];
|
||||
extern float g_demosniperangles[3];
|
||||
extern float g_demozoom;
|
||||
|
||||
#endif
|
1948
cl_dll/entity.cpp
1948
cl_dll/entity.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,205 +1,205 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// shared event functions
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
|
||||
#include "r_efx.h"
|
||||
|
||||
#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
|
||||
|
||||
Return's the requested cl_entity_t
|
||||
=================
|
||||
*/
|
||||
struct cl_entity_s *GetEntity( int idx )
|
||||
{
|
||||
return gEngfuncs.GetEntityByIndex( idx );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GetViewEntity
|
||||
|
||||
Return's the current weapon/view model
|
||||
=================
|
||||
*/
|
||||
struct cl_entity_s *GetViewEntity( void )
|
||||
{
|
||||
return gEngfuncs.GetViewModel();
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_CreateTracer
|
||||
|
||||
Creates a tracer effect
|
||||
=================
|
||||
*/
|
||||
void EV_CreateTracer( float *start, float *end )
|
||||
{
|
||||
gEngfuncs.pEfxAPI->R_TracerEffect( start, end );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_IsPlayer
|
||||
|
||||
Is the entity's index in the player range?
|
||||
=================
|
||||
*/
|
||||
qboolean EV_IsPlayer( int idx )
|
||||
{
|
||||
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_IsLocal
|
||||
|
||||
Is the entity == the local player
|
||||
=================
|
||||
*/
|
||||
qboolean EV_IsLocal( int idx )
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_GetGunPosition
|
||||
|
||||
Figure out the height of the gun
|
||||
=================
|
||||
*/
|
||||
void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
|
||||
{
|
||||
int idx;
|
||||
vec3_t view_ofs;
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorClear( view_ofs );
|
||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
||||
|
||||
if ( EV_IsPlayer( 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 );
|
||||
}
|
||||
else if ( args->ducking == 1 )
|
||||
{
|
||||
view_ofs[2] = VEC_DUCK_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
VectorAdd( origin, view_ofs, pos );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_EjectBrass
|
||||
|
||||
Bullet shell casings
|
||||
=================
|
||||
*/
|
||||
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype )
|
||||
{
|
||||
vec3_t endpos;
|
||||
VectorClear( endpos );
|
||||
endpos[1] = rotation;
|
||||
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, 2.5, model, soundtype );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_GetDefaultShellInfo
|
||||
|
||||
Determine where to eject shells from
|
||||
=================
|
||||
*/
|
||||
void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale )
|
||||
{
|
||||
int i;
|
||||
vec3_t view_ofs;
|
||||
float fR, fU;
|
||||
|
||||
int idx;
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorClear( view_ofs );
|
||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
||||
|
||||
if ( EV_IsPlayer( idx ) )
|
||||
{
|
||||
if ( EV_IsLocal( idx ) )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
||||
}
|
||||
else if ( args->ducking == 1 )
|
||||
{
|
||||
view_ofs[2] = VEC_DUCK_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
fR = gEngfuncs.pfnRandomFloat( 50, 70 );
|
||||
fU = gEngfuncs.pfnRandomFloat( 100, 150 );
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25;
|
||||
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_MuzzleFlash
|
||||
|
||||
Flag weapon/view model for muzzle flash
|
||||
=================
|
||||
*/
|
||||
void EV_MuzzleFlash( void )
|
||||
{
|
||||
// Add muzzle flash to current weapon model
|
||||
cl_entity_t *ent = GetViewEntity();
|
||||
if ( !ent )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Or in the muzzle flash
|
||||
ent->curstate.effects |= EF_MUZZLEFLASH;
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// shared event functions
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
|
||||
#include "r_efx.h"
|
||||
|
||||
#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
|
||||
|
||||
Return's the requested cl_entity_t
|
||||
=================
|
||||
*/
|
||||
struct cl_entity_s *GetEntity( int idx )
|
||||
{
|
||||
return gEngfuncs.GetEntityByIndex( idx );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GetViewEntity
|
||||
|
||||
Return's the current weapon/view model
|
||||
=================
|
||||
*/
|
||||
struct cl_entity_s *GetViewEntity( void )
|
||||
{
|
||||
return gEngfuncs.GetViewModel();
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_CreateTracer
|
||||
|
||||
Creates a tracer effect
|
||||
=================
|
||||
*/
|
||||
void EV_CreateTracer( float *start, float *end )
|
||||
{
|
||||
gEngfuncs.pEfxAPI->R_TracerEffect( start, end );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_IsPlayer
|
||||
|
||||
Is the entity's index in the player range?
|
||||
=================
|
||||
*/
|
||||
qboolean EV_IsPlayer( int idx )
|
||||
{
|
||||
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_IsLocal
|
||||
|
||||
Is the entity == the local player
|
||||
=================
|
||||
*/
|
||||
qboolean EV_IsLocal( int idx )
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_GetGunPosition
|
||||
|
||||
Figure out the height of the gun
|
||||
=================
|
||||
*/
|
||||
void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
|
||||
{
|
||||
int idx;
|
||||
vec3_t view_ofs;
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorClear( view_ofs );
|
||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
||||
|
||||
if ( EV_IsPlayer( 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 );
|
||||
}
|
||||
else if ( args->ducking == 1 )
|
||||
{
|
||||
view_ofs[2] = VEC_DUCK_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
VectorAdd( origin, view_ofs, pos );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_EjectBrass
|
||||
|
||||
Bullet shell casings
|
||||
=================
|
||||
*/
|
||||
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype )
|
||||
{
|
||||
vec3_t endpos;
|
||||
VectorClear( endpos );
|
||||
endpos[1] = rotation;
|
||||
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, 2.5, model, soundtype );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_GetDefaultShellInfo
|
||||
|
||||
Determine where to eject shells from
|
||||
=================
|
||||
*/
|
||||
void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale )
|
||||
{
|
||||
int i;
|
||||
vec3_t view_ofs;
|
||||
float fR, fU;
|
||||
|
||||
int idx;
|
||||
|
||||
idx = args->entindex;
|
||||
|
||||
VectorClear( view_ofs );
|
||||
view_ofs[2] = DEFAULT_VIEWHEIGHT;
|
||||
|
||||
if ( EV_IsPlayer( idx ) )
|
||||
{
|
||||
if ( EV_IsLocal( idx ) )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
|
||||
}
|
||||
else if ( args->ducking == 1 )
|
||||
{
|
||||
view_ofs[2] = VEC_DUCK_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
fR = gEngfuncs.pfnRandomFloat( 50, 70 );
|
||||
fU = gEngfuncs.pfnRandomFloat( 100, 150 );
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25;
|
||||
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
EV_MuzzleFlash
|
||||
|
||||
Flag weapon/view model for muzzle flash
|
||||
=================
|
||||
*/
|
||||
void EV_MuzzleFlash( void )
|
||||
{
|
||||
// Add muzzle flash to current weapon model
|
||||
cl_entity_t *ent = GetViewEntity();
|
||||
if ( !ent )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Or in the muzzle flash
|
||||
ent->curstate.effects |= EF_MUZZLEFLASH;
|
||||
}
|
3398
cl_dll/ev_hldm.cpp
3398
cl_dll/ev_hldm.cpp
File diff suppressed because it is too large
Load Diff
188
cl_dll/ev_hldm.h
188
cl_dll/ev_hldm.h
|
@ -1,95 +1,95 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined ( EV_HLDMH )
|
||||
#define EV_HLDMH
|
||||
|
||||
// bullet types
|
||||
typedef enum
|
||||
{
|
||||
BULLET_NONE = 0,
|
||||
BULLET_PLAYER_9MM, // glock
|
||||
BULLET_PLAYER_MP5, // mp5
|
||||
BULLET_PLAYER_357, // python
|
||||
BULLET_PLAYER_BUCKSHOT, // shotgun
|
||||
BULLET_PLAYER_CROWBAR, // crowbar swipe
|
||||
|
||||
BULLET_MONSTER_9MM,
|
||||
BULLET_MONSTER_MP5,
|
||||
BULLET_MONSTER_12MM,
|
||||
} Bullet;
|
||||
|
||||
enum glock_e {
|
||||
GLOCK_IDLE1 = 0,
|
||||
GLOCK_IDLE2,
|
||||
GLOCK_IDLE3,
|
||||
GLOCK_SHOOT,
|
||||
GLOCK_SHOOT_EMPTY,
|
||||
GLOCK_RELOAD,
|
||||
GLOCK_RELOAD_NOT_EMPTY,
|
||||
GLOCK_DRAW,
|
||||
GLOCK_HOLSTER,
|
||||
GLOCK_ADD_SILENCER
|
||||
};
|
||||
|
||||
enum shotgun_e {
|
||||
SHOTGUN_IDLE = 0,
|
||||
SHOTGUN_FIRE,
|
||||
SHOTGUN_FIRE2,
|
||||
SHOTGUN_RELOAD,
|
||||
SHOTGUN_PUMP,
|
||||
SHOTGUN_START_RELOAD,
|
||||
SHOTGUN_DRAW,
|
||||
SHOTGUN_HOLSTER,
|
||||
SHOTGUN_IDLE4,
|
||||
SHOTGUN_IDLE_DEEP
|
||||
};
|
||||
|
||||
enum mp5_e
|
||||
{
|
||||
MP5_LONGIDLE = 0,
|
||||
MP5_IDLE1,
|
||||
MP5_LAUNCH,
|
||||
MP5_RELOAD,
|
||||
MP5_DEPLOY,
|
||||
MP5_FIRE1,
|
||||
MP5_FIRE2,
|
||||
MP5_FIRE3,
|
||||
};
|
||||
|
||||
enum python_e {
|
||||
PYTHON_IDLE1 = 0,
|
||||
PYTHON_FIDGET,
|
||||
PYTHON_FIRE1,
|
||||
PYTHON_RELOAD,
|
||||
PYTHON_HOLSTER,
|
||||
PYTHON_DRAW,
|
||||
PYTHON_IDLE2,
|
||||
PYTHON_IDLE3
|
||||
};
|
||||
|
||||
#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging
|
||||
#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged
|
||||
|
||||
enum gauss_e {
|
||||
GAUSS_IDLE = 0,
|
||||
GAUSS_IDLE2,
|
||||
GAUSS_FIDGET,
|
||||
GAUSS_SPINUP,
|
||||
GAUSS_SPIN,
|
||||
GAUSS_FIRE,
|
||||
GAUSS_FIRE2,
|
||||
GAUSS_HOLSTER,
|
||||
GAUSS_DRAW
|
||||
};
|
||||
|
||||
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 flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY );
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined ( EV_HLDMH )
|
||||
#define EV_HLDMH
|
||||
|
||||
// bullet types
|
||||
typedef enum
|
||||
{
|
||||
BULLET_NONE = 0,
|
||||
BULLET_PLAYER_9MM, // glock
|
||||
BULLET_PLAYER_MP5, // mp5
|
||||
BULLET_PLAYER_357, // python
|
||||
BULLET_PLAYER_BUCKSHOT, // shotgun
|
||||
BULLET_PLAYER_CROWBAR, // crowbar swipe
|
||||
|
||||
BULLET_MONSTER_9MM,
|
||||
BULLET_MONSTER_MP5,
|
||||
BULLET_MONSTER_12MM,
|
||||
} Bullet;
|
||||
|
||||
enum glock_e {
|
||||
GLOCK_IDLE1 = 0,
|
||||
GLOCK_IDLE2,
|
||||
GLOCK_IDLE3,
|
||||
GLOCK_SHOOT,
|
||||
GLOCK_SHOOT_EMPTY,
|
||||
GLOCK_RELOAD,
|
||||
GLOCK_RELOAD_NOT_EMPTY,
|
||||
GLOCK_DRAW,
|
||||
GLOCK_HOLSTER,
|
||||
GLOCK_ADD_SILENCER
|
||||
};
|
||||
|
||||
enum shotgun_e {
|
||||
SHOTGUN_IDLE = 0,
|
||||
SHOTGUN_FIRE,
|
||||
SHOTGUN_FIRE2,
|
||||
SHOTGUN_RELOAD,
|
||||
SHOTGUN_PUMP,
|
||||
SHOTGUN_START_RELOAD,
|
||||
SHOTGUN_DRAW,
|
||||
SHOTGUN_HOLSTER,
|
||||
SHOTGUN_IDLE4,
|
||||
SHOTGUN_IDLE_DEEP
|
||||
};
|
||||
|
||||
enum mp5_e
|
||||
{
|
||||
MP5_LONGIDLE = 0,
|
||||
MP5_IDLE1,
|
||||
MP5_LAUNCH,
|
||||
MP5_RELOAD,
|
||||
MP5_DEPLOY,
|
||||
MP5_FIRE1,
|
||||
MP5_FIRE2,
|
||||
MP5_FIRE3,
|
||||
};
|
||||
|
||||
enum python_e {
|
||||
PYTHON_IDLE1 = 0,
|
||||
PYTHON_FIDGET,
|
||||
PYTHON_FIRE1,
|
||||
PYTHON_RELOAD,
|
||||
PYTHON_HOLSTER,
|
||||
PYTHON_DRAW,
|
||||
PYTHON_IDLE2,
|
||||
PYTHON_IDLE3
|
||||
};
|
||||
|
||||
#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging
|
||||
#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged
|
||||
|
||||
enum gauss_e {
|
||||
GAUSS_IDLE = 0,
|
||||
GAUSS_IDLE2,
|
||||
GAUSS_FIDGET,
|
||||
GAUSS_SPINUP,
|
||||
GAUSS_SPIN,
|
||||
GAUSS_FIRE,
|
||||
GAUSS_FIRE2,
|
||||
GAUSS_HOLSTER,
|
||||
GAUSS_DRAW
|
||||
};
|
||||
|
||||
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 flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY );
|
||||
|
||||
#endif // EV_HLDMH
|
|
@ -1,23 +1,23 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
void Game_HookEvents( void );
|
||||
|
||||
/*
|
||||
===================
|
||||
EV_HookEvents
|
||||
|
||||
See if game specific code wants to hook any events.
|
||||
===================
|
||||
*/
|
||||
void EV_HookEvents( void )
|
||||
{
|
||||
Game_HookEvents();
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
void Game_HookEvents( void );
|
||||
|
||||
/*
|
||||
===================
|
||||
EV_HookEvents
|
||||
|
||||
See if game specific code wants to hook any events.
|
||||
===================
|
||||
*/
|
||||
void EV_HookEvents( void )
|
||||
{
|
||||
Game_HookEvents();
|
||||
}
|
|
@ -1,73 +1,73 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// eventscripts.h
|
||||
#if !defined ( EVENTSCRIPTSH )
|
||||
#define EVENTSCRIPTSH
|
||||
|
||||
// defaults for clientinfo messages
|
||||
#define DEFAULT_VIEWHEIGHT 28
|
||||
#define VEC_DUCK_VIEW 12
|
||||
|
||||
#define FTENT_FADEOUT 0x00000080
|
||||
|
||||
#define DMG_GENERIC 0 // generic damage was done
|
||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
||||
#define DMG_BULLET (1 << 1) // shot
|
||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||
#define DMG_BURN (1 << 3) // heat burned
|
||||
#define DMG_FREEZE (1 << 4) // frozen
|
||||
#define DMG_FALL (1 << 5) // fell too far
|
||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
||||
#define DMG_SHOCK (1 << 8) // electric shock
|
||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
||||
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
|
||||
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
|
||||
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
||||
|
||||
// time-based damage
|
||||
//mask off TF-specific stuff too
|
||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
||||
|
||||
#define DMG_DROWN (1 << 14) // Drowning
|
||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
||||
|
||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
||||
#define DMG_POISON (1 << 17) // blood poisioning
|
||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
||||
|
||||
//TF ADDITIONS
|
||||
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
|
||||
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
|
||||
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
|
||||
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
|
||||
#define DMG_AIMED (1 << 28) // Does Hit location damage
|
||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
||||
|
||||
#define DMG_CALTROP (1<<30)
|
||||
#define DMG_HALLUC (1<<31)
|
||||
|
||||
// Some of these are HL/TFC specific?
|
||||
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype );
|
||||
void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin );
|
||||
void EV_GetDefaultShellInfo( struct event_args_s *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale );
|
||||
qboolean EV_IsLocal( int idx );
|
||||
qboolean EV_IsPlayer( int idx );
|
||||
void EV_CreateTracer( float *start, float *end );
|
||||
|
||||
struct cl_entity_s *GetEntity( int idx );
|
||||
struct cl_entity_s *GetViewEntity( void );
|
||||
void EV_MuzzleFlash( void );
|
||||
|
||||
#endif // EVENTSCRIPTSH
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// eventscripts.h
|
||||
#if !defined ( EVENTSCRIPTSH )
|
||||
#define EVENTSCRIPTSH
|
||||
|
||||
// defaults for clientinfo messages
|
||||
#define DEFAULT_VIEWHEIGHT 28
|
||||
#define VEC_DUCK_VIEW 12
|
||||
|
||||
#define FTENT_FADEOUT 0x00000080
|
||||
|
||||
#define DMG_GENERIC 0 // generic damage was done
|
||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
||||
#define DMG_BULLET (1 << 1) // shot
|
||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||
#define DMG_BURN (1 << 3) // heat burned
|
||||
#define DMG_FREEZE (1 << 4) // frozen
|
||||
#define DMG_FALL (1 << 5) // fell too far
|
||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
||||
#define DMG_SHOCK (1 << 8) // electric shock
|
||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
||||
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
|
||||
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
|
||||
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
||||
|
||||
// time-based damage
|
||||
//mask off TF-specific stuff too
|
||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
||||
|
||||
#define DMG_DROWN (1 << 14) // Drowning
|
||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
||||
|
||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
||||
#define DMG_POISON (1 << 17) // blood poisioning
|
||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
||||
|
||||
//TF ADDITIONS
|
||||
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
|
||||
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
|
||||
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
|
||||
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
|
||||
#define DMG_AIMED (1 << 28) // Does Hit location damage
|
||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
||||
|
||||
#define DMG_CALTROP (1<<30)
|
||||
#define DMG_HALLUC (1<<31)
|
||||
|
||||
// Some of these are HL/TFC specific?
|
||||
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype );
|
||||
void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin );
|
||||
void EV_GetDefaultShellInfo( struct event_args_s *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale );
|
||||
qboolean EV_IsLocal( int idx );
|
||||
qboolean EV_IsPlayer( int idx );
|
||||
void EV_CreateTracer( float *start, float *end );
|
||||
|
||||
struct cl_entity_s *GetEntity( int idx );
|
||||
struct cl_entity_s *GetViewEntity( void );
|
||||
void EV_MuzzleFlash( void );
|
||||
|
||||
#endif // EVENTSCRIPTSH
|
||||
|
|
|
@ -1,101 +1,101 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// flashlight.cpp
|
||||
//
|
||||
// implementation of CHudFlashlight class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
DECLARE_MESSAGE(m_Flash, FlashBat)
|
||||
DECLARE_MESSAGE(m_Flash, Flashlight)
|
||||
|
||||
#define BAT_NAME "sprites/%d_Flashlight.spr"
|
||||
|
||||
int CHudFlashlight::Init(void)
|
||||
{
|
||||
m_fFade = 0;
|
||||
m_fOn = 0;
|
||||
|
||||
HOOK_MESSAGE(Flashlight);
|
||||
HOOK_MESSAGE(FlashBat);
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
void CHudFlashlight::Reset(void)
|
||||
{
|
||||
m_fFade = 0;
|
||||
m_fOn = 0;
|
||||
}
|
||||
|
||||
int CHudFlashlight::VidInit(void)
|
||||
{
|
||||
int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" );
|
||||
int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" );
|
||||
int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" );
|
||||
|
||||
m_hSprite1 = gHUD.GetSprite(HUD_flash_empty);
|
||||
m_hSprite2 = gHUD.GetSprite(HUD_flash_full);
|
||||
m_hBeam = gHUD.GetSprite(HUD_flash_beam);
|
||||
m_prc1 = &gHUD.GetSpriteRect(HUD_flash_empty);
|
||||
m_prc2 = &gHUD.GetSpriteRect(HUD_flash_full);
|
||||
m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam);
|
||||
m_iWidth = m_prc2->right - m_prc2->left;
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ((float)x)/100.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_fOn = READ_BYTE();
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ((float)x)/100.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudFlashlight::Draw(float flTime)
|
||||
{
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// flashlight.cpp
|
||||
//
|
||||
// implementation of CHudFlashlight class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
DECLARE_MESSAGE(m_Flash, FlashBat)
|
||||
DECLARE_MESSAGE(m_Flash, Flashlight)
|
||||
|
||||
#define BAT_NAME "sprites/%d_Flashlight.spr"
|
||||
|
||||
int CHudFlashlight::Init(void)
|
||||
{
|
||||
m_fFade = 0;
|
||||
m_fOn = 0;
|
||||
|
||||
HOOK_MESSAGE(Flashlight);
|
||||
HOOK_MESSAGE(FlashBat);
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
void CHudFlashlight::Reset(void)
|
||||
{
|
||||
m_fFade = 0;
|
||||
m_fOn = 0;
|
||||
}
|
||||
|
||||
int CHudFlashlight::VidInit(void)
|
||||
{
|
||||
int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" );
|
||||
int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" );
|
||||
int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" );
|
||||
|
||||
m_hSprite1 = gHUD.GetSprite(HUD_flash_empty);
|
||||
m_hSprite2 = gHUD.GetSprite(HUD_flash_full);
|
||||
m_hBeam = gHUD.GetSprite(HUD_flash_beam);
|
||||
m_prc1 = &gHUD.GetSpriteRect(HUD_flash_empty);
|
||||
m_prc2 = &gHUD.GetSpriteRect(HUD_flash_full);
|
||||
m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam);
|
||||
m_iWidth = m_prc2->right - m_prc2->left;
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ((float)x)/100.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_fOn = READ_BYTE();
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ((float)x)/100.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudFlashlight::Draw(float flTime)
|
||||
{
|
||||
static bool show = ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) );
|
||||
if( show != !( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) ) )
|
||||
{
|
||||
|
@ -106,53 +106,53 @@ int CHudFlashlight::Draw(float flTime)
|
|||
}
|
||||
}
|
||||
if ( !show )
|
||||
return 1;
|
||||
|
||||
int r, g, b, x, y, a;
|
||||
wrect_t rc;
|
||||
|
||||
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
|
||||
return 1;
|
||||
|
||||
if (m_fOn)
|
||||
a = 225;
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
if (m_flBat < 0.20)
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
else
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
ScaleColors(r, g, b, a);
|
||||
|
||||
y = (m_prc1->bottom - m_prc2->top)/2;
|
||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
||||
|
||||
// Draw the flashlight casing
|
||||
SPR_Set(m_hSprite1, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, m_prc1);
|
||||
|
||||
if ( m_fOn )
|
||||
{ // draw the flashlight beam
|
||||
x = ScreenWidth - m_iWidth/2;
|
||||
|
||||
SPR_Set( m_hBeam, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, m_prcBeam );
|
||||
}
|
||||
|
||||
// draw the flashlight energy level
|
||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
||||
int iOffset = m_iWidth * (1.0 - m_flBat);
|
||||
if (iOffset < m_iWidth)
|
||||
{
|
||||
rc = *m_prc2;
|
||||
rc.left += iOffset;
|
||||
|
||||
SPR_Set(m_hSprite2, r, g, b );
|
||||
SPR_DrawAdditive( 0, x + iOffset, y, &rc);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
|
||||
int r, g, b, x, y, a;
|
||||
wrect_t rc;
|
||||
|
||||
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
|
||||
return 1;
|
||||
|
||||
if (m_fOn)
|
||||
a = 225;
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
if (m_flBat < 0.20)
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
else
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
ScaleColors(r, g, b, a);
|
||||
|
||||
y = (m_prc1->bottom - m_prc2->top)/2;
|
||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
||||
|
||||
// Draw the flashlight casing
|
||||
SPR_Set(m_hSprite1, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, m_prc1);
|
||||
|
||||
if ( m_fOn )
|
||||
{ // draw the flashlight beam
|
||||
x = ScreenWidth - m_iWidth/2;
|
||||
|
||||
SPR_Set( m_hBeam, r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, m_prcBeam );
|
||||
}
|
||||
|
||||
// draw the flashlight energy level
|
||||
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
|
||||
int iOffset = m_iWidth * (1.0 - m_flBat);
|
||||
if (iOffset < m_iWidth)
|
||||
{
|
||||
rc = *m_prc2;
|
||||
rc.left += iOffset;
|
||||
|
||||
SPR_Set(m_hSprite2, r, g, b );
|
||||
SPR_DrawAdditive( 0, x + iOffset, y, &rc);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -1,184 +1,184 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// Geiger.cpp
|
||||
//
|
||||
// implementation of CHudAmmo class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Geiger, Geiger )
|
||||
|
||||
int CHudGeiger::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Geiger );
|
||||
|
||||
m_iGeigerRange = 0;
|
||||
m_iFlags = 0;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
srand( (unsigned)time( NULL ) );
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudGeiger::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
// update geiger data
|
||||
m_iGeigerRange = READ_BYTE();
|
||||
m_iGeigerRange = m_iGeigerRange << 2;
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudGeiger::Draw (float flTime)
|
||||
{
|
||||
int pct;
|
||||
float flvol = 0.0f;
|
||||
int rg[3];
|
||||
int i;
|
||||
|
||||
if (m_iGeigerRange < 1000 && m_iGeigerRange > 0)
|
||||
{
|
||||
// peicewise linear is better than continuous formula for this
|
||||
if (m_iGeigerRange > 800)
|
||||
{
|
||||
pct = 0; //Con_Printf ( "range > 800\n");
|
||||
}
|
||||
else if (m_iGeigerRange > 600)
|
||||
{
|
||||
pct = 2;
|
||||
flvol = 0.4; //Con_Printf ( "range > 600\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 1;
|
||||
i = 2;
|
||||
}
|
||||
else if (m_iGeigerRange > 500)
|
||||
{
|
||||
pct = 4;
|
||||
flvol = 0.5; //Con_Printf ( "range > 500\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 2;
|
||||
i = 2;
|
||||
}
|
||||
else if (m_iGeigerRange > 400)
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.6; //Con_Printf ( "range > 400\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 2;
|
||||
rg[2] = 3;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 300)
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.7; //Con_Printf ( "range > 300\n");
|
||||
rg[0] = 2;
|
||||
rg[1] = 3;
|
||||
rg[2] = 4;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 200)
|
||||
{
|
||||
pct = 28;
|
||||
flvol = 0.78; //Con_Printf ( "range > 200\n");
|
||||
rg[0] = 2;
|
||||
rg[1] = 3;
|
||||
rg[2] = 4;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 150)
|
||||
{
|
||||
pct = 40;
|
||||
flvol = 0.80; //Con_Printf ( "range > 150\n");
|
||||
rg[0] = 3;
|
||||
rg[1] = 4;
|
||||
rg[2] = 5;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 100)
|
||||
{
|
||||
pct = 60;
|
||||
flvol = 0.85; //Con_Printf ( "range > 100\n");
|
||||
rg[0] = 3;
|
||||
rg[1] = 4;
|
||||
rg[2] = 5;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 75)
|
||||
{
|
||||
pct = 80;
|
||||
flvol = 0.9; //Con_Printf ( "range > 75\n");
|
||||
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
|
||||
rg[0] = 4;
|
||||
rg[1] = 5;
|
||||
rg[2] = 6;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 50)
|
||||
{
|
||||
pct = 90;
|
||||
flvol = 0.95; //Con_Printf ( "range > 50\n");
|
||||
rg[0] = 5;
|
||||
rg[1] = 6;
|
||||
i = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pct = 95;
|
||||
flvol = 1.0; //Con_Printf ( "range < 50\n");
|
||||
rg[0] = 5;
|
||||
rg[1] = 6;
|
||||
i = 2;
|
||||
}
|
||||
|
||||
flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5);
|
||||
|
||||
if ((rand() & 127) < pct || (rand() & 127) < pct)
|
||||
{
|
||||
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100);
|
||||
char sz[256];
|
||||
|
||||
int j = rand() & 1;
|
||||
if (i > 2)
|
||||
j += rand() & 1;
|
||||
|
||||
sprintf(sz, "player/geiger%d.wav", j + 1);
|
||||
PlaySound(sz, flvol);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// Geiger.cpp
|
||||
//
|
||||
// implementation of CHudAmmo class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Geiger, Geiger )
|
||||
|
||||
int CHudGeiger::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Geiger );
|
||||
|
||||
m_iGeigerRange = 0;
|
||||
m_iFlags = 0;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
srand( (unsigned)time( NULL ) );
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudGeiger::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
// update geiger data
|
||||
m_iGeigerRange = READ_BYTE();
|
||||
m_iGeigerRange = m_iGeigerRange << 2;
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudGeiger::Draw (float flTime)
|
||||
{
|
||||
int pct;
|
||||
float flvol = 0.0f;
|
||||
int rg[3];
|
||||
int i;
|
||||
|
||||
if (m_iGeigerRange < 1000 && m_iGeigerRange > 0)
|
||||
{
|
||||
// peicewise linear is better than continuous formula for this
|
||||
if (m_iGeigerRange > 800)
|
||||
{
|
||||
pct = 0; //Con_Printf ( "range > 800\n");
|
||||
}
|
||||
else if (m_iGeigerRange > 600)
|
||||
{
|
||||
pct = 2;
|
||||
flvol = 0.4; //Con_Printf ( "range > 600\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 1;
|
||||
i = 2;
|
||||
}
|
||||
else if (m_iGeigerRange > 500)
|
||||
{
|
||||
pct = 4;
|
||||
flvol = 0.5; //Con_Printf ( "range > 500\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 2;
|
||||
i = 2;
|
||||
}
|
||||
else if (m_iGeigerRange > 400)
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.6; //Con_Printf ( "range > 400\n");
|
||||
rg[0] = 1;
|
||||
rg[1] = 2;
|
||||
rg[2] = 3;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 300)
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.7; //Con_Printf ( "range > 300\n");
|
||||
rg[0] = 2;
|
||||
rg[1] = 3;
|
||||
rg[2] = 4;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 200)
|
||||
{
|
||||
pct = 28;
|
||||
flvol = 0.78; //Con_Printf ( "range > 200\n");
|
||||
rg[0] = 2;
|
||||
rg[1] = 3;
|
||||
rg[2] = 4;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 150)
|
||||
{
|
||||
pct = 40;
|
||||
flvol = 0.80; //Con_Printf ( "range > 150\n");
|
||||
rg[0] = 3;
|
||||
rg[1] = 4;
|
||||
rg[2] = 5;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 100)
|
||||
{
|
||||
pct = 60;
|
||||
flvol = 0.85; //Con_Printf ( "range > 100\n");
|
||||
rg[0] = 3;
|
||||
rg[1] = 4;
|
||||
rg[2] = 5;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 75)
|
||||
{
|
||||
pct = 80;
|
||||
flvol = 0.9; //Con_Printf ( "range > 75\n");
|
||||
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
|
||||
rg[0] = 4;
|
||||
rg[1] = 5;
|
||||
rg[2] = 6;
|
||||
i = 3;
|
||||
}
|
||||
else if (m_iGeigerRange > 50)
|
||||
{
|
||||
pct = 90;
|
||||
flvol = 0.95; //Con_Printf ( "range > 50\n");
|
||||
rg[0] = 5;
|
||||
rg[1] = 6;
|
||||
i = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pct = 95;
|
||||
flvol = 1.0; //Con_Printf ( "range < 50\n");
|
||||
rg[0] = 5;
|
||||
rg[1] = 6;
|
||||
i = 2;
|
||||
}
|
||||
|
||||
flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5);
|
||||
|
||||
if ((rand() & 127) < pct || (rand() & 127) < pct)
|
||||
{
|
||||
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100);
|
||||
char sz[256];
|
||||
|
||||
int j = rand() & 1;
|
||||
if (i > 2)
|
||||
j += rand() & 1;
|
||||
|
||||
sprintf(sz, "player/geiger%d.wav", j + 1);
|
||||
PlaySound(sz, flvol);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,483 +1,483 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// Health.cpp
|
||||
//
|
||||
// implementation of CHudHealth class
|
||||
//
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "mobility_int.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Health, Health )
|
||||
DECLARE_MESSAGE(m_Health, Damage )
|
||||
|
||||
#define PAIN_NAME "sprites/%d_pain.spr"
|
||||
#define DAMAGE_NAME "sprites/%d_dmg.spr"
|
||||
|
||||
int giDmgHeight, giDmgWidth;
|
||||
|
||||
int giDmgFlags[NUM_DMG_TYPES] =
|
||||
{
|
||||
DMG_POISON,
|
||||
DMG_ACID,
|
||||
DMG_FREEZE|DMG_SLOWFREEZE,
|
||||
DMG_DROWN,
|
||||
DMG_BURN|DMG_SLOWBURN,
|
||||
DMG_NERVEGAS,
|
||||
DMG_RADIATION,
|
||||
DMG_SHOCK,
|
||||
DMG_CALTROP,
|
||||
DMG_TRANQ,
|
||||
DMG_CONCUSS,
|
||||
DMG_HALLUC
|
||||
};
|
||||
|
||||
int CHudHealth::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE(Health);
|
||||
HOOK_MESSAGE(Damage);
|
||||
m_iHealth = 100;
|
||||
m_fFade = 0;
|
||||
m_iFlags = 0;
|
||||
m_bitsDamage = 0;
|
||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
|
||||
giDmgHeight = 0;
|
||||
giDmgWidth = 0;
|
||||
|
||||
memset(m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES);
|
||||
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudHealth::Reset( void )
|
||||
{
|
||||
// make sure the pain compass is cleared when the player respawns
|
||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
|
||||
|
||||
|
||||
// force all the flashing damage icons to expire
|
||||
m_bitsDamage = 0;
|
||||
for ( int i = 0; i < NUM_DMG_TYPES; i++ )
|
||||
{
|
||||
m_dmg[i].fExpire = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int CHudHealth::VidInit(void)
|
||||
{
|
||||
m_hSprite = 0;
|
||||
|
||||
m_HUD_dmg_bio = gHUD.GetSpriteIndex( "dmg_bio" ) + 1;
|
||||
m_HUD_cross = gHUD.GetSpriteIndex( "cross" );
|
||||
|
||||
giDmgHeight = gHUD.GetSpriteRect(m_HUD_dmg_bio).right - gHUD.GetSpriteRect(m_HUD_dmg_bio).left;
|
||||
giDmgWidth = gHUD.GetSpriteRect(m_HUD_dmg_bio).bottom - gHUD.GetSpriteRect(m_HUD_dmg_bio).top;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
// TODO: update local health data
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_BYTE();
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
// Only update the fade if we've changed health
|
||||
if (x != m_iHealth)
|
||||
{
|
||||
m_fFade = FADE_TIME;
|
||||
m_iHealth = x;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int armor = READ_BYTE(); // armor
|
||||
int damageTaken = READ_BYTE(); // health
|
||||
long bitsDamage = READ_LONG(); // damage bits
|
||||
|
||||
vec3_t vecFrom;
|
||||
|
||||
for ( int i = 0 ; i < 3 ; i++)
|
||||
vecFrom[i] = READ_COORD();
|
||||
|
||||
UpdateTiles(gHUD.m_flTime, bitsDamage);
|
||||
|
||||
// Actually took damage?
|
||||
if ( damageTaken > 0 || armor > 0 )
|
||||
{
|
||||
CalcDamageDirection(vecFrom);
|
||||
|
||||
if( gMobileEngfuncs && damageTaken > 0 )
|
||||
{
|
||||
float time = damageTaken * 4.0f;
|
||||
|
||||
if( time > 200.0f ) time = 200.0f;
|
||||
gMobileEngfuncs->pfnVibrate( time, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Returns back a color from the
|
||||
// Green <-> Yellow <-> Red ramp
|
||||
void CHudHealth::GetPainColor( int &r, int &g, int &b )
|
||||
{
|
||||
int iHealth = m_iHealth;
|
||||
|
||||
if (iHealth > 25)
|
||||
iHealth -= 25;
|
||||
else if ( iHealth < 0 )
|
||||
iHealth = 0;
|
||||
#if 0
|
||||
g = iHealth * 255 / 100;
|
||||
r = 255 - g;
|
||||
b = 0;
|
||||
#else
|
||||
if (m_iHealth > 25)
|
||||
{
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = 250;
|
||||
g = 0;
|
||||
b = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int CHudHealth::Draw(float flTime)
|
||||
{
|
||||
int r, g, b;
|
||||
int a = 0, x, y;
|
||||
int HealthWidth;
|
||||
|
||||
if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() )
|
||||
return 1;
|
||||
|
||||
if ( !m_hSprite )
|
||||
m_hSprite = LoadSprite(PAIN_NAME);
|
||||
|
||||
// Has health changed? Flash the health #
|
||||
if (m_fFade)
|
||||
{
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20);
|
||||
if (m_fFade <= 0)
|
||||
{
|
||||
a = MIN_ALPHA;
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
// Fade the health number back to dim
|
||||
|
||||
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
|
||||
|
||||
}
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
// If health is getting low, make it bright red
|
||||
if (m_iHealth <= 15)
|
||||
a = 255;
|
||||
|
||||
GetPainColor( r, g, b );
|
||||
ScaleColors(r, g, b, a );
|
||||
|
||||
// Only draw health if we have the suit.
|
||||
if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)))
|
||||
{
|
||||
HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
|
||||
int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;
|
||||
|
||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
||||
x = CrossWidth /2;
|
||||
|
||||
SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
|
||||
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));
|
||||
|
||||
x = CrossWidth + HealthWidth / 2;
|
||||
|
||||
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
|
||||
|
||||
x += HealthWidth/2;
|
||||
|
||||
int iHeight = gHUD.m_iFontHeight;
|
||||
int iWidth = HealthWidth/10;
|
||||
FillRGBA(x, y, iWidth, iHeight, 255, 160, 0, a);
|
||||
}
|
||||
|
||||
DrawDamage(flTime);
|
||||
return DrawPain(flTime);
|
||||
}
|
||||
|
||||
void CHudHealth::CalcDamageDirection(vec3_t vecFrom)
|
||||
{
|
||||
vec3_t forward, right, up;
|
||||
float side, front;
|
||||
vec3_t vecOrigin, vecAngles;
|
||||
|
||||
if (!vecFrom[0] && !vecFrom[1] && !vecFrom[2])
|
||||
{
|
||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
memcpy(vecOrigin, gHUD.m_vecOrigin, sizeof(vec3_t));
|
||||
memcpy(vecAngles, gHUD.m_vecAngles, sizeof(vec3_t));
|
||||
|
||||
|
||||
VectorSubtract (vecFrom, vecOrigin, vecFrom);
|
||||
|
||||
float flDistToTarget = vecFrom.Length();
|
||||
|
||||
vecFrom = vecFrom.Normalize();
|
||||
AngleVectors (vecAngles, forward, right, up);
|
||||
|
||||
front = DotProduct (vecFrom, right);
|
||||
side = DotProduct (vecFrom, forward);
|
||||
|
||||
if (flDistToTarget <= 50)
|
||||
{
|
||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (side > 0)
|
||||
{
|
||||
if (side > 0.3)
|
||||
m_fAttackFront = max(m_fAttackFront, side);
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs(side);
|
||||
if (f > 0.3)
|
||||
m_fAttackRear = max(m_fAttackRear, f);
|
||||
}
|
||||
|
||||
if (front > 0)
|
||||
{
|
||||
if (front > 0.3)
|
||||
m_fAttackRight = max(m_fAttackRight, front);
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs(front);
|
||||
if (f > 0.3)
|
||||
m_fAttackLeft = max(m_fAttackLeft, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CHudHealth::DrawPain(float flTime)
|
||||
{
|
||||
if (!(m_fAttackFront || m_fAttackRear || m_fAttackLeft || m_fAttackRight))
|
||||
return 1;
|
||||
|
||||
int r, g, b;
|
||||
int x, y, a, shade;
|
||||
|
||||
// TODO: get the shift value of the health
|
||||
a = 255; // max brightness until then
|
||||
|
||||
float fFade = gHUD.m_flTimeDelta * 2;
|
||||
|
||||
// SPR_Draw top
|
||||
if (m_fAttackFront > 0.4)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackFront, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 0)/2;
|
||||
y = ScreenHeight/2 - SPR_Height(m_hSprite,0) * 3;
|
||||
SPR_DrawAdditive(0, x, y, NULL);
|
||||
m_fAttackFront = max( 0, m_fAttackFront - fFade );
|
||||
} else
|
||||
m_fAttackFront = 0;
|
||||
|
||||
if (m_fAttackRight > 0.4)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackRight, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 + SPR_Width(m_hSprite, 1) * 2;
|
||||
y = ScreenHeight/2 - SPR_Height(m_hSprite,1)/2;
|
||||
SPR_DrawAdditive(1, x, y, NULL);
|
||||
m_fAttackRight = max( 0, m_fAttackRight - fFade );
|
||||
} else
|
||||
m_fAttackRight = 0;
|
||||
|
||||
if (m_fAttackRear > 0.4)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackRear, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 2)/2;
|
||||
y = ScreenHeight/2 + SPR_Height(m_hSprite,2) * 2;
|
||||
SPR_DrawAdditive(2, x, y, NULL);
|
||||
m_fAttackRear = max( 0, m_fAttackRear - fFade );
|
||||
} else
|
||||
m_fAttackRear = 0;
|
||||
|
||||
if (m_fAttackLeft > 0.4)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackLeft, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 3) * 3;
|
||||
y = ScreenHeight/2 - SPR_Height(m_hSprite,3)/2;
|
||||
SPR_DrawAdditive(3, x, y, NULL);
|
||||
|
||||
m_fAttackLeft = max( 0, m_fAttackLeft - fFade );
|
||||
} else
|
||||
m_fAttackLeft = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudHealth::DrawDamage(float flTime)
|
||||
{
|
||||
int i, r, g, b, a;
|
||||
DAMAGE_IMAGE *pdmg;
|
||||
|
||||
if (!m_bitsDamage)
|
||||
return 1;
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
a = (int)( fabs(sin(flTime*2)) * 256.0);
|
||||
|
||||
ScaleColors(r, g, b, a);
|
||||
|
||||
// Draw all the items
|
||||
for (i = 0; i < NUM_DMG_TYPES; i++)
|
||||
{
|
||||
if (m_bitsDamage & giDmgFlags[i])
|
||||
{
|
||||
pdmg = &m_dmg[i];
|
||||
SPR_Set(gHUD.GetSprite(m_HUD_dmg_bio + i), r, g, b );
|
||||
SPR_DrawAdditive(0, pdmg->x, pdmg->y, &gHUD.GetSpriteRect(m_HUD_dmg_bio + i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check for bits that should be expired
|
||||
for ( i = 0; i < NUM_DMG_TYPES; i++ )
|
||||
{
|
||||
pdmg = &m_dmg[i];
|
||||
|
||||
if ( m_bitsDamage & giDmgFlags[i] )
|
||||
{
|
||||
pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire );
|
||||
|
||||
if ( pdmg->fExpire <= flTime // when the time has expired
|
||||
&& a < 40 ) // and the flash is at the low point of the cycle
|
||||
{
|
||||
pdmg->fExpire = 0;
|
||||
|
||||
int y = pdmg->y;
|
||||
pdmg->x = pdmg->y = 0;
|
||||
|
||||
// move everyone above down
|
||||
for (int j = 0; j < NUM_DMG_TYPES; j++)
|
||||
{
|
||||
pdmg = &m_dmg[j];
|
||||
if ((pdmg->y) && (pdmg->y < y))
|
||||
pdmg->y += giDmgHeight;
|
||||
|
||||
}
|
||||
|
||||
m_bitsDamage &= ~giDmgFlags[i]; // clear the bits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CHudHealth::UpdateTiles(float flTime, long bitsDamage)
|
||||
{
|
||||
DAMAGE_IMAGE *pdmg;
|
||||
|
||||
// Which types are new?
|
||||
long bitsOn = ~m_bitsDamage & bitsDamage;
|
||||
|
||||
for (int i = 0; i < NUM_DMG_TYPES; i++)
|
||||
{
|
||||
pdmg = &m_dmg[i];
|
||||
|
||||
// Is this one already on?
|
||||
if (m_bitsDamage & giDmgFlags[i])
|
||||
{
|
||||
pdmg->fExpire = flTime + DMG_IMAGE_LIFE; // extend the duration
|
||||
if (!pdmg->fBaseline)
|
||||
pdmg->fBaseline = flTime;
|
||||
}
|
||||
|
||||
// Are we just turning it on?
|
||||
if (bitsOn & giDmgFlags[i])
|
||||
{
|
||||
// put this one at the bottom
|
||||
pdmg->x = giDmgWidth/8;
|
||||
pdmg->y = ScreenHeight - giDmgHeight * 2;
|
||||
pdmg->fExpire=flTime + DMG_IMAGE_LIFE;
|
||||
|
||||
// move everyone else up
|
||||
for (int j = 0; j < NUM_DMG_TYPES; j++)
|
||||
{
|
||||
if (j == i)
|
||||
continue;
|
||||
|
||||
pdmg = &m_dmg[j];
|
||||
if (pdmg->y)
|
||||
pdmg->y -= giDmgHeight;
|
||||
|
||||
}
|
||||
pdmg = &m_dmg[i];
|
||||
}
|
||||
}
|
||||
|
||||
// damage bits are only turned on here; they are turned off when the draw time has expired (in DrawDamage())
|
||||
m_bitsDamage |= bitsDamage;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// Health.cpp
|
||||
//
|
||||
// implementation of CHudHealth class
|
||||
//
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "mobility_int.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Health, Health )
|
||||
DECLARE_MESSAGE(m_Health, Damage )
|
||||
|
||||
#define PAIN_NAME "sprites/%d_pain.spr"
|
||||
#define DAMAGE_NAME "sprites/%d_dmg.spr"
|
||||
|
||||
int giDmgHeight, giDmgWidth;
|
||||
|
||||
int giDmgFlags[NUM_DMG_TYPES] =
|
||||
{
|
||||
DMG_POISON,
|
||||
DMG_ACID,
|
||||
DMG_FREEZE|DMG_SLOWFREEZE,
|
||||
DMG_DROWN,
|
||||
DMG_BURN|DMG_SLOWBURN,
|
||||
DMG_NERVEGAS,
|
||||
DMG_RADIATION,
|
||||
DMG_SHOCK,
|
||||
DMG_CALTROP,
|
||||
DMG_TRANQ,
|
||||
DMG_CONCUSS,
|
||||
DMG_HALLUC
|
||||
};
|
||||
|
||||
int CHudHealth::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE(Health);
|
||||
HOOK_MESSAGE(Damage);
|
||||
m_iHealth = 100;
|
||||
m_fFade = 0;
|
||||
m_iFlags = 0;
|
||||
m_bitsDamage = 0;
|
||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
|
||||
giDmgHeight = 0;
|
||||
giDmgWidth = 0;
|
||||
|
||||
memset(m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES);
|
||||
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudHealth::Reset( void )
|
||||
{
|
||||
// make sure the pain compass is cleared when the player respawns
|
||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
|
||||
|
||||
|
||||
// force all the flashing damage icons to expire
|
||||
m_bitsDamage = 0;
|
||||
for ( int i = 0; i < NUM_DMG_TYPES; i++ )
|
||||
{
|
||||
m_dmg[i].fExpire = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int CHudHealth::VidInit(void)
|
||||
{
|
||||
m_hSprite = 0;
|
||||
|
||||
m_HUD_dmg_bio = gHUD.GetSpriteIndex( "dmg_bio" ) + 1;
|
||||
m_HUD_cross = gHUD.GetSpriteIndex( "cross" );
|
||||
|
||||
giDmgHeight = gHUD.GetSpriteRect(m_HUD_dmg_bio).right - gHUD.GetSpriteRect(m_HUD_dmg_bio).left;
|
||||
giDmgWidth = gHUD.GetSpriteRect(m_HUD_dmg_bio).bottom - gHUD.GetSpriteRect(m_HUD_dmg_bio).top;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
// TODO: update local health data
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_BYTE();
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
// Only update the fade if we've changed health
|
||||
if (x != m_iHealth)
|
||||
{
|
||||
m_fFade = FADE_TIME;
|
||||
m_iHealth = x;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int armor = READ_BYTE(); // armor
|
||||
int damageTaken = READ_BYTE(); // health
|
||||
long bitsDamage = READ_LONG(); // damage bits
|
||||
|
||||
vec3_t vecFrom;
|
||||
|
||||
for ( int i = 0 ; i < 3 ; i++)
|
||||
vecFrom[i] = READ_COORD();
|
||||
|
||||
UpdateTiles(gHUD.m_flTime, bitsDamage);
|
||||
|
||||
// Actually took damage?
|
||||
if ( damageTaken > 0 || armor > 0 )
|
||||
{
|
||||
CalcDamageDirection(vecFrom);
|
||||
|
||||
if( gMobileEngfuncs && damageTaken > 0 )
|
||||
{
|
||||
float time = damageTaken * 4.0f;
|
||||
|
||||
if( time > 200.0f ) time = 200.0f;
|
||||
gMobileEngfuncs->pfnVibrate( time, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Returns back a color from the
|
||||
// Green <-> Yellow <-> Red ramp
|
||||
void CHudHealth::GetPainColor( int &r, int &g, int &b )
|
||||
{
|
||||
int iHealth = m_iHealth;
|
||||
|
||||
if (iHealth > 25)
|
||||
iHealth -= 25;
|
||||
else if ( iHealth < 0 )
|
||||
iHealth = 0;
|
||||
#if 0
|
||||
g = iHealth * 255 / 100;
|
||||
r = 255 - g;
|
||||
b = 0;
|
||||
#else
|
||||
if (m_iHealth > 25)
|
||||
{
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = 250;
|
||||
g = 0;
|
||||
b = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int CHudHealth::Draw(float flTime)
|
||||
{
|
||||
int r, g, b;
|
||||
int a = 0, x, y;
|
||||
int HealthWidth;
|
||||
|
||||
if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() )
|
||||
return 1;
|
||||
|
||||
if ( !m_hSprite )
|
||||
m_hSprite = LoadSprite(PAIN_NAME);
|
||||
|
||||
// Has health changed? Flash the health #
|
||||
if (m_fFade)
|
||||
{
|
||||
m_fFade -= (gHUD.m_flTimeDelta * 20);
|
||||
if (m_fFade <= 0)
|
||||
{
|
||||
a = MIN_ALPHA;
|
||||
m_fFade = 0;
|
||||
}
|
||||
|
||||
// Fade the health number back to dim
|
||||
|
||||
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
|
||||
|
||||
}
|
||||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
// If health is getting low, make it bright red
|
||||
if (m_iHealth <= 15)
|
||||
a = 255;
|
||||
|
||||
GetPainColor( r, g, b );
|
||||
ScaleColors(r, g, b, a );
|
||||
|
||||
// Only draw health if we have the suit.
|
||||
if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)))
|
||||
{
|
||||
HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
|
||||
int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;
|
||||
|
||||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
||||
x = CrossWidth /2;
|
||||
|
||||
SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
|
||||
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));
|
||||
|
||||
x = CrossWidth + HealthWidth / 2;
|
||||
|
||||
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
|
||||
|
||||
x += HealthWidth/2;
|
||||
|
||||
int iHeight = gHUD.m_iFontHeight;
|
||||
int iWidth = HealthWidth/10;
|
||||
FillRGBA(x, y, iWidth, iHeight, 255, 160, 0, a);
|
||||
}
|
||||
|
||||
DrawDamage(flTime);
|
||||
return DrawPain(flTime);
|
||||
}
|
||||
|
||||
void CHudHealth::CalcDamageDirection(vec3_t vecFrom)
|
||||
{
|
||||
vec3_t forward, right, up;
|
||||
float side, front;
|
||||
vec3_t vecOrigin, vecAngles;
|
||||
|
||||
if (!vecFrom[0] && !vecFrom[1] && !vecFrom[2])
|
||||
{
|
||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
memcpy(vecOrigin, gHUD.m_vecOrigin, sizeof(vec3_t));
|
||||
memcpy(vecAngles, gHUD.m_vecAngles, sizeof(vec3_t));
|
||||
|
||||
|
||||
VectorSubtract (vecFrom, vecOrigin, vecFrom);
|
||||
|
||||
float flDistToTarget = vecFrom.Length();
|
||||
|
||||
vecFrom = vecFrom.Normalize();
|
||||
AngleVectors (vecAngles, forward, right, up);
|
||||
|
||||
front = DotProduct (vecFrom, right);
|
||||
side = DotProduct (vecFrom, forward);
|
||||
|
||||
if (flDistToTarget <= 50)
|
||||
{
|
||||
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (side > 0)
|
||||
{
|
||||
if (side > 0.3)
|
||||
m_fAttackFront = max(m_fAttackFront, side);
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs(side);
|
||||
if (f > 0.3)
|
||||
m_fAttackRear = max(m_fAttackRear, f);
|
||||
}
|
||||
|
||||
if (front > 0)
|
||||
{
|
||||
if (front > 0.3)
|
||||
m_fAttackRight = max(m_fAttackRight, front);
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs(front);
|
||||
if (f > 0.3)
|
||||
m_fAttackLeft = max(m_fAttackLeft, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CHudHealth::DrawPain(float flTime)
|
||||
{
|
||||
if (!(m_fAttackFront || m_fAttackRear || m_fAttackLeft || m_fAttackRight))
|
||||
return 1;
|
||||
|
||||
int r, g, b;
|
||||
int x, y, a, shade;
|
||||
|
||||
// TODO: get the shift value of the health
|
||||
a = 255; // max brightness until then
|
||||
|
||||
float fFade = gHUD.m_flTimeDelta * 2;
|
||||
|
||||
// SPR_Draw top
|
||||
if (m_fAttackFront > 0.4)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackFront, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 0)/2;
|
||||
y = ScreenHeight/2 - SPR_Height(m_hSprite,0) * 3;
|
||||
SPR_DrawAdditive(0, x, y, NULL);
|
||||
m_fAttackFront = max( 0, m_fAttackFront - fFade );
|
||||
} else
|
||||
m_fAttackFront = 0;
|
||||
|
||||
if (m_fAttackRight > 0.4)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackRight, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 + SPR_Width(m_hSprite, 1) * 2;
|
||||
y = ScreenHeight/2 - SPR_Height(m_hSprite,1)/2;
|
||||
SPR_DrawAdditive(1, x, y, NULL);
|
||||
m_fAttackRight = max( 0, m_fAttackRight - fFade );
|
||||
} else
|
||||
m_fAttackRight = 0;
|
||||
|
||||
if (m_fAttackRear > 0.4)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackRear, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 2)/2;
|
||||
y = ScreenHeight/2 + SPR_Height(m_hSprite,2) * 2;
|
||||
SPR_DrawAdditive(2, x, y, NULL);
|
||||
m_fAttackRear = max( 0, m_fAttackRear - fFade );
|
||||
} else
|
||||
m_fAttackRear = 0;
|
||||
|
||||
if (m_fAttackLeft > 0.4)
|
||||
{
|
||||
GetPainColor(r,g,b);
|
||||
shade = a * max( m_fAttackLeft, 0.5 );
|
||||
ScaleColors(r, g, b, shade);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
x = ScreenWidth/2 - SPR_Width(m_hSprite, 3) * 3;
|
||||
y = ScreenHeight/2 - SPR_Height(m_hSprite,3)/2;
|
||||
SPR_DrawAdditive(3, x, y, NULL);
|
||||
|
||||
m_fAttackLeft = max( 0, m_fAttackLeft - fFade );
|
||||
} else
|
||||
m_fAttackLeft = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudHealth::DrawDamage(float flTime)
|
||||
{
|
||||
int i, r, g, b, a;
|
||||
DAMAGE_IMAGE *pdmg;
|
||||
|
||||
if (!m_bitsDamage)
|
||||
return 1;
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
a = (int)( fabs(sin(flTime*2)) * 256.0);
|
||||
|
||||
ScaleColors(r, g, b, a);
|
||||
|
||||
// Draw all the items
|
||||
for (i = 0; i < NUM_DMG_TYPES; i++)
|
||||
{
|
||||
if (m_bitsDamage & giDmgFlags[i])
|
||||
{
|
||||
pdmg = &m_dmg[i];
|
||||
SPR_Set(gHUD.GetSprite(m_HUD_dmg_bio + i), r, g, b );
|
||||
SPR_DrawAdditive(0, pdmg->x, pdmg->y, &gHUD.GetSpriteRect(m_HUD_dmg_bio + i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check for bits that should be expired
|
||||
for ( i = 0; i < NUM_DMG_TYPES; i++ )
|
||||
{
|
||||
pdmg = &m_dmg[i];
|
||||
|
||||
if ( m_bitsDamage & giDmgFlags[i] )
|
||||
{
|
||||
pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire );
|
||||
|
||||
if ( pdmg->fExpire <= flTime // when the time has expired
|
||||
&& a < 40 ) // and the flash is at the low point of the cycle
|
||||
{
|
||||
pdmg->fExpire = 0;
|
||||
|
||||
int y = pdmg->y;
|
||||
pdmg->x = pdmg->y = 0;
|
||||
|
||||
// move everyone above down
|
||||
for (int j = 0; j < NUM_DMG_TYPES; j++)
|
||||
{
|
||||
pdmg = &m_dmg[j];
|
||||
if ((pdmg->y) && (pdmg->y < y))
|
||||
pdmg->y += giDmgHeight;
|
||||
|
||||
}
|
||||
|
||||
m_bitsDamage &= ~giDmgFlags[i]; // clear the bits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CHudHealth::UpdateTiles(float flTime, long bitsDamage)
|
||||
{
|
||||
DAMAGE_IMAGE *pdmg;
|
||||
|
||||
// Which types are new?
|
||||
long bitsOn = ~m_bitsDamage & bitsDamage;
|
||||
|
||||
for (int i = 0; i < NUM_DMG_TYPES; i++)
|
||||
{
|
||||
pdmg = &m_dmg[i];
|
||||
|
||||
// Is this one already on?
|
||||
if (m_bitsDamage & giDmgFlags[i])
|
||||
{
|
||||
pdmg->fExpire = flTime + DMG_IMAGE_LIFE; // extend the duration
|
||||
if (!pdmg->fBaseline)
|
||||
pdmg->fBaseline = flTime;
|
||||
}
|
||||
|
||||
// Are we just turning it on?
|
||||
if (bitsOn & giDmgFlags[i])
|
||||
{
|
||||
// put this one at the bottom
|
||||
pdmg->x = giDmgWidth/8;
|
||||
pdmg->y = ScreenHeight - giDmgHeight * 2;
|
||||
pdmg->fExpire=flTime + DMG_IMAGE_LIFE;
|
||||
|
||||
// move everyone else up
|
||||
for (int j = 0; j < NUM_DMG_TYPES; j++)
|
||||
{
|
||||
if (j == i)
|
||||
continue;
|
||||
|
||||
pdmg = &m_dmg[j];
|
||||
if (pdmg->y)
|
||||
pdmg->y -= giDmgHeight;
|
||||
|
||||
}
|
||||
pdmg = &m_dmg[i];
|
||||
}
|
||||
}
|
||||
|
||||
// damage bits are only turned on here; they are turned off when the draw time has expired (in DrawDamage())
|
||||
m_bitsDamage |= bitsDamage;
|
||||
}
|
||||
|
|
254
cl_dll/health.h
254
cl_dll/health.h
|
@ -1,127 +1,127 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#define DMG_IMAGE_LIFE 2 // seconds that image is up
|
||||
|
||||
#define DMG_IMAGE_POISON 0
|
||||
#define DMG_IMAGE_ACID 1
|
||||
#define DMG_IMAGE_COLD 2
|
||||
#define DMG_IMAGE_DROWN 3
|
||||
#define DMG_IMAGE_BURN 4
|
||||
#define DMG_IMAGE_NERVE 5
|
||||
#define DMG_IMAGE_RAD 6
|
||||
#define DMG_IMAGE_SHOCK 7
|
||||
//tf defines
|
||||
#define DMG_IMAGE_CALTROP 8
|
||||
#define DMG_IMAGE_TRANQ 9
|
||||
#define DMG_IMAGE_CONCUSS 10
|
||||
#define DMG_IMAGE_HALLUC 11
|
||||
#define NUM_DMG_TYPES 12
|
||||
// instant damage
|
||||
|
||||
#define DMG_GENERIC 0 // generic damage was done
|
||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
||||
#define DMG_BULLET (1 << 1) // shot
|
||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||
#define DMG_BURN (1 << 3) // heat burned
|
||||
#define DMG_FREEZE (1 << 4) // frozen
|
||||
#define DMG_FALL (1 << 5) // fell too far
|
||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
||||
#define DMG_SHOCK (1 << 8) // electric shock
|
||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
||||
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
|
||||
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
|
||||
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
||||
|
||||
|
||||
// time-based damage
|
||||
//mask off TF-specific stuff too
|
||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
||||
|
||||
|
||||
#define DMG_DROWN (1 << 14) // Drowning
|
||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
||||
|
||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
||||
#define DMG_POISON (1 << 17) // blood poisioning
|
||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
||||
|
||||
//TF ADDITIONS
|
||||
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
|
||||
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
|
||||
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
|
||||
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
|
||||
#define DMG_AIMED (1 << 28) // Does Hit location damage
|
||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
||||
|
||||
#define DMG_CALTROP (1<<30)
|
||||
#define DMG_HALLUC (1<<31)
|
||||
|
||||
// TF Healing Additions for TakeHealth
|
||||
#define DMG_IGNORE_MAXHEALTH DMG_IGNITE
|
||||
// TF Redefines since we never use the originals
|
||||
#define DMG_NAIL DMG_SLASH
|
||||
#define DMG_NOT_SELF DMG_FREEZE
|
||||
|
||||
|
||||
#define DMG_TRANQ DMG_MORTAR
|
||||
#define DMG_CONCUSS DMG_SONIC
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float fExpire;
|
||||
float fBaseline;
|
||||
int x, y;
|
||||
} DAMAGE_IMAGE;
|
||||
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
//
|
||||
class CHudHealth: public CHudBase
|
||||
{
|
||||
public:
|
||||
virtual int Init( void );
|
||||
virtual int VidInit( void );
|
||||
virtual int Draw(float fTime);
|
||||
virtual void Reset( void );
|
||||
int MsgFunc_Health(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_Damage(const char *pszName, int iSize, void *pbuf);
|
||||
int m_iHealth;
|
||||
int m_HUD_dmg_bio;
|
||||
int m_HUD_cross;
|
||||
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
|
||||
void GetPainColor( int &r, int &g, int &b );
|
||||
float m_fFade;
|
||||
|
||||
private:
|
||||
HSPRITE m_hSprite;
|
||||
HSPRITE m_hDamage;
|
||||
|
||||
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
|
||||
int m_bitsDamage;
|
||||
int DrawPain(float fTime);
|
||||
int DrawDamage(float fTime);
|
||||
void CalcDamageDirection(vec3_t vecFrom);
|
||||
void UpdateTiles(float fTime, long bits);
|
||||
};
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#define DMG_IMAGE_LIFE 2 // seconds that image is up
|
||||
|
||||
#define DMG_IMAGE_POISON 0
|
||||
#define DMG_IMAGE_ACID 1
|
||||
#define DMG_IMAGE_COLD 2
|
||||
#define DMG_IMAGE_DROWN 3
|
||||
#define DMG_IMAGE_BURN 4
|
||||
#define DMG_IMAGE_NERVE 5
|
||||
#define DMG_IMAGE_RAD 6
|
||||
#define DMG_IMAGE_SHOCK 7
|
||||
//tf defines
|
||||
#define DMG_IMAGE_CALTROP 8
|
||||
#define DMG_IMAGE_TRANQ 9
|
||||
#define DMG_IMAGE_CONCUSS 10
|
||||
#define DMG_IMAGE_HALLUC 11
|
||||
#define NUM_DMG_TYPES 12
|
||||
// instant damage
|
||||
|
||||
#define DMG_GENERIC 0 // generic damage was done
|
||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
|
||||
#define DMG_BULLET (1 << 1) // shot
|
||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||
#define DMG_BURN (1 << 3) // heat burned
|
||||
#define DMG_FREEZE (1 << 4) // frozen
|
||||
#define DMG_FALL (1 << 5) // fell too far
|
||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
||||
#define DMG_SHOCK (1 << 8) // electric shock
|
||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
||||
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
|
||||
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
|
||||
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
||||
|
||||
|
||||
// time-based damage
|
||||
//mask off TF-specific stuff too
|
||||
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
|
||||
|
||||
|
||||
#define DMG_DROWN (1 << 14) // Drowning
|
||||
#define DMG_FIRSTTIMEBASED DMG_DROWN
|
||||
|
||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
||||
#define DMG_POISON (1 << 17) // blood poisioning
|
||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
||||
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
|
||||
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
|
||||
|
||||
//TF ADDITIONS
|
||||
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
|
||||
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
|
||||
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
|
||||
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
|
||||
#define DMG_AIMED (1 << 28) // Does Hit location damage
|
||||
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
|
||||
|
||||
#define DMG_CALTROP (1<<30)
|
||||
#define DMG_HALLUC (1<<31)
|
||||
|
||||
// TF Healing Additions for TakeHealth
|
||||
#define DMG_IGNORE_MAXHEALTH DMG_IGNITE
|
||||
// TF Redefines since we never use the originals
|
||||
#define DMG_NAIL DMG_SLASH
|
||||
#define DMG_NOT_SELF DMG_FREEZE
|
||||
|
||||
|
||||
#define DMG_TRANQ DMG_MORTAR
|
||||
#define DMG_CONCUSS DMG_SONIC
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float fExpire;
|
||||
float fBaseline;
|
||||
int x, y;
|
||||
} DAMAGE_IMAGE;
|
||||
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
//
|
||||
class CHudHealth: public CHudBase
|
||||
{
|
||||
public:
|
||||
virtual int Init( void );
|
||||
virtual int VidInit( void );
|
||||
virtual int Draw(float fTime);
|
||||
virtual void Reset( void );
|
||||
int MsgFunc_Health(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_Damage(const char *pszName, int iSize, void *pbuf);
|
||||
int m_iHealth;
|
||||
int m_HUD_dmg_bio;
|
||||
int m_HUD_cross;
|
||||
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
|
||||
void GetPainColor( int &r, int &g, int &b );
|
||||
float m_fFade;
|
||||
|
||||
private:
|
||||
HSPRITE m_hSprite;
|
||||
HSPRITE m_hDamage;
|
||||
|
||||
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
|
||||
int m_bitsDamage;
|
||||
int DrawPain(float fTime);
|
||||
int DrawDamage(float fTime);
|
||||
void CalcDamageDirection(vec3_t vecFrom);
|
||||
void UpdateTiles(float fTime, long bits);
|
||||
};
|
||||
|
|
|
@ -1,347 +1,347 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
/*
|
||||
==========================
|
||||
This file contains "stubs" of class member implementations so that we can predict certain
|
||||
weapons client side. From time to time you might find that you need to implement part of the
|
||||
these functions. If so, cut it from here, paste it in hl_weapons.cpp or somewhere else and
|
||||
add in the functionality you need.
|
||||
==========================
|
||||
*/
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "soundent.h"
|
||||
#include "skill.h"
|
||||
|
||||
// Globals used by game logic
|
||||
const Vector g_vecZero = Vector( 0, 0, 0 );
|
||||
int gmsgWeapPickup = 0;
|
||||
enginefuncs_t g_engfuncs;
|
||||
globalvars_t *gpGlobals;
|
||||
|
||||
ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS];
|
||||
|
||||
void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch) { }
|
||||
|
||||
// CBaseEntity Stubs
|
||||
int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) { return 1; }
|
||||
int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { return 1; }
|
||||
CBaseEntity *CBaseEntity::GetNextTarget( void ) { return NULL; }
|
||||
int CBaseEntity::Save( CSave &save ) { return 1; }
|
||||
int CBaseEntity::Restore( CRestore &restore ) { return 1; }
|
||||
void CBaseEntity::SetObjectCollisionBox( void ) { }
|
||||
int CBaseEntity :: Intersects( CBaseEntity *pOther ) { return 0; }
|
||||
void CBaseEntity :: MakeDormant( void ) { }
|
||||
int CBaseEntity :: IsDormant( void ) { return 0; }
|
||||
BOOL CBaseEntity :: IsInWorld( void ) { return TRUE; }
|
||||
int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; }
|
||||
int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; }
|
||||
CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; }
|
||||
void CBaseEntity::SUB_Remove( void ) { }
|
||||
|
||||
// CBaseDelay Stubs
|
||||
void CBaseDelay :: KeyValue( struct KeyValueData_s * ) { }
|
||||
int CBaseDelay::Restore( class CRestore & ) { return 1; }
|
||||
int CBaseDelay::Save( class CSave & ) { return 1; }
|
||||
|
||||
// CBaseAnimating Stubs
|
||||
int CBaseAnimating::Restore( class CRestore & ) { return 1; }
|
||||
int CBaseAnimating::Save( class CSave & ) { return 1; }
|
||||
|
||||
// DEBUG Stubs
|
||||
edict_t *DBG_EntOfVars( const entvars_t *pev ) { return NULL; }
|
||||
void DBG_AssertFunction(BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage) { }
|
||||
|
||||
// UTIL_* Stubs
|
||||
void UTIL_PrecacheOther( const char *szClassname ) { }
|
||||
void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ) { }
|
||||
void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) { }
|
||||
void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) { }
|
||||
void UTIL_MakeVectors( const Vector &vecAngles ) { }
|
||||
BOOL UTIL_IsValidEntity( edict_t *pent ) { return TRUE; }
|
||||
void UTIL_SetOrigin( entvars_t *, const Vector &org ) { }
|
||||
BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { return TRUE; }
|
||||
void UTIL_LogPrintf(char *,...) { }
|
||||
void UTIL_ClientPrintAll( int,char const *,char const *,char const *,char const *,char const *) { }
|
||||
void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 ) { }
|
||||
|
||||
// CBaseToggle Stubs
|
||||
int CBaseToggle::Restore( class CRestore & ) { return 1; }
|
||||
int CBaseToggle::Save( class CSave & ) { return 1; }
|
||||
void CBaseToggle :: KeyValue( struct KeyValueData_s * ) { }
|
||||
|
||||
// CGrenade Stubs
|
||||
void CGrenade::BounceSound( void ) { }
|
||||
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; }
|
||||
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) { }
|
||||
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) { }
|
||||
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; }
|
||||
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { }
|
||||
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) { }
|
||||
int CBaseAnimating :: GetBodygroup( int iGroup ) { return 0; }
|
||||
Vector CBaseMonster :: GetGunPosition( 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 ) { }
|
||||
void CBaseMonster::FadeMonster( void ) { }
|
||||
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() { }
|
||||
BOOL CBasePlayer::IsOnLadder( void ) { return FALSE; }
|
||||
void CBasePlayer::PlayerDeathThink(void) { }
|
||||
void CBasePlayer::StartDeathCam( void ) { }
|
||||
void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { }
|
||||
void CBasePlayer::PlayerUse ( void ) { }
|
||||
void CBasePlayer::Jump() { }
|
||||
void CBasePlayer::Duck( ) { }
|
||||
int CBasePlayer::Classify ( void ) { return 0; }
|
||||
void CBasePlayer::PreThink(void) { }
|
||||
void CBasePlayer::CheckTimeBasedDamage() { }
|
||||
void CBasePlayer :: UpdateGeigerCounter( void ) { }
|
||||
void CBasePlayer::CheckSuitUpdate() { }
|
||||
void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { }
|
||||
void CBasePlayer :: UpdatePlayerSound ( void ) { }
|
||||
void CBasePlayer::PostThink() { }
|
||||
void CBasePlayer :: Precache( void ) { }
|
||||
int CBasePlayer::Save( CSave &save ) { return 0; }
|
||||
void CBasePlayer::RenewItems(void) { }
|
||||
int CBasePlayer::Restore( CRestore &restore ) { return 0; }
|
||||
void CBasePlayer::SelectNextItem( int iItem ) { }
|
||||
BOOL CBasePlayer::HasWeapons( void ) { return FALSE; }
|
||||
void CBasePlayer::SelectPrevItem( int iItem ) { }
|
||||
CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { return NULL; }
|
||||
BOOL CBasePlayer :: FlashlightIsOn( void ) { return FALSE; }
|
||||
void CBasePlayer :: FlashlightTurnOn( void ) { }
|
||||
void CBasePlayer :: FlashlightTurnOff( void ) { }
|
||||
void CBasePlayer :: ForceClientDllUpdate( void ) { }
|
||||
void CBasePlayer::ImpulseCommands( ) { }
|
||||
void CBasePlayer::CheatImpulseCommands( int iImpulse ) { }
|
||||
int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
|
||||
int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
|
||||
void CBasePlayer::ItemPreFrame() { }
|
||||
void CBasePlayer::ItemPostFrame() { }
|
||||
int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; }
|
||||
int CBasePlayer::GetAmmoIndex(const char *psz) { return -1; }
|
||||
void CBasePlayer::SendAmmoUpdate(void) { }
|
||||
void CBasePlayer :: UpdateClientData( void ) { }
|
||||
BOOL CBasePlayer :: FBecomeProne ( void ) { return TRUE; }
|
||||
void CBasePlayer :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { }
|
||||
void CBasePlayer :: BarnacleVictimReleased ( void ) { }
|
||||
int CBasePlayer :: Illumination( void ) { return 0; }
|
||||
void CBasePlayer :: EnableControl(BOOL fControl) { }
|
||||
Vector CBasePlayer :: GetAutoaimVector( float flDelta ) { return g_vecZero; }
|
||||
Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; }
|
||||
void CBasePlayer :: ResetAutoaim( ) { }
|
||||
void CBasePlayer :: SetCustomDecalFrames( int nFrames ) { }
|
||||
int CBasePlayer :: GetCustomDecalFrames( void ) { return -1; }
|
||||
void CBasePlayer::DropPlayerItem ( char *pszItemName ) { }
|
||||
BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; }
|
||||
BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; }
|
||||
Vector CBasePlayer :: GetGunPosition( void ) { return g_vecZero; }
|
||||
const char *CBasePlayer::TeamID( void ) { return ""; }
|
||||
int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) { return 0; }
|
||||
void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { }
|
||||
void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { }
|
||||
|
||||
void ClearMultiDamage(void) { }
|
||||
void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) { }
|
||||
void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { }
|
||||
void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) { }
|
||||
int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { return 0; }
|
||||
void DecalGunshot( TraceResult *pTrace, int iBulletType ) { }
|
||||
void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { }
|
||||
void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) { }
|
||||
int CBasePlayerItem::Restore( class CRestore & ) { return 1; }
|
||||
int CBasePlayerItem::Save( class CSave & ) { return 1; }
|
||||
int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; }
|
||||
int CBasePlayerWeapon::Save( class CSave & ) { return 1; }
|
||||
void CBasePlayerItem :: SetObjectCollisionBox( void ) { }
|
||||
void CBasePlayerItem :: FallInit( void ) { }
|
||||
void CBasePlayerItem::FallThink ( void ) { }
|
||||
void CBasePlayerItem::Materialize( void ) { }
|
||||
void CBasePlayerItem::AttemptToMaterialize( void ) { }
|
||||
void CBasePlayerItem :: CheckRespawn ( void ) { }
|
||||
CBaseEntity* CBasePlayerItem::Respawn( void ) { return NULL; }
|
||||
void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { }
|
||||
void CBasePlayerItem::DestroyItem( void ) { }
|
||||
int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) { return TRUE; }
|
||||
void CBasePlayerItem::Drop( void ) { }
|
||||
void CBasePlayerItem::Kill( void ) { }
|
||||
void CBasePlayerItem::Holster( int skiplocal ) { }
|
||||
void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { }
|
||||
int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; }
|
||||
int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; }
|
||||
int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; }
|
||||
BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; }
|
||||
BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; }
|
||||
BOOL CBasePlayerWeapon :: IsUseable( void ) { return TRUE; }
|
||||
int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; }
|
||||
int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; }
|
||||
void CBasePlayerAmmo::Spawn( void ) { }
|
||||
CBaseEntity* CBasePlayerAmmo::Respawn( void ) { return this; }
|
||||
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 CSoundEnt::InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
/*
|
||||
==========================
|
||||
This file contains "stubs" of class member implementations so that we can predict certain
|
||||
weapons client side. From time to time you might find that you need to implement part of the
|
||||
these functions. If so, cut it from here, paste it in hl_weapons.cpp or somewhere else and
|
||||
add in the functionality you need.
|
||||
==========================
|
||||
*/
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "soundent.h"
|
||||
#include "skill.h"
|
||||
|
||||
// Globals used by game logic
|
||||
const Vector g_vecZero = Vector( 0, 0, 0 );
|
||||
int gmsgWeapPickup = 0;
|
||||
enginefuncs_t g_engfuncs;
|
||||
globalvars_t *gpGlobals;
|
||||
|
||||
ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS];
|
||||
|
||||
void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch) { }
|
||||
|
||||
// CBaseEntity Stubs
|
||||
int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) { return 1; }
|
||||
int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { return 1; }
|
||||
CBaseEntity *CBaseEntity::GetNextTarget( void ) { return NULL; }
|
||||
int CBaseEntity::Save( CSave &save ) { return 1; }
|
||||
int CBaseEntity::Restore( CRestore &restore ) { return 1; }
|
||||
void CBaseEntity::SetObjectCollisionBox( void ) { }
|
||||
int CBaseEntity :: Intersects( CBaseEntity *pOther ) { return 0; }
|
||||
void CBaseEntity :: MakeDormant( void ) { }
|
||||
int CBaseEntity :: IsDormant( void ) { return 0; }
|
||||
BOOL CBaseEntity :: IsInWorld( void ) { return TRUE; }
|
||||
int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; }
|
||||
int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; }
|
||||
CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; }
|
||||
void CBaseEntity::SUB_Remove( void ) { }
|
||||
|
||||
// CBaseDelay Stubs
|
||||
void CBaseDelay :: KeyValue( struct KeyValueData_s * ) { }
|
||||
int CBaseDelay::Restore( class CRestore & ) { return 1; }
|
||||
int CBaseDelay::Save( class CSave & ) { return 1; }
|
||||
|
||||
// CBaseAnimating Stubs
|
||||
int CBaseAnimating::Restore( class CRestore & ) { return 1; }
|
||||
int CBaseAnimating::Save( class CSave & ) { return 1; }
|
||||
|
||||
// DEBUG Stubs
|
||||
edict_t *DBG_EntOfVars( const entvars_t *pev ) { return NULL; }
|
||||
void DBG_AssertFunction(BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage) { }
|
||||
|
||||
// UTIL_* Stubs
|
||||
void UTIL_PrecacheOther( const char *szClassname ) { }
|
||||
void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ) { }
|
||||
void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) { }
|
||||
void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) { }
|
||||
void UTIL_MakeVectors( const Vector &vecAngles ) { }
|
||||
BOOL UTIL_IsValidEntity( edict_t *pent ) { return TRUE; }
|
||||
void UTIL_SetOrigin( entvars_t *, const Vector &org ) { }
|
||||
BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { return TRUE; }
|
||||
void UTIL_LogPrintf(char *,...) { }
|
||||
void UTIL_ClientPrintAll( int,char const *,char const *,char const *,char const *,char const *) { }
|
||||
void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 ) { }
|
||||
|
||||
// CBaseToggle Stubs
|
||||
int CBaseToggle::Restore( class CRestore & ) { return 1; }
|
||||
int CBaseToggle::Save( class CSave & ) { return 1; }
|
||||
void CBaseToggle :: KeyValue( struct KeyValueData_s * ) { }
|
||||
|
||||
// CGrenade Stubs
|
||||
void CGrenade::BounceSound( void ) { }
|
||||
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; }
|
||||
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) { }
|
||||
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) { }
|
||||
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; }
|
||||
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { }
|
||||
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) { }
|
||||
int CBaseAnimating :: GetBodygroup( int iGroup ) { return 0; }
|
||||
Vector CBaseMonster :: GetGunPosition( 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 ) { }
|
||||
void CBaseMonster::FadeMonster( void ) { }
|
||||
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() { }
|
||||
BOOL CBasePlayer::IsOnLadder( void ) { return FALSE; }
|
||||
void CBasePlayer::PlayerDeathThink(void) { }
|
||||
void CBasePlayer::StartDeathCam( void ) { }
|
||||
void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { }
|
||||
void CBasePlayer::PlayerUse ( void ) { }
|
||||
void CBasePlayer::Jump() { }
|
||||
void CBasePlayer::Duck( ) { }
|
||||
int CBasePlayer::Classify ( void ) { return 0; }
|
||||
void CBasePlayer::PreThink(void) { }
|
||||
void CBasePlayer::CheckTimeBasedDamage() { }
|
||||
void CBasePlayer :: UpdateGeigerCounter( void ) { }
|
||||
void CBasePlayer::CheckSuitUpdate() { }
|
||||
void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { }
|
||||
void CBasePlayer :: UpdatePlayerSound ( void ) { }
|
||||
void CBasePlayer::PostThink() { }
|
||||
void CBasePlayer :: Precache( void ) { }
|
||||
int CBasePlayer::Save( CSave &save ) { return 0; }
|
||||
void CBasePlayer::RenewItems(void) { }
|
||||
int CBasePlayer::Restore( CRestore &restore ) { return 0; }
|
||||
void CBasePlayer::SelectNextItem( int iItem ) { }
|
||||
BOOL CBasePlayer::HasWeapons( void ) { return FALSE; }
|
||||
void CBasePlayer::SelectPrevItem( int iItem ) { }
|
||||
CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { return NULL; }
|
||||
BOOL CBasePlayer :: FlashlightIsOn( void ) { return FALSE; }
|
||||
void CBasePlayer :: FlashlightTurnOn( void ) { }
|
||||
void CBasePlayer :: FlashlightTurnOff( void ) { }
|
||||
void CBasePlayer :: ForceClientDllUpdate( void ) { }
|
||||
void CBasePlayer::ImpulseCommands( ) { }
|
||||
void CBasePlayer::CheatImpulseCommands( int iImpulse ) { }
|
||||
int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
|
||||
int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
|
||||
void CBasePlayer::ItemPreFrame() { }
|
||||
void CBasePlayer::ItemPostFrame() { }
|
||||
int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; }
|
||||
int CBasePlayer::GetAmmoIndex(const char *psz) { return -1; }
|
||||
void CBasePlayer::SendAmmoUpdate(void) { }
|
||||
void CBasePlayer :: UpdateClientData( void ) { }
|
||||
BOOL CBasePlayer :: FBecomeProne ( void ) { return TRUE; }
|
||||
void CBasePlayer :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { }
|
||||
void CBasePlayer :: BarnacleVictimReleased ( void ) { }
|
||||
int CBasePlayer :: Illumination( void ) { return 0; }
|
||||
void CBasePlayer :: EnableControl(BOOL fControl) { }
|
||||
Vector CBasePlayer :: GetAutoaimVector( float flDelta ) { return g_vecZero; }
|
||||
Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; }
|
||||
void CBasePlayer :: ResetAutoaim( ) { }
|
||||
void CBasePlayer :: SetCustomDecalFrames( int nFrames ) { }
|
||||
int CBasePlayer :: GetCustomDecalFrames( void ) { return -1; }
|
||||
void CBasePlayer::DropPlayerItem ( char *pszItemName ) { }
|
||||
BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; }
|
||||
BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; }
|
||||
Vector CBasePlayer :: GetGunPosition( void ) { return g_vecZero; }
|
||||
const char *CBasePlayer::TeamID( void ) { return ""; }
|
||||
int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) { return 0; }
|
||||
void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { }
|
||||
void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { }
|
||||
|
||||
void ClearMultiDamage(void) { }
|
||||
void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) { }
|
||||
void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { }
|
||||
void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) { }
|
||||
int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { return 0; }
|
||||
void DecalGunshot( TraceResult *pTrace, int iBulletType ) { }
|
||||
void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { }
|
||||
void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) { }
|
||||
int CBasePlayerItem::Restore( class CRestore & ) { return 1; }
|
||||
int CBasePlayerItem::Save( class CSave & ) { return 1; }
|
||||
int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; }
|
||||
int CBasePlayerWeapon::Save( class CSave & ) { return 1; }
|
||||
void CBasePlayerItem :: SetObjectCollisionBox( void ) { }
|
||||
void CBasePlayerItem :: FallInit( void ) { }
|
||||
void CBasePlayerItem::FallThink ( void ) { }
|
||||
void CBasePlayerItem::Materialize( void ) { }
|
||||
void CBasePlayerItem::AttemptToMaterialize( void ) { }
|
||||
void CBasePlayerItem :: CheckRespawn ( void ) { }
|
||||
CBaseEntity* CBasePlayerItem::Respawn( void ) { return NULL; }
|
||||
void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { }
|
||||
void CBasePlayerItem::DestroyItem( void ) { }
|
||||
int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) { return TRUE; }
|
||||
void CBasePlayerItem::Drop( void ) { }
|
||||
void CBasePlayerItem::Kill( void ) { }
|
||||
void CBasePlayerItem::Holster( int skiplocal ) { }
|
||||
void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { }
|
||||
int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; }
|
||||
int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; }
|
||||
int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; }
|
||||
BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; }
|
||||
BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; }
|
||||
BOOL CBasePlayerWeapon :: IsUseable( void ) { return TRUE; }
|
||||
int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; }
|
||||
int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; }
|
||||
void CBasePlayerAmmo::Spawn( void ) { }
|
||||
CBaseEntity* CBasePlayerAmmo::Respawn( void ) { return this; }
|
||||
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 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 ){}
|
|
@ -1,80 +1,80 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "../hud.h"
|
||||
#include "../cl_util.h"
|
||||
#include "event_api.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// HLDM
|
||||
void EV_FireGlock1( struct event_args_s *args );
|
||||
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 );
|
||||
}
|
||||
|
||||
/*
|
||||
======================
|
||||
Game_HookEvents
|
||||
|
||||
Associate script file name with callback functions. Callback's must be extern "C" so
|
||||
the engine doesn't get confused about name mangling stuff. Note that the format is
|
||||
always the same. Of course, a clever mod team could actually embed parameters, behavior
|
||||
into the actual .sc files and create a .sc file parser and hook their functionality through
|
||||
that.. i.e., a scripting system.
|
||||
|
||||
That was what we were going to do, but we ran out of time...oh well.
|
||||
======================
|
||||
*/
|
||||
void Game_HookEvents( void )
|
||||
{
|
||||
gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 );
|
||||
gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 );
|
||||
gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle );
|
||||
gEngfuncs.pfnHookEvent( "events/shotgun2.sc", EV_FireShotGunDouble );
|
||||
gEngfuncs.pfnHookEvent( "events/mp5.sc", EV_FireMP5 );
|
||||
gEngfuncs.pfnHookEvent( "events/mp52.sc", EV_FireMP52 );
|
||||
gEngfuncs.pfnHookEvent( "events/python.sc", EV_FirePython );
|
||||
gEngfuncs.pfnHookEvent( "events/gauss.sc", EV_FireGauss );
|
||||
gEngfuncs.pfnHookEvent( "events/gaussspin.sc", EV_SpinGauss );
|
||||
gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust );
|
||||
gEngfuncs.pfnHookEvent( "events/crowbar.sc", EV_Crowbar );
|
||||
gEngfuncs.pfnHookEvent( "events/crossbow1.sc", EV_FireCrossbow );
|
||||
gEngfuncs.pfnHookEvent( "events/crossbow2.sc", EV_FireCrossbow2 );
|
||||
gEngfuncs.pfnHookEvent( "events/rpg.sc", EV_FireRpg );
|
||||
gEngfuncs.pfnHookEvent( "events/egon_fire.sc", EV_EgonFire );
|
||||
gEngfuncs.pfnHookEvent( "events/egon_stop.sc", EV_EgonStop );
|
||||
gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire );
|
||||
gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire );
|
||||
gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire );
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "../hud.h"
|
||||
#include "../cl_util.h"
|
||||
#include "event_api.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// HLDM
|
||||
void EV_FireGlock1( struct event_args_s *args );
|
||||
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 );
|
||||
}
|
||||
|
||||
/*
|
||||
======================
|
||||
Game_HookEvents
|
||||
|
||||
Associate script file name with callback functions. Callback's must be extern "C" so
|
||||
the engine doesn't get confused about name mangling stuff. Note that the format is
|
||||
always the same. Of course, a clever mod team could actually embed parameters, behavior
|
||||
into the actual .sc files and create a .sc file parser and hook their functionality through
|
||||
that.. i.e., a scripting system.
|
||||
|
||||
That was what we were going to do, but we ran out of time...oh well.
|
||||
======================
|
||||
*/
|
||||
void Game_HookEvents( void )
|
||||
{
|
||||
gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 );
|
||||
gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 );
|
||||
gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle );
|
||||
gEngfuncs.pfnHookEvent( "events/shotgun2.sc", EV_FireShotGunDouble );
|
||||
gEngfuncs.pfnHookEvent( "events/mp5.sc", EV_FireMP5 );
|
||||
gEngfuncs.pfnHookEvent( "events/mp52.sc", EV_FireMP52 );
|
||||
gEngfuncs.pfnHookEvent( "events/python.sc", EV_FirePython );
|
||||
gEngfuncs.pfnHookEvent( "events/gauss.sc", EV_FireGauss );
|
||||
gEngfuncs.pfnHookEvent( "events/gaussspin.sc", EV_SpinGauss );
|
||||
gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust );
|
||||
gEngfuncs.pfnHookEvent( "events/crowbar.sc", EV_Crowbar );
|
||||
gEngfuncs.pfnHookEvent( "events/crossbow1.sc", EV_FireCrossbow );
|
||||
gEngfuncs.pfnHookEvent( "events/crossbow2.sc", EV_FireCrossbow2 );
|
||||
gEngfuncs.pfnHookEvent( "events/rpg.sc", EV_FireRpg );
|
||||
gEngfuncs.pfnHookEvent( "events/egon_fire.sc", EV_EgonFire );
|
||||
gEngfuncs.pfnHookEvent( "events/egon_stop.sc", EV_EgonStop );
|
||||
gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire );
|
||||
gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire );
|
||||
gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire );
|
||||
}
|
||||
|
|
|
@ -1,90 +1,90 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "../hud.h"
|
||||
#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
|
||||
|
||||
Add game specific, client-side objects here
|
||||
=====================
|
||||
*/
|
||||
void Game_AddObjects( void )
|
||||
{
|
||||
if ( pBeam && pBeam2 )
|
||||
UpdateBeams();
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "../hud.h"
|
||||
#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
|
||||
|
||||
Add game specific, client-side objects here
|
||||
=====================
|
||||
*/
|
||||
void Game_AddObjects( void )
|
||||
{
|
||||
if ( pBeam && pBeam2 )
|
||||
UpdateBeams();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
1176
cl_dll/hud.cpp
1176
cl_dll/hud.cpp
File diff suppressed because it is too large
Load Diff
1404
cl_dll/hud.h
1404
cl_dll/hud.h
File diff suppressed because it is too large
Load Diff
|
@ -1,19 +1,19 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_IFACEH )
|
||||
#define HUD_IFACEH
|
||||
#pragma once
|
||||
|
||||
#include "exportdef.h"
|
||||
|
||||
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
|
||||
#include "wrect.h"
|
||||
#include "../engine/cdll_int.h"
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
||||
#endif
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_IFACEH )
|
||||
#define HUD_IFACEH
|
||||
#pragma once
|
||||
|
||||
#include "exportdef.h"
|
||||
|
||||
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
|
||||
#include "wrect.h"
|
||||
#include "../engine/cdll_int.h"
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,120 +1,120 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// hud_msg.cpp
|
||||
//
|
||||
|
||||
#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
|
||||
|
||||
int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
ASSERT( iSize == 0 );
|
||||
|
||||
// clear all hud data
|
||||
HUDLIST *pList = m_pHudList;
|
||||
|
||||
while ( pList )
|
||||
{
|
||||
if ( pList->p )
|
||||
pList->p->Reset();
|
||||
pList = pList->pNext;
|
||||
}
|
||||
|
||||
// reset sensitivity
|
||||
m_flMouseSensitivity = 0;
|
||||
|
||||
// reset concussion effect
|
||||
m_iConcussionEffect = 0;
|
||||
|
||||
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
|
||||
HUDLIST *pList = m_pHudList;
|
||||
|
||||
while (pList)
|
||||
{
|
||||
if ( pList->p )
|
||||
pList->p->InitHUDData();
|
||||
pList = pList->pNext;
|
||||
}
|
||||
|
||||
//Probably not a good place to put this.
|
||||
pBeam = pBeam2 = NULL;
|
||||
}
|
||||
|
||||
|
||||
int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_Teamplay = READ_BYTE();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
int armor, blood;
|
||||
Vector from;
|
||||
int i;
|
||||
float count;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
armor = READ_BYTE();
|
||||
blood = READ_BYTE();
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
from[i] = READ_COORD();
|
||||
|
||||
count = (blood * 0.5) + (armor * 0.5);
|
||||
|
||||
if (count < 10)
|
||||
count = 10;
|
||||
|
||||
// TODO: kick viewangles, show damage visually
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_iConcussionEffect = READ_BYTE();
|
||||
if (m_iConcussionEffect)
|
||||
this->m_StatusIcons.EnableIcon("dmg_concuss",255,160,0);
|
||||
else
|
||||
this->m_StatusIcons.DisableIcon("dmg_concuss");
|
||||
return 1;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// hud_msg.cpp
|
||||
//
|
||||
|
||||
#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
|
||||
|
||||
int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
ASSERT( iSize == 0 );
|
||||
|
||||
// clear all hud data
|
||||
HUDLIST *pList = m_pHudList;
|
||||
|
||||
while ( pList )
|
||||
{
|
||||
if ( pList->p )
|
||||
pList->p->Reset();
|
||||
pList = pList->pNext;
|
||||
}
|
||||
|
||||
// reset sensitivity
|
||||
m_flMouseSensitivity = 0;
|
||||
|
||||
// reset concussion effect
|
||||
m_iConcussionEffect = 0;
|
||||
|
||||
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
|
||||
HUDLIST *pList = m_pHudList;
|
||||
|
||||
while (pList)
|
||||
{
|
||||
if ( pList->p )
|
||||
pList->p->InitHUDData();
|
||||
pList = pList->pNext;
|
||||
}
|
||||
|
||||
//Probably not a good place to put this.
|
||||
pBeam = pBeam2 = NULL;
|
||||
}
|
||||
|
||||
|
||||
int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_Teamplay = READ_BYTE();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
int armor, blood;
|
||||
Vector from;
|
||||
int i;
|
||||
float count;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
armor = READ_BYTE();
|
||||
blood = READ_BYTE();
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
from[i] = READ_COORD();
|
||||
|
||||
count = (blood * 0.5) + (armor * 0.5);
|
||||
|
||||
if (count < 10)
|
||||
count = 10;
|
||||
|
||||
// TODO: kick viewangles, show damage visually
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_iConcussionEffect = READ_BYTE();
|
||||
if (m_iConcussionEffect)
|
||||
this->m_StatusIcons.EnableIcon("dmg_concuss",255,160,0);
|
||||
else
|
||||
this->m_StatusIcons.DisableIcon("dmg_concuss");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,365 +1,365 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// hud_redraw.cpp
|
||||
//
|
||||
#include <math.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
//#include "triangleapi.h"
|
||||
|
||||
|
||||
#define MAX_LOGO_FRAMES 56
|
||||
|
||||
int grgLogoFrame[MAX_LOGO_FRAMES] =
|
||||
{
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, 13, 13, 13, 12, 11, 10, 9, 8, 14, 15,
|
||||
16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
||||
29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31
|
||||
};
|
||||
|
||||
|
||||
extern int g_iVisibleMouse;
|
||||
|
||||
float HUD_GetFOV( void );
|
||||
|
||||
extern cvar_t *sensitivity;
|
||||
|
||||
// Think
|
||||
void CHud::Think(void)
|
||||
{
|
||||
int newfov;
|
||||
HUDLIST *pList = m_pHudList;
|
||||
|
||||
while (pList)
|
||||
{
|
||||
if (pList->p->m_iFlags & HUD_ACTIVE)
|
||||
pList->p->Think();
|
||||
pList = pList->pNext;
|
||||
}
|
||||
|
||||
newfov = HUD_GetFOV();
|
||||
if ( newfov == 0 )
|
||||
{
|
||||
m_iFOV = default_fov->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iFOV = newfov;
|
||||
}
|
||||
|
||||
// the clients fov is actually set in the client data update section of the hud
|
||||
|
||||
// Set a new sensitivity
|
||||
if ( m_iFOV == default_fov->value )
|
||||
{
|
||||
// reset to saved sensitivity
|
||||
m_flMouseSensitivity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// set a new sensitivity that is proportional to the change from the FOV default
|
||||
m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)default_fov->value) * CVAR_GET_FLOAT("zoom_sensitivity_ratio");
|
||||
}
|
||||
|
||||
// think about default fov
|
||||
if ( m_iFOV == 0 )
|
||||
{ // only let players adjust up in fov, and only if they are not overriden by something else
|
||||
m_iFOV = max( default_fov->value, 90 );
|
||||
}
|
||||
}
|
||||
|
||||
// Redraw
|
||||
// step through the local data, placing the appropriate graphics & text as appropriate
|
||||
// returns 1 if they've changed, 0 otherwise
|
||||
int CHud :: Redraw( float flTime, int intermission )
|
||||
{
|
||||
m_fOldTime = m_flTime; // save time of previous redraw
|
||||
m_flTime = flTime;
|
||||
m_flTimeDelta = (double)m_flTime - m_fOldTime;
|
||||
static float m_flShotTime = 0;
|
||||
|
||||
// Clock was reset, reset delta
|
||||
if ( m_flTimeDelta < 0 )
|
||||
m_flTimeDelta = 0;
|
||||
|
||||
|
||||
if (m_flShotTime && m_flShotTime < flTime)
|
||||
{
|
||||
gEngfuncs.pfnClientCmd("snapshot\n");
|
||||
m_flShotTime = 0;
|
||||
}
|
||||
|
||||
m_iIntermission = intermission;
|
||||
|
||||
// if no redrawing is necessary
|
||||
// return 0;
|
||||
|
||||
if ( m_pCvarDraw->value )
|
||||
{
|
||||
HUDLIST *pList = m_pHudList;
|
||||
|
||||
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?
|
||||
if (m_iLogo)
|
||||
{
|
||||
int x, y, i;
|
||||
|
||||
if (m_hsprLogo == 0)
|
||||
m_hsprLogo = LoadSprite("sprites/%d_logo.spr");
|
||||
|
||||
SPR_Set(m_hsprLogo, 250, 250, 250 );
|
||||
|
||||
x = SPR_Width(m_hsprLogo, 0);
|
||||
x = ScreenWidth - x;
|
||||
y = SPR_Height(m_hsprLogo, 0)/2;
|
||||
|
||||
// Draw the logo at 20 fps
|
||||
int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
|
||||
i = grgLogoFrame[iFrame] - 1;
|
||||
|
||||
SPR_DrawAdditive(i, x, y, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
if ( g_iVisibleMouse )
|
||||
{
|
||||
void IN_GetMousePos( int *mx, int *my );
|
||||
int mx, my;
|
||||
|
||||
IN_GetMousePos( &mx, &my );
|
||||
|
||||
if (m_hsprCursor == 0)
|
||||
{
|
||||
char sz[256];
|
||||
sprintf( sz, "sprites/cursor.spr" );
|
||||
m_hsprCursor = SPR_Load( sz );
|
||||
}
|
||||
|
||||
SPR_Set(m_hsprCursor, 250, 250, 250 );
|
||||
|
||||
// Draw the logo at 20 fps
|
||||
SPR_DrawAdditive( 0, mx, my, NULL );
|
||||
}
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ScaleColors( int &r, int &g, int &b, int a )
|
||||
{
|
||||
float x = (float)a / 255;
|
||||
r = (int)(r * x);
|
||||
g = (int)(g * x);
|
||||
b = (int)(b * x);
|
||||
}
|
||||
|
||||
const unsigned char colors[8][3] =
|
||||
{
|
||||
{127, 127, 127}, // additive cannot be black
|
||||
{255, 0, 0},
|
||||
{ 0, 255, 0},
|
||||
{255, 255, 0},
|
||||
{ 0, 0, 255},
|
||||
{ 0, 255, 255},
|
||||
{255, 0, 255},
|
||||
{240, 180, 24}
|
||||
};
|
||||
|
||||
int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b )
|
||||
{
|
||||
if( hud_textmode->value == 2 )
|
||||
{
|
||||
gEngfuncs.pfnDrawSetTextColor( r/255.0, g/255.0, b/255.0 );
|
||||
return gEngfuncs.pfnDrawConsoleString( xpos, ypos, (char*) szIt );
|
||||
}
|
||||
|
||||
// xash3d: reset unicode state
|
||||
TextMessageDrawChar( 0, 0, 0, 0, 0, 0 );
|
||||
|
||||
// draw the string until we hit the null character or a newline character
|
||||
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
|
||||
{
|
||||
int w = gHUD.m_scrinfo.charWidths[ 'M' ];
|
||||
if ( xpos + w > iMaxX )
|
||||
return xpos;
|
||||
if( (*szIt == '^') && (*(szIt + 1) >= '0') && (*(szIt + 1) <= '7') )
|
||||
{
|
||||
szIt++;
|
||||
r = colors[ *szIt - '0' ][0];
|
||||
g = colors[ *szIt - '0' ][1];
|
||||
b = colors[ *szIt - '0' ][2];
|
||||
if( !*(++szIt))
|
||||
return xpos;
|
||||
}
|
||||
int c = (unsigned int)(unsigned char)*szIt;
|
||||
|
||||
xpos += TextMessageDrawChar( xpos, ypos, c, r, g, b );
|
||||
}
|
||||
|
||||
return xpos;
|
||||
}
|
||||
|
||||
int CHud :: DrawHudStringLen( char *szIt )
|
||||
{
|
||||
int l = 0;
|
||||
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
|
||||
{
|
||||
l += gHUD.m_scrinfo.charWidths[ (unsigned char)*szIt ];
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
|
||||
{
|
||||
char szString[32];
|
||||
sprintf( szString, "%d", iNumber );
|
||||
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
|
||||
|
||||
}
|
||||
|
||||
// draws a string from right to left (right-aligned)
|
||||
int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b )
|
||||
{
|
||||
// find the end of the string
|
||||
for( char *szIt = szString; *szIt != 0; szIt++ )
|
||||
xpos -= gHUD.m_scrinfo.charWidths[ (unsigned char) *szIt ];
|
||||
if( xpos < iMinX )
|
||||
xpos = iMinX;
|
||||
DrawHudString( xpos, ypos, gHUD.m_scrinfo.iWidth, szString, r, g, b );
|
||||
return xpos;
|
||||
}
|
||||
|
||||
int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b)
|
||||
{
|
||||
int iWidth = GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left;
|
||||
int k;
|
||||
|
||||
if (iNumber > 0)
|
||||
{
|
||||
// SPR_Draw 100's
|
||||
if (iNumber >= 100)
|
||||
{
|
||||
k = iNumber/100;
|
||||
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
|
||||
x += iWidth;
|
||||
}
|
||||
else if (iFlags & (DHN_3DIGITS))
|
||||
{
|
||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
// SPR_Draw 10's
|
||||
if (iNumber >= 10)
|
||||
{
|
||||
k = (iNumber % 100)/10;
|
||||
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
|
||||
x += iWidth;
|
||||
}
|
||||
else if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
|
||||
{
|
||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
// SPR_Draw ones
|
||||
k = iNumber % 10;
|
||||
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
|
||||
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
|
||||
x += iWidth;
|
||||
}
|
||||
else if (iFlags & DHN_DRAWZERO)
|
||||
{
|
||||
SPR_Set(GetSprite(m_HUD_number_0), r, g, b );
|
||||
|
||||
// SPR_Draw 100's
|
||||
if (iFlags & (DHN_3DIGITS))
|
||||
{
|
||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
|
||||
{
|
||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
// SPR_Draw ones
|
||||
|
||||
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0));
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
int CHud::GetNumWidth( int iNumber, int iFlags )
|
||||
{
|
||||
if (iFlags & (DHN_3DIGITS))
|
||||
return 3;
|
||||
|
||||
if (iFlags & (DHN_2DIGITS))
|
||||
return 2;
|
||||
|
||||
if (iNumber <= 0)
|
||||
{
|
||||
if (iFlags & (DHN_DRAWZERO))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (iNumber < 10)
|
||||
return 1;
|
||||
|
||||
if (iNumber < 100)
|
||||
return 2;
|
||||
|
||||
return 3;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CHud::DrawDarkRectangle( int x, int y, int wide, int tall )
|
||||
{
|
||||
//gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture );
|
||||
gEngfuncs.pfnFillRGBABlend( x, y, wide, tall, 0, 0, 0, 255 * 0.6 );
|
||||
FillRGBA( x+1, y, wide-1, 1, 255, 140, 0, 255 );
|
||||
FillRGBA( x, y, 1, tall-1, 255, 140, 0, 255 );
|
||||
FillRGBA( x+wide-1, y+1, 1, tall-1, 255, 140, 0, 255 );
|
||||
FillRGBA( x, y+tall-1, wide-1, 1, 255, 140, 0, 255 );
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// hud_redraw.cpp
|
||||
//
|
||||
#include <math.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
//#include "triangleapi.h"
|
||||
|
||||
|
||||
#define MAX_LOGO_FRAMES 56
|
||||
|
||||
int grgLogoFrame[MAX_LOGO_FRAMES] =
|
||||
{
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, 13, 13, 13, 12, 11, 10, 9, 8, 14, 15,
|
||||
16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
||||
29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31
|
||||
};
|
||||
|
||||
|
||||
extern int g_iVisibleMouse;
|
||||
|
||||
float HUD_GetFOV( void );
|
||||
|
||||
extern cvar_t *sensitivity;
|
||||
|
||||
// Think
|
||||
void CHud::Think(void)
|
||||
{
|
||||
int newfov;
|
||||
HUDLIST *pList = m_pHudList;
|
||||
|
||||
while (pList)
|
||||
{
|
||||
if (pList->p->m_iFlags & HUD_ACTIVE)
|
||||
pList->p->Think();
|
||||
pList = pList->pNext;
|
||||
}
|
||||
|
||||
newfov = HUD_GetFOV();
|
||||
if ( newfov == 0 )
|
||||
{
|
||||
m_iFOV = default_fov->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iFOV = newfov;
|
||||
}
|
||||
|
||||
// the clients fov is actually set in the client data update section of the hud
|
||||
|
||||
// Set a new sensitivity
|
||||
if ( m_iFOV == default_fov->value )
|
||||
{
|
||||
// reset to saved sensitivity
|
||||
m_flMouseSensitivity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// set a new sensitivity that is proportional to the change from the FOV default
|
||||
m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)default_fov->value) * CVAR_GET_FLOAT("zoom_sensitivity_ratio");
|
||||
}
|
||||
|
||||
// think about default fov
|
||||
if ( m_iFOV == 0 )
|
||||
{ // only let players adjust up in fov, and only if they are not overriden by something else
|
||||
m_iFOV = max( default_fov->value, 90 );
|
||||
}
|
||||
}
|
||||
|
||||
// Redraw
|
||||
// step through the local data, placing the appropriate graphics & text as appropriate
|
||||
// returns 1 if they've changed, 0 otherwise
|
||||
int CHud :: Redraw( float flTime, int intermission )
|
||||
{
|
||||
m_fOldTime = m_flTime; // save time of previous redraw
|
||||
m_flTime = flTime;
|
||||
m_flTimeDelta = (double)m_flTime - m_fOldTime;
|
||||
static float m_flShotTime = 0;
|
||||
|
||||
// Clock was reset, reset delta
|
||||
if ( m_flTimeDelta < 0 )
|
||||
m_flTimeDelta = 0;
|
||||
|
||||
|
||||
if (m_flShotTime && m_flShotTime < flTime)
|
||||
{
|
||||
gEngfuncs.pfnClientCmd("snapshot\n");
|
||||
m_flShotTime = 0;
|
||||
}
|
||||
|
||||
m_iIntermission = intermission;
|
||||
|
||||
// if no redrawing is necessary
|
||||
// return 0;
|
||||
|
||||
if ( m_pCvarDraw->value )
|
||||
{
|
||||
HUDLIST *pList = m_pHudList;
|
||||
|
||||
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?
|
||||
if (m_iLogo)
|
||||
{
|
||||
int x, y, i;
|
||||
|
||||
if (m_hsprLogo == 0)
|
||||
m_hsprLogo = LoadSprite("sprites/%d_logo.spr");
|
||||
|
||||
SPR_Set(m_hsprLogo, 250, 250, 250 );
|
||||
|
||||
x = SPR_Width(m_hsprLogo, 0);
|
||||
x = ScreenWidth - x;
|
||||
y = SPR_Height(m_hsprLogo, 0)/2;
|
||||
|
||||
// Draw the logo at 20 fps
|
||||
int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
|
||||
i = grgLogoFrame[iFrame] - 1;
|
||||
|
||||
SPR_DrawAdditive(i, x, y, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
if ( g_iVisibleMouse )
|
||||
{
|
||||
void IN_GetMousePos( int *mx, int *my );
|
||||
int mx, my;
|
||||
|
||||
IN_GetMousePos( &mx, &my );
|
||||
|
||||
if (m_hsprCursor == 0)
|
||||
{
|
||||
char sz[256];
|
||||
sprintf( sz, "sprites/cursor.spr" );
|
||||
m_hsprCursor = SPR_Load( sz );
|
||||
}
|
||||
|
||||
SPR_Set(m_hsprCursor, 250, 250, 250 );
|
||||
|
||||
// Draw the logo at 20 fps
|
||||
SPR_DrawAdditive( 0, mx, my, NULL );
|
||||
}
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ScaleColors( int &r, int &g, int &b, int a )
|
||||
{
|
||||
float x = (float)a / 255;
|
||||
r = (int)(r * x);
|
||||
g = (int)(g * x);
|
||||
b = (int)(b * x);
|
||||
}
|
||||
|
||||
const unsigned char colors[8][3] =
|
||||
{
|
||||
{127, 127, 127}, // additive cannot be black
|
||||
{255, 0, 0},
|
||||
{ 0, 255, 0},
|
||||
{255, 255, 0},
|
||||
{ 0, 0, 255},
|
||||
{ 0, 255, 255},
|
||||
{255, 0, 255},
|
||||
{240, 180, 24}
|
||||
};
|
||||
|
||||
int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b )
|
||||
{
|
||||
if( hud_textmode->value == 2 )
|
||||
{
|
||||
gEngfuncs.pfnDrawSetTextColor( r/255.0, g/255.0, b/255.0 );
|
||||
return gEngfuncs.pfnDrawConsoleString( xpos, ypos, (char*) szIt );
|
||||
}
|
||||
|
||||
// xash3d: reset unicode state
|
||||
TextMessageDrawChar( 0, 0, 0, 0, 0, 0 );
|
||||
|
||||
// draw the string until we hit the null character or a newline character
|
||||
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
|
||||
{
|
||||
int w = gHUD.m_scrinfo.charWidths[ 'M' ];
|
||||
if ( xpos + w > iMaxX )
|
||||
return xpos;
|
||||
if( (*szIt == '^') && (*(szIt + 1) >= '0') && (*(szIt + 1) <= '7') )
|
||||
{
|
||||
szIt++;
|
||||
r = colors[ *szIt - '0' ][0];
|
||||
g = colors[ *szIt - '0' ][1];
|
||||
b = colors[ *szIt - '0' ][2];
|
||||
if( !*(++szIt))
|
||||
return xpos;
|
||||
}
|
||||
int c = (unsigned int)(unsigned char)*szIt;
|
||||
|
||||
xpos += TextMessageDrawChar( xpos, ypos, c, r, g, b );
|
||||
}
|
||||
|
||||
return xpos;
|
||||
}
|
||||
|
||||
int CHud :: DrawHudStringLen( char *szIt )
|
||||
{
|
||||
int l = 0;
|
||||
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
|
||||
{
|
||||
l += gHUD.m_scrinfo.charWidths[ (unsigned char)*szIt ];
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
|
||||
{
|
||||
char szString[32];
|
||||
sprintf( szString, "%d", iNumber );
|
||||
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
|
||||
|
||||
}
|
||||
|
||||
// draws a string from right to left (right-aligned)
|
||||
int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b )
|
||||
{
|
||||
// find the end of the string
|
||||
for( char *szIt = szString; *szIt != 0; szIt++ )
|
||||
xpos -= gHUD.m_scrinfo.charWidths[ (unsigned char) *szIt ];
|
||||
if( xpos < iMinX )
|
||||
xpos = iMinX;
|
||||
DrawHudString( xpos, ypos, gHUD.m_scrinfo.iWidth, szString, r, g, b );
|
||||
return xpos;
|
||||
}
|
||||
|
||||
int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b)
|
||||
{
|
||||
int iWidth = GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left;
|
||||
int k;
|
||||
|
||||
if (iNumber > 0)
|
||||
{
|
||||
// SPR_Draw 100's
|
||||
if (iNumber >= 100)
|
||||
{
|
||||
k = iNumber/100;
|
||||
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
|
||||
x += iWidth;
|
||||
}
|
||||
else if (iFlags & (DHN_3DIGITS))
|
||||
{
|
||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
// SPR_Draw 10's
|
||||
if (iNumber >= 10)
|
||||
{
|
||||
k = (iNumber % 100)/10;
|
||||
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
|
||||
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
|
||||
x += iWidth;
|
||||
}
|
||||
else if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
|
||||
{
|
||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
// SPR_Draw ones
|
||||
k = iNumber % 10;
|
||||
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b );
|
||||
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k));
|
||||
x += iWidth;
|
||||
}
|
||||
else if (iFlags & DHN_DRAWZERO)
|
||||
{
|
||||
SPR_Set(GetSprite(m_HUD_number_0), r, g, b );
|
||||
|
||||
// SPR_Draw 100's
|
||||
if (iFlags & (DHN_3DIGITS))
|
||||
{
|
||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
if (iFlags & (DHN_3DIGITS | DHN_2DIGITS))
|
||||
{
|
||||
//SPR_DrawAdditive( 0, x, y, &rc );
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
// SPR_Draw ones
|
||||
|
||||
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0));
|
||||
x += iWidth;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
int CHud::GetNumWidth( int iNumber, int iFlags )
|
||||
{
|
||||
if (iFlags & (DHN_3DIGITS))
|
||||
return 3;
|
||||
|
||||
if (iFlags & (DHN_2DIGITS))
|
||||
return 2;
|
||||
|
||||
if (iNumber <= 0)
|
||||
{
|
||||
if (iFlags & (DHN_DRAWZERO))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (iNumber < 10)
|
||||
return 1;
|
||||
|
||||
if (iNumber < 100)
|
||||
return 2;
|
||||
|
||||
return 3;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CHud::DrawDarkRectangle( int x, int y, int wide, int tall )
|
||||
{
|
||||
//gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture );
|
||||
gEngfuncs.pfnFillRGBABlend( x, y, wide, tall, 0, 0, 0, 255 * 0.6 );
|
||||
FillRGBA( x+1, y, wide-1, 1, 255, 140, 0, 255 );
|
||||
FillRGBA( x, y, 1, tall-1, 255, 140, 0, 255 );
|
||||
FillRGBA( x+wide-1, y+1, 1, tall-1, 255, 140, 0, 255 );
|
||||
FillRGBA( x, y+tall-1, wide-1, 1, 255, 140, 0, 255 );
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,41 +1,41 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_SERVERSH )
|
||||
#define HUD_SERVERSH
|
||||
#pragma once
|
||||
|
||||
#define NET_CALLBACK /* */
|
||||
|
||||
// Dispatchers
|
||||
void NET_CALLBACK ListResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK ServerResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK PingResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK RulesResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK PlayersResponse( struct net_response_s *response );
|
||||
|
||||
void ServersInit( void );
|
||||
void ServersShutdown( void );
|
||||
void ServersThink( double time );
|
||||
void ServersCancel( void );
|
||||
|
||||
// Get list and get server info from each
|
||||
void ServersList( void );
|
||||
|
||||
// Query for IP / IPX LAN servers
|
||||
void BroadcastServersList( int clearpending );
|
||||
|
||||
void ServerPing( int server );
|
||||
void ServerRules( int server );
|
||||
void ServerPlayers( int server );
|
||||
|
||||
int ServersGetCount( void );
|
||||
const char *ServersGetInfo( int server );
|
||||
int ServersIsQuerying( void );
|
||||
void SortServers( const char *fieldname );
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_SERVERSH )
|
||||
#define HUD_SERVERSH
|
||||
#pragma once
|
||||
|
||||
#define NET_CALLBACK /* */
|
||||
|
||||
// Dispatchers
|
||||
void NET_CALLBACK ListResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK ServerResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK PingResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK RulesResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK PlayersResponse( struct net_response_s *response );
|
||||
|
||||
void ServersInit( void );
|
||||
void ServersShutdown( void );
|
||||
void ServersThink( double time );
|
||||
void ServersCancel( void );
|
||||
|
||||
// Get list and get server info from each
|
||||
void ServersList( void );
|
||||
|
||||
// Query for IP / IPX LAN servers
|
||||
void BroadcastServersList( int clearpending );
|
||||
|
||||
void ServerPing( int server );
|
||||
void ServerRules( int server );
|
||||
void ServerPlayers( int server );
|
||||
|
||||
int ServersGetCount( void );
|
||||
const char *ServersGetInfo( int server );
|
||||
int ServersIsQuerying( void );
|
||||
void SortServers( const char *fieldname );
|
||||
|
||||
#endif // HUD_SERVERSH
|
|
@ -1,98 +1,98 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_SERVERS_PRIVH )
|
||||
#define HUD_SERVERS_PRIVH
|
||||
#pragma once
|
||||
|
||||
#include "netadr.h"
|
||||
|
||||
class CHudServers
|
||||
{
|
||||
public:
|
||||
typedef struct request_s
|
||||
{
|
||||
struct request_s *next;
|
||||
netadr_t remote_address;
|
||||
int context;
|
||||
} request_t;
|
||||
|
||||
typedef struct server_s
|
||||
{
|
||||
struct server_s *next;
|
||||
netadr_t remote_address;
|
||||
char *info;
|
||||
int ping;
|
||||
} server_t;
|
||||
|
||||
CHudServers();
|
||||
~CHudServers();
|
||||
|
||||
void Think( double time );
|
||||
void QueryThink( void );
|
||||
int isQuerying( void );
|
||||
|
||||
int LoadMasterAddresses( int maxservers, int *count, netadr_t *padr );
|
||||
|
||||
void RequestList( void );
|
||||
void RequestBroadcastList( int clearpending );
|
||||
|
||||
void ServerPing( int server );
|
||||
void ServerRules( int server );
|
||||
void ServerPlayers( int server );
|
||||
|
||||
void CancelRequest( void );
|
||||
|
||||
int CompareServers( server_t *p1, server_t *p2 );
|
||||
|
||||
void ClearServerList( server_t **ppList );
|
||||
void ClearRequestList( request_t **ppList );
|
||||
|
||||
void AddServer( server_t **ppList, server_t *p );
|
||||
|
||||
void RemoveServerFromList( request_t **ppList, request_t *item );
|
||||
|
||||
request_t *FindRequest( int context, request_t *pList );
|
||||
|
||||
int ServerListSize( void );
|
||||
char *GetServerInfo( int server );
|
||||
int GetServerCount( void );
|
||||
void SortServers( const char *fieldname );
|
||||
|
||||
void ListResponse( struct net_response_s *response );
|
||||
void ServerResponse( struct net_response_s *response );
|
||||
void PingResponse( struct net_response_s *response );
|
||||
void RulesResponse( struct net_response_s *response );
|
||||
void PlayersResponse( struct net_response_s *response );
|
||||
private:
|
||||
|
||||
server_t *GetServer( int server );
|
||||
|
||||
//
|
||||
char m_szToken[ 1024 ];
|
||||
int m_nRequesting;
|
||||
int m_nDone;
|
||||
|
||||
double m_dStarted;
|
||||
|
||||
request_t *m_pServerList;
|
||||
request_t *m_pActiveList;
|
||||
|
||||
server_t *m_pServers;
|
||||
|
||||
int m_nServerCount;
|
||||
|
||||
int m_nActiveQueries;
|
||||
int m_nQuerying;
|
||||
double m_fElapsed;
|
||||
|
||||
request_t *m_pPingRequest;
|
||||
request_t *m_pRulesRequest;
|
||||
request_t *m_pPlayersRequest;
|
||||
};
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_SERVERS_PRIVH )
|
||||
#define HUD_SERVERS_PRIVH
|
||||
#pragma once
|
||||
|
||||
#include "netadr.h"
|
||||
|
||||
class CHudServers
|
||||
{
|
||||
public:
|
||||
typedef struct request_s
|
||||
{
|
||||
struct request_s *next;
|
||||
netadr_t remote_address;
|
||||
int context;
|
||||
} request_t;
|
||||
|
||||
typedef struct server_s
|
||||
{
|
||||
struct server_s *next;
|
||||
netadr_t remote_address;
|
||||
char *info;
|
||||
int ping;
|
||||
} server_t;
|
||||
|
||||
CHudServers();
|
||||
~CHudServers();
|
||||
|
||||
void Think( double time );
|
||||
void QueryThink( void );
|
||||
int isQuerying( void );
|
||||
|
||||
int LoadMasterAddresses( int maxservers, int *count, netadr_t *padr );
|
||||
|
||||
void RequestList( void );
|
||||
void RequestBroadcastList( int clearpending );
|
||||
|
||||
void ServerPing( int server );
|
||||
void ServerRules( int server );
|
||||
void ServerPlayers( int server );
|
||||
|
||||
void CancelRequest( void );
|
||||
|
||||
int CompareServers( server_t *p1, server_t *p2 );
|
||||
|
||||
void ClearServerList( server_t **ppList );
|
||||
void ClearRequestList( request_t **ppList );
|
||||
|
||||
void AddServer( server_t **ppList, server_t *p );
|
||||
|
||||
void RemoveServerFromList( request_t **ppList, request_t *item );
|
||||
|
||||
request_t *FindRequest( int context, request_t *pList );
|
||||
|
||||
int ServerListSize( void );
|
||||
char *GetServerInfo( int server );
|
||||
int GetServerCount( void );
|
||||
void SortServers( const char *fieldname );
|
||||
|
||||
void ListResponse( struct net_response_s *response );
|
||||
void ServerResponse( struct net_response_s *response );
|
||||
void PingResponse( struct net_response_s *response );
|
||||
void RulesResponse( struct net_response_s *response );
|
||||
void PlayersResponse( struct net_response_s *response );
|
||||
private:
|
||||
|
||||
server_t *GetServer( int server );
|
||||
|
||||
//
|
||||
char m_szToken[ 1024 ];
|
||||
int m_nRequesting;
|
||||
int m_nDone;
|
||||
|
||||
double m_dStarted;
|
||||
|
||||
request_t *m_pServerList;
|
||||
request_t *m_pActiveList;
|
||||
|
||||
server_t *m_pServers;
|
||||
|
||||
int m_nServerCount;
|
||||
|
||||
int m_nActiveQueries;
|
||||
int m_nQuerying;
|
||||
double m_fElapsed;
|
||||
|
||||
request_t *m_pPingRequest;
|
||||
request_t *m_pRulesRequest;
|
||||
request_t *m_pPlayersRequest;
|
||||
};
|
||||
|
||||
#endif // HUD_SERVERS_PRIVH
|
File diff suppressed because it is too large
Load Diff
|
@ -1,132 +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
|
||||
//========= 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
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// hud_update.cpp
|
||||
//
|
||||
|
||||
#include <math.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
int CL_ButtonBits( int );
|
||||
void CL_ResetButtonBits( int bits );
|
||||
|
||||
extern float v_idlescale;
|
||||
float in_fov;
|
||||
extern void HUD_SetCmdBits( int bits );
|
||||
|
||||
int CHud::UpdateClientData(client_data_t *cdata, float time)
|
||||
{
|
||||
memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t));
|
||||
memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t));
|
||||
|
||||
m_iKeyBits = CL_ButtonBits( 0 );
|
||||
m_iWeaponBits = cdata->iWeaponBits;
|
||||
|
||||
in_fov = cdata->fov;
|
||||
|
||||
Think();
|
||||
|
||||
cdata->fov = m_iFOV;
|
||||
|
||||
v_idlescale = m_iConcussionEffect;
|
||||
|
||||
CL_ResetButtonBits( m_iKeyBits );
|
||||
|
||||
// return 1 if in anything in the client_data struct has been changed, 0 otherwise
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// hud_update.cpp
|
||||
//
|
||||
|
||||
#include <math.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
int CL_ButtonBits( int );
|
||||
void CL_ResetButtonBits( int bits );
|
||||
|
||||
extern float v_idlescale;
|
||||
float in_fov;
|
||||
extern void HUD_SetCmdBits( int bits );
|
||||
|
||||
int CHud::UpdateClientData(client_data_t *cdata, float time)
|
||||
{
|
||||
memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t));
|
||||
memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t));
|
||||
|
||||
m_iKeyBits = CL_ButtonBits( 0 );
|
||||
m_iWeaponBits = cdata->iWeaponBits;
|
||||
|
||||
in_fov = cdata->fov;
|
||||
|
||||
Think();
|
||||
|
||||
cdata->fov = m_iFOV;
|
||||
|
||||
v_idlescale = m_iConcussionEffect;
|
||||
|
||||
CL_ResetButtonBits( m_iKeyBits );
|
||||
|
||||
// return 1 if in anything in the client_data struct has been changed, 0 otherwise
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
1240
cl_dll/in_camera.cpp
1240
cl_dll/in_camera.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,30 +1,30 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( IN_DEFSH )
|
||||
#define IN_DEFSH
|
||||
#pragma once
|
||||
|
||||
// up / down
|
||||
#define PITCH 0
|
||||
// left / right
|
||||
#define YAW 1
|
||||
// fall over
|
||||
#define ROLL 2
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
typedef struct point_s{
|
||||
int x;
|
||||
int y;
|
||||
} POINT;
|
||||
#define GetCursorPos(x)
|
||||
#define SetCursorPos(x,y)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( IN_DEFSH )
|
||||
#define IN_DEFSH
|
||||
#pragma once
|
||||
|
||||
// up / down
|
||||
#define PITCH 0
|
||||
// left / right
|
||||
#define YAW 1
|
||||
// fall over
|
||||
#define ROLL 2
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
typedef struct point_s{
|
||||
int x;
|
||||
int y;
|
||||
} POINT;
|
||||
#define GetCursorPos(x)
|
||||
#define SetCursorPos(x,y)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
2008
cl_dll/input.cpp
2008
cl_dll/input.cpp
File diff suppressed because it is too large
Load Diff
1892
cl_dll/inputw32.cpp
1892
cl_dll/inputw32.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +1,18 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( KBUTTONH )
|
||||
#define KBUTTONH
|
||||
#pragma once
|
||||
|
||||
typedef struct kbutton_s
|
||||
{
|
||||
int down[2]; // key nums holding it down
|
||||
int state; // low bit is down state
|
||||
} kbutton_t;
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( KBUTTONH )
|
||||
#define KBUTTONH
|
||||
#pragma once
|
||||
|
||||
typedef struct kbutton_s
|
||||
{
|
||||
int down[2]; // key nums holding it down
|
||||
int state; // low bit is down state
|
||||
} kbutton_t;
|
||||
|
||||
#endif // !KBUTTONH
|
368
cl_dll/menu.cpp
368
cl_dll/menu.cpp
|
@ -1,188 +1,188 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// menu.cpp
|
||||
//
|
||||
// generic menu handler
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define MAX_MENU_STRING 512
|
||||
char g_szMenuString[MAX_MENU_STRING];
|
||||
char g_szPrelocalisedMenuString[MAX_MENU_STRING];
|
||||
|
||||
int KB_ConvertString( char *in, char **ppout );
|
||||
|
||||
DECLARE_MESSAGE( m_Menu, ShowMenu );
|
||||
|
||||
int CHudMenu :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( ShowMenu );
|
||||
|
||||
InitHUDData();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudMenu :: InitHUDData( void )
|
||||
{
|
||||
m_fMenuDisplayed = 0;
|
||||
m_bitsValidSlots = 0;
|
||||
Reset();
|
||||
}
|
||||
|
||||
void CHudMenu :: Reset( void )
|
||||
{
|
||||
g_szPrelocalisedMenuString[0] = 0;
|
||||
m_fWaitingForMore = FALSE;
|
||||
}
|
||||
|
||||
int CHudMenu :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudMenu :: Draw( float flTime )
|
||||
{
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// menu.cpp
|
||||
//
|
||||
// generic menu handler
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define MAX_MENU_STRING 512
|
||||
char g_szMenuString[MAX_MENU_STRING];
|
||||
char g_szPrelocalisedMenuString[MAX_MENU_STRING];
|
||||
|
||||
int KB_ConvertString( char *in, char **ppout );
|
||||
|
||||
DECLARE_MESSAGE( m_Menu, ShowMenu );
|
||||
|
||||
int CHudMenu :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( ShowMenu );
|
||||
|
||||
InitHUDData();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudMenu :: InitHUDData( void )
|
||||
{
|
||||
m_fMenuDisplayed = 0;
|
||||
m_bitsValidSlots = 0;
|
||||
Reset();
|
||||
}
|
||||
|
||||
void CHudMenu :: Reset( void )
|
||||
{
|
||||
g_szPrelocalisedMenuString[0] = 0;
|
||||
m_fWaitingForMore = FALSE;
|
||||
}
|
||||
|
||||
int CHudMenu :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudMenu :: Draw( float flTime )
|
||||
{
|
||||
int i;
|
||||
|
||||
// check for if menu is set to disappear
|
||||
if ( m_flShutoffTime > 0 )
|
||||
{
|
||||
if ( m_flShutoffTime <= gHUD.m_flTime )
|
||||
{ // times up, shutoff
|
||||
m_fMenuDisplayed = 0;
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// don't draw the menu if the scoreboard is being shown
|
||||
// check for if menu is set to disappear
|
||||
if ( m_flShutoffTime > 0 )
|
||||
{
|
||||
if ( m_flShutoffTime <= gHUD.m_flTime )
|
||||
{ // times up, shutoff
|
||||
m_fMenuDisplayed = 0;
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// don't draw the menu if the scoreboard is being shown
|
||||
|
||||
|
||||
|
||||
// draw the menu, along the left-hand side of the screen
|
||||
|
||||
// count the number of newlines
|
||||
int nlc = 0;
|
||||
for ( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
|
||||
{
|
||||
if ( g_szMenuString[i] == '\n' )
|
||||
nlc++;
|
||||
}
|
||||
|
||||
// center it
|
||||
int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text
|
||||
int x = 20;
|
||||
|
||||
i = 0;
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' )
|
||||
{
|
||||
gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
|
||||
y += 12;
|
||||
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' )
|
||||
i++;
|
||||
if ( g_szMenuString[i] == '\n' )
|
||||
i++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// selects an item from the menu
|
||||
void CHudMenu :: SelectMenuItem( int menu_item )
|
||||
{
|
||||
// if menu_item is in a valid slot, send a menuselect command to the server
|
||||
if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) )
|
||||
{
|
||||
char szbuf[32];
|
||||
sprintf( szbuf, "menuselect %d\n", menu_item );
|
||||
ClientCmd( szbuf );
|
||||
|
||||
// remove the menu
|
||||
m_fMenuDisplayed = 0;
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Message handler for ShowMenu message
|
||||
// takes four values:
|
||||
// short: a bitfield of keys that are valid input
|
||||
// char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen.
|
||||
// byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string
|
||||
// string: menu string to display
|
||||
// if this message is never received, then scores will simply be the combined totals of the players.
|
||||
int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
char *temp = NULL;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
m_bitsValidSlots = READ_SHORT();
|
||||
int DisplayTime = READ_CHAR();
|
||||
int NeedMore = READ_BYTE();
|
||||
|
||||
if ( DisplayTime > 0 )
|
||||
m_flShutoffTime = DisplayTime + gHUD.m_flTime;
|
||||
else
|
||||
m_flShutoffTime = -1;
|
||||
|
||||
if ( m_bitsValidSlots )
|
||||
{
|
||||
if ( !m_fWaitingForMore ) // this is the start of a new menu
|
||||
{
|
||||
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
|
||||
}
|
||||
else
|
||||
{ // append to the current menu string
|
||||
strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) );
|
||||
}
|
||||
g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not)
|
||||
|
||||
if ( !NeedMore )
|
||||
{ // we have the whole string, so we can localise it now
|
||||
strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) );
|
||||
|
||||
// Swap in characters
|
||||
if ( KB_ConvertString( g_szMenuString, &temp ) )
|
||||
{
|
||||
strcpy( g_szMenuString, temp );
|
||||
free( temp );
|
||||
}
|
||||
}
|
||||
|
||||
m_fMenuDisplayed = 1;
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
m_fWaitingForMore = NeedMore;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// draw the menu, along the left-hand side of the screen
|
||||
|
||||
// count the number of newlines
|
||||
int nlc = 0;
|
||||
for ( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
|
||||
{
|
||||
if ( g_szMenuString[i] == '\n' )
|
||||
nlc++;
|
||||
}
|
||||
|
||||
// center it
|
||||
int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text
|
||||
int x = 20;
|
||||
|
||||
i = 0;
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' )
|
||||
{
|
||||
gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
|
||||
y += 12;
|
||||
|
||||
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' )
|
||||
i++;
|
||||
if ( g_szMenuString[i] == '\n' )
|
||||
i++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// selects an item from the menu
|
||||
void CHudMenu :: SelectMenuItem( int menu_item )
|
||||
{
|
||||
// if menu_item is in a valid slot, send a menuselect command to the server
|
||||
if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) )
|
||||
{
|
||||
char szbuf[32];
|
||||
sprintf( szbuf, "menuselect %d\n", menu_item );
|
||||
ClientCmd( szbuf );
|
||||
|
||||
// remove the menu
|
||||
m_fMenuDisplayed = 0;
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Message handler for ShowMenu message
|
||||
// takes four values:
|
||||
// short: a bitfield of keys that are valid input
|
||||
// char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen.
|
||||
// byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string
|
||||
// string: menu string to display
|
||||
// if this message is never received, then scores will simply be the combined totals of the players.
|
||||
int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
char *temp = NULL;
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
m_bitsValidSlots = READ_SHORT();
|
||||
int DisplayTime = READ_CHAR();
|
||||
int NeedMore = READ_BYTE();
|
||||
|
||||
if ( DisplayTime > 0 )
|
||||
m_flShutoffTime = DisplayTime + gHUD.m_flTime;
|
||||
else
|
||||
m_flShutoffTime = -1;
|
||||
|
||||
if ( m_bitsValidSlots )
|
||||
{
|
||||
if ( !m_fWaitingForMore ) // this is the start of a new menu
|
||||
{
|
||||
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
|
||||
}
|
||||
else
|
||||
{ // append to the current menu string
|
||||
strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) );
|
||||
}
|
||||
g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not)
|
||||
|
||||
if ( !NeedMore )
|
||||
{ // we have the whole string, so we can localise it now
|
||||
strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) );
|
||||
|
||||
// Swap in characters
|
||||
if ( KB_ConvertString( g_szMenuString, &temp ) )
|
||||
{
|
||||
strcpy( g_szMenuString, temp );
|
||||
free( temp );
|
||||
}
|
||||
}
|
||||
|
||||
m_fMenuDisplayed = 1;
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
m_fWaitingForMore = NeedMore;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
1072
cl_dll/message.cpp
1072
cl_dll/message.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,163 +1,163 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "cl_entity.h"
|
||||
#include "triangleapi.h"
|
||||
//========= 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 "overview.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)
|
||||
{
|
||||
|
||||
// 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)
|
||||
{
|
||||
#if 0
|
||||
// only draw in overview mode
|
||||
if (!gEngfuncs.Overview_GetOverviewState())
|
||||
return 1;
|
||||
|
||||
// make sure we have player info
|
||||
// gViewPort->GetAllPlayersInfo();
|
||||
// only draw in overview mode
|
||||
if (!gEngfuncs.Overview_GetOverviewState())
|
||||
return 1;
|
||||
|
||||
// make sure we have player info
|
||||
// gViewPort->GetAllPlayersInfo();
|
||||
gHUD.m_Scoreboard.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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
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 );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +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
|
||||
//========= 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
|
||||
|
|
|
@ -1,166 +1,166 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// parsemsg.cpp
|
||||
//
|
||||
typedef unsigned char byte;
|
||||
#define true 1
|
||||
|
||||
static byte *gpBuf;
|
||||
static int giSize;
|
||||
static int giRead;
|
||||
static int giBadRead;
|
||||
|
||||
void BEGIN_READ( void *buf, int size )
|
||||
{
|
||||
giRead = 0;
|
||||
giBadRead = 0;
|
||||
giSize = size;
|
||||
gpBuf = (byte*)buf;
|
||||
}
|
||||
|
||||
|
||||
int READ_CHAR( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead + 1 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (signed char)gpBuf[giRead];
|
||||
giRead++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_BYTE( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+1 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (unsigned char)gpBuf[giRead];
|
||||
giRead++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_SHORT( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+2 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) );
|
||||
|
||||
giRead += 2;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_WORD( void )
|
||||
{
|
||||
return READ_SHORT();
|
||||
}
|
||||
|
||||
|
||||
int READ_LONG( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+4 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24);
|
||||
|
||||
giRead += 4;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
float READ_FLOAT( void )
|
||||
{
|
||||
union
|
||||
{
|
||||
byte b[4];
|
||||
float f;
|
||||
int l;
|
||||
} dat;
|
||||
|
||||
dat.b[0] = gpBuf[giRead];
|
||||
dat.b[1] = gpBuf[giRead+1];
|
||||
dat.b[2] = gpBuf[giRead+2];
|
||||
dat.b[3] = gpBuf[giRead+3];
|
||||
giRead += 4;
|
||||
|
||||
// dat.l = LittleLong (dat.l);
|
||||
|
||||
return dat.f;
|
||||
}
|
||||
|
||||
char* READ_STRING( void )
|
||||
{
|
||||
static char string[2048];
|
||||
int l,c;
|
||||
|
||||
string[0] = 0;
|
||||
|
||||
l = 0;
|
||||
do
|
||||
{
|
||||
if ( giRead+1 > giSize )
|
||||
break; // no more characters
|
||||
|
||||
c = READ_BYTE();
|
||||
if (c == -1 || c == 0)
|
||||
break;
|
||||
string[l] = c;
|
||||
l++;
|
||||
} while (l < sizeof(string)-1);
|
||||
|
||||
string[l] = 0;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
float READ_COORD( void )
|
||||
{
|
||||
return (float)(READ_SHORT() * (1.0/8));
|
||||
}
|
||||
|
||||
float READ_ANGLE( void )
|
||||
{
|
||||
return (float)(READ_CHAR() * (360.0/256));
|
||||
}
|
||||
|
||||
float READ_HIRESANGLE( void )
|
||||
{
|
||||
return (float)(READ_SHORT() * (360.0/65536));
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// parsemsg.cpp
|
||||
//
|
||||
typedef unsigned char byte;
|
||||
#define true 1
|
||||
|
||||
static byte *gpBuf;
|
||||
static int giSize;
|
||||
static int giRead;
|
||||
static int giBadRead;
|
||||
|
||||
void BEGIN_READ( void *buf, int size )
|
||||
{
|
||||
giRead = 0;
|
||||
giBadRead = 0;
|
||||
giSize = size;
|
||||
gpBuf = (byte*)buf;
|
||||
}
|
||||
|
||||
|
||||
int READ_CHAR( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead + 1 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (signed char)gpBuf[giRead];
|
||||
giRead++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_BYTE( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+1 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (unsigned char)gpBuf[giRead];
|
||||
giRead++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_SHORT( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+2 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) );
|
||||
|
||||
giRead += 2;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int READ_WORD( void )
|
||||
{
|
||||
return READ_SHORT();
|
||||
}
|
||||
|
||||
|
||||
int READ_LONG( void )
|
||||
{
|
||||
int c;
|
||||
|
||||
if (giRead+4 > giSize)
|
||||
{
|
||||
giBadRead = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24);
|
||||
|
||||
giRead += 4;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
float READ_FLOAT( void )
|
||||
{
|
||||
union
|
||||
{
|
||||
byte b[4];
|
||||
float f;
|
||||
int l;
|
||||
} dat;
|
||||
|
||||
dat.b[0] = gpBuf[giRead];
|
||||
dat.b[1] = gpBuf[giRead+1];
|
||||
dat.b[2] = gpBuf[giRead+2];
|
||||
dat.b[3] = gpBuf[giRead+3];
|
||||
giRead += 4;
|
||||
|
||||
// dat.l = LittleLong (dat.l);
|
||||
|
||||
return dat.f;
|
||||
}
|
||||
|
||||
char* READ_STRING( void )
|
||||
{
|
||||
static char string[2048];
|
||||
int l,c;
|
||||
|
||||
string[0] = 0;
|
||||
|
||||
l = 0;
|
||||
do
|
||||
{
|
||||
if ( giRead+1 > giSize )
|
||||
break; // no more characters
|
||||
|
||||
c = READ_BYTE();
|
||||
if (c == -1 || c == 0)
|
||||
break;
|
||||
string[l] = c;
|
||||
l++;
|
||||
} while (l < sizeof(string)-1);
|
||||
|
||||
string[l] = 0;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
float READ_COORD( void )
|
||||
{
|
||||
return (float)(READ_SHORT() * (1.0/8));
|
||||
}
|
||||
|
||||
float READ_ANGLE( void )
|
||||
{
|
||||
return (float)(READ_CHAR() * (360.0/256));
|
||||
}
|
||||
|
||||
float READ_HIRESANGLE( void )
|
||||
{
|
||||
return (float)(READ_SHORT() * (360.0/65536));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// parsemsg.h
|
||||
//
|
||||
|
||||
#define ASSERT( x )
|
||||
|
||||
void BEGIN_READ( void *buf, int size );
|
||||
int READ_CHAR( void );
|
||||
int READ_BYTE( void );
|
||||
int READ_SHORT( void );
|
||||
int READ_WORD( void );
|
||||
int READ_LONG( void );
|
||||
float READ_FLOAT( void );
|
||||
char* READ_STRING( void );
|
||||
float READ_COORD( void );
|
||||
float READ_ANGLE( void );
|
||||
float READ_HIRESANGLE( void );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// parsemsg.h
|
||||
//
|
||||
|
||||
#define ASSERT( x )
|
||||
|
||||
void BEGIN_READ( void *buf, int size );
|
||||
int READ_CHAR( void );
|
||||
int READ_BYTE( void );
|
||||
int READ_SHORT( void );
|
||||
int READ_WORD( void );
|
||||
int READ_LONG( void );
|
||||
float READ_FLOAT( void );
|
||||
char* READ_STRING( void );
|
||||
float READ_COORD( void );
|
||||
float READ_ANGLE( void );
|
||||
float READ_HIRESANGLE( void );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,313 +1,313 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// saytext.cpp
|
||||
//
|
||||
// implementation of CHudSayText class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
extern float *GetClientColor( int clientIndex );
|
||||
|
||||
#define MAX_LINES 5
|
||||
#define MAX_CHARS_PER_LINE 256 /* it can be less than this, depending on char size */
|
||||
|
||||
// allow 20 pixels on either side of the text
|
||||
#define MAX_LINE_WIDTH ( ScreenWidth - 40 )
|
||||
#define LINE_START 10
|
||||
static float SCROLL_SPEED = 5;
|
||||
|
||||
static char g_szLineBuffer[ MAX_LINES + 1 ][ MAX_CHARS_PER_LINE ];
|
||||
static float *g_pflNameColors[ MAX_LINES + 1 ];
|
||||
static int g_iNameLengths[ MAX_LINES + 1 ];
|
||||
static float flScrollTime = 0; // the time at which the lines next scroll up
|
||||
|
||||
static int Y_START = 0;
|
||||
static int line_height = 0;
|
||||
|
||||
DECLARE_MESSAGE( m_SayText, SayText );
|
||||
|
||||
int CHudSayText :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( SayText );
|
||||
|
||||
InitHUDData();
|
||||
|
||||
m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext", "1", 0 );
|
||||
m_HUD_saytext_time = gEngfuncs.pfnRegisterVariable( "hud_saytext_time", "5", 0 );
|
||||
|
||||
m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CHudSayText :: InitHUDData( void )
|
||||
{
|
||||
memset( g_szLineBuffer, 0, sizeof g_szLineBuffer );
|
||||
memset( g_pflNameColors, 0, sizeof g_pflNameColors );
|
||||
memset( g_iNameLengths, 0, sizeof g_iNameLengths );
|
||||
}
|
||||
|
||||
int CHudSayText :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int ScrollTextUp( void )
|
||||
{
|
||||
ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer
|
||||
g_szLineBuffer[MAX_LINES][0] = 0;
|
||||
memmove( g_szLineBuffer[0], g_szLineBuffer[1], sizeof(g_szLineBuffer) - sizeof(g_szLineBuffer[0]) ); // overwrite the first line
|
||||
memmove( &g_pflNameColors[0], &g_pflNameColors[1], sizeof(g_pflNameColors) - sizeof(g_pflNameColors[0]) );
|
||||
memmove( &g_iNameLengths[0], &g_iNameLengths[1], sizeof(g_iNameLengths) - sizeof(g_iNameLengths[0]) );
|
||||
g_szLineBuffer[MAX_LINES-1][0] = 0;
|
||||
|
||||
if ( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines
|
||||
{
|
||||
g_szLineBuffer[0][0] = 2;
|
||||
return 1 + ScrollTextUp();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudSayText :: Draw( float flTime )
|
||||
{
|
||||
int y = Y_START;
|
||||
|
||||
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
|
||||
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 + m_HUD_saytext_time->value );
|
||||
|
||||
if ( flScrollTime <= flTime )
|
||||
{
|
||||
if ( *g_szLineBuffer[0] )
|
||||
{
|
||||
flScrollTime = flTime + m_HUD_saytext_time->value;
|
||||
// push the console up
|
||||
ScrollTextUp();
|
||||
}
|
||||
else
|
||||
{ // buffer is empty, just disable drawing of this section
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < MAX_LINES; i++ )
|
||||
{
|
||||
if ( *g_szLineBuffer[i] )
|
||||
{
|
||||
if ( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] )
|
||||
{
|
||||
// it's a saytext string
|
||||
static char buf[MAX_PLAYER_NAME_LENGTH+32];
|
||||
|
||||
// draw the first x characters in the player color
|
||||
strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) );
|
||||
buf[ min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31) ] = 0;
|
||||
DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
||||
int x = DrawConsoleString( LINE_START, y, buf );
|
||||
|
||||
// color is reset after each string draw
|
||||
DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] );
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal draw
|
||||
DrawConsoleString( LINE_START, y, g_szLineBuffer[i] );
|
||||
}
|
||||
}
|
||||
|
||||
y += line_height;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int client_index = READ_BYTE(); // the client who spoke the message
|
||||
SayTextPrint( READ_STRING(), iSize - 1, client_index );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
|
||||
{
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// saytext.cpp
|
||||
//
|
||||
// implementation of CHudSayText class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
extern float *GetClientColor( int clientIndex );
|
||||
|
||||
#define MAX_LINES 5
|
||||
#define MAX_CHARS_PER_LINE 256 /* it can be less than this, depending on char size */
|
||||
|
||||
// allow 20 pixels on either side of the text
|
||||
#define MAX_LINE_WIDTH ( ScreenWidth - 40 )
|
||||
#define LINE_START 10
|
||||
static float SCROLL_SPEED = 5;
|
||||
|
||||
static char g_szLineBuffer[ MAX_LINES + 1 ][ MAX_CHARS_PER_LINE ];
|
||||
static float *g_pflNameColors[ MAX_LINES + 1 ];
|
||||
static int g_iNameLengths[ MAX_LINES + 1 ];
|
||||
static float flScrollTime = 0; // the time at which the lines next scroll up
|
||||
|
||||
static int Y_START = 0;
|
||||
static int line_height = 0;
|
||||
|
||||
DECLARE_MESSAGE( m_SayText, SayText );
|
||||
|
||||
int CHudSayText :: Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
HOOK_MESSAGE( SayText );
|
||||
|
||||
InitHUDData();
|
||||
|
||||
m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext", "1", 0 );
|
||||
m_HUD_saytext_time = gEngfuncs.pfnRegisterVariable( "hud_saytext_time", "5", 0 );
|
||||
|
||||
m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CHudSayText :: InitHUDData( void )
|
||||
{
|
||||
memset( g_szLineBuffer, 0, sizeof g_szLineBuffer );
|
||||
memset( g_pflNameColors, 0, sizeof g_pflNameColors );
|
||||
memset( g_iNameLengths, 0, sizeof g_iNameLengths );
|
||||
}
|
||||
|
||||
int CHudSayText :: VidInit( void )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int ScrollTextUp( void )
|
||||
{
|
||||
ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer
|
||||
g_szLineBuffer[MAX_LINES][0] = 0;
|
||||
memmove( g_szLineBuffer[0], g_szLineBuffer[1], sizeof(g_szLineBuffer) - sizeof(g_szLineBuffer[0]) ); // overwrite the first line
|
||||
memmove( &g_pflNameColors[0], &g_pflNameColors[1], sizeof(g_pflNameColors) - sizeof(g_pflNameColors[0]) );
|
||||
memmove( &g_iNameLengths[0], &g_iNameLengths[1], sizeof(g_iNameLengths) - sizeof(g_iNameLengths[0]) );
|
||||
g_szLineBuffer[MAX_LINES-1][0] = 0;
|
||||
|
||||
if ( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines
|
||||
{
|
||||
g_szLineBuffer[0][0] = 2;
|
||||
return 1 + ScrollTextUp();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudSayText :: Draw( float flTime )
|
||||
{
|
||||
int y = Y_START;
|
||||
|
||||
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
|
||||
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 + m_HUD_saytext_time->value );
|
||||
|
||||
if ( flScrollTime <= flTime )
|
||||
{
|
||||
if ( *g_szLineBuffer[0] )
|
||||
{
|
||||
flScrollTime = flTime + m_HUD_saytext_time->value;
|
||||
// push the console up
|
||||
ScrollTextUp();
|
||||
}
|
||||
else
|
||||
{ // buffer is empty, just disable drawing of this section
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < MAX_LINES; i++ )
|
||||
{
|
||||
if ( *g_szLineBuffer[i] )
|
||||
{
|
||||
if ( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] )
|
||||
{
|
||||
// it's a saytext string
|
||||
static char buf[MAX_PLAYER_NAME_LENGTH+32];
|
||||
|
||||
// draw the first x characters in the player color
|
||||
strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) );
|
||||
buf[ min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31) ] = 0;
|
||||
DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
||||
int x = DrawConsoleString( LINE_START, y, buf );
|
||||
|
||||
// color is reset after each string draw
|
||||
DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] );
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal draw
|
||||
DrawConsoleString( LINE_START, y, g_szLineBuffer[i] );
|
||||
}
|
||||
}
|
||||
|
||||
y += line_height;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int client_index = READ_BYTE(); // the client who spoke the message
|
||||
SayTextPrint( READ_STRING(), iSize - 1, client_index );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
|
||||
{
|
||||
int i;
|
||||
ConsolePrint( pszBuf );
|
||||
|
||||
// find an empty string slot
|
||||
for ( i = 0; i < MAX_LINES; i++ )
|
||||
{
|
||||
if ( ! *g_szLineBuffer[i] )
|
||||
break;
|
||||
}
|
||||
if ( i == MAX_LINES )
|
||||
{
|
||||
// force scroll buffer up
|
||||
ScrollTextUp();
|
||||
i = MAX_LINES - 1;
|
||||
}
|
||||
|
||||
g_iNameLengths[i] = 0;
|
||||
g_pflNameColors[i] = NULL;
|
||||
|
||||
// if it's a say message, search for the players name in the string
|
||||
if ( *pszBuf == 2 && clientIndex > 0 )
|
||||
{
|
||||
GetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] );
|
||||
const char *pName = g_PlayerInfoList[clientIndex].name;
|
||||
|
||||
if ( pName )
|
||||
{
|
||||
const char *nameInString = strstr( pszBuf, pName );
|
||||
|
||||
if ( nameInString )
|
||||
{
|
||||
g_iNameLengths[i] = strlen( pName ) + (nameInString - pszBuf);
|
||||
g_pflNameColors[i] = GetClientColor( clientIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
strncpy( g_szLineBuffer[i], pszBuf, max(iBufSize -1, MAX_CHARS_PER_LINE-1) );
|
||||
|
||||
// make sure the text fits in one line
|
||||
EnsureTextFitsInOneLineAndWrapIfHaveTo( i );
|
||||
|
||||
// Set scroll time
|
||||
if ( i == 0 )
|
||||
{
|
||||
flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value;
|
||||
}
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
PlaySound( "misc/talk.wav", 1 );
|
||||
|
||||
if ( ScreenHeight >= 480 )
|
||||
Y_START = ScreenHeight - 60;
|
||||
else
|
||||
Y_START = ScreenHeight - 45;
|
||||
Y_START -= (line_height * (MAX_LINES+1));
|
||||
|
||||
}
|
||||
|
||||
void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
|
||||
{
|
||||
int line_width = 0;
|
||||
GetConsoleStringSize( g_szLineBuffer[line], &line_width, &line_height );
|
||||
|
||||
if ( (line_width + LINE_START) > MAX_LINE_WIDTH )
|
||||
{ // string is too long to fit on line
|
||||
// scan the string until we find what word is too long, and wrap the end of the sentence after the word
|
||||
int length = LINE_START;
|
||||
int tmp_len = 0;
|
||||
char *last_break = NULL;
|
||||
for ( char *x = g_szLineBuffer[line]; *x != 0; x++ )
|
||||
{
|
||||
// check for a color change, if so skip past it
|
||||
if ( x[0] == '/' && x[1] == '(' )
|
||||
{
|
||||
x += 2;
|
||||
// skip forward until past mode specifier
|
||||
while ( *x != 0 && *x != ')' )
|
||||
x++;
|
||||
|
||||
if ( *x != 0 )
|
||||
x++;
|
||||
|
||||
if ( *x == 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
char buf[2];
|
||||
buf[1] = 0;
|
||||
|
||||
if ( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character
|
||||
last_break = x;
|
||||
|
||||
buf[0] = *x; // get the length of the current character
|
||||
GetConsoleStringSize( buf, &tmp_len, &line_height );
|
||||
length += tmp_len;
|
||||
|
||||
if ( length > MAX_LINE_WIDTH )
|
||||
{ // needs to be broken up
|
||||
if ( !last_break )
|
||||
last_break = x-1;
|
||||
|
||||
x = last_break;
|
||||
|
||||
// find an empty string slot
|
||||
int j;
|
||||
do
|
||||
{
|
||||
for ( j = 0; j < MAX_LINES; j++ )
|
||||
{
|
||||
if ( ! *g_szLineBuffer[j] )
|
||||
break;
|
||||
}
|
||||
if ( j == MAX_LINES )
|
||||
{
|
||||
// need to make more room to display text, scroll stuff up then fix the pointers
|
||||
int linesmoved = ScrollTextUp();
|
||||
line -= linesmoved;
|
||||
last_break = last_break - (sizeof(g_szLineBuffer[0]) * linesmoved);
|
||||
}
|
||||
}
|
||||
while ( j == MAX_LINES );
|
||||
|
||||
// copy remaining string into next buffer, making sure it starts with a space character
|
||||
if ( (char)*last_break == (char)' ' )
|
||||
{
|
||||
int linelen = strlen(g_szLineBuffer[j]);
|
||||
int remaininglen = strlen(last_break);
|
||||
|
||||
if ( (linelen - remaininglen) <= MAX_CHARS_PER_LINE )
|
||||
strcat( g_szLineBuffer[j], last_break );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (strlen(g_szLineBuffer[j]) - strlen(last_break) - 2) < MAX_CHARS_PER_LINE )
|
||||
{
|
||||
strcat( g_szLineBuffer[j], " " );
|
||||
strcat( g_szLineBuffer[j], last_break );
|
||||
}
|
||||
}
|
||||
|
||||
*last_break = 0; // cut off the last string
|
||||
|
||||
EnsureTextFitsInOneLineAndWrapIfHaveTo( j );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ConsolePrint( pszBuf );
|
||||
|
||||
// find an empty string slot
|
||||
for ( i = 0; i < MAX_LINES; i++ )
|
||||
{
|
||||
if ( ! *g_szLineBuffer[i] )
|
||||
break;
|
||||
}
|
||||
if ( i == MAX_LINES )
|
||||
{
|
||||
// force scroll buffer up
|
||||
ScrollTextUp();
|
||||
i = MAX_LINES - 1;
|
||||
}
|
||||
|
||||
g_iNameLengths[i] = 0;
|
||||
g_pflNameColors[i] = NULL;
|
||||
|
||||
// if it's a say message, search for the players name in the string
|
||||
if ( *pszBuf == 2 && clientIndex > 0 )
|
||||
{
|
||||
GetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] );
|
||||
const char *pName = g_PlayerInfoList[clientIndex].name;
|
||||
|
||||
if ( pName )
|
||||
{
|
||||
const char *nameInString = strstr( pszBuf, pName );
|
||||
|
||||
if ( nameInString )
|
||||
{
|
||||
g_iNameLengths[i] = strlen( pName ) + (nameInString - pszBuf);
|
||||
g_pflNameColors[i] = GetClientColor( clientIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
strncpy( g_szLineBuffer[i], pszBuf, max(iBufSize -1, MAX_CHARS_PER_LINE-1) );
|
||||
|
||||
// make sure the text fits in one line
|
||||
EnsureTextFitsInOneLineAndWrapIfHaveTo( i );
|
||||
|
||||
// Set scroll time
|
||||
if ( i == 0 )
|
||||
{
|
||||
flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value;
|
||||
}
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
PlaySound( "misc/talk.wav", 1 );
|
||||
|
||||
if ( ScreenHeight >= 480 )
|
||||
Y_START = ScreenHeight - 60;
|
||||
else
|
||||
Y_START = ScreenHeight - 45;
|
||||
Y_START -= (line_height * (MAX_LINES+1));
|
||||
|
||||
}
|
||||
|
||||
void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
|
||||
{
|
||||
int line_width = 0;
|
||||
GetConsoleStringSize( g_szLineBuffer[line], &line_width, &line_height );
|
||||
|
||||
if ( (line_width + LINE_START) > MAX_LINE_WIDTH )
|
||||
{ // string is too long to fit on line
|
||||
// scan the string until we find what word is too long, and wrap the end of the sentence after the word
|
||||
int length = LINE_START;
|
||||
int tmp_len = 0;
|
||||
char *last_break = NULL;
|
||||
for ( char *x = g_szLineBuffer[line]; *x != 0; x++ )
|
||||
{
|
||||
// check for a color change, if so skip past it
|
||||
if ( x[0] == '/' && x[1] == '(' )
|
||||
{
|
||||
x += 2;
|
||||
// skip forward until past mode specifier
|
||||
while ( *x != 0 && *x != ')' )
|
||||
x++;
|
||||
|
||||
if ( *x != 0 )
|
||||
x++;
|
||||
|
||||
if ( *x == 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
char buf[2];
|
||||
buf[1] = 0;
|
||||
|
||||
if ( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character
|
||||
last_break = x;
|
||||
|
||||
buf[0] = *x; // get the length of the current character
|
||||
GetConsoleStringSize( buf, &tmp_len, &line_height );
|
||||
length += tmp_len;
|
||||
|
||||
if ( length > MAX_LINE_WIDTH )
|
||||
{ // needs to be broken up
|
||||
if ( !last_break )
|
||||
last_break = x-1;
|
||||
|
||||
x = last_break;
|
||||
|
||||
// find an empty string slot
|
||||
int j;
|
||||
do
|
||||
{
|
||||
for ( j = 0; j < MAX_LINES; j++ )
|
||||
{
|
||||
if ( ! *g_szLineBuffer[j] )
|
||||
break;
|
||||
}
|
||||
if ( j == MAX_LINES )
|
||||
{
|
||||
// need to make more room to display text, scroll stuff up then fix the pointers
|
||||
int linesmoved = ScrollTextUp();
|
||||
line -= linesmoved;
|
||||
last_break = last_break - (sizeof(g_szLineBuffer[0]) * linesmoved);
|
||||
}
|
||||
}
|
||||
while ( j == MAX_LINES );
|
||||
|
||||
// copy remaining string into next buffer, making sure it starts with a space character
|
||||
if ( (char)*last_break == (char)' ' )
|
||||
{
|
||||
int linelen = strlen(g_szLineBuffer[j]);
|
||||
int remaininglen = strlen(last_break);
|
||||
|
||||
if ( (linelen - remaininglen) <= MAX_CHARS_PER_LINE )
|
||||
strcat( g_szLineBuffer[j], last_break );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (strlen(g_szLineBuffer[j]) - strlen(last_break) - 2) < MAX_CHARS_PER_LINE )
|
||||
{
|
||||
strcat( g_szLineBuffer[j], " " );
|
||||
strcat( g_szLineBuffer[j], last_break );
|
||||
}
|
||||
}
|
||||
|
||||
*last_break = 0; // cut off the last string
|
||||
|
||||
EnsureTextFitsInOneLineAndWrapIfHaveTo( j );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,162 +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;
|
||||
}
|
||||
//======== (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;
|
||||
}
|
||||
|
|
|
@ -1,164 +1,164 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// status_icons.cpp
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
#include "event_api.h"
|
||||
|
||||
DECLARE_MESSAGE( m_StatusIcons, StatusIcon );
|
||||
|
||||
int CHudStatusIcons::Init( void )
|
||||
{
|
||||
HOOK_MESSAGE( StatusIcon );
|
||||
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
Reset();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudStatusIcons::VidInit( void )
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudStatusIcons::Reset( void )
|
||||
{
|
||||
memset( m_IconList, 0, sizeof m_IconList );
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// loop through icon list, and draw any valid icons drawing up from the middle of screen
|
||||
for ( int i = 0; i < MAX_ICONSPRITES; i++ )
|
||||
{
|
||||
if ( m_IconList[i].spr )
|
||||
{
|
||||
y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5;
|
||||
|
||||
SPR_Set( m_IconList[i].spr, m_IconList[i].r, m_IconList[i].g, m_IconList[i].b );
|
||||
SPR_DrawAdditive( 0, x, y, &m_IconList[i].rc );
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for StatusIcon message
|
||||
// accepts five values:
|
||||
// byte : TRUE = ENABLE icon, FALSE = DISABLE icon
|
||||
// string : the sprite name to display
|
||||
// byte : red
|
||||
// byte : green
|
||||
// byte : blue
|
||||
int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int ShouldEnable = READ_BYTE();
|
||||
char *pszIconName = READ_STRING();
|
||||
if ( ShouldEnable )
|
||||
{
|
||||
int r = READ_BYTE();
|
||||
int g = READ_BYTE();
|
||||
int b = READ_BYTE();
|
||||
EnableIcon( pszIconName, r, g, b );
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DisableIcon( pszIconName );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// add the icon to the icon list, and set it's drawing color
|
||||
void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue )
|
||||
{
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// status_icons.cpp
|
||||
//
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
#include "event_api.h"
|
||||
|
||||
DECLARE_MESSAGE( m_StatusIcons, StatusIcon );
|
||||
|
||||
int CHudStatusIcons::Init( void )
|
||||
{
|
||||
HOOK_MESSAGE( StatusIcon );
|
||||
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
Reset();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudStatusIcons::VidInit( void )
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudStatusIcons::Reset( void )
|
||||
{
|
||||
memset( m_IconList, 0, sizeof m_IconList );
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// loop through icon list, and draw any valid icons drawing up from the middle of screen
|
||||
for ( int i = 0; i < MAX_ICONSPRITES; i++ )
|
||||
{
|
||||
if ( m_IconList[i].spr )
|
||||
{
|
||||
y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5;
|
||||
|
||||
SPR_Set( m_IconList[i].spr, m_IconList[i].r, m_IconList[i].g, m_IconList[i].b );
|
||||
SPR_DrawAdditive( 0, x, y, &m_IconList[i].rc );
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for StatusIcon message
|
||||
// accepts five values:
|
||||
// byte : TRUE = ENABLE icon, FALSE = DISABLE icon
|
||||
// string : the sprite name to display
|
||||
// byte : red
|
||||
// byte : green
|
||||
// byte : blue
|
||||
int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int ShouldEnable = READ_BYTE();
|
||||
char *pszIconName = READ_STRING();
|
||||
if ( ShouldEnable )
|
||||
{
|
||||
int r = READ_BYTE();
|
||||
int g = READ_BYTE();
|
||||
int b = READ_BYTE();
|
||||
EnableIcon( pszIconName, r, g, b );
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DisableIcon( pszIconName );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// add the icon to the icon list, and set it's drawing color
|
||||
void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue )
|
||||
{
|
||||
int i;
|
||||
|
||||
// check to see if the sprite is in the current list
|
||||
for ( i = 0; i < MAX_ICONSPRITES; i++ )
|
||||
{
|
||||
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i == MAX_ICONSPRITES )
|
||||
{
|
||||
// icon not in list, so find an empty slot to add to
|
||||
for ( i = 0; i < MAX_ICONSPRITES; i++ )
|
||||
{
|
||||
if ( !m_IconList[i].spr )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we've run out of space in the list, overwrite the first icon
|
||||
if ( i == MAX_ICONSPRITES )
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
|
||||
// Load the sprite and add it to the list
|
||||
// the sprite must be listed in hud.txt
|
||||
int spr_index = gHUD.GetSpriteIndex( pszIconName );
|
||||
m_IconList[i].spr = gHUD.GetSprite( spr_index );
|
||||
m_IconList[i].rc = gHUD.GetSpriteRect( spr_index );
|
||||
m_IconList[i].r = red;
|
||||
m_IconList[i].g = green;
|
||||
m_IconList[i].b = blue;
|
||||
strcpy( m_IconList[i].szSpriteName, pszIconName );
|
||||
|
||||
// Hack: Play Timer sound when a grenade icon is played (in 0.8 seconds)
|
||||
if ( strstr(m_IconList[i].szSpriteName, "grenade") )
|
||||
{
|
||||
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer();
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( pthisplayer->index, pthisplayer->origin, CHAN_STATIC, "weapons/timer.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
|
||||
}
|
||||
}
|
||||
|
||||
void CHudStatusIcons::DisableIcon( char *pszIconName )
|
||||
{
|
||||
// find the sprite is in the current list
|
||||
for ( int i = 0; i < MAX_ICONSPRITES; i++ )
|
||||
{
|
||||
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
|
||||
{
|
||||
// clear the item from the list
|
||||
memset( &m_IconList[i], 0, sizeof( icon_sprite_t ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check to see if the sprite is in the current list
|
||||
for ( i = 0; i < MAX_ICONSPRITES; i++ )
|
||||
{
|
||||
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i == MAX_ICONSPRITES )
|
||||
{
|
||||
// icon not in list, so find an empty slot to add to
|
||||
for ( i = 0; i < MAX_ICONSPRITES; i++ )
|
||||
{
|
||||
if ( !m_IconList[i].spr )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we've run out of space in the list, overwrite the first icon
|
||||
if ( i == MAX_ICONSPRITES )
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
|
||||
// Load the sprite and add it to the list
|
||||
// the sprite must be listed in hud.txt
|
||||
int spr_index = gHUD.GetSpriteIndex( pszIconName );
|
||||
m_IconList[i].spr = gHUD.GetSprite( spr_index );
|
||||
m_IconList[i].rc = gHUD.GetSpriteRect( spr_index );
|
||||
m_IconList[i].r = red;
|
||||
m_IconList[i].g = green;
|
||||
m_IconList[i].b = blue;
|
||||
strcpy( m_IconList[i].szSpriteName, pszIconName );
|
||||
|
||||
// Hack: Play Timer sound when a grenade icon is played (in 0.8 seconds)
|
||||
if ( strstr(m_IconList[i].szSpriteName, "grenade") )
|
||||
{
|
||||
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer();
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( pthisplayer->index, pthisplayer->origin, CHAN_STATIC, "weapons/timer.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
|
||||
}
|
||||
}
|
||||
|
||||
void CHudStatusIcons::DisableIcon( char *pszIconName )
|
||||
{
|
||||
// find the sprite is in the current list
|
||||
for ( int i = 0; i < MAX_ICONSPRITES; i++ )
|
||||
{
|
||||
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
|
||||
{
|
||||
// clear the item from the list
|
||||
memset( &m_IconList[i], 0, sizeof( icon_sprite_t ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,265 +1,265 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// statusbar.cpp
|
||||
//
|
||||
// generic text status bar, set by game dll
|
||||
// runs across bottom of screen
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
DECLARE_MESSAGE( m_StatusBar, StatusText );
|
||||
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 );
|
||||
|
||||
HOOK_MESSAGE( StatusText );
|
||||
HOOK_MESSAGE( StatusValue );
|
||||
|
||||
Reset();
|
||||
|
||||
CVAR_CREATE( "hud_centerid", "0", FCVAR_ARCHIVE );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudStatusBar :: VidInit( void )
|
||||
{
|
||||
// Load sprites here
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudStatusBar :: Reset( void )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
m_iFlags &= ~HUD_ACTIVE; // start out inactive
|
||||
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ )
|
||||
m_szStatusText[i][0] = 0;
|
||||
memset( m_iStatusValues, 0, sizeof m_iStatusValues );
|
||||
|
||||
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 )
|
||||
{
|
||||
// localise string first
|
||||
char szBuffer[MAX_STATUSTEXT_LENGTH];
|
||||
memset( szBuffer, 0, sizeof szBuffer );
|
||||
gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH );
|
||||
|
||||
// parse m_szStatusText & m_iStatusValues into m_szStatusBar
|
||||
memset( m_szStatusBar[line_num], 0, MAX_STATUSTEXT_LENGTH );
|
||||
char *src = szBuffer;
|
||||
char *dst = m_szStatusBar[line_num];
|
||||
|
||||
char *src_start = src, *dst_start = dst;
|
||||
|
||||
while ( *src != 0 )
|
||||
{
|
||||
while ( *src == '\n' )
|
||||
src++; // skip over any newlines
|
||||
|
||||
if ( ((src - src_start) >= MAX_STATUSTEXT_LENGTH) || ((dst - dst_start) >= MAX_STATUSTEXT_LENGTH) )
|
||||
break;
|
||||
|
||||
int index = atoi( src );
|
||||
// should we draw this line?
|
||||
if ( (index >= 0 && index < MAX_STATUSBAR_VALUES) && (m_iStatusValues[index] != 0) )
|
||||
{ // parse this line and append result to the status bar
|
||||
while ( *src >= '0' && *src <= '9' )
|
||||
src++;
|
||||
|
||||
if ( *src == '\n' || *src == 0 )
|
||||
continue; // no more left in this text line
|
||||
|
||||
// copy the text, char by char, until we hit a % or a \n
|
||||
while ( *src != '\n' && *src != 0 )
|
||||
{
|
||||
if ( *src != '%' )
|
||||
{ // just copy the character
|
||||
*dst = *src;
|
||||
dst++, src++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the descriptor
|
||||
char valtype = *(++src); // move over %
|
||||
|
||||
// if it's a %, draw a % sign
|
||||
if ( valtype == '%' )
|
||||
{
|
||||
*dst = valtype;
|
||||
dst++, src++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// move over descriptor, then get and move over the index
|
||||
index = atoi( ++src );
|
||||
while ( *src >= '0' && *src <= '9' )
|
||||
src++;
|
||||
|
||||
if ( index >= 0 && index < MAX_STATUSBAR_VALUES )
|
||||
{
|
||||
int indexval = m_iStatusValues[index];
|
||||
|
||||
// get the string to substitute in place of the %XX
|
||||
char szRepString[MAX_PLAYER_NAME_LENGTH];
|
||||
switch ( valtype )
|
||||
{
|
||||
case 'p': // player name
|
||||
GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] );
|
||||
if ( g_PlayerInfoList[indexval].name != NULL )
|
||||
{
|
||||
strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH );
|
||||
m_pflNameColors[line_num] = GetClientColor( indexval );
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy( szRepString, "******" );
|
||||
}
|
||||
|
||||
break;
|
||||
case 'i': // number
|
||||
sprintf( szRepString, "%d", indexval );
|
||||
break;
|
||||
default:
|
||||
szRepString[0] = 0;
|
||||
}
|
||||
|
||||
for ( char *cp = szRepString; *cp != 0 && ((dst - dst_start) < MAX_STATUSTEXT_LENGTH); cp++, dst++ )
|
||||
*dst = *cp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// skip to next line of text
|
||||
while ( *src != 0 && *src != '\n' )
|
||||
src++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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") )
|
||||
{
|
||||
x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 );
|
||||
y = (ScreenHeight / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid"));
|
||||
}
|
||||
|
||||
if ( m_pflNameColors[i] )
|
||||
DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
|
||||
|
||||
DrawConsoleString( x, y, m_szStatusBar[i] );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for StatusText message
|
||||
// accepts two values:
|
||||
// byte: line number of status bar text
|
||||
// string: status bar text
|
||||
// this string describes how the status bar should be drawn
|
||||
// a semi-regular expression:
|
||||
// ( slotnum ([a..z] [%pX] [%iX])*)*
|
||||
// where slotnum is an index into the Value table (see below)
|
||||
// if slotnum is 0, the string is always drawn
|
||||
// if StatusValue[slotnum] != 0, the following string is drawn, upto the next newline - otherwise the text is skipped upto next newline
|
||||
// %pX, where X is an integer, will substitute a player name here, getting the player index from StatusValue[X]
|
||||
// %iX, where X is an integer, will substitute a number here, getting the number from StatusValue[X]
|
||||
int CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int line = READ_BYTE();
|
||||
|
||||
if ( line < 0 || line >= MAX_STATUSBAR_LINES )
|
||||
return 1;
|
||||
|
||||
strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH );
|
||||
m_szStatusText[line][MAX_STATUSTEXT_LENGTH-1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long)
|
||||
|
||||
if ( m_szStatusText[0] == 0 )
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags |= HUD_ACTIVE; // we have status text, so turn on the status bar
|
||||
|
||||
m_bReparseString = TRUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for StatusText message
|
||||
// accepts two values:
|
||||
// byte: index into the status value array
|
||||
// short: value to store
|
||||
int CHudStatusBar :: MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int index = READ_BYTE();
|
||||
if ( index < 1 || index >= MAX_STATUSBAR_VALUES )
|
||||
return 1; // index out of range
|
||||
|
||||
m_iStatusValues[index] = READ_SHORT();
|
||||
|
||||
m_bReparseString = TRUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// statusbar.cpp
|
||||
//
|
||||
// generic text status bar, set by game dll
|
||||
// runs across bottom of screen
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
DECLARE_MESSAGE( m_StatusBar, StatusText );
|
||||
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 );
|
||||
|
||||
HOOK_MESSAGE( StatusText );
|
||||
HOOK_MESSAGE( StatusValue );
|
||||
|
||||
Reset();
|
||||
|
||||
CVAR_CREATE( "hud_centerid", "0", FCVAR_ARCHIVE );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CHudStatusBar :: VidInit( void )
|
||||
{
|
||||
// Load sprites here
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CHudStatusBar :: Reset( void )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
m_iFlags &= ~HUD_ACTIVE; // start out inactive
|
||||
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ )
|
||||
m_szStatusText[i][0] = 0;
|
||||
memset( m_iStatusValues, 0, sizeof m_iStatusValues );
|
||||
|
||||
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 )
|
||||
{
|
||||
// localise string first
|
||||
char szBuffer[MAX_STATUSTEXT_LENGTH];
|
||||
memset( szBuffer, 0, sizeof szBuffer );
|
||||
gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH );
|
||||
|
||||
// parse m_szStatusText & m_iStatusValues into m_szStatusBar
|
||||
memset( m_szStatusBar[line_num], 0, MAX_STATUSTEXT_LENGTH );
|
||||
char *src = szBuffer;
|
||||
char *dst = m_szStatusBar[line_num];
|
||||
|
||||
char *src_start = src, *dst_start = dst;
|
||||
|
||||
while ( *src != 0 )
|
||||
{
|
||||
while ( *src == '\n' )
|
||||
src++; // skip over any newlines
|
||||
|
||||
if ( ((src - src_start) >= MAX_STATUSTEXT_LENGTH) || ((dst - dst_start) >= MAX_STATUSTEXT_LENGTH) )
|
||||
break;
|
||||
|
||||
int index = atoi( src );
|
||||
// should we draw this line?
|
||||
if ( (index >= 0 && index < MAX_STATUSBAR_VALUES) && (m_iStatusValues[index] != 0) )
|
||||
{ // parse this line and append result to the status bar
|
||||
while ( *src >= '0' && *src <= '9' )
|
||||
src++;
|
||||
|
||||
if ( *src == '\n' || *src == 0 )
|
||||
continue; // no more left in this text line
|
||||
|
||||
// copy the text, char by char, until we hit a % or a \n
|
||||
while ( *src != '\n' && *src != 0 )
|
||||
{
|
||||
if ( *src != '%' )
|
||||
{ // just copy the character
|
||||
*dst = *src;
|
||||
dst++, src++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the descriptor
|
||||
char valtype = *(++src); // move over %
|
||||
|
||||
// if it's a %, draw a % sign
|
||||
if ( valtype == '%' )
|
||||
{
|
||||
*dst = valtype;
|
||||
dst++, src++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// move over descriptor, then get and move over the index
|
||||
index = atoi( ++src );
|
||||
while ( *src >= '0' && *src <= '9' )
|
||||
src++;
|
||||
|
||||
if ( index >= 0 && index < MAX_STATUSBAR_VALUES )
|
||||
{
|
||||
int indexval = m_iStatusValues[index];
|
||||
|
||||
// get the string to substitute in place of the %XX
|
||||
char szRepString[MAX_PLAYER_NAME_LENGTH];
|
||||
switch ( valtype )
|
||||
{
|
||||
case 'p': // player name
|
||||
GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] );
|
||||
if ( g_PlayerInfoList[indexval].name != NULL )
|
||||
{
|
||||
strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH );
|
||||
m_pflNameColors[line_num] = GetClientColor( indexval );
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy( szRepString, "******" );
|
||||
}
|
||||
|
||||
break;
|
||||
case 'i': // number
|
||||
sprintf( szRepString, "%d", indexval );
|
||||
break;
|
||||
default:
|
||||
szRepString[0] = 0;
|
||||
}
|
||||
|
||||
for ( char *cp = szRepString; *cp != 0 && ((dst - dst_start) < MAX_STATUSTEXT_LENGTH); cp++, dst++ )
|
||||
*dst = *cp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// skip to next line of text
|
||||
while ( *src != 0 && *src != '\n' )
|
||||
src++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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") )
|
||||
{
|
||||
x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 );
|
||||
y = (ScreenHeight / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid"));
|
||||
}
|
||||
|
||||
if ( m_pflNameColors[i] )
|
||||
DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
|
||||
|
||||
DrawConsoleString( x, y, m_szStatusBar[i] );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for StatusText message
|
||||
// accepts two values:
|
||||
// byte: line number of status bar text
|
||||
// string: status bar text
|
||||
// this string describes how the status bar should be drawn
|
||||
// a semi-regular expression:
|
||||
// ( slotnum ([a..z] [%pX] [%iX])*)*
|
||||
// where slotnum is an index into the Value table (see below)
|
||||
// if slotnum is 0, the string is always drawn
|
||||
// if StatusValue[slotnum] != 0, the following string is drawn, upto the next newline - otherwise the text is skipped upto next newline
|
||||
// %pX, where X is an integer, will substitute a player name here, getting the player index from StatusValue[X]
|
||||
// %iX, where X is an integer, will substitute a number here, getting the number from StatusValue[X]
|
||||
int CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int line = READ_BYTE();
|
||||
|
||||
if ( line < 0 || line >= MAX_STATUSBAR_LINES )
|
||||
return 1;
|
||||
|
||||
strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH );
|
||||
m_szStatusText[line][MAX_STATUSTEXT_LENGTH-1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long)
|
||||
|
||||
if ( m_szStatusText[0] == 0 )
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags |= HUD_ACTIVE; // we have status text, so turn on the status bar
|
||||
|
||||
m_bReparseString = TRUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Message handler for StatusText message
|
||||
// accepts two values:
|
||||
// byte: index into the status value array
|
||||
// short: value to store
|
||||
int CHudStatusBar :: MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int index = READ_BYTE();
|
||||
if ( index < 1 || index >= MAX_STATUSBAR_VALUES )
|
||||
return 1; // index out of range
|
||||
|
||||
m_iStatusValues[index] = READ_SHORT();
|
||||
|
||||
m_bReparseString = TRUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,251 +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 );
|
||||
//========= 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 );
|
||||
}
|
|
@ -1,40 +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 );
|
||||
|
||||
//========= 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
|
|
@ -1,209 +1,209 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// text_message.cpp
|
||||
//
|
||||
// implementation of CHudTextMessage class
|
||||
//
|
||||
// this class routes messages through titles.txt for localisation
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
|
||||
DECLARE_MESSAGE( m_TextMessage, TextMsg );
|
||||
|
||||
int CHudTextMessage::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( TextMsg );
|
||||
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
Reset();
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
// Searches through the string for any msg names (indicated by a '#')
|
||||
// any found are looked up in titles.txt and the new message substituted
|
||||
// the new value is pushed into dst_buffer
|
||||
char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size )
|
||||
{
|
||||
char *dst = dst_buffer;
|
||||
for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- )
|
||||
{
|
||||
if ( *src == '#' )
|
||||
{
|
||||
// cut msg name out of string
|
||||
static char word_buf[255];
|
||||
char *wdst = word_buf, *word_start = src;
|
||||
for ( ++src ; (*src >= 'A' && *src <= 'z') || (*src >= '0' && *src <= '9'); wdst++, src++ )
|
||||
{
|
||||
*wdst = *src;
|
||||
}
|
||||
*wdst = 0;
|
||||
|
||||
// lookup msg name in titles.txt
|
||||
client_textmessage_t *clmsg = TextMessageGet( word_buf );
|
||||
if ( !clmsg || !(clmsg->pMessage) )
|
||||
{
|
||||
src = word_start;
|
||||
*dst = *src;
|
||||
dst++, src++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// copy string into message over the msg name
|
||||
for ( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ )
|
||||
{
|
||||
*dst = *wsrc;
|
||||
}
|
||||
*dst = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dst = *src;
|
||||
dst++, src++;
|
||||
*dst = 0;
|
||||
}
|
||||
}
|
||||
|
||||
dst_buffer[buffer_size-1] = 0; // ensure null termination
|
||||
return dst_buffer;
|
||||
}
|
||||
|
||||
// As above, but with a local static buffer
|
||||
char *CHudTextMessage::BufferedLocaliseTextString( const char *msg )
|
||||
{
|
||||
static char dst_buffer[1024];
|
||||
LocaliseTextString( msg, dst_buffer, 1024 );
|
||||
return dst_buffer;
|
||||
}
|
||||
|
||||
// Simplified version of LocaliseTextString; assumes string is only one word
|
||||
char *CHudTextMessage::LookupString( const char *msg, int *msg_dest )
|
||||
{
|
||||
if ( !msg )
|
||||
return "";
|
||||
|
||||
// '#' character indicates this is a reference to a string in titles.txt, and not the string itself
|
||||
if ( msg[0] == '#' )
|
||||
{
|
||||
// this is a message name, so look up the real message
|
||||
client_textmessage_t *clmsg = TextMessageGet( msg+1 );
|
||||
|
||||
if ( !clmsg || !(clmsg->pMessage) )
|
||||
return (char*)msg; // lookup failed, so return the original string
|
||||
|
||||
if ( msg_dest )
|
||||
{
|
||||
// check to see if titles.txt info overrides msg destination
|
||||
// if clmsg->effect is less than 0, then clmsg->effect holds -1 * message_destination
|
||||
if ( clmsg->effect < 0 ) //
|
||||
*msg_dest = -clmsg->effect;
|
||||
}
|
||||
|
||||
return (char*)clmsg->pMessage;
|
||||
}
|
||||
else
|
||||
{ // nothing special about this message, so just return the same string
|
||||
return (char*)msg;
|
||||
}
|
||||
}
|
||||
|
||||
void StripEndNewlineFromString( char *str )
|
||||
{
|
||||
int s = strlen( str ) - 1;
|
||||
if ( str[s] == '\n' || str[s] == '\r' )
|
||||
str[s] = 0;
|
||||
}
|
||||
|
||||
// converts all '\r' characters to '\n', so that the engine can deal with the properly
|
||||
// returns a pointer to str
|
||||
char* ConvertCRtoNL( char *str )
|
||||
{
|
||||
for ( char *ch = str; *ch != 0; ch++ )
|
||||
if ( *ch == '\r' )
|
||||
*ch = '\n';
|
||||
return str;
|
||||
}
|
||||
|
||||
// Message handler for text messages
|
||||
// displays a string, looking them up from the titles.txt file, which can be localised
|
||||
// parameters:
|
||||
// byte: message direction ( HUD_PRINTCONSOLE, HUD_PRINTNOTIFY, HUD_PRINTCENTER, HUD_PRINTTALK )
|
||||
// string: message
|
||||
// optional parameters:
|
||||
// string: message parameter 1
|
||||
// string: message parameter 2
|
||||
// string: message parameter 3
|
||||
// string: message parameter 4
|
||||
// any string that starts with the character '#' is a message name, and is used to look up the real message in titles.txt
|
||||
// the next (optional) one to four strings are parameters for that string (which can also be message names if they begin with '#')
|
||||
int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int msg_dest = READ_BYTE();
|
||||
|
||||
static char szBuf[6][128];
|
||||
char *msg_text = LookupString( READ_STRING(), &msg_dest );
|
||||
msg_text = strcpy( szBuf[0], msg_text );
|
||||
|
||||
// keep reading strings and using C format strings for subsituting the strings into the localised text string
|
||||
char *sstr1 = LookupString( READ_STRING() );
|
||||
sstr1 = strcpy( szBuf[1], sstr1 );
|
||||
StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines
|
||||
char *sstr2 = LookupString( READ_STRING() );
|
||||
sstr2 = strcpy( szBuf[2], sstr2 );
|
||||
StripEndNewlineFromString( sstr2 );
|
||||
char *sstr3 = LookupString( READ_STRING() );
|
||||
sstr3 = strcpy( szBuf[3], sstr3 );
|
||||
StripEndNewlineFromString( sstr3 );
|
||||
char *sstr4 = LookupString( READ_STRING() );
|
||||
sstr4 = strcpy( szBuf[4], sstr4 );
|
||||
StripEndNewlineFromString( sstr4 );
|
||||
char *psz = szBuf[5];
|
||||
|
||||
switch ( msg_dest )
|
||||
{
|
||||
case HUD_PRINTCENTER:
|
||||
sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
||||
CenterPrint( ConvertCRtoNL( psz ) );
|
||||
break;
|
||||
|
||||
case HUD_PRINTNOTIFY:
|
||||
psz[0] = 1; // mark this message to go into the notify buffer
|
||||
sprintf( psz+1, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
||||
ConsolePrint( ConvertCRtoNL( psz ) );
|
||||
break;
|
||||
|
||||
case HUD_PRINTTALK:
|
||||
sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
||||
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 );
|
||||
break;
|
||||
|
||||
case HUD_PRINTCONSOLE:
|
||||
sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
||||
ConsolePrint( ConvertCRtoNL( psz ) );
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// text_message.cpp
|
||||
//
|
||||
// implementation of CHudTextMessage class
|
||||
//
|
||||
// this class routes messages through titles.txt for localisation
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
|
||||
DECLARE_MESSAGE( m_TextMessage, TextMsg );
|
||||
|
||||
int CHudTextMessage::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( TextMsg );
|
||||
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
Reset();
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
// Searches through the string for any msg names (indicated by a '#')
|
||||
// any found are looked up in titles.txt and the new message substituted
|
||||
// the new value is pushed into dst_buffer
|
||||
char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size )
|
||||
{
|
||||
char *dst = dst_buffer;
|
||||
for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- )
|
||||
{
|
||||
if ( *src == '#' )
|
||||
{
|
||||
// cut msg name out of string
|
||||
static char word_buf[255];
|
||||
char *wdst = word_buf, *word_start = src;
|
||||
for ( ++src ; (*src >= 'A' && *src <= 'z') || (*src >= '0' && *src <= '9'); wdst++, src++ )
|
||||
{
|
||||
*wdst = *src;
|
||||
}
|
||||
*wdst = 0;
|
||||
|
||||
// lookup msg name in titles.txt
|
||||
client_textmessage_t *clmsg = TextMessageGet( word_buf );
|
||||
if ( !clmsg || !(clmsg->pMessage) )
|
||||
{
|
||||
src = word_start;
|
||||
*dst = *src;
|
||||
dst++, src++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// copy string into message over the msg name
|
||||
for ( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ )
|
||||
{
|
||||
*dst = *wsrc;
|
||||
}
|
||||
*dst = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dst = *src;
|
||||
dst++, src++;
|
||||
*dst = 0;
|
||||
}
|
||||
}
|
||||
|
||||
dst_buffer[buffer_size-1] = 0; // ensure null termination
|
||||
return dst_buffer;
|
||||
}
|
||||
|
||||
// As above, but with a local static buffer
|
||||
char *CHudTextMessage::BufferedLocaliseTextString( const char *msg )
|
||||
{
|
||||
static char dst_buffer[1024];
|
||||
LocaliseTextString( msg, dst_buffer, 1024 );
|
||||
return dst_buffer;
|
||||
}
|
||||
|
||||
// Simplified version of LocaliseTextString; assumes string is only one word
|
||||
char *CHudTextMessage::LookupString( const char *msg, int *msg_dest )
|
||||
{
|
||||
if ( !msg )
|
||||
return "";
|
||||
|
||||
// '#' character indicates this is a reference to a string in titles.txt, and not the string itself
|
||||
if ( msg[0] == '#' )
|
||||
{
|
||||
// this is a message name, so look up the real message
|
||||
client_textmessage_t *clmsg = TextMessageGet( msg+1 );
|
||||
|
||||
if ( !clmsg || !(clmsg->pMessage) )
|
||||
return (char*)msg; // lookup failed, so return the original string
|
||||
|
||||
if ( msg_dest )
|
||||
{
|
||||
// check to see if titles.txt info overrides msg destination
|
||||
// if clmsg->effect is less than 0, then clmsg->effect holds -1 * message_destination
|
||||
if ( clmsg->effect < 0 ) //
|
||||
*msg_dest = -clmsg->effect;
|
||||
}
|
||||
|
||||
return (char*)clmsg->pMessage;
|
||||
}
|
||||
else
|
||||
{ // nothing special about this message, so just return the same string
|
||||
return (char*)msg;
|
||||
}
|
||||
}
|
||||
|
||||
void StripEndNewlineFromString( char *str )
|
||||
{
|
||||
int s = strlen( str ) - 1;
|
||||
if ( str[s] == '\n' || str[s] == '\r' )
|
||||
str[s] = 0;
|
||||
}
|
||||
|
||||
// converts all '\r' characters to '\n', so that the engine can deal with the properly
|
||||
// returns a pointer to str
|
||||
char* ConvertCRtoNL( char *str )
|
||||
{
|
||||
for ( char *ch = str; *ch != 0; ch++ )
|
||||
if ( *ch == '\r' )
|
||||
*ch = '\n';
|
||||
return str;
|
||||
}
|
||||
|
||||
// Message handler for text messages
|
||||
// displays a string, looking them up from the titles.txt file, which can be localised
|
||||
// parameters:
|
||||
// byte: message direction ( HUD_PRINTCONSOLE, HUD_PRINTNOTIFY, HUD_PRINTCENTER, HUD_PRINTTALK )
|
||||
// string: message
|
||||
// optional parameters:
|
||||
// string: message parameter 1
|
||||
// string: message parameter 2
|
||||
// string: message parameter 3
|
||||
// string: message parameter 4
|
||||
// any string that starts with the character '#' is a message name, and is used to look up the real message in titles.txt
|
||||
// the next (optional) one to four strings are parameters for that string (which can also be message names if they begin with '#')
|
||||
int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int msg_dest = READ_BYTE();
|
||||
|
||||
static char szBuf[6][128];
|
||||
char *msg_text = LookupString( READ_STRING(), &msg_dest );
|
||||
msg_text = strcpy( szBuf[0], msg_text );
|
||||
|
||||
// keep reading strings and using C format strings for subsituting the strings into the localised text string
|
||||
char *sstr1 = LookupString( READ_STRING() );
|
||||
sstr1 = strcpy( szBuf[1], sstr1 );
|
||||
StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines
|
||||
char *sstr2 = LookupString( READ_STRING() );
|
||||
sstr2 = strcpy( szBuf[2], sstr2 );
|
||||
StripEndNewlineFromString( sstr2 );
|
||||
char *sstr3 = LookupString( READ_STRING() );
|
||||
sstr3 = strcpy( szBuf[3], sstr3 );
|
||||
StripEndNewlineFromString( sstr3 );
|
||||
char *sstr4 = LookupString( READ_STRING() );
|
||||
sstr4 = strcpy( szBuf[4], sstr4 );
|
||||
StripEndNewlineFromString( sstr4 );
|
||||
char *psz = szBuf[5];
|
||||
|
||||
switch ( msg_dest )
|
||||
{
|
||||
case HUD_PRINTCENTER:
|
||||
sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
||||
CenterPrint( ConvertCRtoNL( psz ) );
|
||||
break;
|
||||
|
||||
case HUD_PRINTNOTIFY:
|
||||
psz[0] = 1; // mark this message to go into the notify buffer
|
||||
sprintf( psz+1, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
||||
ConsolePrint( ConvertCRtoNL( psz ) );
|
||||
break;
|
||||
|
||||
case HUD_PRINTTALK:
|
||||
sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
||||
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 );
|
||||
break;
|
||||
|
||||
case HUD_PRINTCONSOLE:
|
||||
sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 );
|
||||
ConsolePrint( ConvertCRtoNL( psz ) );
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
2778
cl_dll/tf_defs.h
2778
cl_dll/tf_defs.h
File diff suppressed because it is too large
Load Diff
170
cl_dll/train.cpp
170
cl_dll/train.cpp
|
@ -1,85 +1,85 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// Train.cpp
|
||||
//
|
||||
// implementation of CHudAmmo class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Train, Train )
|
||||
|
||||
|
||||
int CHudTrain::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Train );
|
||||
|
||||
m_iPos = 0;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudTrain::VidInit(void)
|
||||
{
|
||||
m_hSprite = 0;
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudTrain::Draw(float fTime)
|
||||
{
|
||||
if ( !m_hSprite )
|
||||
m_hSprite = LoadSprite("sprites/%d_train.spr");
|
||||
|
||||
if (m_iPos)
|
||||
{
|
||||
int r, g, b, x, y;
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
// This should show up to the right and part way up the armor number
|
||||
y = ScreenHeight - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight;
|
||||
x = ScreenWidth/3 + SPR_Width(m_hSprite,0)/4;
|
||||
|
||||
SPR_DrawAdditive( m_iPos - 1, x, y, NULL);
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHudTrain::MsgFunc_Train(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
// update Train data
|
||||
m_iPos = READ_BYTE();
|
||||
|
||||
if (m_iPos)
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// Train.cpp
|
||||
//
|
||||
// implementation of CHudAmmo class
|
||||
//
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Train, Train )
|
||||
|
||||
|
||||
int CHudTrain::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Train );
|
||||
|
||||
m_iPos = 0;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudTrain::VidInit(void)
|
||||
{
|
||||
m_hSprite = 0;
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int CHudTrain::Draw(float fTime)
|
||||
{
|
||||
if ( !m_hSprite )
|
||||
m_hSprite = LoadSprite("sprites/%d_train.spr");
|
||||
|
||||
if (m_iPos)
|
||||
{
|
||||
int r, g, b, x, y;
|
||||
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
|
||||
// This should show up to the right and part way up the armor number
|
||||
y = ScreenHeight - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight;
|
||||
x = ScreenWidth/3 + SPR_Width(m_hSprite,0)/4;
|
||||
|
||||
SPR_DrawAdditive( m_iPos - 1, x, y, NULL);
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CHudTrain::MsgFunc_Train(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
// update Train data
|
||||
m_iPos = READ_BYTE();
|
||||
|
||||
if (m_iPos)
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
244
cl_dll/tri.cpp
244
cl_dll/tri.cpp
|
@ -1,122 +1,122 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// Triangle rendering, if any
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
// Triangle rendering apis are in gEngfuncs.pTriAPI
|
||||
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "triangleapi.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void DLLEXPORT HUD_DrawNormalTriangles( void );
|
||||
void DLLEXPORT HUD_DrawTransparentTriangles( void );
|
||||
};
|
||||
|
||||
//#define TEST_IT
|
||||
#if defined( TEST_IT )
|
||||
|
||||
/*
|
||||
=================
|
||||
Draw_Triangles
|
||||
|
||||
Example routine. Draws a sprite offset from the player origin.
|
||||
=================
|
||||
*/
|
||||
void Draw_Triangles( void )
|
||||
{
|
||||
cl_entity_t *player;
|
||||
vec3_t org;
|
||||
|
||||
// Load it up with some bogus data
|
||||
player = gEngfuncs.GetLocalPlayer();
|
||||
if ( !player )
|
||||
return;
|
||||
|
||||
org = player->origin;
|
||||
|
||||
org.x += 50;
|
||||
org.y += 50;
|
||||
|
||||
if (gHUD.m_hsprCursor == 0)
|
||||
{
|
||||
char sz[256];
|
||||
sprintf( sz, "sprites/cursor.spr" );
|
||||
gHUD.m_hsprCursor = SPR_Load( sz );
|
||||
}
|
||||
|
||||
if ( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a triangle, sigh
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
|
||||
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
|
||||
// Overload p->color with index into tracer palette, p->packedColor with brightness
|
||||
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 );
|
||||
// UNDONE: This gouraud shading causes tracers to disappear on some cards (permedia2)
|
||||
gEngfuncs.pTriAPI->Brightness( 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( org.x, org.y, org.z );
|
||||
|
||||
gEngfuncs.pTriAPI->Brightness( 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( org.x, org.y + 50, org.z );
|
||||
|
||||
gEngfuncs.pTriAPI->Brightness( 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y + 50, org.z );
|
||||
|
||||
gEngfuncs.pTriAPI->Brightness( 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y, org.z );
|
||||
|
||||
gEngfuncs.pTriAPI->End();
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
=================
|
||||
HUD_DrawNormalTriangles
|
||||
|
||||
Non-transparent triangles-- add them here
|
||||
=================
|
||||
*/
|
||||
void DLLEXPORT HUD_DrawNormalTriangles( void )
|
||||
{
|
||||
|
||||
gHUD.m_Spectator.DrawOverview();
|
||||
|
||||
#if defined( TEST_IT )
|
||||
// Draw_Triangles();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
HUD_DrawTransparentTriangles
|
||||
|
||||
Render any triangles with transparent rendermode needs here
|
||||
=================
|
||||
*/
|
||||
void DLLEXPORT HUD_DrawTransparentTriangles( void )
|
||||
{
|
||||
|
||||
#if defined( TEST_IT )
|
||||
// Draw_Triangles();
|
||||
#endif
|
||||
}
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// Triangle rendering, if any
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
// Triangle rendering apis are in gEngfuncs.pTriAPI
|
||||
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "triangleapi.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void DLLEXPORT HUD_DrawNormalTriangles( void );
|
||||
void DLLEXPORT HUD_DrawTransparentTriangles( void );
|
||||
};
|
||||
|
||||
//#define TEST_IT
|
||||
#if defined( TEST_IT )
|
||||
|
||||
/*
|
||||
=================
|
||||
Draw_Triangles
|
||||
|
||||
Example routine. Draws a sprite offset from the player origin.
|
||||
=================
|
||||
*/
|
||||
void Draw_Triangles( void )
|
||||
{
|
||||
cl_entity_t *player;
|
||||
vec3_t org;
|
||||
|
||||
// Load it up with some bogus data
|
||||
player = gEngfuncs.GetLocalPlayer();
|
||||
if ( !player )
|
||||
return;
|
||||
|
||||
org = player->origin;
|
||||
|
||||
org.x += 50;
|
||||
org.y += 50;
|
||||
|
||||
if (gHUD.m_hsprCursor == 0)
|
||||
{
|
||||
char sz[256];
|
||||
sprintf( sz, "sprites/cursor.spr" );
|
||||
gHUD.m_hsprCursor = SPR_Load( sz );
|
||||
}
|
||||
|
||||
if ( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a triangle, sigh
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
|
||||
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
|
||||
// Overload p->color with index into tracer palette, p->packedColor with brightness
|
||||
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 );
|
||||
// UNDONE: This gouraud shading causes tracers to disappear on some cards (permedia2)
|
||||
gEngfuncs.pTriAPI->Brightness( 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( org.x, org.y, org.z );
|
||||
|
||||
gEngfuncs.pTriAPI->Brightness( 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( org.x, org.y + 50, org.z );
|
||||
|
||||
gEngfuncs.pTriAPI->Brightness( 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y + 50, org.z );
|
||||
|
||||
gEngfuncs.pTriAPI->Brightness( 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y, org.z );
|
||||
|
||||
gEngfuncs.pTriAPI->End();
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
=================
|
||||
HUD_DrawNormalTriangles
|
||||
|
||||
Non-transparent triangles-- add them here
|
||||
=================
|
||||
*/
|
||||
void DLLEXPORT HUD_DrawNormalTriangles( void )
|
||||
{
|
||||
|
||||
gHUD.m_Spectator.DrawOverview();
|
||||
|
||||
#if defined( TEST_IT )
|
||||
// Draw_Triangles();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
HUD_DrawTransparentTriangles
|
||||
|
||||
Render any triangles with transparent rendermode needs here
|
||||
=================
|
||||
*/
|
||||
void DLLEXPORT HUD_DrawTransparentTriangles( void )
|
||||
{
|
||||
|
||||
#if defined( TEST_IT )
|
||||
// Draw_Triangles();
|
||||
#endif
|
||||
}
|
||||
|
|
266
cl_dll/util.cpp
266
cl_dll/util.cpp
|
@ -1,133 +1,133 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// util.cpp
|
||||
//
|
||||
// implementation of class-less helper functions
|
||||
//
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
extern vec3_t vec3_origin;
|
||||
|
||||
double sqrt(double x);
|
||||
|
||||
float Length(const float *v)
|
||||
{
|
||||
int i;
|
||||
float length;
|
||||
|
||||
length = 0;
|
||||
for (i=0 ; i< 3 ; i++)
|
||||
length += v[i]*v[i];
|
||||
length = sqrt (length); // FIXME
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void VectorAngles( const float *forward, float *angles )
|
||||
{
|
||||
float tmp, yaw, pitch;
|
||||
|
||||
if (forward[1] == 0 && forward[0] == 0)
|
||||
{
|
||||
yaw = 0;
|
||||
if (forward[2] > 0)
|
||||
pitch = 90;
|
||||
else
|
||||
pitch = 270;
|
||||
}
|
||||
else
|
||||
{
|
||||
yaw = (atan2(forward[1], forward[0]) * 180 / M_PI);
|
||||
if (yaw < 0)
|
||||
yaw += 360;
|
||||
|
||||
tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]);
|
||||
pitch = (atan2(forward[2], tmp) * 180 / M_PI);
|
||||
if (pitch < 0)
|
||||
pitch += 360;
|
||||
}
|
||||
|
||||
angles[0] = pitch;
|
||||
angles[1] = yaw;
|
||||
angles[2] = 0;
|
||||
}
|
||||
|
||||
float VectorNormalize (float *v)
|
||||
{
|
||||
float length, ilength;
|
||||
|
||||
length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
|
||||
length = sqrt (length); // FIXME
|
||||
|
||||
if (length)
|
||||
{
|
||||
ilength = 1/length;
|
||||
v[0] *= ilength;
|
||||
v[1] *= ilength;
|
||||
v[2] *= ilength;
|
||||
}
|
||||
|
||||
return length;
|
||||
|
||||
}
|
||||
|
||||
void VectorInverse ( float *v )
|
||||
{
|
||||
v[0] = -v[0];
|
||||
v[1] = -v[1];
|
||||
v[2] = -v[2];
|
||||
}
|
||||
|
||||
void VectorScale (const float *in, float scale, float *out)
|
||||
{
|
||||
out[0] = in[0]*scale;
|
||||
out[1] = in[1]*scale;
|
||||
out[2] = in[2]*scale;
|
||||
}
|
||||
|
||||
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc)
|
||||
{
|
||||
vecc[0] = veca[0] + scale*vecb[0];
|
||||
vecc[1] = veca[1] + scale*vecb[1];
|
||||
vecc[2] = veca[2] + scale*vecb[2];
|
||||
}
|
||||
|
||||
HSPRITE LoadSprite(const char *pszName)
|
||||
{
|
||||
int i;
|
||||
char sz[256];
|
||||
|
||||
if (ScreenWidth < 640)
|
||||
i = 320;
|
||||
else
|
||||
i = 640;
|
||||
|
||||
sprintf(sz, pszName, i);
|
||||
|
||||
return SPR_Load(sz);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// util.cpp
|
||||
//
|
||||
// implementation of class-less helper functions
|
||||
//
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
extern vec3_t vec3_origin;
|
||||
|
||||
double sqrt(double x);
|
||||
|
||||
float Length(const float *v)
|
||||
{
|
||||
int i;
|
||||
float length;
|
||||
|
||||
length = 0;
|
||||
for (i=0 ; i< 3 ; i++)
|
||||
length += v[i]*v[i];
|
||||
length = sqrt (length); // FIXME
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void VectorAngles( const float *forward, float *angles )
|
||||
{
|
||||
float tmp, yaw, pitch;
|
||||
|
||||
if (forward[1] == 0 && forward[0] == 0)
|
||||
{
|
||||
yaw = 0;
|
||||
if (forward[2] > 0)
|
||||
pitch = 90;
|
||||
else
|
||||
pitch = 270;
|
||||
}
|
||||
else
|
||||
{
|
||||
yaw = (atan2(forward[1], forward[0]) * 180 / M_PI);
|
||||
if (yaw < 0)
|
||||
yaw += 360;
|
||||
|
||||
tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]);
|
||||
pitch = (atan2(forward[2], tmp) * 180 / M_PI);
|
||||
if (pitch < 0)
|
||||
pitch += 360;
|
||||
}
|
||||
|
||||
angles[0] = pitch;
|
||||
angles[1] = yaw;
|
||||
angles[2] = 0;
|
||||
}
|
||||
|
||||
float VectorNormalize (float *v)
|
||||
{
|
||||
float length, ilength;
|
||||
|
||||
length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
|
||||
length = sqrt (length); // FIXME
|
||||
|
||||
if (length)
|
||||
{
|
||||
ilength = 1/length;
|
||||
v[0] *= ilength;
|
||||
v[1] *= ilength;
|
||||
v[2] *= ilength;
|
||||
}
|
||||
|
||||
return length;
|
||||
|
||||
}
|
||||
|
||||
void VectorInverse ( float *v )
|
||||
{
|
||||
v[0] = -v[0];
|
||||
v[1] = -v[1];
|
||||
v[2] = -v[2];
|
||||
}
|
||||
|
||||
void VectorScale (const float *in, float scale, float *out)
|
||||
{
|
||||
out[0] = in[0]*scale;
|
||||
out[1] = in[1]*scale;
|
||||
out[2] = in[2]*scale;
|
||||
}
|
||||
|
||||
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc)
|
||||
{
|
||||
vecc[0] = veca[0] + scale*vecb[0];
|
||||
vecc[1] = veca[1] + scale*vecb[1];
|
||||
vecc[2] = veca[2] + scale*vecb[2];
|
||||
}
|
||||
|
||||
HSPRITE LoadSprite(const char *pszName)
|
||||
{
|
||||
int i;
|
||||
char sz[256];
|
||||
|
||||
if (ScreenWidth < 640)
|
||||
i = 320;
|
||||
else
|
||||
i = 640;
|
||||
|
||||
sprintf(sz, pszName, i);
|
||||
|
||||
return SPR_Load(sz);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,121 +1,121 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// Vector.h
|
||||
// A subset of the extdll.h in the project HL Entity DLL
|
||||
//
|
||||
|
||||
// Misc C-runtime library headers
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
|
||||
// Header file containing definition of globalvars_t and entvars_t
|
||||
typedef unsigned int func_t; //
|
||||
typedef unsigned int string_t; // from engine's pr_comp.h;
|
||||
typedef float vec_t; // needed before including progdefs.h
|
||||
|
||||
//=========================================================
|
||||
// 2DVector - used for many pathfinding and many other
|
||||
// operations that are treated as planar rather than 3d.
|
||||
//=========================================================
|
||||
class Vector2D
|
||||
{
|
||||
public:
|
||||
inline Vector2D(void) { }
|
||||
inline Vector2D(float X, float Y) { x = X; y = Y; }
|
||||
inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); }
|
||||
inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); }
|
||||
inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); }
|
||||
inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); }
|
||||
|
||||
inline float Length(void) const { return (float)sqrt(x*x + y*y ); }
|
||||
|
||||
inline Vector2D Normalize ( void ) const
|
||||
{
|
||||
Vector2D vec2;
|
||||
|
||||
float flLen = Length();
|
||||
if ( flLen == 0 )
|
||||
{
|
||||
return Vector2D( (float)0, (float)0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
flLen = 1 / flLen;
|
||||
return Vector2D( x * flLen, y * flLen );
|
||||
}
|
||||
}
|
||||
|
||||
vec_t x, y;
|
||||
};
|
||||
|
||||
inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); }
|
||||
inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; }
|
||||
|
||||
//=========================================================
|
||||
// 3D Vector
|
||||
//=========================================================
|
||||
class Vector // same data-layout as engine's vec3_t,
|
||||
{ // which is a vec_t[3]
|
||||
public:
|
||||
// Construction/destruction
|
||||
inline Vector(void) { }
|
||||
inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; }
|
||||
inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; }
|
||||
inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; }
|
||||
inline Vector(const Vector& v) { x = v.x; y = v.y; z = v.z; }
|
||||
inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; }
|
||||
|
||||
// Operators
|
||||
inline Vector operator-(void) const { return Vector(-x,-y,-z); }
|
||||
inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; }
|
||||
inline int operator!=(const Vector& v) const { return !(*this==v); }
|
||||
inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); }
|
||||
inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); }
|
||||
inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); }
|
||||
inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); }
|
||||
|
||||
// Methods
|
||||
inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; }
|
||||
inline float Length(void) const { return (float)sqrt(x*x + y*y + z*z); }
|
||||
operator float *() { return &x; } // Vectors will now automatically convert to float * when needed
|
||||
operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed
|
||||
inline Vector Normalize(void) const
|
||||
{
|
||||
float flLen = Length();
|
||||
if (flLen == 0) return Vector(0,0,1); // ????
|
||||
flLen = 1 / flLen;
|
||||
return Vector(x * flLen, y * flLen, z * flLen);
|
||||
}
|
||||
|
||||
inline Vector2D Make2D ( void ) const
|
||||
{
|
||||
Vector2D Vec2;
|
||||
|
||||
Vec2.x = x;
|
||||
Vec2.y = y;
|
||||
|
||||
return Vec2;
|
||||
}
|
||||
inline float Length2D(void) const { return (float)sqrt(x*x + y*y); }
|
||||
|
||||
// Members
|
||||
vec_t x, y, z;
|
||||
};
|
||||
inline Vector operator*(float fl, const Vector& v) { return v * fl; }
|
||||
inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); }
|
||||
inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); }
|
||||
|
||||
#define vec3_t Vector
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// Vector.h
|
||||
// A subset of the extdll.h in the project HL Entity DLL
|
||||
//
|
||||
|
||||
// Misc C-runtime library headers
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
|
||||
// Header file containing definition of globalvars_t and entvars_t
|
||||
typedef unsigned int func_t; //
|
||||
typedef unsigned int string_t; // from engine's pr_comp.h;
|
||||
typedef float vec_t; // needed before including progdefs.h
|
||||
|
||||
//=========================================================
|
||||
// 2DVector - used for many pathfinding and many other
|
||||
// operations that are treated as planar rather than 3d.
|
||||
//=========================================================
|
||||
class Vector2D
|
||||
{
|
||||
public:
|
||||
inline Vector2D(void) { }
|
||||
inline Vector2D(float X, float Y) { x = X; y = Y; }
|
||||
inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); }
|
||||
inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); }
|
||||
inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); }
|
||||
inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); }
|
||||
|
||||
inline float Length(void) const { return (float)sqrt(x*x + y*y ); }
|
||||
|
||||
inline Vector2D Normalize ( void ) const
|
||||
{
|
||||
Vector2D vec2;
|
||||
|
||||
float flLen = Length();
|
||||
if ( flLen == 0 )
|
||||
{
|
||||
return Vector2D( (float)0, (float)0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
flLen = 1 / flLen;
|
||||
return Vector2D( x * flLen, y * flLen );
|
||||
}
|
||||
}
|
||||
|
||||
vec_t x, y;
|
||||
};
|
||||
|
||||
inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); }
|
||||
inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; }
|
||||
|
||||
//=========================================================
|
||||
// 3D Vector
|
||||
//=========================================================
|
||||
class Vector // same data-layout as engine's vec3_t,
|
||||
{ // which is a vec_t[3]
|
||||
public:
|
||||
// Construction/destruction
|
||||
inline Vector(void) { }
|
||||
inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; }
|
||||
inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; }
|
||||
inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; }
|
||||
inline Vector(const Vector& v) { x = v.x; y = v.y; z = v.z; }
|
||||
inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; }
|
||||
|
||||
// Operators
|
||||
inline Vector operator-(void) const { return Vector(-x,-y,-z); }
|
||||
inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; }
|
||||
inline int operator!=(const Vector& v) const { return !(*this==v); }
|
||||
inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); }
|
||||
inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); }
|
||||
inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); }
|
||||
inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); }
|
||||
|
||||
// Methods
|
||||
inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; }
|
||||
inline float Length(void) const { return (float)sqrt(x*x + y*y + z*z); }
|
||||
operator float *() { return &x; } // Vectors will now automatically convert to float * when needed
|
||||
operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed
|
||||
inline Vector Normalize(void) const
|
||||
{
|
||||
float flLen = Length();
|
||||
if (flLen == 0) return Vector(0,0,1); // ????
|
||||
flLen = 1 / flLen;
|
||||
return Vector(x * flLen, y * flLen, z * flLen);
|
||||
}
|
||||
|
||||
inline Vector2D Make2D ( void ) const
|
||||
{
|
||||
Vector2D Vec2;
|
||||
|
||||
Vec2.x = x;
|
||||
Vec2.y = y;
|
||||
|
||||
return Vec2;
|
||||
}
|
||||
inline float Length2D(void) const { return (float)sqrt(x*x + y*y); }
|
||||
|
||||
// Members
|
||||
vec_t x, y, z;
|
||||
};
|
||||
inline Vector operator*(float fl, const Vector& v) { return v * fl; }
|
||||
inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); }
|
||||
inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); }
|
||||
|
||||
#define vec3_t Vector
|
||||
|
|
3384
cl_dll/view.cpp
3384
cl_dll/view.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,15 +1,15 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined ( VIEWH )
|
||||
#define VIEWH
|
||||
#pragma once
|
||||
|
||||
void V_StartPitchDrift( void );
|
||||
void V_StopPitchDrift( void );
|
||||
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined ( VIEWH )
|
||||
#define VIEWH
|
||||
#pragma once
|
||||
|
||||
void V_StartPitchDrift( void );
|
||||
void V_StopPitchDrift( void );
|
||||
|
||||
#endif // !VIEWH
|
118
common/beamdef.h
118
common/beamdef.h
|
@ -1,60 +1,60 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef BEAMDEF_H
|
||||
#define BEAMDEF_H
|
||||
|
||||
#define FBEAM_STARTENTITY 0x00000001
|
||||
#define FBEAM_ENDENTITY 0x00000002
|
||||
#define FBEAM_FADEIN 0x00000004
|
||||
#define FBEAM_FADEOUT 0x00000008
|
||||
#define FBEAM_SINENOISE 0x00000010
|
||||
#define FBEAM_SOLID 0x00000020
|
||||
#define FBEAM_SHADEIN 0x00000040
|
||||
#define FBEAM_SHADEOUT 0x00000080
|
||||
#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet?
|
||||
#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet?
|
||||
#define FBEAM_ISACTIVE 0x40000000
|
||||
#define FBEAM_FOREVER 0x80000000
|
||||
|
||||
typedef struct beam_s BEAM;
|
||||
struct beam_s
|
||||
{
|
||||
BEAM *next;
|
||||
int type;
|
||||
int flags;
|
||||
vec3_t source;
|
||||
vec3_t target;
|
||||
vec3_t delta;
|
||||
float t; // 0 .. 1 over lifetime of beam
|
||||
float freq;
|
||||
float die;
|
||||
float width;
|
||||
float amplitude;
|
||||
float r, g, b;
|
||||
float brightness;
|
||||
float speed;
|
||||
float frameRate;
|
||||
float frame;
|
||||
int segments;
|
||||
int startEntity;
|
||||
int endEntity;
|
||||
int modelIndex;
|
||||
int frameCount;
|
||||
struct model_s *pFollowModel;
|
||||
struct particle_s *particles;
|
||||
};
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef BEAMDEF_H
|
||||
#define BEAMDEF_H
|
||||
|
||||
#define FBEAM_STARTENTITY 0x00000001
|
||||
#define FBEAM_ENDENTITY 0x00000002
|
||||
#define FBEAM_FADEIN 0x00000004
|
||||
#define FBEAM_FADEOUT 0x00000008
|
||||
#define FBEAM_SINENOISE 0x00000010
|
||||
#define FBEAM_SOLID 0x00000020
|
||||
#define FBEAM_SHADEIN 0x00000040
|
||||
#define FBEAM_SHADEOUT 0x00000080
|
||||
#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet?
|
||||
#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet?
|
||||
#define FBEAM_ISACTIVE 0x40000000
|
||||
#define FBEAM_FOREVER 0x80000000
|
||||
|
||||
typedef struct beam_s BEAM;
|
||||
struct beam_s
|
||||
{
|
||||
BEAM *next;
|
||||
int type;
|
||||
int flags;
|
||||
vec3_t source;
|
||||
vec3_t target;
|
||||
vec3_t delta;
|
||||
float t; // 0 .. 1 over lifetime of beam
|
||||
float freq;
|
||||
float die;
|
||||
float width;
|
||||
float amplitude;
|
||||
float r, g, b;
|
||||
float brightness;
|
||||
float speed;
|
||||
float frameRate;
|
||||
float frame;
|
||||
int segments;
|
||||
int startEntity;
|
||||
int endEntity;
|
||||
int modelIndex;
|
||||
int frameCount;
|
||||
struct model_s *pFollowModel;
|
||||
struct particle_s *particles;
|
||||
};
|
||||
|
||||
#endif//BEAMDEF_H
|
490
common/bspfile.h
490
common/bspfile.h
|
@ -1,246 +1,246 @@
|
|||
/*
|
||||
bspfile.h - BSP format included q1, hl1 support
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef BSPFILE_H
|
||||
#define BSPFILE_H
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
BRUSH MODELS
|
||||
|
||||
.bsp contain level static geometry with including PVS and lightning info
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
// header
|
||||
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
|
||||
#define HLBSP_VERSION 30 // half-life regular version
|
||||
#define XTBSP_VERSION 31 // extended lightmaps and expanded clipnodes limit
|
||||
|
||||
#define IDEXTRAHEADER (('H'<<24)+('S'<<16)+('A'<<8)+'X') // little-endian "XASH"
|
||||
#define EXTRA_VERSION 2 // because version 1 was occupied by old versions of XashXT
|
||||
|
||||
#define DELUXEMAP_VERSION 1
|
||||
#define IDDELUXEMAPHEADER (('T'<<24)+('I'<<16)+('L'<<8)+'Q') // little-endian "QLIT"
|
||||
|
||||
// worldcraft predefined angles
|
||||
#define ANGLE_UP -1
|
||||
#define ANGLE_DOWN -2
|
||||
|
||||
// bmodel limits
|
||||
#define MAX_MAP_HULLS 4 // MAX_HULLS
|
||||
|
||||
#define SURF_NOCULL BIT( 0 ) // two-sided polygon (e.g. 'water4b')
|
||||
#define SURF_PLANEBACK BIT( 1 ) // plane should be negated
|
||||
#define SURF_DRAWSKY BIT( 2 ) // sky surface
|
||||
#define SURF_WATERCSG BIT( 3 ) // culled by csg (was SURF_DRAWSPRITE)
|
||||
#define SURF_DRAWTURB BIT( 4 ) // warp surface
|
||||
#define SURF_DRAWTILED BIT( 5 ) // face without lighmap
|
||||
#define SURF_CONVEYOR BIT( 6 ) // scrolled texture (was SURF_DRAWBACKGROUND)
|
||||
#define SURF_UNDERWATER BIT( 7 ) // caustics
|
||||
#define SURF_TRANSPARENT BIT( 8 ) // it's a transparent texture (was SURF_DONTWARP)
|
||||
|
||||
#define SURF_REFLECT BIT( 31 ) // reflect surface (mirror)
|
||||
|
||||
// lightstyle management
|
||||
#define LM_STYLES 4 // MAXLIGHTMAPS
|
||||
#define LS_NORMAL 0x00
|
||||
#define LS_UNUSED 0xFE
|
||||
#define LS_NONE 0xFF
|
||||
|
||||
#define MAX_MAP_MODELS 1024 // can be increased up to 2048 if needed
|
||||
#define MAX_MAP_BRUSHES 32768 // unsigned short limit
|
||||
#define MAX_MAP_ENTITIES 8192 // can be increased up to 32768 if needed
|
||||
#define MAX_MAP_ENTSTRING 0x80000 // 512 kB should be enough
|
||||
#define MAX_MAP_PLANES 65536 // can be increased without problems
|
||||
#define MAX_MAP_NODES 32767 // because negative shorts are leafs
|
||||
#define MAX_MAP_CLIPNODES 32767 // because negative shorts are contents
|
||||
#define MAX_MAP_LEAFS 32767 // signed short limit
|
||||
#define MAX_MAP_VERTS 65535 // unsigned short limit
|
||||
#define MAX_MAP_FACES 65535 // unsigned short limit
|
||||
#define MAX_MAP_MARKSURFACES 65535 // unsigned short limit
|
||||
#define MAX_MAP_TEXINFO MAX_MAP_FACES // in theory each face may have personal texinfo
|
||||
#define MAX_MAP_EDGES 0x100000 // can be increased but not needed
|
||||
#define MAX_MAP_SURFEDGES 0x200000 // can be increased but not needed
|
||||
#define MAX_MAP_TEXTURES 2048 // can be increased but not needed
|
||||
#define MAX_MAP_MIPTEX 0x2000000 // 32 Mb internal textures data
|
||||
#define MAX_MAP_LIGHTING 0x2000000 // 32 Mb lightmap raw data (can contain deluxemaps)
|
||||
#define MAX_MAP_VISIBILITY 0x800000 // 8 Mb visdata
|
||||
|
||||
// quake lump ordering
|
||||
#define LUMP_ENTITIES 0
|
||||
#define LUMP_PLANES 1
|
||||
#define LUMP_TEXTURES 2 // internal textures
|
||||
#define LUMP_VERTEXES 3
|
||||
#define LUMP_VISIBILITY 4
|
||||
#define LUMP_NODES 5
|
||||
#define LUMP_TEXINFO 6
|
||||
#define LUMP_FACES 7
|
||||
#define LUMP_LIGHTING 8
|
||||
#define LUMP_CLIPNODES 9
|
||||
#define LUMP_LEAFS 10
|
||||
#define LUMP_MARKSURFACES 11
|
||||
#define LUMP_EDGES 12
|
||||
#define LUMP_SURFEDGES 13
|
||||
#define LUMP_MODELS 14 // internal submodels
|
||||
#define HEADER_LUMPS 15
|
||||
|
||||
// version 31
|
||||
#define LUMP_CLIPNODES2 15 // hull0 goes into LUMP_NODES, hull1 goes into LUMP_CLIPNODES,
|
||||
#define LUMP_CLIPNODES3 16 // hull2 goes into LUMP_CLIPNODES2, hull3 goes into LUMP_CLIPNODES3
|
||||
#define HEADER_LUMPS_31 17
|
||||
|
||||
#define LUMP_FACES_EXTRADATA 0 // extension of dface_t
|
||||
#define LUMP_VERTS_EXTRADATA 1 // extension of dvertex_t
|
||||
#define LUMP_CUBEMAPS 2 // cubemap description
|
||||
|
||||
#define EXTRA_LUMPS 8 // g-cont. just for future expansions
|
||||
|
||||
// texture flags
|
||||
#define TEX_SPECIAL BIT( 0 ) // sky or slime, no lightmap or 256 subdivision
|
||||
|
||||
// ambient sound types
|
||||
enum
|
||||
{
|
||||
AMBIENT_WATER = 0, // waterfall
|
||||
AMBIENT_SKY, // wind
|
||||
AMBIENT_SLIME, // never used in quake
|
||||
AMBIENT_LAVA, // never used in quake
|
||||
NUM_AMBIENTS, // automatic ambient sounds
|
||||
};
|
||||
|
||||
//
|
||||
// BSP File Structures
|
||||
//
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int fileofs;
|
||||
int filelen;
|
||||
} dlump_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int version;
|
||||
dlump_t lumps[HEADER_LUMPS];
|
||||
} dheader_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int version;
|
||||
dlump_t lumps[HEADER_LUMPS_31];
|
||||
} dheader31_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int id; // must be little endian XASH
|
||||
int version;
|
||||
dlump_t lumps[EXTRA_LUMPS];
|
||||
} dextrahdr_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t mins;
|
||||
vec3_t maxs;
|
||||
vec3_t origin; // for sounds or lights
|
||||
int headnode[MAX_MAP_HULLS];
|
||||
int visleafs; // not including the solid leaf 0
|
||||
int firstface;
|
||||
int numfaces;
|
||||
} dmodel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nummiptex;
|
||||
int dataofs[4]; // [nummiptex]
|
||||
} dmiptexlump_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t point;
|
||||
} dvertex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
int type; // PLANE_X - PLANE_ANYZ ?
|
||||
} dplane_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int planenum;
|
||||
short children[2]; // negative numbers are -(leafs + 1), not nodes
|
||||
short mins[3]; // for sphere culling
|
||||
short maxs[3];
|
||||
word firstface;
|
||||
word numfaces; // counting both sides
|
||||
} dnode_t;
|
||||
|
||||
// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
|
||||
// all other leafs need visibility info
|
||||
typedef struct
|
||||
{
|
||||
int contents;
|
||||
int visofs; // -1 = no visibility info
|
||||
|
||||
short mins[3]; // for frustum culling
|
||||
short maxs[3];
|
||||
word firstmarksurface;
|
||||
word nummarksurfaces;
|
||||
|
||||
// automatic ambient sounds
|
||||
byte ambient_level[NUM_AMBIENTS]; // ambient sound level (0 - 255)
|
||||
} dleaf_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int planenum;
|
||||
short children[2]; // negative numbers are contents
|
||||
} dclipnode_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float vecs[2][4]; // texmatrix [s/t][xyz offset]
|
||||
int miptex;
|
||||
int flags;
|
||||
} dtexinfo_t;
|
||||
|
||||
typedef word dmarkface_t; // leaf marksurfaces indexes
|
||||
typedef int dsurfedge_t; // map surfedges
|
||||
|
||||
// NOTE: that edge 0 is never used, because negative edge nums
|
||||
// are used for counterclockwise use of the edge in a face
|
||||
typedef struct
|
||||
{
|
||||
word v[2]; // vertex numbers
|
||||
} dedge_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word planenum;
|
||||
short side;
|
||||
|
||||
int firstedge; // we must support > 64k edges
|
||||
short numedges;
|
||||
short texinfo;
|
||||
|
||||
// lighting info
|
||||
byte styles[LM_STYLES];
|
||||
int lightofs; // start of [numstyles*surfsize] samples
|
||||
} dface_t;
|
||||
|
||||
/*
|
||||
bspfile.h - BSP format included q1, hl1 support
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef BSPFILE_H
|
||||
#define BSPFILE_H
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
BRUSH MODELS
|
||||
|
||||
.bsp contain level static geometry with including PVS and lightning info
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
// header
|
||||
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
|
||||
#define HLBSP_VERSION 30 // half-life regular version
|
||||
#define XTBSP_VERSION 31 // extended lightmaps and expanded clipnodes limit
|
||||
|
||||
#define IDEXTRAHEADER (('H'<<24)+('S'<<16)+('A'<<8)+'X') // little-endian "XASH"
|
||||
#define EXTRA_VERSION 2 // because version 1 was occupied by old versions of XashXT
|
||||
|
||||
#define DELUXEMAP_VERSION 1
|
||||
#define IDDELUXEMAPHEADER (('T'<<24)+('I'<<16)+('L'<<8)+'Q') // little-endian "QLIT"
|
||||
|
||||
// worldcraft predefined angles
|
||||
#define ANGLE_UP -1
|
||||
#define ANGLE_DOWN -2
|
||||
|
||||
// bmodel limits
|
||||
#define MAX_MAP_HULLS 4 // MAX_HULLS
|
||||
|
||||
#define SURF_NOCULL BIT( 0 ) // two-sided polygon (e.g. 'water4b')
|
||||
#define SURF_PLANEBACK BIT( 1 ) // plane should be negated
|
||||
#define SURF_DRAWSKY BIT( 2 ) // sky surface
|
||||
#define SURF_WATERCSG BIT( 3 ) // culled by csg (was SURF_DRAWSPRITE)
|
||||
#define SURF_DRAWTURB BIT( 4 ) // warp surface
|
||||
#define SURF_DRAWTILED BIT( 5 ) // face without lighmap
|
||||
#define SURF_CONVEYOR BIT( 6 ) // scrolled texture (was SURF_DRAWBACKGROUND)
|
||||
#define SURF_UNDERWATER BIT( 7 ) // caustics
|
||||
#define SURF_TRANSPARENT BIT( 8 ) // it's a transparent texture (was SURF_DONTWARP)
|
||||
|
||||
#define SURF_REFLECT BIT( 31 ) // reflect surface (mirror)
|
||||
|
||||
// lightstyle management
|
||||
#define LM_STYLES 4 // MAXLIGHTMAPS
|
||||
#define LS_NORMAL 0x00
|
||||
#define LS_UNUSED 0xFE
|
||||
#define LS_NONE 0xFF
|
||||
|
||||
#define MAX_MAP_MODELS 1024 // can be increased up to 2048 if needed
|
||||
#define MAX_MAP_BRUSHES 32768 // unsigned short limit
|
||||
#define MAX_MAP_ENTITIES 8192 // can be increased up to 32768 if needed
|
||||
#define MAX_MAP_ENTSTRING 0x80000 // 512 kB should be enough
|
||||
#define MAX_MAP_PLANES 65536 // can be increased without problems
|
||||
#define MAX_MAP_NODES 32767 // because negative shorts are leafs
|
||||
#define MAX_MAP_CLIPNODES 32767 // because negative shorts are contents
|
||||
#define MAX_MAP_LEAFS 32767 // signed short limit
|
||||
#define MAX_MAP_VERTS 65535 // unsigned short limit
|
||||
#define MAX_MAP_FACES 65535 // unsigned short limit
|
||||
#define MAX_MAP_MARKSURFACES 65535 // unsigned short limit
|
||||
#define MAX_MAP_TEXINFO MAX_MAP_FACES // in theory each face may have personal texinfo
|
||||
#define MAX_MAP_EDGES 0x100000 // can be increased but not needed
|
||||
#define MAX_MAP_SURFEDGES 0x200000 // can be increased but not needed
|
||||
#define MAX_MAP_TEXTURES 2048 // can be increased but not needed
|
||||
#define MAX_MAP_MIPTEX 0x2000000 // 32 Mb internal textures data
|
||||
#define MAX_MAP_LIGHTING 0x2000000 // 32 Mb lightmap raw data (can contain deluxemaps)
|
||||
#define MAX_MAP_VISIBILITY 0x800000 // 8 Mb visdata
|
||||
|
||||
// quake lump ordering
|
||||
#define LUMP_ENTITIES 0
|
||||
#define LUMP_PLANES 1
|
||||
#define LUMP_TEXTURES 2 // internal textures
|
||||
#define LUMP_VERTEXES 3
|
||||
#define LUMP_VISIBILITY 4
|
||||
#define LUMP_NODES 5
|
||||
#define LUMP_TEXINFO 6
|
||||
#define LUMP_FACES 7
|
||||
#define LUMP_LIGHTING 8
|
||||
#define LUMP_CLIPNODES 9
|
||||
#define LUMP_LEAFS 10
|
||||
#define LUMP_MARKSURFACES 11
|
||||
#define LUMP_EDGES 12
|
||||
#define LUMP_SURFEDGES 13
|
||||
#define LUMP_MODELS 14 // internal submodels
|
||||
#define HEADER_LUMPS 15
|
||||
|
||||
// version 31
|
||||
#define LUMP_CLIPNODES2 15 // hull0 goes into LUMP_NODES, hull1 goes into LUMP_CLIPNODES,
|
||||
#define LUMP_CLIPNODES3 16 // hull2 goes into LUMP_CLIPNODES2, hull3 goes into LUMP_CLIPNODES3
|
||||
#define HEADER_LUMPS_31 17
|
||||
|
||||
#define LUMP_FACES_EXTRADATA 0 // extension of dface_t
|
||||
#define LUMP_VERTS_EXTRADATA 1 // extension of dvertex_t
|
||||
#define LUMP_CUBEMAPS 2 // cubemap description
|
||||
|
||||
#define EXTRA_LUMPS 8 // g-cont. just for future expansions
|
||||
|
||||
// texture flags
|
||||
#define TEX_SPECIAL BIT( 0 ) // sky or slime, no lightmap or 256 subdivision
|
||||
|
||||
// ambient sound types
|
||||
enum
|
||||
{
|
||||
AMBIENT_WATER = 0, // waterfall
|
||||
AMBIENT_SKY, // wind
|
||||
AMBIENT_SLIME, // never used in quake
|
||||
AMBIENT_LAVA, // never used in quake
|
||||
NUM_AMBIENTS, // automatic ambient sounds
|
||||
};
|
||||
|
||||
//
|
||||
// BSP File Structures
|
||||
//
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int fileofs;
|
||||
int filelen;
|
||||
} dlump_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int version;
|
||||
dlump_t lumps[HEADER_LUMPS];
|
||||
} dheader_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int version;
|
||||
dlump_t lumps[HEADER_LUMPS_31];
|
||||
} dheader31_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int id; // must be little endian XASH
|
||||
int version;
|
||||
dlump_t lumps[EXTRA_LUMPS];
|
||||
} dextrahdr_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t mins;
|
||||
vec3_t maxs;
|
||||
vec3_t origin; // for sounds or lights
|
||||
int headnode[MAX_MAP_HULLS];
|
||||
int visleafs; // not including the solid leaf 0
|
||||
int firstface;
|
||||
int numfaces;
|
||||
} dmodel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nummiptex;
|
||||
int dataofs[4]; // [nummiptex]
|
||||
} dmiptexlump_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t point;
|
||||
} dvertex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
int type; // PLANE_X - PLANE_ANYZ ?
|
||||
} dplane_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int planenum;
|
||||
short children[2]; // negative numbers are -(leafs + 1), not nodes
|
||||
short mins[3]; // for sphere culling
|
||||
short maxs[3];
|
||||
word firstface;
|
||||
word numfaces; // counting both sides
|
||||
} dnode_t;
|
||||
|
||||
// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
|
||||
// all other leafs need visibility info
|
||||
typedef struct
|
||||
{
|
||||
int contents;
|
||||
int visofs; // -1 = no visibility info
|
||||
|
||||
short mins[3]; // for frustum culling
|
||||
short maxs[3];
|
||||
word firstmarksurface;
|
||||
word nummarksurfaces;
|
||||
|
||||
// automatic ambient sounds
|
||||
byte ambient_level[NUM_AMBIENTS]; // ambient sound level (0 - 255)
|
||||
} dleaf_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int planenum;
|
||||
short children[2]; // negative numbers are contents
|
||||
} dclipnode_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float vecs[2][4]; // texmatrix [s/t][xyz offset]
|
||||
int miptex;
|
||||
int flags;
|
||||
} dtexinfo_t;
|
||||
|
||||
typedef word dmarkface_t; // leaf marksurfaces indexes
|
||||
typedef int dsurfedge_t; // map surfedges
|
||||
|
||||
// NOTE: that edge 0 is never used, because negative edge nums
|
||||
// are used for counterclockwise use of the edge in a face
|
||||
typedef struct
|
||||
{
|
||||
word v[2]; // vertex numbers
|
||||
} dedge_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word planenum;
|
||||
short side;
|
||||
|
||||
int firstedge; // we must support > 64k edges
|
||||
short numedges;
|
||||
short texinfo;
|
||||
|
||||
// lighting info
|
||||
byte styles[LM_STYLES];
|
||||
int lightofs; // start of [numstyles*surfsize] samples
|
||||
} dface_t;
|
||||
|
||||
#endif//BSPFILE_H
|
|
@ -1,105 +1,105 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef CL_ENTITY_H
|
||||
#define CL_ENTITY_H
|
||||
|
||||
typedef struct efrag_s
|
||||
{
|
||||
struct mleaf_s *leaf;
|
||||
struct efrag_s *leafnext;
|
||||
struct cl_entity_s *entity;
|
||||
struct efrag_s *entnext;
|
||||
} efrag_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte mouthopen; // 0 = mouth closed, 255 = mouth agape
|
||||
byte sndcount; // counter for running average
|
||||
int sndavg; // running average
|
||||
} mouth_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float prevanimtime;
|
||||
float sequencetime;
|
||||
byte prevseqblending[2];
|
||||
vec3_t prevorigin;
|
||||
vec3_t prevangles;
|
||||
|
||||
int prevsequence;
|
||||
float prevframe;
|
||||
|
||||
byte prevcontroller[4];
|
||||
byte prevblending[2];
|
||||
} latchedvars_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Time stamp for this movement
|
||||
float animtime;
|
||||
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
} position_history_t;
|
||||
|
||||
typedef struct cl_entity_s cl_entity_t;
|
||||
|
||||
#define HISTORY_MAX 64 // Must be power of 2
|
||||
#define HISTORY_MASK ( HISTORY_MAX - 1 )
|
||||
|
||||
#include "entity_state.h"
|
||||
#include "event_args.h"
|
||||
|
||||
struct cl_entity_s
|
||||
{
|
||||
int index; // Index into cl_entities ( should match actual slot, but not necessarily )
|
||||
qboolean player; // True if this entity is a "player"
|
||||
|
||||
entity_state_t baseline; // The original state from which to delta during an uncompressed message
|
||||
entity_state_t prevstate; // The state information from the penultimate message received from the server
|
||||
entity_state_t curstate; // The state information from the last message received from server
|
||||
|
||||
int current_position; // Last received history update index
|
||||
position_history_t ph[HISTORY_MAX]; // History of position and angle updates for this player
|
||||
|
||||
mouth_t mouth; // For synchronizing mouth movements.
|
||||
|
||||
latchedvars_t latched; // Variables used by studio model rendering routines
|
||||
|
||||
// Information based on interplocation, extrapolation, prediction, or just copied from last msg received.
|
||||
//
|
||||
float lastmove;
|
||||
|
||||
// Actual render position and angles
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
|
||||
// Attachment points
|
||||
vec3_t attachment[4];
|
||||
|
||||
// Other entity local information
|
||||
int trivial_accept;
|
||||
|
||||
struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model
|
||||
struct efrag_s *efrag; // linked list of efrags
|
||||
struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split
|
||||
|
||||
float syncbase; // for client-side animations -- used by obsolete alias animation system, remove?
|
||||
int visframe; // last frame this entity was found in an active leaf
|
||||
colorVec cvFloorColor;
|
||||
};
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef CL_ENTITY_H
|
||||
#define CL_ENTITY_H
|
||||
|
||||
typedef struct efrag_s
|
||||
{
|
||||
struct mleaf_s *leaf;
|
||||
struct efrag_s *leafnext;
|
||||
struct cl_entity_s *entity;
|
||||
struct efrag_s *entnext;
|
||||
} efrag_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte mouthopen; // 0 = mouth closed, 255 = mouth agape
|
||||
byte sndcount; // counter for running average
|
||||
int sndavg; // running average
|
||||
} mouth_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float prevanimtime;
|
||||
float sequencetime;
|
||||
byte prevseqblending[2];
|
||||
vec3_t prevorigin;
|
||||
vec3_t prevangles;
|
||||
|
||||
int prevsequence;
|
||||
float prevframe;
|
||||
|
||||
byte prevcontroller[4];
|
||||
byte prevblending[2];
|
||||
} latchedvars_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Time stamp for this movement
|
||||
float animtime;
|
||||
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
} position_history_t;
|
||||
|
||||
typedef struct cl_entity_s cl_entity_t;
|
||||
|
||||
#define HISTORY_MAX 64 // Must be power of 2
|
||||
#define HISTORY_MASK ( HISTORY_MAX - 1 )
|
||||
|
||||
#include "entity_state.h"
|
||||
#include "event_args.h"
|
||||
|
||||
struct cl_entity_s
|
||||
{
|
||||
int index; // Index into cl_entities ( should match actual slot, but not necessarily )
|
||||
qboolean player; // True if this entity is a "player"
|
||||
|
||||
entity_state_t baseline; // The original state from which to delta during an uncompressed message
|
||||
entity_state_t prevstate; // The state information from the penultimate message received from the server
|
||||
entity_state_t curstate; // The state information from the last message received from server
|
||||
|
||||
int current_position; // Last received history update index
|
||||
position_history_t ph[HISTORY_MAX]; // History of position and angle updates for this player
|
||||
|
||||
mouth_t mouth; // For synchronizing mouth movements.
|
||||
|
||||
latchedvars_t latched; // Variables used by studio model rendering routines
|
||||
|
||||
// Information based on interplocation, extrapolation, prediction, or just copied from last msg received.
|
||||
//
|
||||
float lastmove;
|
||||
|
||||
// Actual render position and angles
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
|
||||
// Attachment points
|
||||
vec3_t attachment[4];
|
||||
|
||||
// Other entity local information
|
||||
int trivial_accept;
|
||||
|
||||
struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model
|
||||
struct efrag_s *efrag; // linked list of efrags
|
||||
struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split
|
||||
|
||||
float syncbase; // for client-side animations -- used by obsolete alias animation system, remove?
|
||||
int visframe; // last frame this entity was found in an active leaf
|
||||
colorVec cvFloorColor;
|
||||
};
|
||||
|
||||
#endif//CL_ENTITY_H
|
|
@ -1,413 +1,413 @@
|
|||
/*
|
||||
com_model.h - cient model structures
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef COM_MODEL_H
|
||||
#define COM_MODEL_H
|
||||
|
||||
#include "bspfile.h" // we need some declarations from it
|
||||
|
||||
typedef vec_t vec2_t[2];
|
||||
typedef vec_t vec4_t[4];
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
ENGINE MODEL FORMAT
|
||||
==============================================================================
|
||||
*/
|
||||
#define STUDIO_RENDER 1
|
||||
#define STUDIO_EVENTS 2
|
||||
|
||||
#define ZISCALE ((float)0x8000)
|
||||
|
||||
#define MIPLEVELS 4
|
||||
#define VERTEXSIZE 7
|
||||
#define MAXLIGHTMAPS 4
|
||||
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
||||
|
||||
// model types
|
||||
typedef enum
|
||||
{
|
||||
mod_bad = -1,
|
||||
mod_brush,
|
||||
mod_sprite,
|
||||
mod_alias,
|
||||
mod_studio
|
||||
} modtype_t;
|
||||
|
||||
typedef struct mplane_s
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
byte type; // for 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 int width, height;
|
||||
int gl_texturenum;
|
||||
struct msurface_s *texturechain; // for gl_texsort drawing
|
||||
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 short fb_texturenum; // auto-luma texturenum
|
||||
unsigned short dt_texturenum; // detail-texture binding
|
||||
unsigned int unused[3]; // reserved
|
||||
} 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;
|
||||
|
||||
// 73 bytes per VBO vertex
|
||||
// FIXME: align to 32 bytes
|
||||
typedef struct glvert_s
|
||||
{
|
||||
vec3_t vertex; // position
|
||||
vec3_t normal; // normal
|
||||
vec2_t stcoord; // ST texture coords
|
||||
vec2_t lmcoord; // ST lightmap coords
|
||||
vec2_t sccoord; // ST scissor coords (decals only) - for normalmap coords migration
|
||||
vec3_t tangent; // tangent
|
||||
vec3_t binormal; // binormal
|
||||
byte color[4]; // colors per vertex
|
||||
} glvert_t;
|
||||
|
||||
typedef struct glpoly_s
|
||||
{
|
||||
struct glpoly_s *next;
|
||||
struct glpoly_s *chain;
|
||||
int numverts;
|
||||
int flags; // for SURF_UNDERWATER
|
||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||
} glpoly_t;
|
||||
|
||||
typedef struct mnode_s
|
||||
{
|
||||
// common with leaf
|
||||
int contents; // 0, to differentiate from leafs
|
||||
int visframe; // node needs to be traversed if current
|
||||
|
||||
float 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
|
||||
float dx; // local texture coordinates
|
||||
float dy; //
|
||||
float scale; // Pixel scale
|
||||
short texture; // Decal texture
|
||||
byte flags; // Decal flags FDECAL_*
|
||||
short entityIndex; // Entity this is attached to
|
||||
// Xash3D added
|
||||
vec3_t position; // location of the decal center in world space.
|
||||
vec3_t saxis; // direction of the s axis in world space
|
||||
struct msurfmesh_s *mesh; // decal mesh in local space
|
||||
int reserved[4]; // for future expansions
|
||||
};
|
||||
|
||||
typedef struct mleaf_s
|
||||
{
|
||||
// common with node
|
||||
int contents;
|
||||
int visframe; // node needs to be traversed if current
|
||||
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
|
||||
struct mnode_s *parent;
|
||||
// leaf specific
|
||||
byte *compressed_vis;
|
||||
struct efrag_s *efrags;
|
||||
|
||||
msurface_t **firstmarksurface;
|
||||
int nummarksurfaces;
|
||||
byte *compressed_pas;
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
|
||||
} mleaf_t;
|
||||
|
||||
typedef struct msurface_s
|
||||
{
|
||||
int visframe; // should be drawn when node is crossed
|
||||
|
||||
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
|
||||
|
||||
short texturemins[2];
|
||||
short extents[2];
|
||||
|
||||
int light_s, light_t; // gl lightmap coordinates
|
||||
|
||||
glpoly_t *polys; // multiple if warped
|
||||
struct msurface_s *texturechain;
|
||||
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
// lighting info
|
||||
int dlightframe; // last frame the surface was checked by an animated light
|
||||
int dlightbits; // dynamically generated. Indicates if the surface illumination
|
||||
// is modified by an animated light.
|
||||
|
||||
int lightmaptexturenum;
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
|
||||
struct msurface_s *lightmapchain; // for new dlights rendering (was cached_dlight)
|
||||
|
||||
color24 *samples; // note: this is the actual lightmap data for this surface
|
||||
decal_t *pdecals;
|
||||
} msurface_t;
|
||||
|
||||
typedef struct msurfmesh_s
|
||||
{
|
||||
unsigned short numVerts;
|
||||
unsigned short numElems; // ~ 20 000 vertex per one surface. Should be enough
|
||||
unsigned int startVert; // user-variable. may be used for construct world single-VBO
|
||||
unsigned int startElem; // user-variable. may be used for construct world single-VBO
|
||||
|
||||
glvert_t *verts; // vertexes array
|
||||
unsigned short *elems; // indices
|
||||
|
||||
struct msurface_s *surf; // pointer to parent surface. Just for consistency
|
||||
struct msurfmesh_s *next; // temporary chain of subdivided surfaces
|
||||
} msurfmesh_t;
|
||||
|
||||
// surface extradata stored in cache.data for all brushmodels
|
||||
typedef struct mextrasurf_s
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
vec3_t origin; // surface origin
|
||||
msurfmesh_t *mesh; // VBO\VA ready surface mesh. Not used by engine but can be used by mod-makers
|
||||
|
||||
int dlight_s, dlight_t; // gl lightmap coordinates for dynamic lightmaps
|
||||
|
||||
int mirrortexturenum; // gl texnum
|
||||
float mirrormatrix[4][4];
|
||||
struct mextrasurf_s *mirrorchain; // for gl_texsort drawing
|
||||
struct mextrasurf_s *detailchain; // for detail textures drawing
|
||||
color24 *deluxemap; // note: this is the actual deluxemap data for this surface
|
||||
|
||||
int reserved[32]; // just for future expansions or mod-makers
|
||||
} mextrasurf_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;
|
||||
|
||||
#ifndef CACHE_USER
|
||||
#define CACHE_USER
|
||||
typedef struct cache_user_s
|
||||
{
|
||||
void *data; // extradata
|
||||
} cache_user_t;
|
||||
#endif
|
||||
|
||||
typedef struct model_s
|
||||
{
|
||||
char name[64]; // model name
|
||||
qboolean needload; // bmodels and sprites don't cache normally
|
||||
|
||||
// shared modelinfo
|
||||
modtype_t type; // model type
|
||||
int numframes; // sprite's framecount
|
||||
byte *mempool; // private mempool (was synctype)
|
||||
int flags; // hl compatibility
|
||||
|
||||
//
|
||||
// volume occupied by the model
|
||||
//
|
||||
vec3_t mins, maxs; // bounding box at angles '0 0 0'
|
||||
float radius;
|
||||
|
||||
// brush model
|
||||
int firstmodelsurface;
|
||||
int nummodelsurfaces;
|
||||
|
||||
int numsubmodels;
|
||||
dmodel_t *submodels; // or studio animations
|
||||
|
||||
int numplanes;
|
||||
mplane_t *planes;
|
||||
|
||||
int numleafs; // number of visible leafs, not counting 0
|
||||
mleaf_t *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 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;
|
||||
|
||||
#define MAX_SCOREBOARDNAME 32
|
||||
#define MAX_INFO_STRING 256
|
||||
|
||||
#include "custom.h"
|
||||
|
||||
typedef struct player_info_s
|
||||
{
|
||||
int userid; // User id on server
|
||||
char userinfo[MAX_INFO_STRING]; // User info string
|
||||
char name[MAX_SCOREBOARDNAME]; // Name (extracted from userinfo)
|
||||
int spectator; // Spectator or not, unused
|
||||
|
||||
int ping;
|
||||
int packet_loss;
|
||||
|
||||
// skin information
|
||||
char model[64];
|
||||
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;
|
||||
|
||||
//
|
||||
// sprite representation in memory
|
||||
//
|
||||
typedef enum { SPR_SINGLE = 0, SPR_GROUP, SPR_ANGLED } spriteframetype_t;
|
||||
|
||||
typedef struct mspriteframe_s
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
float up, down, left, right;
|
||||
int gl_texturenum;
|
||||
} mspriteframe_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int numframes;
|
||||
float *intervals;
|
||||
mspriteframe_t *frames[1];
|
||||
} mspritegroup_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
spriteframetype_t type;
|
||||
mspriteframe_t *frameptr;
|
||||
} mspriteframedesc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short type;
|
||||
short texFormat;
|
||||
int maxwidth;
|
||||
int maxheight;
|
||||
int numframes;
|
||||
int radius;
|
||||
int facecull;
|
||||
int synctype;
|
||||
mspriteframedesc_t frames[1];
|
||||
} msprite_t;
|
||||
|
||||
/*
|
||||
com_model.h - cient model structures
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef COM_MODEL_H
|
||||
#define COM_MODEL_H
|
||||
|
||||
#include "bspfile.h" // we need some declarations from it
|
||||
|
||||
typedef vec_t vec2_t[2];
|
||||
typedef vec_t vec4_t[4];
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
ENGINE MODEL FORMAT
|
||||
==============================================================================
|
||||
*/
|
||||
#define STUDIO_RENDER 1
|
||||
#define STUDIO_EVENTS 2
|
||||
|
||||
#define ZISCALE ((float)0x8000)
|
||||
|
||||
#define MIPLEVELS 4
|
||||
#define VERTEXSIZE 7
|
||||
#define MAXLIGHTMAPS 4
|
||||
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
||||
|
||||
// model types
|
||||
typedef enum
|
||||
{
|
||||
mod_bad = -1,
|
||||
mod_brush,
|
||||
mod_sprite,
|
||||
mod_alias,
|
||||
mod_studio
|
||||
} modtype_t;
|
||||
|
||||
typedef struct mplane_s
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
byte type; // for 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 int width, height;
|
||||
int gl_texturenum;
|
||||
struct msurface_s *texturechain; // for gl_texsort drawing
|
||||
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 short fb_texturenum; // auto-luma texturenum
|
||||
unsigned short dt_texturenum; // detail-texture binding
|
||||
unsigned int unused[3]; // reserved
|
||||
} 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;
|
||||
|
||||
// 73 bytes per VBO vertex
|
||||
// FIXME: align to 32 bytes
|
||||
typedef struct glvert_s
|
||||
{
|
||||
vec3_t vertex; // position
|
||||
vec3_t normal; // normal
|
||||
vec2_t stcoord; // ST texture coords
|
||||
vec2_t lmcoord; // ST lightmap coords
|
||||
vec2_t sccoord; // ST scissor coords (decals only) - for normalmap coords migration
|
||||
vec3_t tangent; // tangent
|
||||
vec3_t binormal; // binormal
|
||||
byte color[4]; // colors per vertex
|
||||
} glvert_t;
|
||||
|
||||
typedef struct glpoly_s
|
||||
{
|
||||
struct glpoly_s *next;
|
||||
struct glpoly_s *chain;
|
||||
int numverts;
|
||||
int flags; // for SURF_UNDERWATER
|
||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||
} glpoly_t;
|
||||
|
||||
typedef struct mnode_s
|
||||
{
|
||||
// common with leaf
|
||||
int contents; // 0, to differentiate from leafs
|
||||
int visframe; // node needs to be traversed if current
|
||||
|
||||
float 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
|
||||
float dx; // local texture coordinates
|
||||
float dy; //
|
||||
float scale; // Pixel scale
|
||||
short texture; // Decal texture
|
||||
byte flags; // Decal flags FDECAL_*
|
||||
short entityIndex; // Entity this is attached to
|
||||
// Xash3D added
|
||||
vec3_t position; // location of the decal center in world space.
|
||||
vec3_t saxis; // direction of the s axis in world space
|
||||
struct msurfmesh_s *mesh; // decal mesh in local space
|
||||
int reserved[4]; // for future expansions
|
||||
};
|
||||
|
||||
typedef struct mleaf_s
|
||||
{
|
||||
// common with node
|
||||
int contents;
|
||||
int visframe; // node needs to be traversed if current
|
||||
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
|
||||
struct mnode_s *parent;
|
||||
// leaf specific
|
||||
byte *compressed_vis;
|
||||
struct efrag_s *efrags;
|
||||
|
||||
msurface_t **firstmarksurface;
|
||||
int nummarksurfaces;
|
||||
byte *compressed_pas;
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
|
||||
} mleaf_t;
|
||||
|
||||
typedef struct msurface_s
|
||||
{
|
||||
int visframe; // should be drawn when node is crossed
|
||||
|
||||
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
|
||||
|
||||
short texturemins[2];
|
||||
short extents[2];
|
||||
|
||||
int light_s, light_t; // gl lightmap coordinates
|
||||
|
||||
glpoly_t *polys; // multiple if warped
|
||||
struct msurface_s *texturechain;
|
||||
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
// lighting info
|
||||
int dlightframe; // last frame the surface was checked by an animated light
|
||||
int dlightbits; // dynamically generated. Indicates if the surface illumination
|
||||
// is modified by an animated light.
|
||||
|
||||
int lightmaptexturenum;
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
|
||||
struct msurface_s *lightmapchain; // for new dlights rendering (was cached_dlight)
|
||||
|
||||
color24 *samples; // note: this is the actual lightmap data for this surface
|
||||
decal_t *pdecals;
|
||||
} msurface_t;
|
||||
|
||||
typedef struct msurfmesh_s
|
||||
{
|
||||
unsigned short numVerts;
|
||||
unsigned short numElems; // ~ 20 000 vertex per one surface. Should be enough
|
||||
unsigned int startVert; // user-variable. may be used for construct world single-VBO
|
||||
unsigned int startElem; // user-variable. may be used for construct world single-VBO
|
||||
|
||||
glvert_t *verts; // vertexes array
|
||||
unsigned short *elems; // indices
|
||||
|
||||
struct msurface_s *surf; // pointer to parent surface. Just for consistency
|
||||
struct msurfmesh_s *next; // temporary chain of subdivided surfaces
|
||||
} msurfmesh_t;
|
||||
|
||||
// surface extradata stored in cache.data for all brushmodels
|
||||
typedef struct mextrasurf_s
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
vec3_t origin; // surface origin
|
||||
msurfmesh_t *mesh; // VBO\VA ready surface mesh. Not used by engine but can be used by mod-makers
|
||||
|
||||
int dlight_s, dlight_t; // gl lightmap coordinates for dynamic lightmaps
|
||||
|
||||
int mirrortexturenum; // gl texnum
|
||||
float mirrormatrix[4][4];
|
||||
struct mextrasurf_s *mirrorchain; // for gl_texsort drawing
|
||||
struct mextrasurf_s *detailchain; // for detail textures drawing
|
||||
color24 *deluxemap; // note: this is the actual deluxemap data for this surface
|
||||
|
||||
int reserved[32]; // just for future expansions or mod-makers
|
||||
} mextrasurf_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;
|
||||
|
||||
#ifndef CACHE_USER
|
||||
#define CACHE_USER
|
||||
typedef struct cache_user_s
|
||||
{
|
||||
void *data; // extradata
|
||||
} cache_user_t;
|
||||
#endif
|
||||
|
||||
typedef struct model_s
|
||||
{
|
||||
char name[64]; // model name
|
||||
qboolean needload; // bmodels and sprites don't cache normally
|
||||
|
||||
// shared modelinfo
|
||||
modtype_t type; // model type
|
||||
int numframes; // sprite's framecount
|
||||
byte *mempool; // private mempool (was synctype)
|
||||
int flags; // hl compatibility
|
||||
|
||||
//
|
||||
// volume occupied by the model
|
||||
//
|
||||
vec3_t mins, maxs; // bounding box at angles '0 0 0'
|
||||
float radius;
|
||||
|
||||
// brush model
|
||||
int firstmodelsurface;
|
||||
int nummodelsurfaces;
|
||||
|
||||
int numsubmodels;
|
||||
dmodel_t *submodels; // or studio animations
|
||||
|
||||
int numplanes;
|
||||
mplane_t *planes;
|
||||
|
||||
int numleafs; // number of visible leafs, not counting 0
|
||||
mleaf_t *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 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;
|
||||
|
||||
#define MAX_SCOREBOARDNAME 32
|
||||
#define MAX_INFO_STRING 256
|
||||
|
||||
#include "custom.h"
|
||||
|
||||
typedef struct player_info_s
|
||||
{
|
||||
int userid; // User id on server
|
||||
char userinfo[MAX_INFO_STRING]; // User info string
|
||||
char name[MAX_SCOREBOARDNAME]; // Name (extracted from userinfo)
|
||||
int spectator; // Spectator or not, unused
|
||||
|
||||
int ping;
|
||||
int packet_loss;
|
||||
|
||||
// skin information
|
||||
char model[64];
|
||||
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;
|
||||
|
||||
//
|
||||
// sprite representation in memory
|
||||
//
|
||||
typedef enum { SPR_SINGLE = 0, SPR_GROUP, SPR_ANGLED } spriteframetype_t;
|
||||
|
||||
typedef struct mspriteframe_s
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
float up, down, left, right;
|
||||
int gl_texturenum;
|
||||
} mspriteframe_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int numframes;
|
||||
float *intervals;
|
||||
mspriteframe_t *frames[1];
|
||||
} mspritegroup_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
spriteframetype_t type;
|
||||
mspriteframe_t *frameptr;
|
||||
} mspriteframedesc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short type;
|
||||
short texFormat;
|
||||
int maxwidth;
|
||||
int maxheight;
|
||||
int numframes;
|
||||
int radius;
|
||||
int facecull;
|
||||
int synctype;
|
||||
mspriteframedesc_t frames[1];
|
||||
} msprite_t;
|
||||
|
||||
#endif//COM_MODEL_H
|
|
@ -1,25 +1,25 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef CON_NPRINT_H
|
||||
#define CON_NPRINT_H
|
||||
|
||||
typedef struct con_nprint_s
|
||||
{
|
||||
int index; // Row #
|
||||
float time_to_live; // # of seconds before it dissappears
|
||||
float color[3]; // RGB colors ( 0.0 -> 1.0 scale )
|
||||
} con_nprint_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef CON_NPRINT_H
|
||||
#define CON_NPRINT_H
|
||||
|
||||
typedef struct con_nprint_s
|
||||
{
|
||||
int index; // Row #
|
||||
float time_to_live; // # of seconds before it dissappears
|
||||
float color[3]; // RGB colors ( 0.0 -> 1.0 scale )
|
||||
} con_nprint_t;
|
||||
|
||||
#endif//CON_NPRINT_H
|
1558
common/const.h
1558
common/const.h
File diff suppressed because it is too large
Load Diff
|
@ -1,37 +1,37 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef CVARDEF_H
|
||||
#define CVARDEF_H
|
||||
|
||||
#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc
|
||||
#define FCVAR_USERINFO (1<<1) // changes the client's info string
|
||||
#define FCVAR_SERVER (1<<2) // notifies players when changed
|
||||
#define FCVAR_EXTDLL (1<<3) // defined by external DLL
|
||||
#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll
|
||||
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
|
||||
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
|
||||
#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
|
||||
#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
|
||||
|
||||
typedef struct cvar_s
|
||||
{
|
||||
char *name;
|
||||
char *string;
|
||||
int flags;
|
||||
float value;
|
||||
struct cvar_s *next;
|
||||
} cvar_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef CVARDEF_H
|
||||
#define CVARDEF_H
|
||||
|
||||
#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc
|
||||
#define FCVAR_USERINFO (1<<1) // changes the client's info string
|
||||
#define FCVAR_SERVER (1<<2) // notifies players when changed
|
||||
#define FCVAR_EXTDLL (1<<3) // defined by external DLL
|
||||
#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll
|
||||
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
|
||||
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
|
||||
#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
|
||||
#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
|
||||
|
||||
typedef struct cvar_s
|
||||
{
|
||||
char *name;
|
||||
char *string;
|
||||
int flags;
|
||||
float value;
|
||||
struct cvar_s *next;
|
||||
} cvar_t;
|
||||
|
||||
#endif//CVARDEF_H
|
|
@ -1,27 +1,27 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef DEMO_API_H
|
||||
#define DEMO_API_H
|
||||
|
||||
typedef struct demo_api_s
|
||||
{
|
||||
int (*IsRecording)( void );
|
||||
int (*IsPlayingback)( void );
|
||||
int (*IsTimeDemo)( void );
|
||||
void (*WriteBuffer)( int size, unsigned char *buffer );
|
||||
} demo_api_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef DEMO_API_H
|
||||
#define DEMO_API_H
|
||||
|
||||
typedef struct demo_api_s
|
||||
{
|
||||
int (*IsRecording)( void );
|
||||
int (*IsPlayingback)( void );
|
||||
int (*IsTimeDemo)( void );
|
||||
void (*WriteBuffer)( int size, unsigned char *buffer );
|
||||
} demo_api_t;
|
||||
|
||||
#endif//DEMO_API_H
|
|
@ -1,31 +1,31 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef DLIGHT_H
|
||||
#define DLIGHT_H
|
||||
|
||||
typedef struct dlight_s
|
||||
{
|
||||
vec3_t origin;
|
||||
float radius;
|
||||
color24 color;
|
||||
float die; // stop lighting after this time
|
||||
float decay; // drop this each second
|
||||
float minlight; // don't add when contributing less
|
||||
int key;
|
||||
qboolean dark; // subtracts light instead of adding
|
||||
} dlight_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef DLIGHT_H
|
||||
#define DLIGHT_H
|
||||
|
||||
typedef struct dlight_s
|
||||
{
|
||||
vec3_t origin;
|
||||
float radius;
|
||||
color24 color;
|
||||
float die; // stop lighting after this time
|
||||
float decay; // drop this each second
|
||||
float minlight; // don't add when contributing less
|
||||
int key;
|
||||
qboolean dark; // subtracts light instead of adding
|
||||
} dlight_t;
|
||||
|
||||
#endif//DLIGHT_H
|
|
@ -1,186 +1,186 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef ENTITY_STATE_H
|
||||
#define ENTITY_STATE_H
|
||||
|
||||
// For entityType below
|
||||
#define ENTITY_NORMAL (1<<0)
|
||||
#define ENTITY_BEAM (1<<1)
|
||||
|
||||
// Entity state is used for the baseline and for delta compression of a packet of
|
||||
// entities that is sent to a client.
|
||||
typedef struct entity_state_s entity_state_t;
|
||||
|
||||
struct entity_state_s
|
||||
{
|
||||
// Fields which are filled in by routines outside of delta compression
|
||||
int entityType;
|
||||
// Index into cl_entities array for this entity.
|
||||
int number;
|
||||
float msg_time;
|
||||
|
||||
// Message number last time the player/entity state was updated.
|
||||
int messagenum;
|
||||
|
||||
// Fields which can be transitted and reconstructed over the network stream
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
|
||||
int modelindex;
|
||||
int sequence;
|
||||
float frame;
|
||||
int colormap;
|
||||
short skin;
|
||||
short solid;
|
||||
int effects;
|
||||
float scale;
|
||||
byte eflags;
|
||||
|
||||
// Render information
|
||||
int rendermode;
|
||||
int renderamt;
|
||||
color24 rendercolor;
|
||||
int renderfx;
|
||||
|
||||
int movetype;
|
||||
float animtime;
|
||||
float framerate;
|
||||
int body;
|
||||
byte controller[4];
|
||||
byte blending[4];
|
||||
vec3_t velocity;
|
||||
|
||||
// Send bbox down to client for use during prediction.
|
||||
vec3_t mins;
|
||||
vec3_t maxs;
|
||||
|
||||
int aiment;
|
||||
// If owned by a player, the index of that player ( for projectiles ).
|
||||
int owner;
|
||||
|
||||
// Friction, for prediction.
|
||||
float friction;
|
||||
// Gravity multiplier
|
||||
float gravity;
|
||||
|
||||
// PLAYER SPECIFIC
|
||||
int team;
|
||||
int playerclass;
|
||||
int health;
|
||||
qboolean spectator;
|
||||
int weaponmodel;
|
||||
int gaitsequence;
|
||||
// If standing on conveyor, e.g.
|
||||
vec3_t basevelocity;
|
||||
// Use the crouched hull, or the regular player hull.
|
||||
int usehull;
|
||||
// Latched buttons last time state updated.
|
||||
int oldbuttons;
|
||||
// -1 = in air, else pmove entity number
|
||||
int onground;
|
||||
int iStepLeft;
|
||||
// How fast we are falling
|
||||
float flFallVelocity;
|
||||
|
||||
float fov;
|
||||
int weaponanim;
|
||||
|
||||
// Parametric movement overrides
|
||||
vec3_t startpos;
|
||||
vec3_t endpos;
|
||||
float impacttime;
|
||||
float starttime;
|
||||
|
||||
// For mods
|
||||
int iuser1;
|
||||
int iuser2;
|
||||
int iuser3;
|
||||
int iuser4;
|
||||
float fuser1;
|
||||
float fuser2;
|
||||
float fuser3;
|
||||
float fuser4;
|
||||
vec3_t vuser1;
|
||||
vec3_t vuser2;
|
||||
vec3_t vuser3;
|
||||
vec3_t vuser4;
|
||||
};
|
||||
|
||||
#include "pm_info.h"
|
||||
|
||||
typedef struct clientdata_s
|
||||
{
|
||||
vec3_t origin;
|
||||
vec3_t velocity;
|
||||
|
||||
int viewmodel;
|
||||
vec3_t punchangle;
|
||||
int flags;
|
||||
int waterlevel;
|
||||
int watertype;
|
||||
vec3_t view_ofs;
|
||||
float health;
|
||||
|
||||
int bInDuck;
|
||||
int weapons; // remove?
|
||||
|
||||
int flTimeStepSound;
|
||||
int flDuckTime;
|
||||
int flSwimTime;
|
||||
int waterjumptime;
|
||||
|
||||
float maxspeed;
|
||||
|
||||
float fov;
|
||||
int weaponanim;
|
||||
|
||||
int m_iId;
|
||||
int ammo_shells;
|
||||
int ammo_nails;
|
||||
int ammo_cells;
|
||||
int ammo_rockets;
|
||||
float m_flNextAttack;
|
||||
|
||||
int tfstate;
|
||||
int pushmsec;
|
||||
int deadflag;
|
||||
char physinfo[MAX_PHYSINFO_STRING];
|
||||
|
||||
// For mods
|
||||
int iuser1;
|
||||
int iuser2;
|
||||
int iuser3;
|
||||
int iuser4;
|
||||
float fuser1;
|
||||
float fuser2;
|
||||
float fuser3;
|
||||
float fuser4;
|
||||
vec3_t vuser1;
|
||||
vec3_t vuser2;
|
||||
vec3_t vuser3;
|
||||
vec3_t vuser4;
|
||||
|
||||
} clientdata_t;
|
||||
|
||||
#include "weaponinfo.h"
|
||||
|
||||
typedef struct local_state_s
|
||||
{
|
||||
entity_state_t playerstate;
|
||||
clientdata_t client;
|
||||
weapon_data_t weapondata[64];
|
||||
} local_state_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef ENTITY_STATE_H
|
||||
#define ENTITY_STATE_H
|
||||
|
||||
// For entityType below
|
||||
#define ENTITY_NORMAL (1<<0)
|
||||
#define ENTITY_BEAM (1<<1)
|
||||
|
||||
// Entity state is used for the baseline and for delta compression of a packet of
|
||||
// entities that is sent to a client.
|
||||
typedef struct entity_state_s entity_state_t;
|
||||
|
||||
struct entity_state_s
|
||||
{
|
||||
// Fields which are filled in by routines outside of delta compression
|
||||
int entityType;
|
||||
// Index into cl_entities array for this entity.
|
||||
int number;
|
||||
float msg_time;
|
||||
|
||||
// Message number last time the player/entity state was updated.
|
||||
int messagenum;
|
||||
|
||||
// Fields which can be transitted and reconstructed over the network stream
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
|
||||
int modelindex;
|
||||
int sequence;
|
||||
float frame;
|
||||
int colormap;
|
||||
short skin;
|
||||
short solid;
|
||||
int effects;
|
||||
float scale;
|
||||
byte eflags;
|
||||
|
||||
// Render information
|
||||
int rendermode;
|
||||
int renderamt;
|
||||
color24 rendercolor;
|
||||
int renderfx;
|
||||
|
||||
int movetype;
|
||||
float animtime;
|
||||
float framerate;
|
||||
int body;
|
||||
byte controller[4];
|
||||
byte blending[4];
|
||||
vec3_t velocity;
|
||||
|
||||
// Send bbox down to client for use during prediction.
|
||||
vec3_t mins;
|
||||
vec3_t maxs;
|
||||
|
||||
int aiment;
|
||||
// If owned by a player, the index of that player ( for projectiles ).
|
||||
int owner;
|
||||
|
||||
// Friction, for prediction.
|
||||
float friction;
|
||||
// Gravity multiplier
|
||||
float gravity;
|
||||
|
||||
// PLAYER SPECIFIC
|
||||
int team;
|
||||
int playerclass;
|
||||
int health;
|
||||
qboolean spectator;
|
||||
int weaponmodel;
|
||||
int gaitsequence;
|
||||
// If standing on conveyor, e.g.
|
||||
vec3_t basevelocity;
|
||||
// Use the crouched hull, or the regular player hull.
|
||||
int usehull;
|
||||
// Latched buttons last time state updated.
|
||||
int oldbuttons;
|
||||
// -1 = in air, else pmove entity number
|
||||
int onground;
|
||||
int iStepLeft;
|
||||
// How fast we are falling
|
||||
float flFallVelocity;
|
||||
|
||||
float fov;
|
||||
int weaponanim;
|
||||
|
||||
// Parametric movement overrides
|
||||
vec3_t startpos;
|
||||
vec3_t endpos;
|
||||
float impacttime;
|
||||
float starttime;
|
||||
|
||||
// For mods
|
||||
int iuser1;
|
||||
int iuser2;
|
||||
int iuser3;
|
||||
int iuser4;
|
||||
float fuser1;
|
||||
float fuser2;
|
||||
float fuser3;
|
||||
float fuser4;
|
||||
vec3_t vuser1;
|
||||
vec3_t vuser2;
|
||||
vec3_t vuser3;
|
||||
vec3_t vuser4;
|
||||
};
|
||||
|
||||
#include "pm_info.h"
|
||||
|
||||
typedef struct clientdata_s
|
||||
{
|
||||
vec3_t origin;
|
||||
vec3_t velocity;
|
||||
|
||||
int viewmodel;
|
||||
vec3_t punchangle;
|
||||
int flags;
|
||||
int waterlevel;
|
||||
int watertype;
|
||||
vec3_t view_ofs;
|
||||
float health;
|
||||
|
||||
int bInDuck;
|
||||
int weapons; // remove?
|
||||
|
||||
int flTimeStepSound;
|
||||
int flDuckTime;
|
||||
int flSwimTime;
|
||||
int waterjumptime;
|
||||
|
||||
float maxspeed;
|
||||
|
||||
float fov;
|
||||
int weaponanim;
|
||||
|
||||
int m_iId;
|
||||
int ammo_shells;
|
||||
int ammo_nails;
|
||||
int ammo_cells;
|
||||
int ammo_rockets;
|
||||
float m_flNextAttack;
|
||||
|
||||
int tfstate;
|
||||
int pushmsec;
|
||||
int deadflag;
|
||||
char physinfo[MAX_PHYSINFO_STRING];
|
||||
|
||||
// For mods
|
||||
int iuser1;
|
||||
int iuser2;
|
||||
int iuser3;
|
||||
int iuser4;
|
||||
float fuser1;
|
||||
float fuser2;
|
||||
float fuser3;
|
||||
float fuser4;
|
||||
vec3_t vuser1;
|
||||
vec3_t vuser2;
|
||||
vec3_t vuser3;
|
||||
vec3_t vuser4;
|
||||
|
||||
} clientdata_t;
|
||||
|
||||
#include "weaponinfo.h"
|
||||
|
||||
typedef struct local_state_s
|
||||
{
|
||||
entity_state_t playerstate;
|
||||
clientdata_t client;
|
||||
weapon_data_t weapondata[64];
|
||||
} local_state_t;
|
||||
|
||||
#endif//ENTITY_STATE_H
|
|
@ -1,25 +1,25 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef ENTITY_TYPES_H
|
||||
#define ENTITY_TYPES_H
|
||||
|
||||
#define ET_NORMAL 0
|
||||
#define ET_PLAYER 1
|
||||
#define ET_TEMPENTITY 2
|
||||
#define ET_BEAM 3
|
||||
#define ET_FRAGMENTED 4 // BMODEL or SPRITE that was split across BSP nodes
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef ENTITY_TYPES_H
|
||||
#define ENTITY_TYPES_H
|
||||
|
||||
#define ET_NORMAL 0
|
||||
#define ET_PLAYER 1
|
||||
#define ET_TEMPENTITY 2
|
||||
#define ET_BEAM 3
|
||||
#define ET_FRAGMENTED 4 // BMODEL or SPRITE that was split across BSP nodes
|
||||
|
||||
#endif//ENTITY_TYPES_H
|
|
@ -1,54 +1,54 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef EVENT_API_H
|
||||
#define EVENT_API_H
|
||||
|
||||
#define EVENT_API_VERSION 1
|
||||
|
||||
typedef struct event_api_s
|
||||
{
|
||||
int version;
|
||||
void ( *EV_PlaySound )( int ent, float *origin, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch );
|
||||
void ( *EV_StopSound )( int ent, int channel, const char *sample );
|
||||
int ( *EV_FindModelIndex )( const char *pmodel );
|
||||
int ( *EV_IsLocal )( int playernum );
|
||||
int ( *EV_LocalPlayerDucking )( void );
|
||||
void ( *EV_LocalPlayerViewheight )( float * );
|
||||
void ( *EV_LocalPlayerBounds )( int hull, float *mins, float *maxs );
|
||||
int ( *EV_IndexFromTrace)( struct pmtrace_s *pTrace );
|
||||
struct physent_s *( *EV_GetPhysent )( int idx );
|
||||
void ( *EV_SetUpPlayerPrediction )( int dopred, int bIncludeLocalClient );
|
||||
void ( *EV_PushPMStates )( void );
|
||||
void ( *EV_PopPMStates )( void );
|
||||
void ( *EV_SetSolidPlayers )( int playernum );
|
||||
void ( *EV_SetTraceHull )( int hull );
|
||||
void ( *EV_PlayerTrace )( float *start, float *end, int traceFlags, int ignore_pe, struct pmtrace_s *tr );
|
||||
void ( *EV_WeaponAnimation )( int sequence, int body );
|
||||
unsigned short ( *EV_PrecacheEvent )( int type, const char* psz );
|
||||
void ( *EV_PlaybackEvent )( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
||||
const char *( *EV_TraceTexture )( int ground, float *vstart, float *vend );
|
||||
void ( *EV_StopAllSounds )( int entnum, int entchannel );
|
||||
void ( *EV_KillEvents )( int entnum, const char *eventname );
|
||||
|
||||
// Xash3D extension
|
||||
unsigned short (*EV_IndexForEvent)( const char *name );
|
||||
const char *(*EV_EventForIndex)( unsigned short index );
|
||||
void ( *EV_PlayerTraceExt )( float *start, float *end, int traceFlags, int (*pfnIgnore)( struct physent_s *pe ), struct pmtrace_s *tr );
|
||||
const char *(*EV_SoundForIndex)( int index );
|
||||
struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend );
|
||||
} event_api_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef EVENT_API_H
|
||||
#define EVENT_API_H
|
||||
|
||||
#define EVENT_API_VERSION 1
|
||||
|
||||
typedef struct event_api_s
|
||||
{
|
||||
int version;
|
||||
void ( *EV_PlaySound )( int ent, float *origin, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch );
|
||||
void ( *EV_StopSound )( int ent, int channel, const char *sample );
|
||||
int ( *EV_FindModelIndex )( const char *pmodel );
|
||||
int ( *EV_IsLocal )( int playernum );
|
||||
int ( *EV_LocalPlayerDucking )( void );
|
||||
void ( *EV_LocalPlayerViewheight )( float * );
|
||||
void ( *EV_LocalPlayerBounds )( int hull, float *mins, float *maxs );
|
||||
int ( *EV_IndexFromTrace)( struct pmtrace_s *pTrace );
|
||||
struct physent_s *( *EV_GetPhysent )( int idx );
|
||||
void ( *EV_SetUpPlayerPrediction )( int dopred, int bIncludeLocalClient );
|
||||
void ( *EV_PushPMStates )( void );
|
||||
void ( *EV_PopPMStates )( void );
|
||||
void ( *EV_SetSolidPlayers )( int playernum );
|
||||
void ( *EV_SetTraceHull )( int hull );
|
||||
void ( *EV_PlayerTrace )( float *start, float *end, int traceFlags, int ignore_pe, struct pmtrace_s *tr );
|
||||
void ( *EV_WeaponAnimation )( int sequence, int body );
|
||||
unsigned short ( *EV_PrecacheEvent )( int type, const char* psz );
|
||||
void ( *EV_PlaybackEvent )( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
||||
const char *( *EV_TraceTexture )( int ground, float *vstart, float *vend );
|
||||
void ( *EV_StopAllSounds )( int entnum, int entchannel );
|
||||
void ( *EV_KillEvents )( int entnum, const char *eventname );
|
||||
|
||||
// Xash3D extension
|
||||
unsigned short (*EV_IndexForEvent)( const char *name );
|
||||
const char *(*EV_EventForIndex)( unsigned short index );
|
||||
void ( *EV_PlayerTraceExt )( float *start, float *end, int traceFlags, int (*pfnIgnore)( struct physent_s *pe ), struct pmtrace_s *tr );
|
||||
const char *(*EV_SoundForIndex)( int index );
|
||||
struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend );
|
||||
} event_api_t;
|
||||
|
||||
#endif//EVENT_API_H
|
|
@ -1,47 +1,47 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef EVENT_ARGS_H
|
||||
#define EVENT_ARGS_H
|
||||
|
||||
// Event was invoked with stated origin
|
||||
#define FEVENT_ORIGIN ( 1<<0 )
|
||||
|
||||
// Event was invoked with stated angles
|
||||
#define FEVENT_ANGLES ( 1<<1 )
|
||||
|
||||
typedef struct event_args_s
|
||||
{
|
||||
int flags;
|
||||
|
||||
// Transmitted
|
||||
int entindex;
|
||||
|
||||
float origin[3];
|
||||
float angles[3];
|
||||
float velocity[3];
|
||||
|
||||
int ducking;
|
||||
|
||||
float fparam1;
|
||||
float fparam2;
|
||||
|
||||
int iparam1;
|
||||
int iparam2;
|
||||
|
||||
int bparam1;
|
||||
int bparam2;
|
||||
} event_args_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef EVENT_ARGS_H
|
||||
#define EVENT_ARGS_H
|
||||
|
||||
// Event was invoked with stated origin
|
||||
#define FEVENT_ORIGIN ( 1<<0 )
|
||||
|
||||
// Event was invoked with stated angles
|
||||
#define FEVENT_ANGLES ( 1<<1 )
|
||||
|
||||
typedef struct event_args_s
|
||||
{
|
||||
int flags;
|
||||
|
||||
// Transmitted
|
||||
int entindex;
|
||||
|
||||
float origin[3];
|
||||
float angles[3];
|
||||
float velocity[3];
|
||||
|
||||
int ducking;
|
||||
|
||||
float fparam1;
|
||||
float fparam2;
|
||||
|
||||
int iparam1;
|
||||
int iparam2;
|
||||
|
||||
int bparam1;
|
||||
int bparam2;
|
||||
} event_args_t;
|
||||
|
||||
#endif//EVENT_ARGS_H
|
|
@ -1,45 +1,45 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef EVENT_FLAGS_H
|
||||
#define EVENT_FLAGS_H
|
||||
|
||||
// Skip local host for event send.
|
||||
#define FEV_NOTHOST (1<<0)
|
||||
|
||||
// Send the event reliably. You must specify the origin and angles and use
|
||||
// PLAYBACK_EVENT_FULL for this to work correctly on the server for anything
|
||||
// that depends on the event origin/angles. I.e., the origin/angles are not
|
||||
// taken from the invoking edict for reliable events.
|
||||
#define FEV_RELIABLE (1<<1)
|
||||
|
||||
// Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC
|
||||
// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ).
|
||||
#define FEV_GLOBAL (1<<2)
|
||||
|
||||
// If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate
|
||||
//
|
||||
#define FEV_UPDATE (1<<3)
|
||||
|
||||
// Only send to entity specified as the invoker
|
||||
#define FEV_HOSTONLY (1<<4)
|
||||
|
||||
// Only send if the event was created on the server.
|
||||
#define FEV_SERVER (1<<5)
|
||||
|
||||
// Only issue event client side ( from shared code )
|
||||
#define FEV_CLIENT (1<<6)
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef EVENT_FLAGS_H
|
||||
#define EVENT_FLAGS_H
|
||||
|
||||
// Skip local host for event send.
|
||||
#define FEV_NOTHOST (1<<0)
|
||||
|
||||
// Send the event reliably. You must specify the origin and angles and use
|
||||
// PLAYBACK_EVENT_FULL for this to work correctly on the server for anything
|
||||
// that depends on the event origin/angles. I.e., the origin/angles are not
|
||||
// taken from the invoking edict for reliable events.
|
||||
#define FEV_RELIABLE (1<<1)
|
||||
|
||||
// Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC
|
||||
// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ).
|
||||
#define FEV_GLOBAL (1<<2)
|
||||
|
||||
// If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate
|
||||
//
|
||||
#define FEV_UPDATE (1<<3)
|
||||
|
||||
// Only send to entity specified as the invoker
|
||||
#define FEV_HOSTONLY (1<<4)
|
||||
|
||||
// Only send if the event was created on the server.
|
||||
#define FEV_SERVER (1<<5)
|
||||
|
||||
// Only issue event client side ( from shared code )
|
||||
#define FEV_CLIENT (1<<6)
|
||||
|
||||
#endif//EVENT_FLAGS_H
|
|
@ -1,49 +1,49 @@
|
|||
/*
|
||||
gameinfo.h - current game info
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GAMEINFO_H
|
||||
#define GAMEINFO_H
|
||||
|
||||
#define GFL_NOMODELS (1<<0)
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
GAMEINFO stuff
|
||||
|
||||
internal shared gameinfo structure (readonly for engine parts)
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
// filesystem info
|
||||
char gamefolder[64]; // used for change game '-game x'
|
||||
char startmap[64]; // map to start singleplayer game
|
||||
char trainmap[64]; // map to start hazard course (if specified)
|
||||
char title[64]; // Game Main Title
|
||||
char version[14]; // game version (optional)
|
||||
short flags; // game flags
|
||||
|
||||
// about mod info
|
||||
char game_url[256]; // link to a developer's site
|
||||
char update_url[256]; // link to updates page
|
||||
char type[64]; // single, toolkit, multiplayer etc
|
||||
char date[64];
|
||||
char size[64]; // displayed mod size
|
||||
|
||||
int gamemode;
|
||||
} GAMEINFO;
|
||||
|
||||
/*
|
||||
gameinfo.h - current game info
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GAMEINFO_H
|
||||
#define GAMEINFO_H
|
||||
|
||||
#define GFL_NOMODELS (1<<0)
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
GAMEINFO stuff
|
||||
|
||||
internal shared gameinfo structure (readonly for engine parts)
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
// filesystem info
|
||||
char gamefolder[64]; // used for change game '-game x'
|
||||
char startmap[64]; // map to start singleplayer game
|
||||
char trainmap[64]; // map to start hazard course (if specified)
|
||||
char title[64]; // Game Main Title
|
||||
char version[14]; // game version (optional)
|
||||
short flags; // game flags
|
||||
|
||||
// about mod info
|
||||
char game_url[256]; // link to a developer's site
|
||||
char update_url[256]; // link to updates page
|
||||
char type[64]; // single, toolkit, multiplayer etc
|
||||
char date[64];
|
||||
char size[64]; // displayed mod size
|
||||
|
||||
int gamemode;
|
||||
} GAMEINFO;
|
||||
|
||||
#endif//GAMEINFO_H
|
116
common/hltv.h
116
common/hltv.h
|
@ -1,59 +1,59 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef HLTV_H
|
||||
#define HLTV_H
|
||||
|
||||
#define TYPE_CLIENT 0 // client is a normal HL client (default)
|
||||
#define TYPE_PROXY 1 // client is another proxy
|
||||
#define TYPE_COMMENTATOR 3 // client is a commentator
|
||||
#define TYPE_DEMO 4 // client is a demo file
|
||||
|
||||
// sub commands of svc_hltv:
|
||||
#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands
|
||||
#define HLTV_STATUS 1 // send status infos about proxy
|
||||
#define HLTV_LISTEN 2 // tell client to listen to a multicast stream
|
||||
|
||||
// sub commands of svc_director:
|
||||
#define DRC_CMD_NONE 0 // NULL director command
|
||||
#define DRC_CMD_START 1 // start director mode
|
||||
#define DRC_CMD_EVENT 2 // informs about director command
|
||||
#define DRC_CMD_MODE 3 // switches camera modes
|
||||
#define DRC_CMD_CAMERA 4 // sets camera registers
|
||||
#define DRC_CMD_TIMESCALE 5 // sets time scale
|
||||
#define DRC_CMD_MESSAGE 6 // send HUD centerprint
|
||||
#define DRC_CMD_SOUND 7 // plays a particular sound
|
||||
#define DRC_CMD_STATUS 8 // status info about broadcast
|
||||
#define DRC_CMD_BANNER 9 // banner file name for HLTV gui
|
||||
#define DRC_CMD_FADE 10 // send screen fade command
|
||||
#define DRC_CMD_SHAKE 11 // send screen shake command
|
||||
#define DRC_CMD_STUFFTEXT 12 // like the normal svc_stufftext but as director command
|
||||
|
||||
#define DRC_CMD_LAST 12
|
||||
|
||||
// HLTV_EVENT event flags
|
||||
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
|
||||
#define DRC_FLAG_SIDE (1<<4) //
|
||||
#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene
|
||||
#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo
|
||||
#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc)
|
||||
#define DRC_FLAG_INTRO (1<<8) // is a introduction scene
|
||||
#define DRC_FLAG_FINAL (1<<9) // is a final scene
|
||||
#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data
|
||||
|
||||
#define MAX_DIRECTOR_CMD_PARAMETERS 4
|
||||
#define MAX_DIRECTOR_CMD_STRING 128
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef HLTV_H
|
||||
#define HLTV_H
|
||||
|
||||
#define TYPE_CLIENT 0 // client is a normal HL client (default)
|
||||
#define TYPE_PROXY 1 // client is another proxy
|
||||
#define TYPE_COMMENTATOR 3 // client is a commentator
|
||||
#define TYPE_DEMO 4 // client is a demo file
|
||||
|
||||
// sub commands of svc_hltv:
|
||||
#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands
|
||||
#define HLTV_STATUS 1 // send status infos about proxy
|
||||
#define HLTV_LISTEN 2 // tell client to listen to a multicast stream
|
||||
|
||||
// sub commands of svc_director:
|
||||
#define DRC_CMD_NONE 0 // NULL director command
|
||||
#define DRC_CMD_START 1 // start director mode
|
||||
#define DRC_CMD_EVENT 2 // informs about director command
|
||||
#define DRC_CMD_MODE 3 // switches camera modes
|
||||
#define DRC_CMD_CAMERA 4 // sets camera registers
|
||||
#define DRC_CMD_TIMESCALE 5 // sets time scale
|
||||
#define DRC_CMD_MESSAGE 6 // send HUD centerprint
|
||||
#define DRC_CMD_SOUND 7 // plays a particular sound
|
||||
#define DRC_CMD_STATUS 8 // status info about broadcast
|
||||
#define DRC_CMD_BANNER 9 // banner file name for HLTV gui
|
||||
#define DRC_CMD_FADE 10 // send screen fade command
|
||||
#define DRC_CMD_SHAKE 11 // send screen shake command
|
||||
#define DRC_CMD_STUFFTEXT 12 // like the normal svc_stufftext but as director command
|
||||
|
||||
#define DRC_CMD_LAST 12
|
||||
|
||||
// HLTV_EVENT event flags
|
||||
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
|
||||
#define DRC_FLAG_SIDE (1<<4) //
|
||||
#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene
|
||||
#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo
|
||||
#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc)
|
||||
#define DRC_FLAG_INTRO (1<<8) // is a introduction scene
|
||||
#define DRC_FLAG_FINAL (1<<9) // is a final scene
|
||||
#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data
|
||||
|
||||
#define MAX_DIRECTOR_CMD_PARAMETERS 4
|
||||
#define MAX_DIRECTOR_CMD_STRING 128
|
||||
|
||||
#endif//HLTV_H
|
|
@ -1,40 +1,40 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef IVOICETWEAK_H
|
||||
#define IVOICETWEAK_H
|
||||
|
||||
// These provide access to the voice controls.
|
||||
typedef enum
|
||||
{
|
||||
MicrophoneVolume = 0, // values 0-1.
|
||||
OtherSpeakerScale // values 0-1. Scales how loud other players are.
|
||||
} VoiceTweakControl;
|
||||
|
||||
typedef struct IVoiceTweak_s
|
||||
{
|
||||
// These turn voice tweak mode on and off. While in voice tweak mode, the user's voice is echoed back
|
||||
// without sending to the server.
|
||||
int (*StartVoiceTweakMode)( void ); // Returns 0 on error.
|
||||
void (*EndVoiceTweakMode)( void );
|
||||
|
||||
// Get/set control values.
|
||||
void (*SetControlFloat)( VoiceTweakControl iControl, float value );
|
||||
float (*GetControlFloat)( VoiceTweakControl iControl );
|
||||
|
||||
int (*GetSpeakingVolume)( void );
|
||||
} IVoiceTweak;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef IVOICETWEAK_H
|
||||
#define IVOICETWEAK_H
|
||||
|
||||
// These provide access to the voice controls.
|
||||
typedef enum
|
||||
{
|
||||
MicrophoneVolume = 0, // values 0-1.
|
||||
OtherSpeakerScale // values 0-1. Scales how loud other players are.
|
||||
} VoiceTweakControl;
|
||||
|
||||
typedef struct IVoiceTweak_s
|
||||
{
|
||||
// These turn voice tweak mode on and off. While in voice tweak mode, the user's voice is echoed back
|
||||
// without sending to the server.
|
||||
int (*StartVoiceTweakMode)( void ); // Returns 0 on error.
|
||||
void (*EndVoiceTweakMode)( void );
|
||||
|
||||
// Get/set control values.
|
||||
void (*SetControlFloat)( VoiceTweakControl iControl, float value );
|
||||
float (*GetControlFloat)( VoiceTweakControl iControl );
|
||||
|
||||
int (*GetSpeakingVolume)( void );
|
||||
} IVoiceTweak;
|
||||
|
||||
#endif//IVOICETWEAK_H
|
|
@ -1,29 +1,29 @@
|
|||
/*
|
||||
lightstyle.h - lighstyle description
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LIGHTSTYLE_H
|
||||
#define LIGHTSTYLE_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char pattern[256];
|
||||
float map[256];
|
||||
int length;
|
||||
float value;
|
||||
qboolean interp; // allow to interpolate this lightstyle
|
||||
float time; // local time is gurantee what new style begins from the start, not mid or end of the sequence
|
||||
} lightstyle_t;
|
||||
|
||||
/*
|
||||
lightstyle.h - lighstyle description
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LIGHTSTYLE_H
|
||||
#define LIGHTSTYLE_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char pattern[256];
|
||||
float map[256];
|
||||
int length;
|
||||
float value;
|
||||
qboolean interp; // allow to interpolate this lightstyle
|
||||
float time; // local time is gurantee what new style begins from the start, not mid or end of the sequence
|
||||
} lightstyle_t;
|
||||
|
||||
#endif//LIGHTSTYLE_H
|
190
common/mathlib.h
190
common/mathlib.h
|
@ -1,95 +1,95 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// mathlib.h
|
||||
|
||||
#include <math.h>
|
||||
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec2_t[2];
|
||||
typedef vec_t vec3_t[3];
|
||||
typedef vec_t vec4_t[4]; // x,y,z,w
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
struct mplane_s;
|
||||
|
||||
extern vec3_t vec3_origin;
|
||||
extern int nanmask;
|
||||
|
||||
#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
|
||||
|
||||
#ifndef VECTOR_H
|
||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
||||
#endif
|
||||
|
||||
#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;}
|
||||
|
||||
void VectorMA (const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc);
|
||||
|
||||
vec_t _DotProduct (vec3_t v1, vec3_t v2);
|
||||
void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
|
||||
void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
|
||||
void _VectorCopy (vec3_t in, vec3_t out);
|
||||
|
||||
int VectorCompare (const vec3_t v1, const vec3_t v2);
|
||||
float Length (const vec3_t v);
|
||||
void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross);
|
||||
float VectorNormalize (vec3_t v); // returns vector length
|
||||
void VectorInverse (vec3_t v);
|
||||
void VectorScale (const vec3_t in, vec_t scale, vec3_t out);
|
||||
|
||||
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
|
||||
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
|
||||
|
||||
void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
|
||||
void AngleVectorsTranspose (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
|
||||
#define AngleIVectors AngleVectorsTranspose
|
||||
|
||||
void AngleMatrix (const vec3_t angles, float (*matrix)[4] );
|
||||
void AngleIMatrix (const vec3_t angles, float (*matrix)[4] );
|
||||
void VectorTransform (const vec3_t in1, float in2[3][4], vec3_t out);
|
||||
|
||||
void NormalizeAngles( vec3_t angles );
|
||||
void InterpolateAngles( vec3_t start, vec3_t end, vec3_t output, float frac );
|
||||
float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 );
|
||||
|
||||
void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up);
|
||||
void VectorAngles( const vec3_t forward, vec3_t angles );
|
||||
|
||||
int InvertMatrix( const float * m, float *out );
|
||||
|
||||
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
|
||||
float anglemod(float a);
|
||||
|
||||
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
|
||||
(((p)->type < 3)? \
|
||||
( \
|
||||
((p)->dist <= (emins)[(p)->type])? \
|
||||
1 \
|
||||
: \
|
||||
( \
|
||||
((p)->dist >= (emaxs)[(p)->type])?\
|
||||
2 \
|
||||
: \
|
||||
3 \
|
||||
) \
|
||||
) \
|
||||
: \
|
||||
BoxOnPlaneSide( (emins), (emaxs), (p)))
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// mathlib.h
|
||||
|
||||
#include <math.h>
|
||||
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec2_t[2];
|
||||
typedef vec_t vec3_t[3];
|
||||
typedef vec_t vec4_t[4]; // x,y,z,w
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
struct mplane_s;
|
||||
|
||||
extern vec3_t vec3_origin;
|
||||
extern int nanmask;
|
||||
|
||||
#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
|
||||
|
||||
#ifndef VECTOR_H
|
||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
||||
#endif
|
||||
|
||||
#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;}
|
||||
|
||||
void VectorMA (const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc);
|
||||
|
||||
vec_t _DotProduct (vec3_t v1, vec3_t v2);
|
||||
void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
|
||||
void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
|
||||
void _VectorCopy (vec3_t in, vec3_t out);
|
||||
|
||||
int VectorCompare (const vec3_t v1, const vec3_t v2);
|
||||
float Length (const vec3_t v);
|
||||
void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross);
|
||||
float VectorNormalize (vec3_t v); // returns vector length
|
||||
void VectorInverse (vec3_t v);
|
||||
void VectorScale (const vec3_t in, vec_t scale, vec3_t out);
|
||||
|
||||
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
|
||||
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
|
||||
|
||||
void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
|
||||
void AngleVectorsTranspose (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
|
||||
#define AngleIVectors AngleVectorsTranspose
|
||||
|
||||
void AngleMatrix (const vec3_t angles, float (*matrix)[4] );
|
||||
void AngleIMatrix (const vec3_t angles, float (*matrix)[4] );
|
||||
void VectorTransform (const vec3_t in1, float in2[3][4], vec3_t out);
|
||||
|
||||
void NormalizeAngles( vec3_t angles );
|
||||
void InterpolateAngles( vec3_t start, vec3_t end, vec3_t output, float frac );
|
||||
float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 );
|
||||
|
||||
void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up);
|
||||
void VectorAngles( const vec3_t forward, vec3_t angles );
|
||||
|
||||
int InvertMatrix( const float * m, float *out );
|
||||
|
||||
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
|
||||
float anglemod(float a);
|
||||
|
||||
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
|
||||
(((p)->type < 3)? \
|
||||
( \
|
||||
((p)->dist <= (emins)[(p)->type])? \
|
||||
1 \
|
||||
: \
|
||||
( \
|
||||
((p)->dist >= (emaxs)[(p)->type])?\
|
||||
2 \
|
||||
: \
|
||||
3 \
|
||||
) \
|
||||
) \
|
||||
: \
|
||||
BoxOnPlaneSide( (emins), (emaxs), (p)))
|
||||
|
|
192
common/net_api.h
192
common/net_api.h
|
@ -1,97 +1,97 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef NET_API_H
|
||||
#define NET_API_H
|
||||
|
||||
#include "netadr.h"
|
||||
|
||||
#define NETAPI_REQUEST_SERVERLIST ( 0 ) // Doesn't need a remote address
|
||||
#define NETAPI_REQUEST_PING ( 1 )
|
||||
#define NETAPI_REQUEST_RULES ( 2 )
|
||||
#define NETAPI_REQUEST_PLAYERS ( 3 )
|
||||
#define NETAPI_REQUEST_DETAILS ( 4 )
|
||||
|
||||
// Set this flag for things like broadcast requests, etc. where the engine should not
|
||||
// kill the request hook after receiving the first response
|
||||
#define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 )
|
||||
|
||||
typedef void (*net_api_response_func_t) ( struct net_response_s *response );
|
||||
|
||||
#define NET_SUCCESS ( 0 )
|
||||
#define NET_ERROR_TIMEOUT ( 1<<0 )
|
||||
#define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 )
|
||||
#define NET_ERROR_UNDEFINED ( 1<<2 )
|
||||
|
||||
typedef struct net_adrlist_s
|
||||
{
|
||||
struct net_adrlist_s *next;
|
||||
netadr_t remote_address;
|
||||
} net_adrlist_t;
|
||||
|
||||
typedef struct net_response_s
|
||||
{
|
||||
// NET_SUCCESS or an error code
|
||||
int error;
|
||||
// Context ID
|
||||
int context;
|
||||
// Type
|
||||
int type;
|
||||
// Server that is responding to the request
|
||||
netadr_t remote_address;
|
||||
// Response RTT ping time
|
||||
double ping;
|
||||
// Key/Value pair string ( separated by backlash \ characters )
|
||||
// WARNING: You must copy this buffer in the callback function, because it is freed
|
||||
// by the engine right after the call!!!!
|
||||
// ALSO: For NETAPI_REQUEST_SERVERLIST requests, this will be a pointer to a linked list of net_adrlist_t's
|
||||
void *response;
|
||||
} net_response_t;
|
||||
|
||||
typedef struct net_status_s
|
||||
{
|
||||
// Connected to remote server? 1 == yes, 0 otherwise
|
||||
int connected;
|
||||
// Client's IP address
|
||||
netadr_t local_address;
|
||||
// Address of remote server
|
||||
netadr_t remote_address;
|
||||
// Packet Loss ( as a percentage )
|
||||
int packet_loss;
|
||||
// Latency, in seconds ( multiply by 1000.0 to get milliseconds )
|
||||
double latency;
|
||||
// Connection time, in seconds
|
||||
double connection_time;
|
||||
// Rate setting ( for incoming data )
|
||||
double rate;
|
||||
} net_status_t;
|
||||
|
||||
typedef struct net_api_s
|
||||
{
|
||||
// APIs
|
||||
void (*InitNetworking)( void );
|
||||
void (*Status )( struct net_status_s *status );
|
||||
void (*SendRequest)( int context, int request, int flags, double timeout, struct netadr_s *remote_address, net_api_response_func_t response );
|
||||
void (*CancelRequest)( int context );
|
||||
void (*CancelAllRequests)( void );
|
||||
char *(*AdrToString)( struct netadr_s *a );
|
||||
int ( *CompareAdr)( struct netadr_s *a, struct netadr_s *b );
|
||||
int ( *StringToAdr)( char *s, struct netadr_s *a );
|
||||
const char *(*ValueForKey)( const char *s, const char *key );
|
||||
void (*RemoveKey)( char *s, const char *key );
|
||||
void (*SetValueForKey)( char *s, const char *key, const char *value, int maxsize );
|
||||
} net_api_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef NET_API_H
|
||||
#define NET_API_H
|
||||
|
||||
#include "netadr.h"
|
||||
|
||||
#define NETAPI_REQUEST_SERVERLIST ( 0 ) // Doesn't need a remote address
|
||||
#define NETAPI_REQUEST_PING ( 1 )
|
||||
#define NETAPI_REQUEST_RULES ( 2 )
|
||||
#define NETAPI_REQUEST_PLAYERS ( 3 )
|
||||
#define NETAPI_REQUEST_DETAILS ( 4 )
|
||||
|
||||
// Set this flag for things like broadcast requests, etc. where the engine should not
|
||||
// kill the request hook after receiving the first response
|
||||
#define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 )
|
||||
|
||||
typedef void (*net_api_response_func_t) ( struct net_response_s *response );
|
||||
|
||||
#define NET_SUCCESS ( 0 )
|
||||
#define NET_ERROR_TIMEOUT ( 1<<0 )
|
||||
#define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 )
|
||||
#define NET_ERROR_UNDEFINED ( 1<<2 )
|
||||
|
||||
typedef struct net_adrlist_s
|
||||
{
|
||||
struct net_adrlist_s *next;
|
||||
netadr_t remote_address;
|
||||
} net_adrlist_t;
|
||||
|
||||
typedef struct net_response_s
|
||||
{
|
||||
// NET_SUCCESS or an error code
|
||||
int error;
|
||||
// Context ID
|
||||
int context;
|
||||
// Type
|
||||
int type;
|
||||
// Server that is responding to the request
|
||||
netadr_t remote_address;
|
||||
// Response RTT ping time
|
||||
double ping;
|
||||
// Key/Value pair string ( separated by backlash \ characters )
|
||||
// WARNING: You must copy this buffer in the callback function, because it is freed
|
||||
// by the engine right after the call!!!!
|
||||
// ALSO: For NETAPI_REQUEST_SERVERLIST requests, this will be a pointer to a linked list of net_adrlist_t's
|
||||
void *response;
|
||||
} net_response_t;
|
||||
|
||||
typedef struct net_status_s
|
||||
{
|
||||
// Connected to remote server? 1 == yes, 0 otherwise
|
||||
int connected;
|
||||
// Client's IP address
|
||||
netadr_t local_address;
|
||||
// Address of remote server
|
||||
netadr_t remote_address;
|
||||
// Packet Loss ( as a percentage )
|
||||
int packet_loss;
|
||||
// Latency, in seconds ( multiply by 1000.0 to get milliseconds )
|
||||
double latency;
|
||||
// Connection time, in seconds
|
||||
double connection_time;
|
||||
// Rate setting ( for incoming data )
|
||||
double rate;
|
||||
} net_status_t;
|
||||
|
||||
typedef struct net_api_s
|
||||
{
|
||||
// APIs
|
||||
void (*InitNetworking)( void );
|
||||
void (*Status )( struct net_status_s *status );
|
||||
void (*SendRequest)( int context, int request, int flags, double timeout, struct netadr_s *remote_address, net_api_response_func_t response );
|
||||
void (*CancelRequest)( int context );
|
||||
void (*CancelAllRequests)( void );
|
||||
char *(*AdrToString)( struct netadr_s *a );
|
||||
int ( *CompareAdr)( struct netadr_s *a, struct netadr_s *b );
|
||||
int ( *StringToAdr)( char *s, struct netadr_s *a );
|
||||
const char *(*ValueForKey)( const char *s, const char *key );
|
||||
void (*RemoveKey)( char *s, const char *key );
|
||||
void (*SetValueForKey)( char *s, const char *key, const char *value, int maxsize );
|
||||
} net_api_t;
|
||||
|
||||
#endif//NET_APIH
|
|
@ -1,37 +1,37 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef NETADR_H
|
||||
#define NETADR_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NA_UNUSED,
|
||||
NA_LOOPBACK,
|
||||
NA_BROADCAST,
|
||||
NA_IP,
|
||||
NA_IPX,
|
||||
NA_BROADCAST_IPX
|
||||
} netadrtype_t;
|
||||
|
||||
typedef struct netadr_s
|
||||
{
|
||||
netadrtype_t type;
|
||||
unsigned char ip[4];
|
||||
unsigned char ipx[10];
|
||||
unsigned short port;
|
||||
} netadr_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef NETADR_H
|
||||
#define NETADR_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NA_UNUSED,
|
||||
NA_LOOPBACK,
|
||||
NA_BROADCAST,
|
||||
NA_IP,
|
||||
NA_IPX,
|
||||
NA_BROADCAST_IPX
|
||||
} netadrtype_t;
|
||||
|
||||
typedef struct netadr_s
|
||||
{
|
||||
netadrtype_t type;
|
||||
unsigned char ip[4];
|
||||
unsigned char ipx[10];
|
||||
unsigned short port;
|
||||
} netadr_t;
|
||||
|
||||
#endif//NETADR_H
|
|
@ -1,54 +1,54 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef PARTICLEDEF_H
|
||||
#define PARTICLEDEF_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
pt_static,
|
||||
pt_grav,
|
||||
pt_slowgrav,
|
||||
pt_fire,
|
||||
pt_explode,
|
||||
pt_explode2,
|
||||
pt_blob,
|
||||
pt_blob2,
|
||||
pt_vox_slowgrav,
|
||||
pt_vox_grav,
|
||||
pt_clientcustom, // Must have callback function specified
|
||||
pt_tracer // Always have callback
|
||||
} ptype_t;
|
||||
|
||||
typedef struct particle_s
|
||||
{
|
||||
vec3_t org;
|
||||
short color;
|
||||
short packedColor;
|
||||
struct particle_s *next;
|
||||
vec3_t vel;
|
||||
float ramp;
|
||||
float die;
|
||||
ptype_t type;
|
||||
void (*deathfunc)( struct particle_s *particle );
|
||||
|
||||
// for pt_clientcusttom, we'll call this function each frame
|
||||
void (*callback)( struct particle_s *particle, float frametime );
|
||||
|
||||
// For deathfunc, etc.
|
||||
unsigned char context;
|
||||
} particle_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef PARTICLEDEF_H
|
||||
#define PARTICLEDEF_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
pt_static,
|
||||
pt_grav,
|
||||
pt_slowgrav,
|
||||
pt_fire,
|
||||
pt_explode,
|
||||
pt_explode2,
|
||||
pt_blob,
|
||||
pt_blob2,
|
||||
pt_vox_slowgrav,
|
||||
pt_vox_grav,
|
||||
pt_clientcustom, // Must have callback function specified
|
||||
pt_tracer // Always have callback
|
||||
} ptype_t;
|
||||
|
||||
typedef struct particle_s
|
||||
{
|
||||
vec3_t org;
|
||||
short color;
|
||||
short packedColor;
|
||||
struct particle_s *next;
|
||||
vec3_t vel;
|
||||
float ramp;
|
||||
float die;
|
||||
ptype_t type;
|
||||
void (*deathfunc)( struct particle_s *particle );
|
||||
|
||||
// for pt_clientcusttom, we'll call this function each frame
|
||||
void (*callback)( struct particle_s *particle, float frametime );
|
||||
|
||||
// For deathfunc, etc.
|
||||
unsigned char context;
|
||||
} particle_t;
|
||||
|
||||
#endif//PARTICLEDEF_H
|
|
@ -1,41 +1,41 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef PM_TRACE_H
|
||||
#define PM_TRACE_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
} pmplane_t;
|
||||
|
||||
typedef struct pmtrace_s pmtrace_t;
|
||||
|
||||
struct pmtrace_s
|
||||
{
|
||||
qboolean allsolid; // if true, plane is not valid
|
||||
qboolean startsolid; // if true, the initial point was in a solid area
|
||||
qboolean inopen, inwater; // End point is in empty space or in water
|
||||
float fraction; // time completed, 1.0 = didn't hit anything
|
||||
vec3_t endpos; // final position
|
||||
pmplane_t plane; // surface normal at impact
|
||||
int ent; // entity at impact
|
||||
vec3_t deltavelocity; // Change in player's velocity caused by impact.
|
||||
// Only run on server.
|
||||
int hitgroup;
|
||||
};
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef PM_TRACE_H
|
||||
#define PM_TRACE_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
} pmplane_t;
|
||||
|
||||
typedef struct pmtrace_s pmtrace_t;
|
||||
|
||||
struct pmtrace_s
|
||||
{
|
||||
qboolean allsolid; // if true, plane is not valid
|
||||
qboolean startsolid; // if true, the initial point was in a solid area
|
||||
qboolean inopen, inwater; // End point is in empty space or in water
|
||||
float fraction; // time completed, 1.0 = didn't hit anything
|
||||
vec3_t endpos; // final position
|
||||
pmplane_t plane; // surface normal at impact
|
||||
int ent; // entity at impact
|
||||
vec3_t deltavelocity; // Change in player's velocity caused by impact.
|
||||
// Only run on server.
|
||||
int hitgroup;
|
||||
};
|
||||
|
||||
#endif//PM_TRACE_H
|
|
@ -1,38 +1,38 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef QFONT_H
|
||||
#define QFONT_H
|
||||
|
||||
// Font stuff
|
||||
|
||||
#define NUM_GLYPHS 256
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short startoffset;
|
||||
short charwidth;
|
||||
} charinfo;
|
||||
|
||||
typedef struct qfont_s
|
||||
{
|
||||
int width, height;
|
||||
int rowcount;
|
||||
int rowheight;
|
||||
charinfo fontinfo[NUM_GLYPHS];
|
||||
byte data[4];
|
||||
} qfont_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef QFONT_H
|
||||
#define QFONT_H
|
||||
|
||||
// Font stuff
|
||||
|
||||
#define NUM_GLYPHS 256
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short startoffset;
|
||||
short charwidth;
|
||||
} charinfo;
|
||||
|
||||
typedef struct qfont_s
|
||||
{
|
||||
int width, height;
|
||||
int rowcount;
|
||||
int rowheight;
|
||||
charinfo fontinfo[NUM_GLYPHS];
|
||||
byte data[4];
|
||||
} qfont_t;
|
||||
|
||||
#endif//QFONT_H
|
388
common/r_efx.h
388
common/r_efx.h
|
@ -1,195 +1,195 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef R_EFX_H
|
||||
#define R_EFX_H
|
||||
|
||||
// particle_t
|
||||
#if !defined( PARTICLEDEFH )
|
||||
#include "particledef.h"
|
||||
#endif
|
||||
|
||||
// BEAM
|
||||
#if !defined( BEAMDEFH )
|
||||
#include "beamdef.h"
|
||||
#endif
|
||||
|
||||
// dlight_t
|
||||
#if !defined ( DLIGHTH )
|
||||
#include "dlight.h"
|
||||
#endif
|
||||
|
||||
// cl_entity_t
|
||||
#if !defined( CL_ENTITYH )
|
||||
#include "cl_entity.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
// FOR REFERENCE, These are the built-in tracer colors. Note, color 4 is the one
|
||||
// that uses the tracerred/tracergreen/tracerblue and traceralpha cvar settings
|
||||
color24 gTracerColors[] =
|
||||
{
|
||||
{ 255, 255, 255 }, // White
|
||||
{ 255, 0, 0 }, // Red
|
||||
{ 0, 255, 0 }, // Green
|
||||
{ 0, 0, 255 }, // Blue
|
||||
{ 0, 0, 0 }, // Tracer default, filled in from cvars, etc.
|
||||
{ 255, 167, 17 }, // Yellow-orange sparks
|
||||
{ 255, 130, 90 }, // Yellowish streaks (garg)
|
||||
{ 55, 60, 144 }, // Blue egon streak
|
||||
{ 255, 130, 90 }, // More Yellowish streaks (garg)
|
||||
{ 255, 140, 90 }, // More Yellowish streaks (garg)
|
||||
{ 200, 130, 90 }, // More red streaks (garg)
|
||||
{ 255, 120, 70 }, // Darker red streaks (garg)
|
||||
};
|
||||
*/
|
||||
|
||||
// Temporary entity array
|
||||
#define TENTPRIORITY_LOW 0
|
||||
#define TENTPRIORITY_HIGH 1
|
||||
|
||||
// TEMPENTITY flags
|
||||
#define FTENT_NONE 0x00000000
|
||||
#define FTENT_SINEWAVE 0x00000001
|
||||
#define FTENT_GRAVITY 0x00000002
|
||||
#define FTENT_ROTATE 0x00000004
|
||||
#define FTENT_SLOWGRAVITY 0x00000008
|
||||
#define FTENT_SMOKETRAIL 0x00000010
|
||||
#define FTENT_COLLIDEWORLD 0x00000020
|
||||
#define FTENT_FLICKER 0x00000040
|
||||
#define FTENT_FADEOUT 0x00000080
|
||||
#define FTENT_SPRANIMATE 0x00000100
|
||||
#define FTENT_HITSOUND 0x00000200
|
||||
#define FTENT_SPIRAL 0x00000400
|
||||
#define FTENT_SPRCYCLE 0x00000800
|
||||
#define FTENT_COLLIDEALL 0x00001000 // will collide with world and slideboxes
|
||||
#define FTENT_PERSIST 0x00002000 // tent is not removed when unable to draw
|
||||
#define FTENT_COLLIDEKILL 0x00004000 // tent is removed upon collision with anything
|
||||
#define FTENT_PLYRATTACHMENT 0x00008000 // tent is attached to a player (owner)
|
||||
#define FTENT_SPRANIMATELOOP 0x00010000 // animating sprite doesn't die when last frame is displayed
|
||||
#define FTENT_SPARKSHOWER 0x00020000
|
||||
#define FTENT_NOMODEL 0x00040000 // Doesn't have a model, never try to draw ( it just triggers other things )
|
||||
#define FTENT_CLIENTCUSTOM 0x00080000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things )
|
||||
#define FTENT_SCALE 0x00100000 // An experiment
|
||||
|
||||
typedef struct tempent_s TEMPENTITY;
|
||||
typedef struct tempent_s
|
||||
{
|
||||
int flags;
|
||||
float die;
|
||||
float frameMax;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float fadeSpeed;
|
||||
float bounceFactor;
|
||||
int hitSound;
|
||||
void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr );
|
||||
void (*callback)( struct tempent_s *ent, float frametime, float currenttime );
|
||||
TEMPENTITY *next;
|
||||
int priority;
|
||||
short clientIndex; // if attached, this is the index of the client to stick to
|
||||
// if COLLIDEALL, this is the index of the client to ignore
|
||||
// TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex!
|
||||
|
||||
vec3_t tentOffset; // if attached, client origin + tentOffset = tent origin.
|
||||
cl_entity_t entity;
|
||||
|
||||
// baseline.origin - velocity
|
||||
// baseline.renderamt - starting fadeout intensity
|
||||
// baseline.angles - angle velocity
|
||||
} TEMPENTITY;
|
||||
|
||||
typedef struct efx_api_s efx_api_t;
|
||||
|
||||
struct efx_api_s
|
||||
{
|
||||
particle_t *(*R_AllocParticle)( void (*callback)( struct particle_s *particle, float frametime ));
|
||||
void (*R_BlobExplosion)( float *org );
|
||||
void (*R_Blood)( float *org, float *dir, int pcolor, int speed );
|
||||
void (*R_BloodSprite)( float *org, int colorindex, int modelIndex, int modelIndex2, float size );
|
||||
void (*R_BloodStream)( float *org, float *dir, int pcolor, int speed );
|
||||
void (*R_BreakModel)( float *pos, float *size, float *dir, float random, float life, int count, int modelIndex, char flags );
|
||||
void (*R_Bubbles)( float *mins, float *maxs, float height, int modelIndex, int count, float speed );
|
||||
void (*R_BubbleTrail)( float *start, float *end, float height, int modelIndex, int count, float speed );
|
||||
void (*R_BulletImpactParticles)( float *pos );
|
||||
void (*R_EntityParticles)( struct cl_entity_s *ent );
|
||||
void (*R_Explosion)( float *pos, int model, float scale, float framerate, int flags );
|
||||
void (*R_FizzEffect)( struct cl_entity_s *pent, int modelIndex, int density );
|
||||
void (*R_FireField)( float *org, int radius, int modelIndex, int count, int flags, float life );
|
||||
void (*R_FlickerParticles)( float *org );
|
||||
void (*R_FunnelSprite)( float *org, int modelIndex, int reverse );
|
||||
void (*R_Implosion)( float *end, float radius, int count, float life );
|
||||
void (*R_LargeFunnel)( float *org, int reverse );
|
||||
void (*R_LavaSplash)( float *org );
|
||||
void (*R_MultiGunshot)( float *org, float *dir, float *noise, int count, int decalCount, int *decalIndices );
|
||||
void (*R_MuzzleFlash)( float *pos1, int type );
|
||||
void (*R_ParticleBox)( float *mins, float *maxs, unsigned char r, unsigned char g, unsigned char b, float life );
|
||||
void (*R_ParticleBurst)( float *pos, int size, int color, float life );
|
||||
void (*R_ParticleExplosion)( float *org );
|
||||
void (*R_ParticleExplosion2)( float *org, int colorStart, int colorLength );
|
||||
void (*R_ParticleLine)( float *start, float *end, unsigned char r, unsigned char g, unsigned char b, float life );
|
||||
void (*R_PlayerSprites)( int client, int modelIndex, int count, int size );
|
||||
void (*R_Projectile)( float *origin, float *velocity, int modelIndex, int life, int owner, void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr ) );
|
||||
void (*R_RicochetSound)( float *pos );
|
||||
void (*R_RicochetSprite)( float *pos, struct model_s *pmodel, float duration, float scale );
|
||||
void (*R_RocketFlare)( float *pos );
|
||||
void (*R_RocketTrail)( float *start, float *end, int type );
|
||||
void (*R_RunParticleEffect)( float *org, float *dir, int color, int count );
|
||||
void (*R_ShowLine)( float *start, float *end );
|
||||
void (*R_SparkEffect)( float *pos, int count, int velocityMin, int velocityMax );
|
||||
void (*R_SparkShower)( float *pos );
|
||||
void (*R_SparkStreaks)( float *pos, int count, int velocityMin, int velocityMax );
|
||||
void (*R_Spray)( float *pos, float *dir, int modelIndex, int count, int speed, int spread, int rendermode );
|
||||
void (*R_Sprite_Explode)( TEMPENTITY *pTemp, float scale, int flags );
|
||||
void (*R_Sprite_Smoke)( TEMPENTITY *pTemp, float scale );
|
||||
void (*R_Sprite_Spray)( float *pos, float *dir, int modelIndex, int count, int speed, int iRand );
|
||||
void (*R_Sprite_Trail)( int type, float *start, float *end, int modelIndex, int count, float life, float size, float amplitude, int renderamt, float speed );
|
||||
void (*R_Sprite_WallPuff)( TEMPENTITY *pTemp, float scale );
|
||||
void (*R_StreakSplash)( float *pos, float *dir, int color, int count, float speed, int velocityMin, int velocityMax );
|
||||
void (*R_TracerEffect)( float *start, float *end );
|
||||
void (*R_UserTracerParticle)( float *org, float *vel, float life, int colorIndex, float length, unsigned char deathcontext, void (*deathfunc)( struct particle_s *particle ));
|
||||
particle_t *(*R_TracerParticles)( float *org, float *vel, float life );
|
||||
void (*R_TeleportSplash)( float *org );
|
||||
void (*R_TempSphereModel)( float *pos, float speed, float life, int count, int modelIndex );
|
||||
TEMPENTITY *(*R_TempModel)( float *pos, float *dir, float *angles, float life, int modelIndex, int soundtype );
|
||||
TEMPENTITY *(*R_DefaultSprite)( float *pos, int spriteIndex, float framerate );
|
||||
TEMPENTITY *(*R_TempSprite)( float *pos, float *dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags );
|
||||
int (*Draw_DecalIndex)( int id );
|
||||
int (*Draw_DecalIndexFromName)( char *name );
|
||||
void (*R_DecalShoot)( int textureIndex, int entity, int modelIndex, float *position, int flags );
|
||||
void (*R_AttachTentToPlayer)( int client, int modelIndex, float zoffset, float life );
|
||||
void (*R_KillAttachedTents)( int client );
|
||||
BEAM *(*R_BeamCirclePoints)( int type, float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
BEAM *(*R_BeamEntPoint)( int startEnt, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
BEAM *(*R_BeamEnts)( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
BEAM *(*R_BeamFollow)( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness );
|
||||
void (*R_BeamKill)( int deadEntity );
|
||||
BEAM *(*R_BeamLightning)( float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed );
|
||||
BEAM *(*R_BeamPoints)( float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
BEAM *(*R_BeamRing)( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
dlight_t *(*CL_AllocDlight)( int key );
|
||||
dlight_t *(*CL_AllocElight)( int key );
|
||||
TEMPENTITY *(*CL_TempEntAlloc)( float *org, struct model_s *model );
|
||||
TEMPENTITY *(*CL_TempEntAllocNoModel)( float *org );
|
||||
TEMPENTITY *(*CL_TempEntAllocHigh)( float *org, struct model_s *model );
|
||||
TEMPENTITY *(*CL_TentEntAllocCustom)( float *origin, struct model_s *model, int high, void (*callback)( struct tempent_s *ent, float frametime, float currenttime ));
|
||||
void (*R_GetPackedColor)( short *packed, short color );
|
||||
short (*R_LookupColor)( unsigned char r, unsigned char g, unsigned char b );
|
||||
void (*R_DecalRemoveAll)( int textureIndex ); // textureIndex points to the decal index in the array, not the actual texture index.
|
||||
void (*R_FireCustomDecal)( int textureIndex, int entity, int modelIndex, float *position, int flags, float scale );
|
||||
};
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef R_EFX_H
|
||||
#define R_EFX_H
|
||||
|
||||
// particle_t
|
||||
#if !defined( PARTICLEDEFH )
|
||||
#include "particledef.h"
|
||||
#endif
|
||||
|
||||
// BEAM
|
||||
#if !defined( BEAMDEFH )
|
||||
#include "beamdef.h"
|
||||
#endif
|
||||
|
||||
// dlight_t
|
||||
#if !defined ( DLIGHTH )
|
||||
#include "dlight.h"
|
||||
#endif
|
||||
|
||||
// cl_entity_t
|
||||
#if !defined( CL_ENTITYH )
|
||||
#include "cl_entity.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
// FOR REFERENCE, These are the built-in tracer colors. Note, color 4 is the one
|
||||
// that uses the tracerred/tracergreen/tracerblue and traceralpha cvar settings
|
||||
color24 gTracerColors[] =
|
||||
{
|
||||
{ 255, 255, 255 }, // White
|
||||
{ 255, 0, 0 }, // Red
|
||||
{ 0, 255, 0 }, // Green
|
||||
{ 0, 0, 255 }, // Blue
|
||||
{ 0, 0, 0 }, // Tracer default, filled in from cvars, etc.
|
||||
{ 255, 167, 17 }, // Yellow-orange sparks
|
||||
{ 255, 130, 90 }, // Yellowish streaks (garg)
|
||||
{ 55, 60, 144 }, // Blue egon streak
|
||||
{ 255, 130, 90 }, // More Yellowish streaks (garg)
|
||||
{ 255, 140, 90 }, // More Yellowish streaks (garg)
|
||||
{ 200, 130, 90 }, // More red streaks (garg)
|
||||
{ 255, 120, 70 }, // Darker red streaks (garg)
|
||||
};
|
||||
*/
|
||||
|
||||
// Temporary entity array
|
||||
#define TENTPRIORITY_LOW 0
|
||||
#define TENTPRIORITY_HIGH 1
|
||||
|
||||
// TEMPENTITY flags
|
||||
#define FTENT_NONE 0x00000000
|
||||
#define FTENT_SINEWAVE 0x00000001
|
||||
#define FTENT_GRAVITY 0x00000002
|
||||
#define FTENT_ROTATE 0x00000004
|
||||
#define FTENT_SLOWGRAVITY 0x00000008
|
||||
#define FTENT_SMOKETRAIL 0x00000010
|
||||
#define FTENT_COLLIDEWORLD 0x00000020
|
||||
#define FTENT_FLICKER 0x00000040
|
||||
#define FTENT_FADEOUT 0x00000080
|
||||
#define FTENT_SPRANIMATE 0x00000100
|
||||
#define FTENT_HITSOUND 0x00000200
|
||||
#define FTENT_SPIRAL 0x00000400
|
||||
#define FTENT_SPRCYCLE 0x00000800
|
||||
#define FTENT_COLLIDEALL 0x00001000 // will collide with world and slideboxes
|
||||
#define FTENT_PERSIST 0x00002000 // tent is not removed when unable to draw
|
||||
#define FTENT_COLLIDEKILL 0x00004000 // tent is removed upon collision with anything
|
||||
#define FTENT_PLYRATTACHMENT 0x00008000 // tent is attached to a player (owner)
|
||||
#define FTENT_SPRANIMATELOOP 0x00010000 // animating sprite doesn't die when last frame is displayed
|
||||
#define FTENT_SPARKSHOWER 0x00020000
|
||||
#define FTENT_NOMODEL 0x00040000 // Doesn't have a model, never try to draw ( it just triggers other things )
|
||||
#define FTENT_CLIENTCUSTOM 0x00080000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things )
|
||||
#define FTENT_SCALE 0x00100000 // An experiment
|
||||
|
||||
typedef struct tempent_s TEMPENTITY;
|
||||
typedef struct tempent_s
|
||||
{
|
||||
int flags;
|
||||
float die;
|
||||
float frameMax;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float fadeSpeed;
|
||||
float bounceFactor;
|
||||
int hitSound;
|
||||
void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr );
|
||||
void (*callback)( struct tempent_s *ent, float frametime, float currenttime );
|
||||
TEMPENTITY *next;
|
||||
int priority;
|
||||
short clientIndex; // if attached, this is the index of the client to stick to
|
||||
// if COLLIDEALL, this is the index of the client to ignore
|
||||
// TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex!
|
||||
|
||||
vec3_t tentOffset; // if attached, client origin + tentOffset = tent origin.
|
||||
cl_entity_t entity;
|
||||
|
||||
// baseline.origin - velocity
|
||||
// baseline.renderamt - starting fadeout intensity
|
||||
// baseline.angles - angle velocity
|
||||
} TEMPENTITY;
|
||||
|
||||
typedef struct efx_api_s efx_api_t;
|
||||
|
||||
struct efx_api_s
|
||||
{
|
||||
particle_t *(*R_AllocParticle)( void (*callback)( struct particle_s *particle, float frametime ));
|
||||
void (*R_BlobExplosion)( float *org );
|
||||
void (*R_Blood)( float *org, float *dir, int pcolor, int speed );
|
||||
void (*R_BloodSprite)( float *org, int colorindex, int modelIndex, int modelIndex2, float size );
|
||||
void (*R_BloodStream)( float *org, float *dir, int pcolor, int speed );
|
||||
void (*R_BreakModel)( float *pos, float *size, float *dir, float random, float life, int count, int modelIndex, char flags );
|
||||
void (*R_Bubbles)( float *mins, float *maxs, float height, int modelIndex, int count, float speed );
|
||||
void (*R_BubbleTrail)( float *start, float *end, float height, int modelIndex, int count, float speed );
|
||||
void (*R_BulletImpactParticles)( float *pos );
|
||||
void (*R_EntityParticles)( struct cl_entity_s *ent );
|
||||
void (*R_Explosion)( float *pos, int model, float scale, float framerate, int flags );
|
||||
void (*R_FizzEffect)( struct cl_entity_s *pent, int modelIndex, int density );
|
||||
void (*R_FireField)( float *org, int radius, int modelIndex, int count, int flags, float life );
|
||||
void (*R_FlickerParticles)( float *org );
|
||||
void (*R_FunnelSprite)( float *org, int modelIndex, int reverse );
|
||||
void (*R_Implosion)( float *end, float radius, int count, float life );
|
||||
void (*R_LargeFunnel)( float *org, int reverse );
|
||||
void (*R_LavaSplash)( float *org );
|
||||
void (*R_MultiGunshot)( float *org, float *dir, float *noise, int count, int decalCount, int *decalIndices );
|
||||
void (*R_MuzzleFlash)( float *pos1, int type );
|
||||
void (*R_ParticleBox)( float *mins, float *maxs, unsigned char r, unsigned char g, unsigned char b, float life );
|
||||
void (*R_ParticleBurst)( float *pos, int size, int color, float life );
|
||||
void (*R_ParticleExplosion)( float *org );
|
||||
void (*R_ParticleExplosion2)( float *org, int colorStart, int colorLength );
|
||||
void (*R_ParticleLine)( float *start, float *end, unsigned char r, unsigned char g, unsigned char b, float life );
|
||||
void (*R_PlayerSprites)( int client, int modelIndex, int count, int size );
|
||||
void (*R_Projectile)( float *origin, float *velocity, int modelIndex, int life, int owner, void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr ) );
|
||||
void (*R_RicochetSound)( float *pos );
|
||||
void (*R_RicochetSprite)( float *pos, struct model_s *pmodel, float duration, float scale );
|
||||
void (*R_RocketFlare)( float *pos );
|
||||
void (*R_RocketTrail)( float *start, float *end, int type );
|
||||
void (*R_RunParticleEffect)( float *org, float *dir, int color, int count );
|
||||
void (*R_ShowLine)( float *start, float *end );
|
||||
void (*R_SparkEffect)( float *pos, int count, int velocityMin, int velocityMax );
|
||||
void (*R_SparkShower)( float *pos );
|
||||
void (*R_SparkStreaks)( float *pos, int count, int velocityMin, int velocityMax );
|
||||
void (*R_Spray)( float *pos, float *dir, int modelIndex, int count, int speed, int spread, int rendermode );
|
||||
void (*R_Sprite_Explode)( TEMPENTITY *pTemp, float scale, int flags );
|
||||
void (*R_Sprite_Smoke)( TEMPENTITY *pTemp, float scale );
|
||||
void (*R_Sprite_Spray)( float *pos, float *dir, int modelIndex, int count, int speed, int iRand );
|
||||
void (*R_Sprite_Trail)( int type, float *start, float *end, int modelIndex, int count, float life, float size, float amplitude, int renderamt, float speed );
|
||||
void (*R_Sprite_WallPuff)( TEMPENTITY *pTemp, float scale );
|
||||
void (*R_StreakSplash)( float *pos, float *dir, int color, int count, float speed, int velocityMin, int velocityMax );
|
||||
void (*R_TracerEffect)( float *start, float *end );
|
||||
void (*R_UserTracerParticle)( float *org, float *vel, float life, int colorIndex, float length, unsigned char deathcontext, void (*deathfunc)( struct particle_s *particle ));
|
||||
particle_t *(*R_TracerParticles)( float *org, float *vel, float life );
|
||||
void (*R_TeleportSplash)( float *org );
|
||||
void (*R_TempSphereModel)( float *pos, float speed, float life, int count, int modelIndex );
|
||||
TEMPENTITY *(*R_TempModel)( float *pos, float *dir, float *angles, float life, int modelIndex, int soundtype );
|
||||
TEMPENTITY *(*R_DefaultSprite)( float *pos, int spriteIndex, float framerate );
|
||||
TEMPENTITY *(*R_TempSprite)( float *pos, float *dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags );
|
||||
int (*Draw_DecalIndex)( int id );
|
||||
int (*Draw_DecalIndexFromName)( char *name );
|
||||
void (*R_DecalShoot)( int textureIndex, int entity, int modelIndex, float *position, int flags );
|
||||
void (*R_AttachTentToPlayer)( int client, int modelIndex, float zoffset, float life );
|
||||
void (*R_KillAttachedTents)( int client );
|
||||
BEAM *(*R_BeamCirclePoints)( int type, float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
BEAM *(*R_BeamEntPoint)( int startEnt, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
BEAM *(*R_BeamEnts)( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
BEAM *(*R_BeamFollow)( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness );
|
||||
void (*R_BeamKill)( int deadEntity );
|
||||
BEAM *(*R_BeamLightning)( float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed );
|
||||
BEAM *(*R_BeamPoints)( float *start, float *end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
BEAM *(*R_BeamRing)( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
|
||||
dlight_t *(*CL_AllocDlight)( int key );
|
||||
dlight_t *(*CL_AllocElight)( int key );
|
||||
TEMPENTITY *(*CL_TempEntAlloc)( float *org, struct model_s *model );
|
||||
TEMPENTITY *(*CL_TempEntAllocNoModel)( float *org );
|
||||
TEMPENTITY *(*CL_TempEntAllocHigh)( float *org, struct model_s *model );
|
||||
TEMPENTITY *(*CL_TentEntAllocCustom)( float *origin, struct model_s *model, int high, void (*callback)( struct tempent_s *ent, float frametime, float currenttime ));
|
||||
void (*R_GetPackedColor)( short *packed, short color );
|
||||
short (*R_LookupColor)( unsigned char r, unsigned char g, unsigned char b );
|
||||
void (*R_DecalRemoveAll)( int textureIndex ); // textureIndex points to the decal index in the array, not the actual texture index.
|
||||
void (*R_FireCustomDecal)( int textureIndex, int entity, int modelIndex, float *position, int flags, float scale );
|
||||
};
|
||||
|
||||
#endif//R_EFX_H
|
|
@ -1,154 +1,154 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
|
||||
#ifndef R_STUDIOINT_H
|
||||
#define R_STUDIOINT_H
|
||||
|
||||
#define STUDIO_INTERFACE_VERSION 1
|
||||
|
||||
typedef struct engine_studio_api_s
|
||||
{
|
||||
// Allocate number*size bytes and zero it
|
||||
void *( *Mem_Calloc )( int number, size_t size );
|
||||
// Check to see if pointer is in the cache
|
||||
void *( *Cache_Check )( struct cache_user_s *c );
|
||||
// Load file into cache ( can be swapped out on demand )
|
||||
void ( *LoadCacheFile )( char *path, struct cache_user_s *cu );
|
||||
// Retrieve model pointer for the named model
|
||||
struct model_s *( *Mod_ForName )( const char *name, int crash_if_missing );
|
||||
// Retrieve pointer to studio model data block from a model
|
||||
void *( *Mod_Extradata )( struct model_s *mod );
|
||||
// Retrieve indexed model from client side model precache list
|
||||
struct model_s *( *GetModelByIndex )( int index );
|
||||
// Get entity that is set for rendering
|
||||
struct cl_entity_s * ( *GetCurrentEntity )( void );
|
||||
// Get referenced player_info_t
|
||||
struct player_info_s *( *PlayerInfo )( int index );
|
||||
// Get most recently received player state data from network system
|
||||
struct entity_state_s *( *GetPlayerState )( int index );
|
||||
// Get viewentity
|
||||
struct cl_entity_s * ( *GetViewEntity )( void );
|
||||
// Get current frame count, and last two timestampes on client
|
||||
void ( *GetTimes )( int *framecount, double *current, double *old );
|
||||
// Get a pointer to a cvar by name
|
||||
struct cvar_s *( *GetCvar )( const char *name );
|
||||
// Get current render origin and view vectors ( up, right and vpn )
|
||||
void ( *GetViewInfo )( float *origin, float *upv, float *rightv, float *vpnv );
|
||||
// Get sprite model used for applying chrome effect
|
||||
struct model_s *( *GetChromeSprite )( void );
|
||||
// Get model counters so we can incement instrumentation
|
||||
void ( *GetModelCounters )( int **s, int **a );
|
||||
// Get software scaling coefficients
|
||||
void ( *GetAliasScale )( float *x, float *y );
|
||||
|
||||
// Get bone, light, alias, and rotation matrices
|
||||
float ****( *StudioGetBoneTransform )( void );
|
||||
float ****( *StudioGetLightTransform )( void );
|
||||
float ***( *StudioGetAliasTransform )( void );
|
||||
float ***( *StudioGetRotationMatrix )( void );
|
||||
|
||||
// Set up body part, and get submodel pointers
|
||||
void ( *StudioSetupModel )( int bodypart, void **ppbodypart, void **ppsubmodel );
|
||||
// Check if entity's bbox is in the view frustum
|
||||
int ( *StudioCheckBBox )( void );
|
||||
// Apply lighting effects to model
|
||||
void ( *StudioDynamicLight )( struct cl_entity_s *ent, struct alight_s *plight );
|
||||
void ( *StudioEntityLight )( struct alight_s *plight );
|
||||
void ( *StudioSetupLighting )( struct alight_s *plighting );
|
||||
|
||||
// Draw mesh vertices
|
||||
void ( *StudioDrawPoints )( void );
|
||||
|
||||
// Draw hulls around bones
|
||||
void ( *StudioDrawHulls )( void );
|
||||
// Draw bbox around studio models
|
||||
void ( *StudioDrawAbsBBox )( void );
|
||||
// Draws bones
|
||||
void ( *StudioDrawBones )( void );
|
||||
// Loads in appropriate texture for model
|
||||
void ( *StudioSetupSkin )( void *ptexturehdr, int index );
|
||||
// Sets up for remapped colors
|
||||
void ( *StudioSetRemapColors )( int top, int bottom );
|
||||
// Set's player model and returns model pointer
|
||||
struct model_s *( *SetupPlayerModel )( int index );
|
||||
// Fires any events embedded in animation
|
||||
void ( *StudioClientEvents )( void );
|
||||
// Retrieve/set forced render effects flags
|
||||
int ( *GetForceFaceFlags )( void );
|
||||
void ( *SetForceFaceFlags )( int flags );
|
||||
// Tell engine the value of the studio model header
|
||||
void ( *StudioSetHeader )( void *header );
|
||||
// Tell engine which model_t * is being renderered
|
||||
void ( *SetRenderModel )( struct model_s *model );
|
||||
|
||||
// Final state setup and restore for rendering
|
||||
void ( *SetupRenderer )( int rendermode );
|
||||
void ( *RestoreRenderer )( void );
|
||||
|
||||
// Set render origin for applying chrome effect
|
||||
void ( *SetChromeOrigin )( void );
|
||||
|
||||
// True if using D3D/OpenGL
|
||||
int ( *IsHardware )( void );
|
||||
|
||||
// Only called by hardware interface
|
||||
void ( *GL_StudioDrawShadow )( void );
|
||||
void ( *GL_SetRenderMode )( int mode );
|
||||
|
||||
void ( *StudioSetRenderamt )( int iRenderamt );
|
||||
void ( *StudioSetCullState )( int iCull );
|
||||
void ( *StudioRenderShadow )( int iSprite, float *p1, float *p2, float *p3, float *p4 );
|
||||
} engine_studio_api_t;
|
||||
|
||||
typedef struct server_studio_api_s
|
||||
{
|
||||
// Allocate number*size bytes and zero it
|
||||
void *( *Mem_Calloc )( int number, size_t size );
|
||||
// Check to see if pointer is in the cache
|
||||
void *( *Cache_Check )( struct cache_user_s *c );
|
||||
// Load file into cache ( can be swapped out on demand )
|
||||
void ( *LoadCacheFile )( char *path, struct cache_user_s *cu );
|
||||
// Retrieve pointer to studio model data block from a model
|
||||
void *( *Mod_Extradata )( struct model_s *mod );
|
||||
} server_studio_api_t;
|
||||
|
||||
// client blending
|
||||
typedef struct r_studio_interface_s
|
||||
{
|
||||
int version;
|
||||
int ( *StudioDrawModel )( int flags );
|
||||
int ( *StudioDrawPlayer )( int flags, struct entity_state_s *pplayer );
|
||||
} r_studio_interface_t;
|
||||
|
||||
// server blending
|
||||
#define SV_BLENDING_INTERFACE_VERSION 1
|
||||
|
||||
typedef struct sv_blending_interface_s
|
||||
{
|
||||
int version;
|
||||
|
||||
void ( *SV_StudioSetupBones )( struct model_s *pModel,
|
||||
float frame,
|
||||
int sequence,
|
||||
const vec3_t angles,
|
||||
const vec3_t origin,
|
||||
const byte *pcontroller,
|
||||
const byte *pblending,
|
||||
int iBone,
|
||||
const edict_t *pEdict );
|
||||
} sv_blending_interface_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
|
||||
#ifndef R_STUDIOINT_H
|
||||
#define R_STUDIOINT_H
|
||||
|
||||
#define STUDIO_INTERFACE_VERSION 1
|
||||
|
||||
typedef struct engine_studio_api_s
|
||||
{
|
||||
// Allocate number*size bytes and zero it
|
||||
void *( *Mem_Calloc )( int number, size_t size );
|
||||
// Check to see if pointer is in the cache
|
||||
void *( *Cache_Check )( struct cache_user_s *c );
|
||||
// Load file into cache ( can be swapped out on demand )
|
||||
void ( *LoadCacheFile )( char *path, struct cache_user_s *cu );
|
||||
// Retrieve model pointer for the named model
|
||||
struct model_s *( *Mod_ForName )( const char *name, int crash_if_missing );
|
||||
// Retrieve pointer to studio model data block from a model
|
||||
void *( *Mod_Extradata )( struct model_s *mod );
|
||||
// Retrieve indexed model from client side model precache list
|
||||
struct model_s *( *GetModelByIndex )( int index );
|
||||
// Get entity that is set for rendering
|
||||
struct cl_entity_s * ( *GetCurrentEntity )( void );
|
||||
// Get referenced player_info_t
|
||||
struct player_info_s *( *PlayerInfo )( int index );
|
||||
// Get most recently received player state data from network system
|
||||
struct entity_state_s *( *GetPlayerState )( int index );
|
||||
// Get viewentity
|
||||
struct cl_entity_s * ( *GetViewEntity )( void );
|
||||
// Get current frame count, and last two timestampes on client
|
||||
void ( *GetTimes )( int *framecount, double *current, double *old );
|
||||
// Get a pointer to a cvar by name
|
||||
struct cvar_s *( *GetCvar )( const char *name );
|
||||
// Get current render origin and view vectors ( up, right and vpn )
|
||||
void ( *GetViewInfo )( float *origin, float *upv, float *rightv, float *vpnv );
|
||||
// Get sprite model used for applying chrome effect
|
||||
struct model_s *( *GetChromeSprite )( void );
|
||||
// Get model counters so we can incement instrumentation
|
||||
void ( *GetModelCounters )( int **s, int **a );
|
||||
// Get software scaling coefficients
|
||||
void ( *GetAliasScale )( float *x, float *y );
|
||||
|
||||
// Get bone, light, alias, and rotation matrices
|
||||
float ****( *StudioGetBoneTransform )( void );
|
||||
float ****( *StudioGetLightTransform )( void );
|
||||
float ***( *StudioGetAliasTransform )( void );
|
||||
float ***( *StudioGetRotationMatrix )( void );
|
||||
|
||||
// Set up body part, and get submodel pointers
|
||||
void ( *StudioSetupModel )( int bodypart, void **ppbodypart, void **ppsubmodel );
|
||||
// Check if entity's bbox is in the view frustum
|
||||
int ( *StudioCheckBBox )( void );
|
||||
// Apply lighting effects to model
|
||||
void ( *StudioDynamicLight )( struct cl_entity_s *ent, struct alight_s *plight );
|
||||
void ( *StudioEntityLight )( struct alight_s *plight );
|
||||
void ( *StudioSetupLighting )( struct alight_s *plighting );
|
||||
|
||||
// Draw mesh vertices
|
||||
void ( *StudioDrawPoints )( void );
|
||||
|
||||
// Draw hulls around bones
|
||||
void ( *StudioDrawHulls )( void );
|
||||
// Draw bbox around studio models
|
||||
void ( *StudioDrawAbsBBox )( void );
|
||||
// Draws bones
|
||||
void ( *StudioDrawBones )( void );
|
||||
// Loads in appropriate texture for model
|
||||
void ( *StudioSetupSkin )( void *ptexturehdr, int index );
|
||||
// Sets up for remapped colors
|
||||
void ( *StudioSetRemapColors )( int top, int bottom );
|
||||
// Set's player model and returns model pointer
|
||||
struct model_s *( *SetupPlayerModel )( int index );
|
||||
// Fires any events embedded in animation
|
||||
void ( *StudioClientEvents )( void );
|
||||
// Retrieve/set forced render effects flags
|
||||
int ( *GetForceFaceFlags )( void );
|
||||
void ( *SetForceFaceFlags )( int flags );
|
||||
// Tell engine the value of the studio model header
|
||||
void ( *StudioSetHeader )( void *header );
|
||||
// Tell engine which model_t * is being renderered
|
||||
void ( *SetRenderModel )( struct model_s *model );
|
||||
|
||||
// Final state setup and restore for rendering
|
||||
void ( *SetupRenderer )( int rendermode );
|
||||
void ( *RestoreRenderer )( void );
|
||||
|
||||
// Set render origin for applying chrome effect
|
||||
void ( *SetChromeOrigin )( void );
|
||||
|
||||
// True if using D3D/OpenGL
|
||||
int ( *IsHardware )( void );
|
||||
|
||||
// Only called by hardware interface
|
||||
void ( *GL_StudioDrawShadow )( void );
|
||||
void ( *GL_SetRenderMode )( int mode );
|
||||
|
||||
void ( *StudioSetRenderamt )( int iRenderamt );
|
||||
void ( *StudioSetCullState )( int iCull );
|
||||
void ( *StudioRenderShadow )( int iSprite, float *p1, float *p2, float *p3, float *p4 );
|
||||
} engine_studio_api_t;
|
||||
|
||||
typedef struct server_studio_api_s
|
||||
{
|
||||
// Allocate number*size bytes and zero it
|
||||
void *( *Mem_Calloc )( int number, size_t size );
|
||||
// Check to see if pointer is in the cache
|
||||
void *( *Cache_Check )( struct cache_user_s *c );
|
||||
// Load file into cache ( can be swapped out on demand )
|
||||
void ( *LoadCacheFile )( char *path, struct cache_user_s *cu );
|
||||
// Retrieve pointer to studio model data block from a model
|
||||
void *( *Mod_Extradata )( struct model_s *mod );
|
||||
} server_studio_api_t;
|
||||
|
||||
// client blending
|
||||
typedef struct r_studio_interface_s
|
||||
{
|
||||
int version;
|
||||
int ( *StudioDrawModel )( int flags );
|
||||
int ( *StudioDrawPlayer )( int flags, struct entity_state_s *pplayer );
|
||||
} r_studio_interface_t;
|
||||
|
||||
// server blending
|
||||
#define SV_BLENDING_INTERFACE_VERSION 1
|
||||
|
||||
typedef struct sv_blending_interface_s
|
||||
{
|
||||
int version;
|
||||
|
||||
void ( *SV_StudioSetupBones )( struct model_s *pModel,
|
||||
float frame,
|
||||
int sequence,
|
||||
const vec3_t angles,
|
||||
const vec3_t origin,
|
||||
const byte *pcontroller,
|
||||
const byte *pblending,
|
||||
int iBone,
|
||||
const edict_t *pEdict );
|
||||
} sv_blending_interface_t;
|
||||
|
||||
#endif//R_STUDIOINT_H
|
|
@ -1,90 +1,90 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef REF_PARAMS_H
|
||||
#define REF_PARAMS_H
|
||||
|
||||
typedef struct ref_params_s
|
||||
{
|
||||
// output
|
||||
vec3_t vieworg;
|
||||
vec3_t viewangles;
|
||||
|
||||
vec3_t forward;
|
||||
vec3_t right;
|
||||
vec3_t up;
|
||||
|
||||
// Client frametime;
|
||||
float frametime;
|
||||
// Client time
|
||||
float time;
|
||||
|
||||
// Misc
|
||||
int intermission;
|
||||
int paused;
|
||||
int spectator;
|
||||
int onground;
|
||||
int waterlevel;
|
||||
|
||||
vec3_t simvel;
|
||||
vec3_t simorg;
|
||||
|
||||
vec3_t viewheight;
|
||||
float idealpitch;
|
||||
|
||||
vec3_t cl_viewangles;
|
||||
int health;
|
||||
vec3_t crosshairangle;
|
||||
float viewsize;
|
||||
|
||||
vec3_t punchangle;
|
||||
int maxclients;
|
||||
int viewentity;
|
||||
int playernum;
|
||||
int max_entities;
|
||||
int demoplayback;
|
||||
int hardware;
|
||||
int smoothing;
|
||||
|
||||
// Last issued usercmd
|
||||
struct usercmd_s *cmd;
|
||||
|
||||
// Movevars
|
||||
struct movevars_s *movevars;
|
||||
|
||||
int viewport[4]; // the viewport coordinates x, y, width, height
|
||||
int nextView; // the renderer calls ClientDLL_CalcRefdef() and Renderview
|
||||
// so long in cycles until this value is 0 (multiple views)
|
||||
int onlyClientDraw; // if !=0 nothing is drawn by the engine except clientDraw functions
|
||||
// Xash3D extension
|
||||
float fov_x, fov_y; // actual fov can be overrided on nextView
|
||||
} ref_params_t;
|
||||
|
||||
// same as ref_params but for overview mode
|
||||
typedef struct ref_overview_s
|
||||
{
|
||||
vec3_t origin;
|
||||
qboolean rotated;
|
||||
|
||||
float xLeft;
|
||||
float xRight;
|
||||
float xTop;
|
||||
float xBottom;
|
||||
float zFar;
|
||||
float zNear;
|
||||
float flZoom;
|
||||
} ref_overview_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef REF_PARAMS_H
|
||||
#define REF_PARAMS_H
|
||||
|
||||
typedef struct ref_params_s
|
||||
{
|
||||
// output
|
||||
vec3_t vieworg;
|
||||
vec3_t viewangles;
|
||||
|
||||
vec3_t forward;
|
||||
vec3_t right;
|
||||
vec3_t up;
|
||||
|
||||
// Client frametime;
|
||||
float frametime;
|
||||
// Client time
|
||||
float time;
|
||||
|
||||
// Misc
|
||||
int intermission;
|
||||
int paused;
|
||||
int spectator;
|
||||
int onground;
|
||||
int waterlevel;
|
||||
|
||||
vec3_t simvel;
|
||||
vec3_t simorg;
|
||||
|
||||
vec3_t viewheight;
|
||||
float idealpitch;
|
||||
|
||||
vec3_t cl_viewangles;
|
||||
int health;
|
||||
vec3_t crosshairangle;
|
||||
float viewsize;
|
||||
|
||||
vec3_t punchangle;
|
||||
int maxclients;
|
||||
int viewentity;
|
||||
int playernum;
|
||||
int max_entities;
|
||||
int demoplayback;
|
||||
int hardware;
|
||||
int smoothing;
|
||||
|
||||
// Last issued usercmd
|
||||
struct usercmd_s *cmd;
|
||||
|
||||
// Movevars
|
||||
struct movevars_s *movevars;
|
||||
|
||||
int viewport[4]; // the viewport coordinates x, y, width, height
|
||||
int nextView; // the renderer calls ClientDLL_CalcRefdef() and Renderview
|
||||
// so long in cycles until this value is 0 (multiple views)
|
||||
int onlyClientDraw; // if !=0 nothing is drawn by the engine except clientDraw functions
|
||||
// Xash3D extension
|
||||
float fov_x, fov_y; // actual fov can be overrided on nextView
|
||||
} ref_params_t;
|
||||
|
||||
// same as ref_params but for overview mode
|
||||
typedef struct ref_overview_s
|
||||
{
|
||||
vec3_t origin;
|
||||
qboolean rotated;
|
||||
|
||||
float xLeft;
|
||||
float xRight;
|
||||
float xTop;
|
||||
float xBottom;
|
||||
float zFar;
|
||||
float zNear;
|
||||
float flZoom;
|
||||
} ref_overview_t;
|
||||
|
||||
#endif//REF_PARAMS_H
|
|
@ -1,261 +1,261 @@
|
|||
/*
|
||||
render_api.h - Xash3D extension for client interface
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RENDER_API_H
|
||||
#define RENDER_API_H
|
||||
|
||||
#include "lightstyle.h"
|
||||
#include "dlight.h"
|
||||
|
||||
// changes for version 28
|
||||
// replace decal_t from software declaration to hardware (matched to normal HL)
|
||||
// mextrasurf_t->increased limit of reserved fields (up from 7 to 32)
|
||||
// replace R_StoreEfrags with him extended version
|
||||
// formed group for BSP decal manipulating
|
||||
// move misc functions at end of the interface
|
||||
// added new export for clearing studio decals
|
||||
|
||||
#define CL_RENDER_INTERFACE_VERSION 35
|
||||
#define MAX_STUDIO_DECALS 4096 // + unused space of BSP decals
|
||||
|
||||
#define SURF_INFO( surf, mod ) ((mextrasurf_t *)mod->cache.data + (surf - mod->surfaces))
|
||||
#define INFO_SURF( surf, mod ) (mod->surfaces + (surf - (mextrasurf_t *)mod->cache.data))
|
||||
|
||||
// render info parms
|
||||
#define PARM_TEX_WIDTH 1 // all parms with prefix 'TEX_' receive arg as texnum
|
||||
#define PARM_TEX_HEIGHT 2 // otherwise it's not used
|
||||
#define PARM_TEX_SRC_WIDTH 3
|
||||
#define PARM_TEX_SRC_HEIGHT 4
|
||||
#define PARM_TEX_SKYBOX 5 // second arg as skybox ordering num
|
||||
#define PARM_TEX_SKYTEXNUM 6 // skytexturenum for quake sky
|
||||
#define PARM_TEX_LIGHTMAP 7 // second arg as number 0 - 128
|
||||
#define PARM_TEX_TARGET 8
|
||||
#define PARM_TEX_TEXNUM 9
|
||||
#define PARM_TEX_FLAGS 10
|
||||
#define PARM_TEX_TYPE 11
|
||||
#define PARM_TEX_CACHEFRAME 12 // compare with worldmodel->needload
|
||||
#define PARM_TEX_GLFORMAT 13 // get a texture GL-format
|
||||
// reserved
|
||||
#define PARM_WORLD_VERSION 16 // return the version of bsp
|
||||
#define PARM_SKY_SPHERE 17 // sky is quake sphere ?
|
||||
#define PARM_MAP_HAS_MIRRORS 18 // current map has mirorrs
|
||||
#define PARM_MAP_HAS_DELUXE 19 // map has deluxedata
|
||||
#define PARM_MAX_ENTITIES 20
|
||||
#define PARM_WIDESCREEN 21
|
||||
#define PARM_FULLSCREEN 22
|
||||
#define PARM_SCREEN_WIDTH 23
|
||||
#define PARM_SCREEN_HEIGHT 24
|
||||
#define PARM_CLIENT_INGAME 25
|
||||
#define PARM_FEATURES 26 // same as movevars->features
|
||||
#define PARM_ACTIVE_TMU 27 // for debug
|
||||
#define PARM_CACHEFRAME 28
|
||||
#define PARM_MAX_IMAGE_UNITS 29
|
||||
#define PARM_CLIENT_ACTIVE 30
|
||||
#define PARM_REBUILD_GAMMA 31 // if true lightmaps rebuilding for gamma change
|
||||
|
||||
enum
|
||||
{
|
||||
// skybox ordering
|
||||
SKYBOX_RIGHT = 0,
|
||||
SKYBOX_BACK,
|
||||
SKYBOX_LEFT,
|
||||
SKYBOX_FORWARD,
|
||||
SKYBOX_UP,
|
||||
SKYBOX_DOWN,
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEX_INVALID = 0, // free slot
|
||||
TEX_SYSTEM, // generated by engine
|
||||
TEX_NOMIP, // hud pics, menu etc
|
||||
TEX_BRUSH, // a map texture
|
||||
TEX_SPRITE, // sprite frames
|
||||
TEX_STUDIO, // studio skins
|
||||
TEX_LIGHTMAP, // lightmap textures
|
||||
TEX_DECAL, // decals
|
||||
TEX_VGUI, // vgui fonts or images
|
||||
TEX_CUBEMAP, // cubemap textures (sky)
|
||||
TEX_DETAIL, // detail textures
|
||||
TEX_REMAP, // local copy of remap texture
|
||||
TEX_SCREENCOPY, // keep screen copy e.g. for mirror
|
||||
TEX_CUSTOM, // user created texture
|
||||
TEX_DEPTHMAP // shadowmap texture
|
||||
} texType_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TF_NEAREST = (1<<0), // disable texfilter
|
||||
TF_KEEP_RGBDATA = (1<<1), // some images keep source
|
||||
TF_NOFLIP_TGA = (1<<2), // Steam background completely ignore tga attribute 0x20
|
||||
TF_KEEP_8BIT = (1<<3), // keep original 8-bit image (if present)
|
||||
TF_NOPICMIP = (1<<4), // ignore r_picmip resample rules
|
||||
TF_UNCOMPRESSED = (1<<5), // don't compress texture in video memory
|
||||
TF_CUBEMAP = (1<<6), // it's cubemap texture
|
||||
TF_DEPTHMAP = (1<<7), // custom texture filter used
|
||||
TF_INTENSITY = (1<<8), // monochrome intensity image
|
||||
TF_LUMINANCE = (1<<9), // force image to grayscale
|
||||
TF_SKYSIDE = (1<<10), // this is a part of skybox
|
||||
TF_CLAMP = (1<<11), // clamp texcoords to [0..1] range
|
||||
TF_NOMIPMAP = (1<<12), // don't build mips for this image
|
||||
TF_HAS_LUMA = (1<<13), // sets by GL_UploadTexture
|
||||
TF_MAKELUMA = (1<<14), // create luma from quake texture (only q1 textures contain luma-pixels)
|
||||
TF_NORMALMAP = (1<<15), // is a normalmap
|
||||
TF_HAS_ALPHA = (1<<16), // image has alpha (used only for GL_CreateTexture)
|
||||
TF_FORCE_COLOR = (1<<17), // force upload monochrome textures as RGB (detail textures)
|
||||
TF_TEXTURE_1D = (1<<18), // this is GL_TEXTURE_1D
|
||||
TF_BORDER = (1<<19), // zero clamp for projected textures
|
||||
TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D
|
||||
TF_STATIC = (1<<21), // a marker for purge mechanism (not used by engine)
|
||||
TF_TEXTURE_RECTANGLE= (1<<22), // this is GL_TEXTURE_RECTANGLE
|
||||
TF_ALPHA_BORDER = (1<<23), // clamp to (0,0,0,255) (probably no difference)
|
||||
TF_IMAGE_PROGRAM = (1<<24), // enable image program support like in Doom3
|
||||
TF_ALPHACONTRAST = (1<<25), // special texture flags for internal usage
|
||||
TF_FLOAT = (1<<26), // float textures
|
||||
TF_NOCOMPARE = (1<<27), // disable comparing for depth textures
|
||||
TF_FLOATDATA = (1<<28), // incoming dataType has type GL_FLOAT
|
||||
} texFlags_t;
|
||||
|
||||
typedef struct beam_s BEAM;
|
||||
typedef struct particle_s particle_t;
|
||||
|
||||
// 12 bytes here
|
||||
typedef struct modelstate_s
|
||||
{
|
||||
short sequence;
|
||||
short frame; // 10 bits multiple by 4, should be enough
|
||||
byte blending[2];
|
||||
byte controller[4];
|
||||
byte body;
|
||||
byte skin;
|
||||
} modelstate_t;
|
||||
|
||||
typedef struct decallist_s
|
||||
{
|
||||
vec3_t position;
|
||||
char name[64];
|
||||
short entityIndex;
|
||||
byte depth;
|
||||
byte flags;
|
||||
float scale;
|
||||
|
||||
// this is the surface plane that we hit so that
|
||||
// we can move certain decals across
|
||||
// transitions if they hit similar geometry
|
||||
vec3_t impactPlaneNormal;
|
||||
|
||||
modelstate_t studio_state; // studio decals only
|
||||
} decallist_t;
|
||||
|
||||
typedef struct render_api_s
|
||||
{
|
||||
// Get renderer info (doesn't changes engine state at all)
|
||||
int (*RenderGetParm)( int parm, int arg ); // generic
|
||||
void (*GetDetailScaleForTexture)( int texture, float *xScale, float *yScale );
|
||||
void (*GetExtraParmsForTexture)( int texture, byte *red, byte *green, byte *blue, byte *alpha );
|
||||
lightstyle_t* (*GetLightStyle)( int number );
|
||||
dlight_t* (*GetDynamicLight)( int number );
|
||||
dlight_t* (*GetEntityLight)( int number );
|
||||
byte (*TextureToTexGamma)( byte color ); // software gamma support
|
||||
void (*GetBeamChains)( BEAM ***active_beams, BEAM ***free_beams, particle_t ***free_trails );
|
||||
|
||||
// Set renderer info (tell engine about changes)
|
||||
void (*R_SetCurrentEntity)( struct cl_entity_s *ent ); // tell engine about both currententity and currentmodel
|
||||
void (*R_SetCurrentModel)( struct model_s *mod ); // change currentmodel but leave currententity unchanged
|
||||
void (*GL_SetWorldviewProjectionMatrix)( const float *glmatrix ); // update viewprojection matrix (tracers uses it)
|
||||
void (*R_StoreEfrags)( struct efrag_s **ppefrag, int framecount );// store efrags for static entities
|
||||
|
||||
// Texture tools
|
||||
int (*GL_FindTexture)( const char *name );
|
||||
const char* (*GL_TextureName)( unsigned int texnum );
|
||||
const byte* (*GL_TextureData)( unsigned int texnum ); // may be NULL
|
||||
int (*GL_LoadTexture)( const char *name, const byte *buf, size_t size, int flags );
|
||||
int (*GL_CreateTexture)( const char *name, int width, int height, const void *buffer, int flags );
|
||||
void (*GL_SetTextureType)( unsigned int texnum, unsigned int type );
|
||||
void (*GL_TextureCacheFrame)( unsigned int texnum );
|
||||
void (*GL_FreeTexture)( unsigned int texnum );
|
||||
|
||||
// Decals manipulating (draw & remove)
|
||||
void (*DrawSingleDecal)( struct decal_s *pDecal, struct msurface_s *fa );
|
||||
float *(*R_DecalSetupVerts)( struct decal_s *pDecal, struct msurface_s *surf, int texture, int *outCount );
|
||||
void (*R_EntityRemoveDecals)( struct model_s *mod ); // remove all the decals from specified entity (BSP only)
|
||||
|
||||
// AVIkit support
|
||||
void *(*AVI_LoadVideo)( const char *filename, int ignore_hwgamma );
|
||||
int (*AVI_GetVideoInfo)( void *Avi, long *xres, long *yres, float *duration );
|
||||
long (*AVI_GetVideoFrameNumber)( void *Avi, float time );
|
||||
byte *(*AVI_GetVideoFrame)( void *Avi, long frame );
|
||||
void (*AVI_UploadRawFrame)( int texture, int cols, int rows, int width, int height, const byte *data );
|
||||
void (*AVI_FreeVideo)( void *Avi );
|
||||
int (*AVI_IsActive)( void *Avi );
|
||||
|
||||
// glState related calls (must use this instead of normal gl-calls to prevent de-synchornize local states between engine and the client)
|
||||
void (*GL_Bind)( int tmu, unsigned int texnum );
|
||||
void (*GL_SelectTexture)( int tmu );
|
||||
void (*GL_LoadTextureMatrix)( const float *glmatrix );
|
||||
void (*GL_TexMatrixIdentity)( void );
|
||||
void (*GL_CleanUpTextureUnits)( int last ); // pass 0 for clear all the texture units
|
||||
void (*GL_TexGen)( unsigned int coord, unsigned int mode );
|
||||
void (*GL_TextureTarget)( unsigned int target ); // change texture unit mode without bind texture
|
||||
void (*GL_TexCoordArrayMode)( unsigned int texmode );
|
||||
void (*GL_Reserved0)( void ); // for potential interface expansion without broken compatibility
|
||||
void (*GL_Reserved1)( void );
|
||||
void (*GL_Reserved2)( void );
|
||||
void (*GL_Reserved3)( void );
|
||||
|
||||
// Misc renderer functions
|
||||
void (*GL_DrawParticles)( const float *vieworg, const float *fwd, const float *rt, const float *up, unsigned int clipFlags );
|
||||
void (*EnvShot)( const float *vieworg, const char *name, qboolean skyshot, int shotsize ); // creates a cubemap or skybox into gfx\env folder
|
||||
int (*COM_CompareFileTime)( const char *filename1, const char *filename2, int *iCompare );
|
||||
void (*Host_Error)( const char *error, ... ); // cause Host Error
|
||||
int (*SPR_LoadExt)( const char *szPicName, unsigned int texFlags ); // extended version of SPR_Load
|
||||
void (*TessPolygon)( struct msurface_s *surf, struct model_s *mod, float tessSize );
|
||||
struct mstudiotex_s *( *StudioGetTexture )( struct cl_entity_s *e );
|
||||
const struct ref_overview_s *( *GetOverviewParms )( void );
|
||||
void (*S_FadeMusicVolume)( float fadePercent ); // fade background track (0-100 percents)
|
||||
void (*SetRandomSeed)( long lSeed ); // set custom seed for RANDOM_FLOAT\RANDOM_LONG for predictable random
|
||||
// static allocations
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
|
||||
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
|
||||
// find in files
|
||||
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly );
|
||||
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 35
|
||||
} render_api_t;
|
||||
|
||||
// render callbacks
|
||||
typedef struct render_interface_s
|
||||
{
|
||||
int version;
|
||||
// passed through R_RenderFrame (0 - use engine renderer, 1 - use custom client renderer)
|
||||
int (*GL_RenderFrame)( const struct ref_params_s *pparams, qboolean drawWorld );
|
||||
// build all the lightmaps on new level or when gamma is changed
|
||||
void (*GL_BuildLightmaps)( void );
|
||||
// setup map bounds for ortho-projection when we in dev_overview mode
|
||||
void (*GL_OrthoBounds)( const float *mins, const float *maxs );
|
||||
// handle decals which hit mod_studio or mod_sprite
|
||||
void (*R_StudioDecalShoot)( int decalTexture, struct cl_entity_s *ent, const float *start, const float *pos, int flags, modelstate_t *state );
|
||||
// prepare studio decals for save
|
||||
int (*R_CreateStudioDecalList)( decallist_t *pList, int count, qboolean changelevel );
|
||||
// clear decals by engine request (e.g. for demo recording or vid_restart)
|
||||
void (*R_ClearStudioDecals)( void );
|
||||
// grab r_speeds message
|
||||
qboolean (*R_SpeedsMessage)( char *out, size_t size );
|
||||
// replace with built-in R_DrawCubemapView for make skyshots or envshots
|
||||
qboolean (*R_DrawCubemapView)( const float *origin, const float *angles, int size );
|
||||
// alloc or destroy studiomodel custom data
|
||||
void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer );
|
||||
} render_interface_t;
|
||||
|
||||
/*
|
||||
render_api.h - Xash3D extension for client interface
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RENDER_API_H
|
||||
#define RENDER_API_H
|
||||
|
||||
#include "lightstyle.h"
|
||||
#include "dlight.h"
|
||||
|
||||
// changes for version 28
|
||||
// replace decal_t from software declaration to hardware (matched to normal HL)
|
||||
// mextrasurf_t->increased limit of reserved fields (up from 7 to 32)
|
||||
// replace R_StoreEfrags with him extended version
|
||||
// formed group for BSP decal manipulating
|
||||
// move misc functions at end of the interface
|
||||
// added new export for clearing studio decals
|
||||
|
||||
#define CL_RENDER_INTERFACE_VERSION 35
|
||||
#define MAX_STUDIO_DECALS 4096 // + unused space of BSP decals
|
||||
|
||||
#define SURF_INFO( surf, mod ) ((mextrasurf_t *)mod->cache.data + (surf - mod->surfaces))
|
||||
#define INFO_SURF( surf, mod ) (mod->surfaces + (surf - (mextrasurf_t *)mod->cache.data))
|
||||
|
||||
// render info parms
|
||||
#define PARM_TEX_WIDTH 1 // all parms with prefix 'TEX_' receive arg as texnum
|
||||
#define PARM_TEX_HEIGHT 2 // otherwise it's not used
|
||||
#define PARM_TEX_SRC_WIDTH 3
|
||||
#define PARM_TEX_SRC_HEIGHT 4
|
||||
#define PARM_TEX_SKYBOX 5 // second arg as skybox ordering num
|
||||
#define PARM_TEX_SKYTEXNUM 6 // skytexturenum for quake sky
|
||||
#define PARM_TEX_LIGHTMAP 7 // second arg as number 0 - 128
|
||||
#define PARM_TEX_TARGET 8
|
||||
#define PARM_TEX_TEXNUM 9
|
||||
#define PARM_TEX_FLAGS 10
|
||||
#define PARM_TEX_TYPE 11
|
||||
#define PARM_TEX_CACHEFRAME 12 // compare with worldmodel->needload
|
||||
#define PARM_TEX_GLFORMAT 13 // get a texture GL-format
|
||||
// reserved
|
||||
#define PARM_WORLD_VERSION 16 // return the version of bsp
|
||||
#define PARM_SKY_SPHERE 17 // sky is quake sphere ?
|
||||
#define PARM_MAP_HAS_MIRRORS 18 // current map has mirorrs
|
||||
#define PARM_MAP_HAS_DELUXE 19 // map has deluxedata
|
||||
#define PARM_MAX_ENTITIES 20
|
||||
#define PARM_WIDESCREEN 21
|
||||
#define PARM_FULLSCREEN 22
|
||||
#define PARM_SCREEN_WIDTH 23
|
||||
#define PARM_SCREEN_HEIGHT 24
|
||||
#define PARM_CLIENT_INGAME 25
|
||||
#define PARM_FEATURES 26 // same as movevars->features
|
||||
#define PARM_ACTIVE_TMU 27 // for debug
|
||||
#define PARM_CACHEFRAME 28
|
||||
#define PARM_MAX_IMAGE_UNITS 29
|
||||
#define PARM_CLIENT_ACTIVE 30
|
||||
#define PARM_REBUILD_GAMMA 31 // if true lightmaps rebuilding for gamma change
|
||||
|
||||
enum
|
||||
{
|
||||
// skybox ordering
|
||||
SKYBOX_RIGHT = 0,
|
||||
SKYBOX_BACK,
|
||||
SKYBOX_LEFT,
|
||||
SKYBOX_FORWARD,
|
||||
SKYBOX_UP,
|
||||
SKYBOX_DOWN,
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEX_INVALID = 0, // free slot
|
||||
TEX_SYSTEM, // generated by engine
|
||||
TEX_NOMIP, // hud pics, menu etc
|
||||
TEX_BRUSH, // a map texture
|
||||
TEX_SPRITE, // sprite frames
|
||||
TEX_STUDIO, // studio skins
|
||||
TEX_LIGHTMAP, // lightmap textures
|
||||
TEX_DECAL, // decals
|
||||
TEX_VGUI, // vgui fonts or images
|
||||
TEX_CUBEMAP, // cubemap textures (sky)
|
||||
TEX_DETAIL, // detail textures
|
||||
TEX_REMAP, // local copy of remap texture
|
||||
TEX_SCREENCOPY, // keep screen copy e.g. for mirror
|
||||
TEX_CUSTOM, // user created texture
|
||||
TEX_DEPTHMAP // shadowmap texture
|
||||
} texType_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TF_NEAREST = (1<<0), // disable texfilter
|
||||
TF_KEEP_RGBDATA = (1<<1), // some images keep source
|
||||
TF_NOFLIP_TGA = (1<<2), // Steam background completely ignore tga attribute 0x20
|
||||
TF_KEEP_8BIT = (1<<3), // keep original 8-bit image (if present)
|
||||
TF_NOPICMIP = (1<<4), // ignore r_picmip resample rules
|
||||
TF_UNCOMPRESSED = (1<<5), // don't compress texture in video memory
|
||||
TF_CUBEMAP = (1<<6), // it's cubemap texture
|
||||
TF_DEPTHMAP = (1<<7), // custom texture filter used
|
||||
TF_INTENSITY = (1<<8), // monochrome intensity image
|
||||
TF_LUMINANCE = (1<<9), // force image to grayscale
|
||||
TF_SKYSIDE = (1<<10), // this is a part of skybox
|
||||
TF_CLAMP = (1<<11), // clamp texcoords to [0..1] range
|
||||
TF_NOMIPMAP = (1<<12), // don't build mips for this image
|
||||
TF_HAS_LUMA = (1<<13), // sets by GL_UploadTexture
|
||||
TF_MAKELUMA = (1<<14), // create luma from quake texture (only q1 textures contain luma-pixels)
|
||||
TF_NORMALMAP = (1<<15), // is a normalmap
|
||||
TF_HAS_ALPHA = (1<<16), // image has alpha (used only for GL_CreateTexture)
|
||||
TF_FORCE_COLOR = (1<<17), // force upload monochrome textures as RGB (detail textures)
|
||||
TF_TEXTURE_1D = (1<<18), // this is GL_TEXTURE_1D
|
||||
TF_BORDER = (1<<19), // zero clamp for projected textures
|
||||
TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D
|
||||
TF_STATIC = (1<<21), // a marker for purge mechanism (not used by engine)
|
||||
TF_TEXTURE_RECTANGLE= (1<<22), // this is GL_TEXTURE_RECTANGLE
|
||||
TF_ALPHA_BORDER = (1<<23), // clamp to (0,0,0,255) (probably no difference)
|
||||
TF_IMAGE_PROGRAM = (1<<24), // enable image program support like in Doom3
|
||||
TF_ALPHACONTRAST = (1<<25), // special texture flags for internal usage
|
||||
TF_FLOAT = (1<<26), // float textures
|
||||
TF_NOCOMPARE = (1<<27), // disable comparing for depth textures
|
||||
TF_FLOATDATA = (1<<28), // incoming dataType has type GL_FLOAT
|
||||
} texFlags_t;
|
||||
|
||||
typedef struct beam_s BEAM;
|
||||
typedef struct particle_s particle_t;
|
||||
|
||||
// 12 bytes here
|
||||
typedef struct modelstate_s
|
||||
{
|
||||
short sequence;
|
||||
short frame; // 10 bits multiple by 4, should be enough
|
||||
byte blending[2];
|
||||
byte controller[4];
|
||||
byte body;
|
||||
byte skin;
|
||||
} modelstate_t;
|
||||
|
||||
typedef struct decallist_s
|
||||
{
|
||||
vec3_t position;
|
||||
char name[64];
|
||||
short entityIndex;
|
||||
byte depth;
|
||||
byte flags;
|
||||
float scale;
|
||||
|
||||
// this is the surface plane that we hit so that
|
||||
// we can move certain decals across
|
||||
// transitions if they hit similar geometry
|
||||
vec3_t impactPlaneNormal;
|
||||
|
||||
modelstate_t studio_state; // studio decals only
|
||||
} decallist_t;
|
||||
|
||||
typedef struct render_api_s
|
||||
{
|
||||
// Get renderer info (doesn't changes engine state at all)
|
||||
int (*RenderGetParm)( int parm, int arg ); // generic
|
||||
void (*GetDetailScaleForTexture)( int texture, float *xScale, float *yScale );
|
||||
void (*GetExtraParmsForTexture)( int texture, byte *red, byte *green, byte *blue, byte *alpha );
|
||||
lightstyle_t* (*GetLightStyle)( int number );
|
||||
dlight_t* (*GetDynamicLight)( int number );
|
||||
dlight_t* (*GetEntityLight)( int number );
|
||||
byte (*TextureToTexGamma)( byte color ); // software gamma support
|
||||
void (*GetBeamChains)( BEAM ***active_beams, BEAM ***free_beams, particle_t ***free_trails );
|
||||
|
||||
// Set renderer info (tell engine about changes)
|
||||
void (*R_SetCurrentEntity)( struct cl_entity_s *ent ); // tell engine about both currententity and currentmodel
|
||||
void (*R_SetCurrentModel)( struct model_s *mod ); // change currentmodel but leave currententity unchanged
|
||||
void (*GL_SetWorldviewProjectionMatrix)( const float *glmatrix ); // update viewprojection matrix (tracers uses it)
|
||||
void (*R_StoreEfrags)( struct efrag_s **ppefrag, int framecount );// store efrags for static entities
|
||||
|
||||
// Texture tools
|
||||
int (*GL_FindTexture)( const char *name );
|
||||
const char* (*GL_TextureName)( unsigned int texnum );
|
||||
const byte* (*GL_TextureData)( unsigned int texnum ); // may be NULL
|
||||
int (*GL_LoadTexture)( const char *name, const byte *buf, size_t size, int flags );
|
||||
int (*GL_CreateTexture)( const char *name, int width, int height, const void *buffer, int flags );
|
||||
void (*GL_SetTextureType)( unsigned int texnum, unsigned int type );
|
||||
void (*GL_TextureCacheFrame)( unsigned int texnum );
|
||||
void (*GL_FreeTexture)( unsigned int texnum );
|
||||
|
||||
// Decals manipulating (draw & remove)
|
||||
void (*DrawSingleDecal)( struct decal_s *pDecal, struct msurface_s *fa );
|
||||
float *(*R_DecalSetupVerts)( struct decal_s *pDecal, struct msurface_s *surf, int texture, int *outCount );
|
||||
void (*R_EntityRemoveDecals)( struct model_s *mod ); // remove all the decals from specified entity (BSP only)
|
||||
|
||||
// AVIkit support
|
||||
void *(*AVI_LoadVideo)( const char *filename, int ignore_hwgamma );
|
||||
int (*AVI_GetVideoInfo)( void *Avi, long *xres, long *yres, float *duration );
|
||||
long (*AVI_GetVideoFrameNumber)( void *Avi, float time );
|
||||
byte *(*AVI_GetVideoFrame)( void *Avi, long frame );
|
||||
void (*AVI_UploadRawFrame)( int texture, int cols, int rows, int width, int height, const byte *data );
|
||||
void (*AVI_FreeVideo)( void *Avi );
|
||||
int (*AVI_IsActive)( void *Avi );
|
||||
|
||||
// glState related calls (must use this instead of normal gl-calls to prevent de-synchornize local states between engine and the client)
|
||||
void (*GL_Bind)( int tmu, unsigned int texnum );
|
||||
void (*GL_SelectTexture)( int tmu );
|
||||
void (*GL_LoadTextureMatrix)( const float *glmatrix );
|
||||
void (*GL_TexMatrixIdentity)( void );
|
||||
void (*GL_CleanUpTextureUnits)( int last ); // pass 0 for clear all the texture units
|
||||
void (*GL_TexGen)( unsigned int coord, unsigned int mode );
|
||||
void (*GL_TextureTarget)( unsigned int target ); // change texture unit mode without bind texture
|
||||
void (*GL_TexCoordArrayMode)( unsigned int texmode );
|
||||
void (*GL_Reserved0)( void ); // for potential interface expansion without broken compatibility
|
||||
void (*GL_Reserved1)( void );
|
||||
void (*GL_Reserved2)( void );
|
||||
void (*GL_Reserved3)( void );
|
||||
|
||||
// Misc renderer functions
|
||||
void (*GL_DrawParticles)( const float *vieworg, const float *fwd, const float *rt, const float *up, unsigned int clipFlags );
|
||||
void (*EnvShot)( const float *vieworg, const char *name, qboolean skyshot, int shotsize ); // creates a cubemap or skybox into gfx\env folder
|
||||
int (*COM_CompareFileTime)( const char *filename1, const char *filename2, int *iCompare );
|
||||
void (*Host_Error)( const char *error, ... ); // cause Host Error
|
||||
int (*SPR_LoadExt)( const char *szPicName, unsigned int texFlags ); // extended version of SPR_Load
|
||||
void (*TessPolygon)( struct msurface_s *surf, struct model_s *mod, float tessSize );
|
||||
struct mstudiotex_s *( *StudioGetTexture )( struct cl_entity_s *e );
|
||||
const struct ref_overview_s *( *GetOverviewParms )( void );
|
||||
void (*S_FadeMusicVolume)( float fadePercent ); // fade background track (0-100 percents)
|
||||
void (*SetRandomSeed)( long lSeed ); // set custom seed for RANDOM_FLOAT\RANDOM_LONG for predictable random
|
||||
// static allocations
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
|
||||
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
|
||||
// find in files
|
||||
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly );
|
||||
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 35
|
||||
} render_api_t;
|
||||
|
||||
// render callbacks
|
||||
typedef struct render_interface_s
|
||||
{
|
||||
int version;
|
||||
// passed through R_RenderFrame (0 - use engine renderer, 1 - use custom client renderer)
|
||||
int (*GL_RenderFrame)( const struct ref_params_s *pparams, qboolean drawWorld );
|
||||
// build all the lightmaps on new level or when gamma is changed
|
||||
void (*GL_BuildLightmaps)( void );
|
||||
// setup map bounds for ortho-projection when we in dev_overview mode
|
||||
void (*GL_OrthoBounds)( const float *mins, const float *maxs );
|
||||
// handle decals which hit mod_studio or mod_sprite
|
||||
void (*R_StudioDecalShoot)( int decalTexture, struct cl_entity_s *ent, const float *start, const float *pos, int flags, modelstate_t *state );
|
||||
// prepare studio decals for save
|
||||
int (*R_CreateStudioDecalList)( decallist_t *pList, int count, qboolean changelevel );
|
||||
// clear decals by engine request (e.g. for demo recording or vid_restart)
|
||||
void (*R_ClearStudioDecals)( void );
|
||||
// grab r_speeds message
|
||||
qboolean (*R_SpeedsMessage)( char *out, size_t size );
|
||||
// replace with built-in R_DrawCubemapView for make skyshots or envshots
|
||||
qboolean (*R_DrawCubemapView)( const float *origin, const float *angles, int size );
|
||||
// alloc or destroy studiomodel custom data
|
||||
void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer );
|
||||
} render_interface_t;
|
||||
|
||||
#endif//RENDER_API_H
|
|
@ -1,29 +1,29 @@
|
|||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef SCREENFADE_H
|
||||
#define SCREENFADE_H
|
||||
|
||||
typedef struct screenfade_s
|
||||
{
|
||||
float fadeSpeed; // How fast to fade (tics / second) (+ fade in, - fade out)
|
||||
float fadeEnd; // When the fading hits maximum
|
||||
float fadeTotalEnd; // Total End Time of the fade (used for FFADE_OUT)
|
||||
float fadeReset; // When to reset to not fading (for fadeout and hold)
|
||||
byte fader, fadeg, fadeb, fadealpha; // Fade color
|
||||
int fadeFlags; // Fading flags
|
||||
} screenfade_t;
|
||||
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef SCREENFADE_H
|
||||
#define SCREENFADE_H
|
||||
|
||||
typedef struct screenfade_s
|
||||
{
|
||||
float fadeSpeed; // How fast to fade (tics / second) (+ fade in, - fade out)
|
||||
float fadeEnd; // When the fading hits maximum
|
||||
float fadeTotalEnd; // Total End Time of the fade (used for FFADE_OUT)
|
||||
float fadeReset; // When to reset to not fading (for fadeout and hold)
|
||||
byte fader, fadeg, fadeb, fadealpha; // Fade color
|
||||
int fadeFlags; // Fading flags
|
||||
} screenfade_t;
|
||||
|
||||
#endif//SCREENFADE_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue